xsl-list
[Top] [All Lists]

Re: How to sort Using Dom and SelectNodes

2003-06-04 13:40:06
[Rick]
Any way to do this without a stylesheet, just with the XML Dom (with a
method)?
I'm trying to avoid the whole "transformation" piece of this... but mabye I
can't.
Karl

----- Original Message -----
From: "Rick Taylor" <taylor(_at_)ppdm(_dot_)org>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Wednesday, June 04, 2003 12:34 PM
Subject: Re: [xsl] How to sort Using Dom and SelectNodes


Karl,

This should give you what you want.

         <xsl:template match="xml">
           <xsl:apply-templates select="FLD[(_at_)order]">
             <xsl:sort select="@order" data-type="number"/>
           </xsl:apply-templates>
         </xsl:template>

         <xsl:template match="FLD">
            <xsl:value-of select="."/>
        </xsl:template>

-rick

At 11:40 AM 6/4/03 -0700, you wrote:
Hello,

I have a simple selectnodes method which grabs nodes from a nodes list
who
have the attribute ORDER.  I'd actually like to select and then order the
result based on the value of the ORDER attribute.  So:

<xml>
    <FLD order="3">run</FLD>
    <FLD order="1">See</FLD>
    <FLD>foo</FLD>
    <FLD order="2">spot</FLD>
    <FLD>bar</FLD>
</xml>

Would yield the result fragment (tree?):
    <FLD order="1">See</FLD>
    <FLD order="2">spot</FLD>
    <FLD order="3">run</FLD>

How can I achieve this?

Karl


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Rick Taylor
XML Developer
PPDM Association


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list





 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>