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

Re: XSLT - update attribute with new value

Subject: Re: XSLT - update attribute with new value
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 5 Nov 2004 14:49:58 GMT
xsl variable update
you can't have top level variable and parameters of the same name
    <xsl:variable name="attr" select="deployment-version"/>
        <xsl:variable name="value" select='TEST'/>
<xsl:param name="attr"/>
<xsl:param name="value"/>

$value couldn't refer to both the parameter and the variable of that
name. Your XSLT processor should have stopped at that point and not
produced any output.

running saxon 6.5 on your posted stylesheet produces

$ saxon value.xml value.xsl
Error at xsl:variable on line 5 of file:/c:/tmp/value.xsl:
  Duplicate global variable declaration
Error at xsl:variable on line 6 of file:/c:/tmp/value.xsl:
  Duplicate global variable declaration
Error at xsl:param on line 7 of file:/c:/tmp/value.xsl:
  Duplicate global variable declaration
Error at xsl:param on line 8 of file:/c:/tmp/value.xsl:
  Duplicate global variable declaration
Transformation failed: Failed to compile stylesheet. 4 errors detected.

If your XSLT processor didn't do that I'd consider switching processors,
at least for development purposes so you get helpful error messages.

If you delete the spurious variable declarations

 <xsl:variable name="attr" select="deployment-version"/>
        <xsl:variable name="value" select='TEST'/>

and change
   <xsl:output indent="yes" method="xml"/>

to
   <xsl:output indent="no" method="xml"/>
(indenting always messes up an identity transform, by design)

Then running it on in input:

<a a="z">
 <b deployment-version="222"/>
 <c/>
</a>


 you get


$ saxon value.xml value.xsl
<?xml version="1.0" encoding="utf-8"?><a a="z">
 <b deployment-version="222"/>
 <c/>
</a>

and if you supply a parameter:

$ saxon value.xml value.xsl  attr=deployment-version value=voila
<?xml version="1.0" encoding="utf-8"?><a a="z">
 <b deployment-version="voila"/>
 <c/>
</a>

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. 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.