[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

AW: looping

Subject: AW: looping
From: "Zink, Juergen" <Juergen.Zink@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 23 Jun 2003 10:36:22 +0200
xsl loop over attributes
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


Current Thread
  • AW: looping
    • Zink, Juergen - Mon, 23 Jun 2003 04:37:52 -0400 (EDT) <=

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.