This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: from random tags to an ordered tags
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: Re: [xsl] from random tags to an ordered tags
- From: Jörg Heinicke <joerg dot heinicke at gmx dot de>
- Date: Thu, 11 Oct 2001 21:32:07 +0200
- References: <20011011184459.29582.qmail@web10005.mail.yahoo.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
I don't know if I understood you correctly, but this is my solution:
<xsl:template match="root_elem">
<xsl:apply-templates select="*">
<xsl:sort select="@seq"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="*">
<!-- do what you want with <tag_x> -->
</xsl:template>
Look in the spec or in references like on zvon.org or topxml.com for more
options of <xsl:sort> (e.g. sort-order). You can add more <xsl:sort> above,
the applied elements will be sorted at first for the given in 'select=".." '
of the first <xsl:sort>, then the second <xsl:sort> and so on.
Joerg
----- Original Message -----
From: "yan bai" <bytj@yahoo.com>
To: <xsl-list@lists.mulberrytech.com>
Sent: Thursday, October 11, 2001 8:44 PM
Subject: [xsl] from random tags to an ordered tags
> Hi, Gurus,
>
> I have a source file in .xml type. Except the root
> element <root_elem>......</root_elem>, all elements
> come in a time sequence from a server. For instance,
> <root_elem>
> <tag_0 id="b12313" seq="1" content="Here is the
> summary the the book"/>
> <tag_5 id="i234234" seq="2" information="here is some
> info"/>
> <tag_2 id="b12334" seq="3" name="The book title here:
> A"/>
> <tag_8 id="b12337" seq="4" name="Here is a
> publisher"/>
> <tag_4 id="b34533" seq="5" name="here is the date"/>
>
> .
> .
> .
> </root_elem>
>
> Please note <tag_0>, <tag_1>, ..., <tag_x> comes in a
> random sequence. Any tag may come before another in
> this source .xml file. the attribute "seq" indicates
> in the order of tags.
>
> I need to use xslt to transform these tags into a
> well-formed xml file according to the sequence
> attribute "seq". Whatever tag comes the first, it
> needs to be the first tag in the destination xml file.
>
> Anyone knows how?
>
> Thanks a ton in advance.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list