I set a variable depending on the specific value of a field. Inside an <xsl:choose>, the following code works perfectly:
<xsl:when test="property_type='hotel'">47</xsl:when>
However, I now need to check for a string such as “b&b”:
<xsl:when test="property_type='b&b'">48</xsl:when>
This fails, giving:
Error on line 42 column 72 of transform.xslt: SXXP0003: Error
reported by XML parser: The reference to entity “b” must end with the
‘;’ delimiter.
I understand the error but I can’t figure out how to get round it. The ampersand is present in the data xml and is valid (it is in CDATA). The error is in my xslt where it isn’t valid.
You need to escape the ampersand with the xml entity
&. Your code should look like this: