[xsl] Dealing with <![CDATA[]]> when it can't be avoided

Subject: [xsl] Dealing with <![CDATA[]]> when it can't be avoided
From: cknell@xxxxxxxxxx
Date: Thu, 05 Jul 2007 16:19:58 -0400
I have a number of XML files that contain SQL statements. Buried among identifier elements, I have a <sql> element. I generally retrieve the content using Java and XPath and query a database using it with ant.

Here's an example:

<sql><![CDATA[SELECT * FROM users WHERE clue > 0]]></sql>

As you can see, it's necessary to enclose the SQL in <![CDATA[]]> because some of the characters I must use would not be legal XML.

Since I have a number of related queries, I'd like to simplify maintenance by processing the SQL source code with XSLT. One common situation is a need to use a list of quoted string values to evaluate whether a specific record ought to be included.

Here's an example of that:

<sql><![CDATA[SELECT * FROM users WHERE status IN ('alive,'awake','sentient')]]></sql>

Current Thread