RE: Matching attributes that contain both &pos; and "

Subject: RE: Matching attributes that contain both &pos; and "
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Fri, 8 Sep 2000 11:41:02 +0100
> However the following example proves troublesome for XT, Saxon
> and Xalan. All of them generate an error.

> <xsl:template match="channel/location[@name=' "x" &apos;a z']">

It is an error, because it's not well-formed XML. 

> This might be a flaw with the spec,

It's not really a flaw in the spec: this would be a valid XPath expression,
it's just that you can't use it at this place in a well-formed XML document.

>  but given that it isn't, does anyone
> have a work around for how to match this attribute.

Given that variables ca't be used in a template match pattern, I think the
only way around it is with concat().

<xsl:template match="channel/location[
          @name=concat('&quot;x&quot;', &quot'a&quot z)]">

The trick is to write the XPath expression "naturally", and then replace all
occurrences of " with &quot; regardless whether it's being used as an XPath
string delimiter or as a character within a string. 

Mike Kay

 XSL-List info and archive:

Current Thread