[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
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'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 ' 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=""NRC Research Press: Revue du génie et de la science de l'environnement"" /> 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'environnement"' /> Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|