This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Was test for presence of an attribute
- To: xsl-list at lists dot mulberrytech dot com
- Subject: Re: [xsl] Was test for presence of an attribute
- From: Goetz Bock <bock at blacknet dot de>
- Date: Sat, 21 Jul 2001 21:03:07 +0200
- References: <20010720193929.39901.qmail@web20106.mail.yahoo.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
On Fri, Jul 20 '01 at 12:39, val iliescu wrote:
> How would one go about to print the element names,
> followed imediately by their attribute name (if it
> exists ?)
That's easy: write a template that cataches all nodes (except text
nodes) and prints their (local) name, than does a for-each loop over all
attributes and print's this names. (And get yourselfe a good book)
It goes something along this lines (it produces recoverable errros with
saxon for the text nodes):
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!-- filename: test.xsl
created on: 2001 Jul 21 20:48:16 z (CEST)
last modified: 2001 Jul 21 21:00:23 z (CEST)
(c) 2001 by Goetz Bock <bock@blacknet.de>
-->
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version='1.0'>
<xsl:output method="text" />
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="node()">
<xsl:value-of select="name()" />
<xsl:text>: </xsl:text>
<xsl:for-each select="@*">
<xsl:value-of select="name()" />
</xsl:for-each>
<xsl:text>
</xsl:text>
<xsl:apply-templates />
</xsl:template>
<xsl:template match="text()" />
</xsl:transform>
--
Goetz Bock IT Consultant
Dipl.-Inf. Univ.
PGP signature