[xsl] Listing all element/attributes/attribute values

Subject: [xsl] Listing all element/attributes/attribute values
From: James Cummings <cummings.james@xxxxxxxxx>
Date: Thu, 7 Jul 2005 13:58:36 +0100
Hi there,

Since someone has probably already done this and I don't want to
reinvent the wheel, I thought I'd ask here.

What I want to do is with any well-formed XML document list all the
elements, attributes and attribute-values in a sorted list.

So given something like:

<div class="foo"><p xml:id="abc123" style="font-weight: bold"
class="big">foo</p>
<span class="foo"><a
href="http://www.example.com/";>foo</a></span><span
class="bar">bar</span> <p class="small">small</p></div>

I might get output like:

a (1)
      - href
           = http://www.example.com/
div (1)
      - class
           = foo
p (2)
     - class
          = big
          = small
     - style
           = font-weight: bold
     - xml:id
           = abc123
span (2)
     - class
          = foo
          = bar

(Or I suppose an adhoc interim xml format that I could easily convert
to that would be better.)


Is this even easier in xslt2?

Many thanks for any suggestions,

-James
--
James Cummings, Cummings dot James at GMail dot com

Current Thread