[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 [SEC=UNCLASSIFIED]
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 29 Oct 2008 10:45:29 -0400
RE:  Extracting Unique element names and attributes fro
At 06:56 PM 10/28/2008, Mike wrote:
saxon:evaluate seems quite unnecessary here (and will be a lot more
expensive than necessary)....

Also, Mike earlier suggested using xsl:for-each-group, which offers a nice solution:


<xsl:for-each-group select="//*" group-by="name()">
  <xsl:text>&#xA;&#xA;</xsl:text><!-- two new lines -->
  <xsl:value-of select="current-grouping-key()"/>
  <xsl:for-each-group select="current-group()/@*" group-by="name()">
    <xsl:text>&#xA;  </xsl:text><!-- new line, indent -->
    <xsl:value-of select="current-grouping-key()"/>
  </xsl:for-each-group>
</xsl:for-each-group>

This is somewhat different from what was posted, in that it lists distinct attributes that may appear with each element, but this is usually useful information -- and if you do want a list of attributes appearing absolutely, just do the element thing again, except selecting "//@*". (Also, I haven't taken the trouble to make HTML out of it.)

This approach can be taken one more step to report values of attributes, or repeating values of attributes (which sometimes makes for less noise).

Cheers,
Wendell



======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

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.