This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
XML/XSLT Problem
- From: "Alex Genis" <agenis at dtcc dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Mon, 29 Jul 2002 15:30:48 -0400
- Subject: [xsl] XML/XSLT Problem
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi everybody.
I have input XML Document like this:
<ABC>
<efg>fgh</efg>
<hij>sdf</hij>
<abc>
<PP id="111" id-1="222" >
<IPI id="333" id-2="444" >
<p1>p1p1p1</p1>
</IPI>
<IPI id="sss" id-2="666" >
<p1>p2p2p2</p1>
</IPI>
</PP>
<PP id="777" id-1="888" >
<IPI id="123" id-2="234" >
<p1>p3p3p3</p1>
</IPI>
<IPI id="456" id-2="567" >
<p1>p4p4p4</p1>
</IPI>
</PP>
<IP id="rrr" id-1="aaa">
<i1>i1i1i1</i1>
</IP>
<IP id="sss" id-1="bbb">
<i1>i2i2i2</i1>
</IP>
<IP id="ttt" id-1="ccc">
<i1>i3i3i3</i1>
</IP>
<IP id="uuu" id-1="ddd">
<i1>i4i4i4</i1>
</IP>
<PR id="xxx">
<r1>r1r1r1</r1>
</PR>
<PR id="bbb">
<r1>r2r2r2</r1>
</PR>
<PR id="zzz">
<r1>r3r3r3</r1>
</PR>
</abc>
</ABC>
I need to create XSLT Stylesheet which retrieves from this XML only those
elements "PP", "IP" and "PR" where:
(PP/IPI/@id = IP/@id) and (IP/@id-1 = PR/@id).
Other words I should have result containing:
<abc>
<PP id="111" id-1="222" >
<IPI id="333" id-2="444" >
<p1>p1p1p1</p1>
</IPI>
<IPI id="sss" id-2="666" >
<p1>p2p2p2</p1>
</IPI>
</PP>
<IP id="sss" id-1="bbb">
<i1>i2i2i2</i1>
</IP>
<PR id="bbb">
<r1>r2r2r2</r1>
</PR>
</abc>
If beeing already within <xsl:template match="abc">
I use <xsl:apply-templates select="PP|IP|PR"> - I can not refer to the
attributes of this elements ("id" and "id-1") because this attribute names
are not unique.
(the same problem if I use <xsl:for-each...>)
Can somebody give me a hint how can I solve this problem?
Your help will be deeply appreciated. Thanks.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list