Hi,
<snip>
Attached below is the XML and the XSL files. I would like to print the
attribute values of all tags inside the inner <HSDataContainerType> tag for
inputs as well as outputs such as licenceKey, fromCurrency etc. With my XSL
it only prints the first attribute value. How can print them all?
Below is the content of the xsl.
First loop over all the elements you know already.
<xsl:for-each select="*">
Then loop over all the attributes
<xsl:for-each select="@*">
This will do the trick.
Insert only comma between, but not the last attribute. Just for better
reading.
<xsl:if test="position()!=last()">, </xsl:if>
Cheers,
Juergen
<snip>
XML:
<HSContract contractName="ConvertToNum">
<HSDataContainerType name="Inputs">
<HSDataContainerType name="ConvertToNum">
<HSString name="licenseKey" xmlNodeType="1" />
<HSString name="fromCurrency" xmlNodeType="1" />
<HSString name="toCurrency" xmlNodeType="1" />
<HSDouble name="amount" required="true"
xmlNodeType="1" />
<HSBoolean name="rounding" required="true"
xmlNodeType="1" />
</HSDataContainerType>
</HSDataContainerType>
<HSDataContainerType name="Outputs">
<HSDataContainerType name="ConvertToNumResponse">
<HSDouble name="ConvertToNumResult"/>
<HSBoolean name="roundingResult" required="true"
xmlNodeType="1" />
</HSDataContainerType>
</HSDataContainerType>
</HSContract>
XSL:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="HSDataContainerType/HSDataContainerType">
<b><p><xsl:value-of select="@name"/>:</p></b>
<xsl:for-each select="*">
<xsl:for-each select="@*">
<xsl:value-of select="name()" />:<xsl:value-of select="."/>
<xsl:if test="position()!=last()">, </xsl:if>
</xsl:for-each>
<xsl:element name="br" />
</xsl:for-each>
<xsl:apply-templates select="node()"/>
</xsl:template>
</xsl:stylesheet>
*****************************************************************************
Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte
Informationen. Wenn Sie nicht der richtige Adressat sind oder diese
eMail irrtuemlich erhalten haben, informieren Sie bitte sofort den
Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren
sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.
This e-mail may contain confidential and/or privileged information.
If you are not the intended recipient (or have received this e-mail
in error) please notify the sender immediately and destroy this e-mail.
Any unauthorized copying, disclosure or distribution of the material
in this e-mail is strictly forbidden.
*****************************************************************************
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list