meyerweb.com

Skip to: site navigation/presentation
Skip to: Thoughts From Eric

Archive: 25 September 2003

Entity Errors

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[&para;]]>
</xsl:element>

The goal was to get output something like this:

<a ... >&para;</a>

Instead, what I got was this:

<a ... >&amp;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">&para;</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!

September 2003
SMTWTFS
August October
 123456
78910111213
14151617181920
21222324252627
282930  

Archives

Feeds

Extras