This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: looping the attributes
- From: Trevor Nash <tcn at melvaig dot co dot uk>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Tue, 27 Aug 2002 18:58:07 +0100
- Subject: Re: [xsl] looping the attributes
- Organization: Melvaig Software Engineering Limited
- References: <00d501c24e08$09754360$c4c909c0@COHANA>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Charles Ohana wrote:
>Hello,
>I'm trying to display the whole xml data in a table in a generic way.
>I don't know the name of the fields, all I know is the name of the node.
>
>Here is an example
><root>
> <line c1="1" c2="2" />
> <line x1="A" x2="B" />
></root>
>
>I'm looking to produce the following output
><tr>
> <td> 1 </td>
> <td> 2 </td>
></tr>
><tr>
> <td> A </td>
> <td> B </td>
></tr>
>
>
>here is my xsl code below, does anyone knows what am I missing ?
>...
><xsl:for-each select="line">
> <tr>
> <xsl:for-each select="@*">
> <td> <xsl:value-of select="@name()"/> </td>
This is asking for the name of an attribute of the current node, which
is itself an attribute : it will return nothing.
If you want the value of the attribute (e.g. '1') then say
<td> <xsl:value-of select="."/> </td>
( . (dot) means the current node)
If you want the name of the attribute (e.g. 'c1') then say
<td> <xsl:value-of select="name()"./> </td>
(the name of the current node)
Regards,
Trevor Nash
--
Traditional training & distance learning,
Consultancy by email
Melvaig Software Engineering Limited
voice: +44 (0) 1445 771 271
email: tcn@melvaig.co.uk
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list