Subject: RE: [xsl] Need help on that tricky selection From: "Andreas L. Delmelle" <a_l.delmelle@xxxxxxxxxx> Date: Tue, 25 May 2004 21:29:20 +0200 |
> -----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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Need help on that tricky sele, Christoph Wieseke | Thread | Re: [xsl] Need help on that tricky , Jeni Tennison |
RE: [xsl] This could be simple, but, Andreas L. Delmelle | Date | RE: [xsl] This could be simple, but, Andreas L. Delmelle |
Month |