xsl-list
[Top] [All Lists]

RE: [xsl] Multiple search and replace

2008-04-02 04:29:55
I did tried to test by changing the "version' attribute value 
to 2.0 but I am encountering another error at one of my line, 
where I am using <xsl:if 
test="name(following-sibling::keyword)"> Error: XPATH 2.0 
expression, Too many items.

This was perfect in 1.0.

You mean, it didn't fail in 1.0.

The construct in 1.0 means test="name(following-sibling::keyword[1])", that
is, test the name of the first following sibling keyword. If this is what
the code intends to be, then change it to add the "[1]". However, it very
often indicates an error of some kind. 

In this case, if there is a following-sibling keyword then its name is
"keyword", and if there is none, then name() gives "". In the first case the
result of the test is "true", in the second case it is false. So you are
really just testing, in a rather convoluted way, whether a following-sibling
named keyword exists. So change the code to


test="exists(following-sibling::keyword)"

In fact, if you leave the version attribute saying version="1.0" then this
is one of many cases where an XSLT 2.0 processor will execute your code in
backwards-compatibility mode, which means you don't have to change anything,
but can still use new features. Unfortunately though if you use XML Spy then
the only way to use the XSLT 2.0 processor is if your stylesheet specifies
version="2.0", which forces you to make such changes.

Michael Kay
http://www.saxonica.com/ 


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--