1

I am passing NodeList as a parameter to XSLT (Im using SaxonB 9.1/XSLT 2 if that makes any difference).

What I want to do is to insert all of the elements/values from the nodelist into the XSLT output (which is XML file).

When I do below, it only prints the text values of the nodes (ie. it doesnt generate XML elements at all)

<xsl:param name="NL" />
.    <xsl:template match="/">
.          <xsl:value-of select="$NL" />
.     </xsl:template>
<xsl:stylesheet>

I can access particular elements using XPath, ie. $NL/Node1. What do I need to do in order to include all of the NodeList's XML elements and values with the output?

I also tried to do loop like below, but it only prints "top-level" elements of the NOdeList - it doesnt include any children nodes of those elements.

<xsl:for-each select="$NL/*">
.   <xsl:element name="{./name()}">
.       <xsl:value-of select="./text()"/>
.   </xsl:element>
</xsl:for-each>

1 Answer 1

3

<xsl:value-of> gives you the string value, you probably want to use <xsl:copy-of> instead.

Sign up to request clarification or add additional context in comments.

1 Comment

I had a feeling it was something really simple I was missing. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.