Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xsl] Multiple search and replace

From: "Michael Kay" <mike@------------>
To:
Date: 4/2/2008 11:30:00 AM
> 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 XMLSpy">XMLSpy 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/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent