This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Absolute ordering -- determining order when position() won't work
- To: "'xsl-list at mulberrytech dot com'" <xsl-list at mulberrytech dot com>
- Subject: Absolute ordering -- determining order when position() won't work
- From: Ross Bleakney <RossB at datachannel dot com>
- Date: Mon, 4 Dec 2000 14:28:07 -0800
- Reply-To: xsl-list at mulberrytech dot com
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