Re: [xsl] Getting the value of previous Sibling

Subject: Re: [xsl] Getting the value of previous Sibling
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 14 Jul 2004 13:01:04 +0100
       <xsl:template match="//input">

You never want to start a match pattern with // (it doesn't do anything
useful) just use   <xsl:template match="input">

       <xsl:if test="@type='radio'">

This xsl:if isn't closed anywhere so your template is not well formed
XML you need an </xsl:if> as the last line of the template

            <xsl:variable name="name"><xsl:value-of

You don't really need a variable at all here, but if you did, it's
almost always better to go
            <xsl:variable name="name"
as that makes the value of the variable  the node itself which is
lot nore efficient than the version you have which makes the value of
the variable a result tree fragment consisting of a root node cwith
child a text node with vstring value the string value of the node you

            <xsl:variable name="value"><xsl:value-of

same comment as above.
       	<xsl:apply-templates select="@*"/>

This may or may not be OK, depending on what template you have defined
for attribute nodes. By default this will just produce the
values of the attributes as element content and lose the attribute
names. If you have defined a template for attributes that copies
the attributes this will copy the attributes, but that can more simply
be done by <xsl:copy-of select=""@*"/>

           <xsl:attribute name="onclick">$name,$value</xsl:attribute>
That will make onklick="$name,$value" as the $varname syntax only means
something in an XPath expression, not as content of an XSL element.
You would need
<xsl:attribute name="onclick"><xsl:value-of select="concat($name,$value)"/></xsl:attribute>
But as mentioned above you don't really need the variables, you could
just do
<xsl:attribute name="onclick"><xsl:value-of select="concat(
          <xsl:apply-templates select="*|text()"/>
and you need an </xsl:if> here


This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:

Current Thread