Entity ErrorsPublished 19 years, 8 months past
Okay, XSLT folks, here’s one for you. I had the following fragment in my journal recipes, with some whitespace to make everything more readable:
<xsl:element name="a" use-attribute-sets="plink"> <![CDATA[¶]]> </xsl:element>
The goal was to get output something like this:
<a ... >¶</a>
Instead, what I got was this:
<a ... >&para;</a>
So how do I reach my goal? And please don’t tell me that I should just generate the character directly. It isn’t the result I want, even though I’m doing it now as a stopgap measure. All I want to know is how to get what I want, if for no other reason than it will clarify more about XSLT, XML, and how they handle CDATA and entities. Several Google searches turned up nothing useful, but it may very well be that I wasn’t using the right search terms.
Update: Curtis Pew pointed me to an XML.com article that led to the answer. It is:
<xsl:element name="a" use-attribute-sets="plink"> <xsl:text disable-output-escaping="yes">¶</xsl:text> </xsl:element>
The article talks about defining a custom entity, which I tried but failed to do even I’ve done it successfully in the past for less ambitious purposes. xsltproc kept complaining that the namespace prefix
xsl wasn’t defined, even though everything else in the recipe didn’t seem to have that problem. Moving the
xsl:text into the recipe itself was the answer. Thanks to Curtis for the lead!