[xsl] Adding a node to an existing node set

Subject: [xsl] Adding a node to an existing node set
From: Tom Zwick <sammy4352@xxxxxxxxx>
Date: Mon, 22 Jul 2002 14:44:10 -0700 (PDT)
Say the XPath expression ="/parent/child" returns all
children, how can I add a new child element and have
the resulting node set assigned to a variable.

I tried 
<xsl:variable name="newTree">
    <xsl:copy-of select="/parent/child"/>
    <child age="1">foo</child>
</xsl:variable>


However there seems to be a difference between
<xsl:variable name="newTree" select="/parent/child"/>

and 

<xsl:variable name="newTree">
    <xsl:copy-of select="/parent/child"/>
</xsl:variable>

Amont other things, the attributes seem to have
disappeared.
Can someone explain the difference between the two?

Also when I try 
<xsl:variable name="newTree">
    <xsl:for-each select="/parent/child">
       <xsl:copy-of select="."/>
    </xsl:for-each>
</xsl:variable>

Saxon complains saying : "Cannot write an attribute
when there is no open start tag"

Thanks,
Tom



__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread