Re: [xsl] Attribute List

Subject: Re: [xsl] Attribute List
From: Mukul Gandhi <mukul_gandhi@xxxxxxxxx>
Date: Fri, 25 Mar 2005 08:21:07 -0800 (PST)
Hi Carmelo,

I tried this example..

XML file -
<root>
  <term a="1" b="2">
    <term c="3" d="4">
      <term e="5" f="6">
        <x/>
      </term>
    </term>
  </term>
</root>

XSL file -
<?xml version="1.0"?> 
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.0">
 
 <xsl:output method="text" /> 
 
 <xsl:template match="/root">
   <xsl:variable name = "allAttributes" select =
"descendant::term/@*"/>
   
   <xsl:for-each select="$allAttributes">
     <xsl:value-of select="name()" /> , <xsl:value-of
select="." /><xsl:text>&#xa;</xsl:text>
   </xsl:for-each>
   
 </xsl:template>
 
</xsl:stylesheet>

The output produced is -
a , 1
b , 2
c , 3
d , 4
e , 5
f , 6

So descendant::term/@*  "does lists" all attributes of
all descendant "term" elements.

If you can show rest of your code, and tell the exact
problem you are solving(with input XML and the desired
output), someone might suggest the right approach.

Regards,
Mukul

--- Carmelo Montanez <carmelo@xxxxxxxx> wrote:
> All:
> 
> I would think that this statement will select all of
> the attributes of the
> descendant "term" elements of the context node.
> 
> <xsl:variable name = "allAttributes" select =
> "descendant::term/@*"/>
> 
> Instead is only selecting the attribute of the FIRST
> "term" node.  What I 
> am missing?.  I just want a list of all Attributes
> of all descendant "term"
> elements.
> 
> Thanks
> Carmelo
> 
> 


		
__________________________________ 
Do you Yahoo!? 
Make Yahoo! your home page 
http://www.yahoo.com/r/hs

Current Thread