xsl-list
[Top] [All Lists]

Getting the value of previous Sibling

2004-07-14 03:49:12
Hi, 

I want to insert a value of previous sibling in the next. 
Basically there are two consecutive <input> tag. I want to insert the
"name", "value" attribute of first input tag in second one.

I tried with following template:

<xsl:template match="//input">
<xsl:if test="@type='radio'">
<xsl:copy>
     <xsl:variable name="name"><xsl:value-of
select="preceding-sibling::element[position()=1]/@name"
/></xsl:variable>
     <xsl:variable name="value"><xsl:value-of
select="preceding-sibling::element[position()=1]/@value"
/></xsl:variable>       
        <xsl:apply-templates select="@*"/>
    <xsl:attribute name="onclick">$name,$value</xsl:attribute>
   <xsl:apply-templates select="*|text()"/>

</xsl:copy>
</xsl:template>

Can somebody help.

Thanks,
Animesh