Hi,
Here's an example on how to print xml attributes using xsl:
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="
<xsl:template match="/">
<HTML>
<BODY>
<p> Attributes found in the listing element: </p>
<p>
<xsl:for-each select="top/listing">
<xsl:value-of select="@ranking"/> <br />
<xsl:value-of select="@title"/> <br />
<xsl:value-of select="@description"/> <br />
<xsl:value-of select="@siteHost"/> <br />
<xsl:value-of select="@biddedListing"/> <br />
</xsl:for-each>
</p>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
I changed your xml, because it didn't contain a top or root element and I changed Listing to listing. For me it is much easier to work with all lower case to avoid confusion. (xml is case sensitive)
<?xml version="1.0"?>
<!--How to list attributes in output
based on attributes in the input.
-->
<?xml-stylesheet type="text/xsl" href="listing.xsl"?>
<top>
<listing
ranking="1"
title="Find it at CD Store"
description="The CD Store is a UK mail order company selling CDs."
siteHost="
biddedListing="true">
</listing>
</top>
You may want to create html attributes from the xml attributes. This is possible using the <xsl:attribute> element.
eg.
<!--first look for element -->
<xsl:for-each select="top/listing">
<!-- create an attribute title (tooltip in html) from xml attribute title -->
<xsl:attribute name="title">The title is
<xsl:value-of select="@title"/></xsl:attribute>
HTH,
Lillu
If you want to get a job done, ask a busy person. (Sherry Conway Appel - American writer)