|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Absolute ordering -- determining order when position() won't
Hello,
I have XML which consists of elements which are either folders or files:
<Folder name="foldera">
<File name="a" />
<Folder name="folderb">
</ Folder>
<File name="b" />
<Folder name="folderc">
<File name="c" />
<File name="d" />
</ Folder>
</Folder>
The order of the folders and files is arbitrary. I have written some XML to
list the names of all of the files:
<xsl:template name="files_folders">
<xsl:choose>
<xsl:when test="self::File">
<xsl:call-template name="files" />
</xsl:when>
<xsl:when test="self::Folder">
<xsl:for-each select="./*">
<xsl:call-template name="files_folders" />
</xsl:for-each>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template name="files">
<h3>
<xsl:value-of select="@name" />
</h3>
</xsl:template>
What I would like to do, is precede each file name with a number, like so:
1 a
2 b
3 c
4 d
If I use position(), then I will get the order of the element in the
subtree:
1 a
3 b
1 c
2 d
Does anyone have any idea how to solve this problem?
Thanks,
Ross
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








