[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Ignore Tags

Subject: Re: Ignore Tags
From: "Joerg Heinicke" <joerg.heinicke@xxxxxx>
Date: Tue, 26 Feb 2002 21:00:31 +0100
html ignore tags
This is a general grouping problem.

The easiest way is to test (with the preceding-sibling-axis) whether there
was already a child with this id:

<xsl:template match="root">
    <xsl:apply-templates select="child[not(@id =
preceding-sibling::child/@id)]"/>
</xsl:template>

<xsl:template match="child">
    do anything with the happy childs
</xsl:template>

The second way for bigger files (the above way is not so good, because for
every child all preceding childs have to be tested) is using keys (Muenchian
Method, http://www.jenitennison.com/xslt/grouping/muenchian.html)

<xsl:key name="childs" match="child" use="@id"/>

<xsl:template match="root">
    <xsl:apply-templates select="child[count( . | key('childs', @id)[1]) =
1]"/>
</xsl:template>

Hope this helps,

Joerg

> hi
>
> I have a problem .. it goes like this
> an xml file of thie folowing format
>
> <root>
>   <child id = '1'>happy</child>
>   <child id = '2'>happy</child>
>   <child id = '3'>happy</child>
>   <child id = '1'>sad</child>
>   <child id = '2'>sad</child>
>   <child id = '3'>sad</child>
> </root>
>
> my problem is that when i go through each of the child elements,
> then i should ignore the duplicates that is once child id = '1' is
> encountered, the second time it should be ignored.. so effectively
> the result should be
> all happy 'childs' .. Is there a way to do that??
> please help me
> vsd


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread
  • Ignore Tags
    • vasu deva - Tue, 26 Feb 2002 13:24:53 -0500 (EST)
      • Joerg Heinicke - Tue, 26 Feb 2002 14:55:43 -0500 (EST) <=
      • <Possible follow-ups>
      • vasu deva - Tue, 26 Feb 2002 15:09:52 -0500 (EST)

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.