Project

Profile

Help

Implicit Document Nodes

Added by Anonymous over 15 years ago

Legacy ID: #6666340 Legacy Poster: Talmage (qnox)

According to: http://www.w3.org/TR/2006/CR-xslt20-20060608/#temporary-trees You can create implicit document nodes as values of variables and treat them as a source document. In trying to understand how this works I created a simple test document: XSL: <xsl:stylesheet xmlns="http://metrics/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="xml"/> <xsl:variable name="tree"> <data> <row a="apples" num="1"/> <row a="oranges" num="1"/> </data> </xsl:variable> <xsl:template match="/"> <testdoc> <xsl:for-each select="data/row"> <result1><xsl:value-of select="@a"/></result1> </xsl:for-each> <xsl:for-each select="$tree/data"> <result2><xsl:value-of select="@a"/></result2> </xsl:for-each> </testdoc> </xsl:template> </xsl:stylesheet> XML Source: <data> <row a="apples" num="1"/> <row a="oranges" num="1"/> </data> XML Output: <?xml version="1.0" encoding="UTF-8"?> <testdoc xmlns="http://metrics/"> <result1>apples</result1> <result1>oranges</result1> </testdoc> So, for-each over the xml source works fine. Doing the for-each over the implicitly created does not even execute once. I am using the transform.exe version 9.1.0.1N. What am I missing?


Replies (2)

RE: Implicit Document Nodes - Added by Anonymous over 15 years ago

Legacy ID: #6666631 Legacy Poster: Michael Kay (mhkay)

The elements in your temporary tree are not called data and row, they are called {http://metrics/}data and {http://metrics/}row - that is, they are in a namespace, so your XPath expressions need to search for the elements in this namespace. If you don't want them to be in a namespace, try <xsl:variable name="tree" xmlns=""> . . . . </xsl:variable> This posting is really a question about the XSLT language, and not about the Saxon implementation. It would have been more appropriate therefore to post it somewhere like the xsl-list at mulberrytech.com.

RE: Implicit Document Nodes - Added by Anonymous over 15 years ago

Legacy ID: #6667847 Legacy Poster: Talmage (qnox)

Apologies for posting in the wrong location. Thank you for your assistance.

    (1-2/2)

    Please register to reply