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

Re: How to include a single quote in a parameter strin

Subject: Re: How to include a single quote in a parameter string
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 30 Jul 2002 16:04:41 +0100
xpath single double quote
Hi Peiyun,

> I have the following in my stylesheet that gives me errors:
>
> <xsl:param name="fjeestitle" 
> select="'NRC Research Press: Revue du génie et de la science de
> l&#x0027;environnement'" /> 
>
> Why is this not working? How to make it work?            

When this gets read by an XML parser, it reports the value of the
select attribute to the XSLT (or rather XPath) processor to be:

  'NRC Research Press: Revue du génie et de la science de
   l'environnement'

In other words, it's the XML parser's job to resolve the &#x0027;
character reference into the ' character; that's already been done by
the time it gets to the XPath processor.

The XPath processor then tries to parse that value as an XPath. It
pairs the first ' with the second ' and then tries to parse the part
after the second ' as being an operator on that string, which is why
you get the error.

The solution is to make sure that the XPath processor gets a string
that it can parse as an XPath, and since your string has a ' in it,
that means using " to delimit the string rather than ':

  "NRC Research Press: Revue du génie et de la science de
   l'environnement"

Then you can move that into the XML either by delimiting the attribute
value with double quotes and escaping the double quotes in the XPath:

<xsl:param name="fjeestitle"
  select="&quot;NRC Research Press: Revue du génie et de la science de
   l'environnement&quot;" />

or by delimiting the attribute value by single quotes and escaping the
single quote in the XPath:

<xsl:param name="fjeestitle"
  select='"NRC Research Press: Revue du génie et de la science de
   l&apos;environnement"' />

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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