Reputation: 1
I have an XML file that contains an number of SQL queries stored as entities. Further down in the document, attributes reference these entities in order to associate which SQL query to bind an element in the document structure with a matching element in the database.
The intention was: the XML control characters ('<','>', '&', etc..) would remain escaped until the document was loaded. Instead, the document is failing validation because it is removing the escape codes wherever the entity gets referenced.
Is there a better way to use escape characters in Entities?
Sample code (my.xml):
<!ENTITY SQL.typeNot9 "SELECT * FROM my_table WHERE type<>9">
<item name="endFixId" browseType="database" form="example_form" SQLQuery="&SQL.typeNot9;" useRawValue="false" />
Output of xmllint --schema my_schema.xsd my.xml
:
my.xml:123: parser error : '<' in entity 'SQL.typeNot9' is not allowed in attributes values me="endFixId" browseType="database" form="example_form" SQLQuery="&SQL.typeNot9;
Large legacy system, limited options for re-arranging or re-designing.
Upvotes: 0
Views: 39
Reputation: 12777
Could be related to the XSD definition since the XML fragment provided works as expected
Given this XML
<?xml version="1.0"?>
<!DOCTYPE root [
<!ELEMENT item ANY >
<!ENTITY SQL.typeNot9 "SELECT * FROM my_table WHERE type<>9">]>
<root>
<item name="endFixId" browseType="database" form="example_form"
SQLQuery="&SQL.typeNot9;"
useRawValue="false" />
</root>
Testing with xmmlint
xmllint --noent --xpath '//@SQLQuery' tmp.xml ; echo
Result
SQLQuery="SELECT * FROM my_table WHERE type<>9"
Upvotes: 0