[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Getting the value of previous Sibling

Subject: Re: Getting the value of previous Sibling
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 14 Jul 2004 13:01:04 +0100
xsl 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
________________________________________________________________________

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.