Subject: RE: [xsl] XML Group with XSL From: aalikaj@xxxxxxxxxxxx Date: Wed, 21 Apr 2004 12:16:14 -0400 |
Thank you Viral, First, I do not want to hard code on the attribute values, so how can I print out the "node_1" element with all its attributes. Second, How can I exclude the node_1 from the following code <xsl:template match="node_1"> <xsl:copy-of select="."/> </xsl:template> It prints out node_1 with its children. I want only children elements, because "node_1" has been prented once Thank you Ardian Alikaj Software Developer Ntuitive Software & Systems. E: aalikaj@xxxxxxxxxxxx T: 416.863.9566 x326 F: 416.863.8919 "Patel, Viral" <viral.patel@countryfin To: "'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'" <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> ancial.com> cc: Subject: RE: [xsl] XML Group with XSL 04/21/2004 11:44 AM Please respond to xsl-list Hi Ardian, Assuming that you are taking the first xml structure as your input and transforming it into the corrected version of xml as your output using a xsl. You xsl should look something like: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"> <xsl:template match="/"> <xsl:text disable-output-escaping="yes"><?xml version="1.0" encoding="ISO-8859-1"?></xsl:text> <ROOT> <node_1 attrib1_1="3" attrib1_2="282" attrib1_3="ABC" attrib1_4="BCD" attrib1_5="0"> <xsl:apply-templates select="//ROOT/node_1"/> </node_1> </ROOT> </xsl:template> <xsl:template match="node_1"> <xsl:copy-of select="."/> </xsl:template> </xsl:stylesheet> Thanks, Viral. -----Original Message----- From: aalikaj@xxxxxxxxxxxx [mailto:aalikaj@xxxxxxxxxxxx] Sent: Wednesday, April 21, 2004 10:47 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: [xsl] XML Group with XSL 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" 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_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_23 attrib1_1="3" attrib1_2="282" attrib_1="1"/> <node_23 attrib1_1="3" attrib1_2="282" attrib_2="2"/> </node_1> </ROOT> Can anyone help me with this issue? Thanks in advance Ardian Alikaj Software Developer Ntuitive Software & Systems. E: aalikaj@xxxxxxxxxxxx T: 416.863.9566 x326 F: 416.863.8919
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XML Group with XSL, Mukul Gandhi | Thread | RE: [xsl] XML Group with XSL, Michael Kay |
RE: [xsl] Preceding-Sibling Axes in, Wendell Piez | Date | Re: [xsl] Problem with xsl:if, David Carlisle |
Month |