I have the following XSLT stylesheet (simplified):
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
exclude-result-prefixes="exsl">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:variable name="categories">
<category name="one"/>
<category name="two"/>
<category name="three"/>
</xsl:variable>
<xsl:template match="/">
<result>
<xsl:for-each select="exsl:node-set($categories)/category">
<xsl:element name="{@name}">
<!-- THIS IS THE PROBLEMATIC PART -->
<xsl:for-each select="/input/object">
<item>
<xsl:value-of select="."/>
</item>
</xsl:for-each>
</xsl:element>
</xsl:for-each>
</result>
</xsl:template>
</xsl:stylesheet>
This refers to the following source XML document (also simplified):
<?xml version="1.0" encoding="utf-8"?>
<input>
<object category="one">a</object>
<object category="one">b</object>
<object category="two">c</object>
<object category="one">d</object>
<object category="three">e</object>
</input>
The reference to the source document produces no result; the output is just empty elements, one for each category:
<?xml version="1.0" encoding="UTF-8"?>
<result>
<one/>
<two/>
<three/>
</result>
How can I "fill" the elements with items from the source document?
Just to clarify, the "real" problem behind this is already solved, using a different approach. I am just trying to understand why this approach is not working.