Re: 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]"/> </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
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format