[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: sorting related issue

Subject: Re: sorting related issue
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 14 Dec 2001 17:16:57 +0000
xsl sort and related nodes
Hi Sanjay,

> I tried the following
>
>      <xsl:variable name="sortedErrorMessage">
>           <xsl:for-each select="/ErrorMessages/ErrorMessage">
>                <xsl:sort select="Name" order="ascending" />
>                <xsl:sort select="Type" order="ascending" />
>                     <xsl:value-of select="Name" />
>                     <xsl:value-of select="Type" />
>                     <xsl:value-of select="Details" />
>           </xsl:for-each>
>      </xsl:variable>

This creates a variable called $sortedErrorMessage which contains the
*values of* the Name, Type and Details elements, in order. Note that
it doesn't contain any elements.

> and then if I add
>      <xsl:for-each select="msxsl:node-set($sortedErrorMessage)/Name">
>           <xsl:value-of select="."/>
>      </xsl:for-each>

The msxsl:node-set() function converts the result tree fragment to a
node set and returns the root node of that node set. You're then
looking for Name child elements of the root node - there aren't any
because you didn't create any.

I think that you should change the way that you create the variable.
Try using:

  <xsl:variable name="sortedErrorMessage">
    <xsl:for-each select="/ErrorMessages/ErrorMessage">
      <xsl:sort select="Name" order="ascending" />
      <xsl:sort select="Type" order="ascending" />
      <xsl:copy-of select="." />
    </xsl:for-each>
  </xsl:variable>

That creates copies of the ErrorMessage elements, and the
$sortedErrorMessage variable's root node has several ErrorMessage
children, in order. Then you can do:

  <xsl:for-each
      select="msxsl:node-set($sortedErrorMessage)/ErrorMessage">
    <xsl:value-of select="Name"/>
  </xsl:for-each>

For example.

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.