Re: [xsl] creating a string of child node names

Subject: Re: [xsl] creating a string of child node names
From: Manolis Mavrikis <M.Mavrikis@xxxxxxxx>
Date: Wed, 03 Dec 2003 11:37:53 +0000
Haydn,

I would try inside the matching template:

	<xsl:element name="input">
	  <xsl:attribute name="value">
	    <xsl:for-each select="*">
	    	<xsl:value-of select="name(.)"/>
	 	<xsl:if test="position() != last()">,</xsl:if>
	    </xsl:for-each>
	  </xsl:attribute>
	  <xsl:attribute name="type">hidden</xsl:attribute>
	</xsl:element>

or better (depending on what exactly you want to do)

  <xsl:variable name="value">
	<xsl:for-each select="*">
	  <xsl:value-of select="name(.)"/>
      	  <xsl:if test="position() != last()">,</xsl:if>
        </xsl:for-each>
    </xsl:variable>	
   <input name="X2H_VAR_NAMES111" value="{$value}" type="hidden"/>

Cheers,

Manolis
Haydn Flower wrote:
I need to build up a string if child node names.
so far I have <xsl:template match="Invoice">
<input name="X2H_VAR_NAMES" value="{name(./*)}" type="hidden"/>
</xsl:template>


this is a sample of the xml file
<Invoice>
	<InvoiceNumber/>
	<DespatchNoteNumber/>
	<OrderNumber />
	<AccountNo/>
</Invoice>

my result only has 	<input name="X2H_VAR_NAMES" value="InvoiceNumber"
type="hidden"/>

and I would like 	<input name="X2H_VAR_NAMES"
value="InvoiceNumber,DespatchNoteNumber,OrderNumber,AccountNo"
type="hidden"/>

Thank you for your help


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


Current Thread