Subject: Re: [xsl] XML Group with XSL From: Mukul Gandhi <mukulgandhi2003@xxxxxxxxxxx> Date: Wed, 21 Apr 2004 17:35:57 +0100 (BST) |
Hi Ardian, Please try the XSL. <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/> <xsl:template match="/ROOT"> <ROOT> <node_1> <xsl:for-each select="node_1"> <xsl:for-each select="*"> <xsl:copy-of select="."/> </xsl:for-each> </xsl:for-each> </node_1> </ROOT> </xsl:template> </xsl:stylesheet> Regards, Mukul --- aalikaj@xxxxxxxxxxxx wrote: > > Hi all, > > I'm new to XSL, and my question might be quickly > addressed. I have an XML > file with the following structure. > > <?xml version="1.0" encoding="ISO-8859-1"?> > <ROOT> > <node_1 attrib1_1="3" > attrib1_2="282" > attrib1_3="ABC" > attrib1_4="BCD" > attrib1_5="0"> > <node_21 attrib1_1="3" > attrib1_2="282" > attrib2_3="1" > attrib2_4="1" > attrib2_5="BCD"> > <node_3 attrib1_1="3" > attrib1_2="282" > attrib2_3="1" > attrib3_4="1" > attrib3_5="XYZ"> > <node_4 attrib1_1="3" > attrib1_2="282" > attrib2_3="1" > attrib3_4="1" > node4_5="1" > node4_6="Yes"/> > <node_4 attrib1_1="3" > attrib1_2="282" > attrib2_3="1" > attrib3_4="1" > node4_5="2" > node4_6="No"/> > </node_3> > <node_3 attrib1_1="3" > attrib1_2="282" > attrib2_3="1" > attrib3_4="2" > attrib3_5="cvb"> > <node_4 attrib1_1="3" > attrib1_2="282" > attrib2_3="1" > attrib3_4="2" > node4_5="1" > node4_6="A"/> > <node_4 attrib1_1="3" > attrib1_2="282" > attrib2_3="1" > attrib3_4="2" > node4_5="2" > node4_6="B"/> > </node_3> > </node_21> > <node_21 attrib1_1="3" > attrib1_2="282" > attrib2_3="2" > attrib2_4="1" > attrib2_5="bbb"> > <node_3 attrib1_1="3" > attrib1_2="282" > attrib2_3="2" > attrib3_4="1" > attrib3_5="bbb1"> > <node_4 attrib1_1="3" > attrib1_2="282" > attrib2_3="2" > attrib3_4="1" > node4_5="1" > node4_6="aa"/> > <node_4 attrib1_1="3" > attrib1_2="282" > attrib2_3="2" > attrib3_4="1" > node4_5="2" > node4_6="bb"/> > </node_3> > <node_3 attrib1_1="3" > attrib1_2="282" > attrib2_3="2" > attrib3_4="2" > attrib3_5="cvb"> > <node_4 attrib1_1="3" > attrib1_2="282" > attrib2_3="2" > attrib3_4="2" > node4_5="1" > node4_6="yy"/> > <node_4 attrib1_1="3" > attrib1_2="282" > attrib2_3="1" > attrib3_4="2" > node4_5="2" > node4_6="zz"/> > </node_3> > </node_21> > > </node_1> > <node_1 attrib1_1="3" > attrib1_2="282" > attrib1_3="ABC" > attrib1_4="BCD" > attrib1_5="0"> > <node_22 attrib1_1="3" > attrib1_2="282" > attrib_a1="value_a1" > attrib_b1="value_b1" > attrib_c1="value_c1"/> > <node_22 attrib1_1="3" > attrib1_2="282" > attrib_a2="value_a2" > attrib_b2="value_b2" > attrib_c2="value_c2"/> > <node_22 attrib1_1="3" > attrib1_2="282" > attrib_a3="value_a3" > attrib_b3="value_b3" > attrib_c3="value_c3"/> > <node_22 attrib1_1="3" > attrib1_2="282" > attrib_a4="value_a4" > attrib_b4="value_b4" > attrib_c4="value_c4"/> > > </node_1> > <node_1 attrib1_1="3" > attrib1_2="282" > attrib1_3="ABC" > attrib1_4="BCD" > attrib1_5="0"> > > <node_23 attrib1_1="3" > attrib1_2="282" > attrib_1="1"/> > <node_23 attrib1_1="3" > attrib1_2="282" > attrib_2="2"/> > </node_1> > </ROOT> > > > As you see, node_1 is being repeted having the same > attribute values but > different children nodes. I want to group the > children nodes of node_1, so > I want the following output. > > <?xml version="1.0" encoding="ISO-8859-1"?> > <ROOT> > <node_1 attrib1_1="3" > attrib1_2="282" > attrib1_3="ABC" > attrib1_4="BCD" > attrib1_5="0"> > <node_21 attrib1_1="3" > attrib1_2="282" > attrib2_3="1" > attrib2_4="1" > attrib2_5="BCD"> > <node_3 attrib1_1="3" > attrib1_2="282" > attrib2_3="1" > attrib3_4="1" > attrib3_5="XYZ"> > <node_4 attrib1_1="3" > attrib1_2="282" > attrib2_3="1" > attrib3_4="1" > node4_5="1" > node4_6="Yes"/> > <node_4 attrib1_1="3" > attrib1_2="282" > attrib2_3="1" > attrib3_4="1" > node4_5="2" > node4_6="No"/> > </node_3> > <node_3 attrib1_1="3" > attrib1_2="282" > attrib2_3="1" > attrib3_4="2" > attrib3_5="cvb"> > <node_4 attrib1_1="3" > attrib1_2="282" > attrib2_3="1" > attrib3_4="2" > node4_5="1" > node4_6="A"/> > <node_4 attrib1_1="3" > attrib1_2="282" > attrib2_3="1" > attrib3_4="2" > node4_5="2" > node4_6="B"/> > </node_3> > </node_21> > <node_21 attrib1_1="3" > attrib1_2="282" > attrib2_3="2" > === message truncated === ________________________________________________________________________ Yahoo! India Matrimony: Find your partner online. http://yahoo.shaadi.com/india-matrimony/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] XML Group with XSL, aalikaj | Thread | RE: [xsl] XML Group with XSL, aalikaj |
Re: [xsl] Problem with xsl:if, Wendell Piez | Date | RE: [xsl] Problem with xsl:if, Josh Canfield |
Month |