Subject: RE: [xsl] Multiple search and replace From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Wed, 2 Apr 2008 19:28:12 +0800 |
> 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/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Multiple search and repla, Mukul Gandhi | Thread | RE: [xsl] Multiple search and repla, Pankaj Chaturvedi |
Re: [xsl] Multiple search and repla, Mukul Gandhi | Date | Re: [xsl] Multiple search and repla, Michael Müller-Hille |
Month |