[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Getting the value of previous Sibling
<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:copy> <xsl:variable name="name"><xsl:value-of select="preceding-sibling::element[position()=1]/@name" /></xsl:variable> 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" select="preceding-sibling::element[position()=1]/@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 wanted. <xsl:variable name="value"><xsl:value-of select="preceding-sibling::element[position()=1]/@value" /></xsl:variable> 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( preceding-sibling::element[1]/@name, preceding-sibling::element[1]/@value )"/></xsl:attribute> <xsl:apply-templates select="*|text()"/> </xsl:copy> and you need an </xsl:if> here </xsl:template> David ` ________________________________________________________________________ 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: http://www.star.net.uk ________________________________________________________________________
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|