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

key() returning nodes in undesired order.

Subject: key() returning nodes in undesired order.
From: Elliot Schlegelmilch <elliot@xxxxxxxxxxxxxxx>
Date: Sat, 12 Nov 2005 14:09:46 -0700
elliot schlegelmilch
I'm attempting to simplify and reduce the size of my xml. Instead of repeating items many many times, I'm providing a reference. Being a good beginner xsl programmer, I made a key for each 'b' so i can refer to them simply by key('all-b', /set/x/a/reference) and have a very handy node set of b's.
<xsl:key name="all-b" match="/set/y/b" use="reference"/>


This part all works fine. However, the problem is when the references refer to them in an order which differs than how they are contained in y. So "key('all-b', /set/x/a/reference)" returns the B nodes I'm after, but not in the order which they are in A. Is there such a way to get them in the order which I desire?

Unfortunately, having the xml in the 'correct order' before I process isn't an option, and neither is adding sort criteria for each B so I can sort the node set before I use it.

The only way I can think to do it now is individually, like:
<xsl:for-each select="/set/x/a/reference">
<xsl:variable name="x" select="key('all-b', .)"/>
...
</xsl:for-each>




<set>


<x>
<a>
<reference>reference2</reference>
<reference>reference1</reference>
</a>
</x>

<y>
<b>
<reference>reference1</reference>
<c>other data</c>
</b>
<b>
<reference>reference2</reference>
<c>other data</c>
</b>
</y>

</set>

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.