cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robin Green" <gree...@hotmail.com>
Subject RE: Creating XML elements with dynamic names in XSP??? - More Hel p PLEASE!!!!
Date Sat, 12 Aug 2000 16:25:25 GMT
Matt Coolidge <Matt@pcmove.com> wrote:
>Man, I am SO close now. But XSP just doesnt seem to actually place the new
>Element node into the resulting XML document...but it does create it.

You hit the nail on the head. How is it going to insert it into the document 
if you don't TELL it to do so? :) See below for solution.

Merely setting a variable (xspCurrentNode) and then immediately resetting it 
back to what it was before, is not going to actually cause anything else to 
happen - how could it? In fact, the variable setting is just for bookkeeping 
purposes and not even always necessary.

>Here's
>the code:
>
>for (int y = 0; y &lt; dataLength; y++){
>	Node dataNode = contactData.item(y);
>	Element el = (Element) dataNode;
>	String dataName = el.getNodeName();
>	String dataValue = getElementValue(el);
>
>
>	<xsp:logic>
>	xspParentNode = xspCurrentNode;
>	xspNodeStack.push(xspParentNode);
>	xspCurrentNode = document.createElement(dataName);
>	xspCurrentNode.appendChild(document.createTextNode(dataValue));
>	</xsp:logic>
>
>	<xsp:logic>

Node newNode = xspCurrentNode;

>	xspCurrentNode = (Node) xspNodeStack.pop();

xspCurrentNode.appendChild (newNode);

>	</xsp:logic>
>}


--
Robin Green
i-tao Ltd.
4 Skyline Village
Limeharbour
London E14 9TS
United Kingdom
Phone +44 20 7537 2233  Fax +44 70 8081 5118
http://www.i-tao.com


________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com


Mime
View raw message