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

Re: Extracting Unique element names and attributes fro

Subject: Re: 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
Re:  Extracting Unique element names and attributes fro
> 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

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.