Subject: Re: [xsl] Apostrification From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Thu, 5 Apr 2001 13:35:11 +0100 |
Hi Richard, > How do I put an aprotophy in this string... > > <xsl:value-of select="concat('[@name = '',@name,'']')"/> > > I think you can see what I'm trying to produce which is som > debugging message that generates and X-Path to the problem XSLT processors never see anything to do with what entities are used where within XML. So as far as the XSLT processor is concerned, the above attribute value is: concat('[@name = '',@name,'']') This isn't a valid XPath. You need to change this string to be something that the XSLT processor can parse as an XPath. Unfortunately, there's no way to escape quotes in XPath. Fortunately, though you can use both " and ' to delimit strings in XPath, so you can use: concat("[@name = '",@name,"']") instead. So, given this XPath, you have to then convert it to an attribute value that an XML parser can accept. To make it well formed XML, if you use "s to delimit the value of an attribute then you have escape any "s with the XML entity " to give: <xsl:value-of select="concat("[@name = '", @name,"']")" /> Alternatively, you could use 's around the attribute value, in which case you'd have to escape the 's in the XPath with ' to give: <xsl:value-of select='concat("[@name = '", @name,"']")' /> Or you could escape both with just the same effect: <xsl:value-of select="concat("[@name = '", @name,"']")" /> And go mad and do the same thing for spaces: <xsl:value-of select="concat("[@name='", @name,"']")" /> and so on, replacing all the characters with their equivalent entities. It matters not a jot to the XSLT processor - it will always receive the same string, and try to interpret it as an XPath. I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Apostrification, Richard Mitchell | Thread | RE: [xsl] Apostrification, Michael Kay |
Re: [xsl] !!!counters in XSL!!!, Alexey Gokhberg | Date | Re: [xsl] Copying Node Multiple Tim, Jeni Tennison |
Month |