xsl-list
[Top] [All Lists]

Re: current context preceding-sibling then following-sibling

2005-03-08 15:11:57
Unforturnately, stuck with single XPATH queries... so, here is what I
have come up with... I feel like I am really really close:

/data/animals/animal[(_at_)id = /data/code/record[field[(_at_)id = ( '60' ) 
]]/@id]


The above '60' is in correct context of /data/animals/animal (it is
the value of id).. do I lose context on the right hand side of this
equation?  The following substition for '60' does not work
preceding-sibling::animal[1]/@id... so:

/data/animals/animal[(_at_)id = /data/code/record[field[(_at_)id = (
preceding-sibling::animal[1]/@id  ) ]]/@id]




On Tue, 08 Mar 2005 22:19:56 +0100, Joris Gillis <roac(_at_)pandora(_dot_)be> 
wrote:
Tempore 21:58:03, die 03/08/2005 AD, hinc in
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com scripsit Karl Stubsjoen 
<kstubs(_at_)gmail(_dot_)com>:
<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[(_at_)fieldname='chase']" use="../@id"/>

<xsl:template match="data">
       <xsl:copy-of
select="animals/animal[(_at_)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)

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--