Subject: Re: [xsl] Extracting Unique element names and attributes from a XML file From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx> Date: Tue, 28 Oct 2008 09:58:21 +0000 |
> I need to list out all elements and attribute (unique) in a text file > for mapping with other XML file. > > I am able to get all the elements and attributes but I am unable to > achieve the uniqueness. Can any body help on this. > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> If you are stuck with 1.0 then you need to use a key: <xsl:key name="names" match="*|@*" use="name()"/> with <xsl:for-each select="//*|//*/@*"> <xsl:if test="generate-id(.) = generate-id(key('names', name(.))[1])"> <xsl:value-of select="local-name()"/> In 2.0 you can use distinct-values() or xsl:for-each-group, but it always good to learn this technique. -- Andrew Welch http://andrewjwelch.com Kernow: http://kernowforsaxon.sf.net/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Extracting Unique element, Michael Kay | Thread | Re: [xsl] Extracting Unique element, Enrico . Raymund |
RE: [xsl] Extracting Unique element, Michael Kay | Date | Re: [xsl] running a 'pipeline' as a, Dimitre Novatchev |
Month |