This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Assigning variable values


Variables REALLY cannont have values changed!

But it may be possible using some (I don't know what) parsers.
I saw this discussion and tested it myself. Look at my example:

(Using MSXML4 parser from Microsoft):

var.xml
-------

<?xml version="1.0" encoding="UTF-8"?>
<root>
 <load>Father</load>
</root>

var.xslt
--------

<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
	<xsl:variable name="var" select="/"/>
	<xsl:variable name="var" select="root/load"/>
</xsl:transform>

The output was:
---------------

The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and
then click the Refresh button, or try again later.


----------------------------------------------------------------------------
----

Global variable or parameter 'var' cannot be defined more than once with the
same import precedence.

=======================================

To conclude:
------------

If a var changing value IS supported by a parser or more,
it doesn't mean that it is supported by all of them. I consider
you should make use of the <xsl:param> instead in order to
stay compatible and W3C compliant. It's very important that we
all use the same compliance and, besides, you may run your
transformation on EVERY parsers! Have you ever thought what may
happen if you have to change the parser? Redesign your transformation?


Vladimir Stanciu
----------------

vlads@wdd.ro



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]