RE: [xsl] Multiple search and replace

Subject: RE: [xsl] Multiple search and replace
From: "Pankaj Chaturvedi" <pankaj.chaturvedi@xxxxxxxxx>
Date: Wed, 2 Apr 2008 17:54:56 +0530
By the way, I was googling around for free XSLT/XPATH 2.0 tutorials for
newbee for start. Anybody can suggest the tutorial available for a kick
start/test the new functionality of version 2.0.

Thanks

Pankaj



-----Original Message-----
From: Pankaj Chaturvedi [mailto:pankaj.chaturvedi@xxxxxxxxx]
Sent: Wednesday, April 02, 2008 5:33 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] Multiple search and replace


Thanks Michael.

Now it works. Amazingly I was getting the results using
name(following-sibling::keyword[1]) construct or may be I was ignoring the
warnings (if any).

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.

Yes that's what exactly I was testing "the name of the first following
sibling keyword" without specifying position. Hmmmm, I will be now more
specific about syntaxes.

Thanks
Pankaj



-----Original Message-----
From: Michael Kay [mailto:mike@xxxxxxxxxxxx]
Sent: Wednesday, April 02, 2008 4:58 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] 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


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/


Confidentiality Notice:" This message and any attachment(s)
contained here are information that is confidential, proprietary to
IDS Infotech Ltd. and its customers.
Contents may be privileged or otherwise protected by law. The
information is solely intended for the individual or the entity it
is addressed to. If you are not the intended recipient of this
message, you are not authorized to read, forward, print, retain,
copy or disseminate this message or any part of it. If you have
received this e-mail in error, please notify the sender immediately
by return e-mail and delete it from your computer."

Current Thread