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

RE: Multiple search and replace

Subject: RE: Multiple search and replace
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 2 Apr 2008 19:28:12 +0800
RE:  Multiple search and replace
> 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


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

Current Thread


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.
First Name
Last Name
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.