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>
From time to time the values in the list change. I'd like to use XSLT to
process all related XML files containing queries so as to reduce the risk of
forgetting to update a query, as is likely to happen if I try to maintain the
queries manually.
I have complete control over the structure of the XML and, of course, the XSLT.
My puzzle is how to write a template (and, or structure the XML) that would
permit me change the contents of the list while maintaining the rest of the SQL
untouched.
I have thought of enclosing the list in its own element,
<sql><![CDATA[SELECT * FROM users WHERE status IN
(]]><list>'alive,'awake','sentient'</list>><![CDATA[)]]></sql>
but there isn't any XSLT construct to permit me to select all the content of an
element EXCEPT the content of the child <list>. Or at least I can't think of
one.
It seems that this kind of question comes up from time to time on the list, but
this long-winded question is my way of saying I can't think of how to search
for a similar problem.
Thank you.
--
Charles Knell
cknell(_at_)onebox(_dot_)com - email
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--