Using something similar to the answer found in this question I put together a function based off to create an XML result tree fragment that I loaded into a variable.
I was able to convert this XML
<Summary> <Summary>
<Category>
<Category>Tuition and Fees</Category>
<TotalDebits>0.00</TotalDebits>
<TotalCredits>-3509.45</TotalCredits>
</Category>
<Category>
<Category>Miscellaneous</Category>
<TotalDebits>60.62</TotalDebits>
<TotalCredits>-234.36</TotalCredits>
</Category>
</Summary>
</Summary>
to this
<Summary>
<Category>
<Category>Tuition and Fees</Category>
<TotalDebits>0.00</TotalDebits>
<TotalCredits>-3509.45</TotalCredits>
</Category>
<Category>
<Category>Miscellaneous</Category>
<TotalDebits>60.62</TotalDebits>
<TotalCredits>-234.36</TotalCredits>
</Category>
</Summary>
which is contained in this variable
<xsl:variable name="SummaryItems">
<xsl:call-template name="TheGreatUnescape">
<xsl:with-param name="escaped" select="string(//Summary)" />
</xsl:call-template>
</xsl:variable>
Now my issue is that I'm trying to use exslt:node-set()
to gain access to the nodes within this variable but I'm not getting any information.
When using a function like
<xsl:for-each select="exslt:node-set($SummaryItems)/Summary/Category">
it produces no result.
I did include the xmlns:exslt="http://exslt.org/common"
declaration in the xsl:stylesheet
and I've tested the node-set
function so I know it works just not with the converted XML in the variable.
Have I created a real result tree fragment using that code that exslt:node-set
can access?
The most common reason for things not matching is that they are not in the namespace that you expect, it is hard to say as you haven't shown full code but work in stages
You say
<xsl:copy-of select="exslt:node-set($SummaryItems)"/>
works, so try
<xsl:copy-of select="exslt:node-set($SummaryItems)/*"/>
If that works try
<xsl:copy-of select="exslt:node-set($SummaryItems)/Summary"/>
If that does not work then Summary
is not selecting <Summary>
which in 99 times out of 100 is a namespace issue.
Original answer (fixed in question)
<xsl:for-each select="exslt:node-set($SummaryItems)\Summary\Category">
should give an XPath syntax error wrong path separator
<xsl:for-each select="exslt:node-set($SummaryItems)/Summary/Category">