Hi there..
Here's the XML file I'm trying to process with my XSL file (simplified):
input.xml
Code:
<folders>
<folder name="hello"/>
<folder name="world"/>
</folders>
config.xml
Code:
<web>
<icons>
<folder filename="hello" order="1"/>
<folder filename="world" order="2"/>
</icons>
</web>
Basically, I want to apply templates to the 'folder' elements in the input.xml file, but use the order attribute from the config.xml file.
XSL snippet - latest attempt
Code:
<xsl:template match="folders">
<xsl:apply-templates select="folder">
<xsl:sort select="document('config.xml')/web/icons/folder[@filename=@name]/@order" data-type="number"/>
</xsl:apply-templates>
</xsl:template>
Important bit:
Code:
document('config.xml')/web/icons/folder[@filename=@name]/@order
Basically, I'm trying to find the matching 'folder' element in the config.xml file, and use the order attribute of it. The problem lies in the '@filename=@name' part - I really want to do @filename=
(folder-element-in-input.xml)/@name, if you can see where I'm coming from?
I tried this:
Code:
<xsl:template match="folders">
<xsl:for-each select="folder">
<xsl:variable name="theName">
<xsl:value-of select="@name"/>
</xsl:variable>
<xsl:sort select="document('config.xml')/web/icons/folder[@filename=$theName]/@order" data-type="number"/>
<xsl:apply-templates/>
</xsl:for-each>
</xsl:template>
..but msxml rejects it - actually it says xsl:sort cannot be a child element of xsl:for-each! - but what it really means is xsl:sort has to be the first subnode of xsl:for-each - I think.
Can anyone help?
Thanks, much appreciated.
Kieren Johnstone