xsl-list
[Top] [All Lists]

RE: [xsl] Filtering duplicate tags

2008-05-27 00:21:02

hi Mukul / All

Can you please provide a Version 1.0 sample, because I am using this
with Windows .Net 1.1 C#, there I am getting following error.

" cannot be a child of " element

- Buddhi -

-----Original Message-----
From: Mukul Gandhi [mailto:gandhi(_dot_)mukul(_at_)gmail(_dot_)com] 
Sent: Tuesday, May 27, 2008 12:28 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Filtering duplicate tags

With XSLT 2.0, you can accomplish this as following:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="2.0">

  <xsl:output method="xml" indent="yes" />

  <xsl:template match="root">
    <root>
      <xsl:for-each-group select="data" group-by="@name">
        <xsl:copy-of select="current-group()[1]" />
      </xsl:for-each-group>
    </root>
  </xsl:template>

</xsl:stylesheet>


On 5/27/08, Buddhi D. Mahindarathne <buddhi(_at_)exceltech-lanka(_dot_)com> 
wrote:
Hi All,

Following is my sample xml file.
I want to filter out similar (duplicated) elements and make a new xml
which has distinct values.
Matching and filtering need to be done based on Attribute on the first
tag,

Ex,
<data name="LBL_Inch"> --> Attribute "LBL_Inch"



<root>
       <data name="LBL_Inch">
               <value>Inch</value>
               <comment>Inches</comment>
       </data>
       <data name="LBL_MM">
               <value>mm</value>
               <comment>MM</comment>
       </data>
       <data name="LBL_MM">
               <value>mm</value>
               <comment>MM</comment>
       </data>
</root>



After transformation I need a xml file like this,

<root>
       <data name="LBL_Inch">
               <value>Inch</value>
               <comment>Inches</comment>
       </data>
       <data name="LBL_MM">
               <value>mm</value>
               <comment>MM</comment>
       </data>
</root>

Please help me on this...

- Thank you all


 ____            _     _ _     _
 | __ ) _   _  __| | __| | |__ (_)
 |  _ \| | | |/ _` |/ _` | '_ \| |
 | |_) | |_| | (_| | (_| | | | | |
 |____/ \__,_|\__,_|\__,_|_| |_|_|


-- 
Regards,
Mukul Gandhi

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>