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

RE: Need help on that tricky selection

Subject: RE: Need help on that tricky selection
From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx>
Date: Tue, 25 May 2004 21:29:20 +0200
christoph wieseke
> -----Original Message-----
> From: Christoph Wieseke [mailto:virtualize@xxxxxxx]
>
>

Hi,

> as you can maybe see, every <hst> element belongs to a
> <ort> element and can be identified by its <ort_nr>
>
> what i want to do is: select all the <ort> elements, complete
> with all their childs, where the <hst> is equal to the <ort_nr>
> and throw the rest away.
>

Well, you can use a key for this. The following key declaration

<xsl:key name="ort-by-hst" match="ort"
         use="ort_nr" />

in combination with, for example

key('ort-by-hst','1031501')

will return you (all) ort nodes having '1031501' as value for their ort_nr
child node.

One you have this, the solution comes closer...

<xsl:stylesheet ...>

<xsl:key name="ort-by-hst" match="ort"
         use="ort_nr" />

<xsl:template match="/">
  <xsl:apply-templates />
</xsl:template>

<xsl:template match="hst_list">
  <xsl:apply-templates />
</xsl:template>

<xsl:template match="hst">
  <xsl:value-of select="concat(.,'&#x0A;')" />
  <xsl:apply-templates select="key('ort-by-hst',.)" />
</xsl:template>

<xsl:template match="ort">
  <xsl:value-of select="ort_name" />
</xsl:template>

<xsl:stylesheet>

If I'm not overlooking anything, this XSLT when applied to your source XML
will yield an output like:

1031501
HBF Gleis 1
(next ort_name)
(yet another ort_name)
1031401
TOKI
(next ort_name)
(yet another ort_name)



Hope this helps!

Greetz,

Andreas

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.