[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Need help on that tricky selection
> -----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(.,'
')" /> <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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|