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

Re: current context preceding-sibling then following-

Subject: Re: current context preceding-sibling then following-sibling
From: "Joris Gillis" <roac@xxxxxxxxxx>
Date: Tue, 08 Mar 2005 22:19:56 +0100
chase order
Tempore 21:58:03, die 03/08/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Karl Stubsjoen <kstubs@xxxxxxxxx>:
<data>
  <code>
    <record id="40" says="ruff" animal="dog">
    	<field fieldname="chase" id="50">cat</field>
    </record>
    <record id="50" says="meow" animal="cat">
    	<field fieldname="chase" id="60">mouse</field>
    </record>
    <record id="60" says="squeak" animal="mouse">
    	<field fieldname="chase" id="00">cheese</field>
    </record>
  </code>
  <animals>
    <animal id="60" />
    <animal id="50" />
    <animal id="40" />
    <animal id="50" />
    <animal id="60" />
    <animal id="40" />
    <animal id="50" />
    <animal id="40" />
    <animal id="80" />
  </animals>
</data>
I am interested in returning all matches for animals who are in a
proper "chase" order.  So for example, the above animal who's ID is
50, is correctly in order if the proceding-animal is 40 (there should
be 2 matches).  Similarily, the animal who's ID is 60 is in correct
order one time with the proceding-animal who's ID is 50.  This "chase"
order is to be derived by the code/record lookup above.

Hi,

It would be easier to use keys here:

<xsl:key name="chases" match="field[@fieldname='chase']" use="../@id"/>

<xsl:template match="data">
<xsl:copy-of select="animals/animal[@id=key('chases',preceding-sibling::animal[1]/@id)/@id]"/>
</xsl:template>



regards, -- Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041) Spread the wiki (http://www.wikipedia.org)

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.