[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XSLT - update attribute with new value
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 ________________________________________________________________________
|
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
|