xsl-list
[Top] [All Lists]

Re: creating a string of child node names

2003-12-03 04:37:53
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



<Prev in Thread] Current Thread [Next in Thread>