Reputation: 949
Looking at some posts and others, I'm close to what I'm looking for, but not there yet.
Overall goal
To have XML ENTITY files included within other XML files, with the URI to SYSTEM taken from the an environment variable!
Sample XML ENTITY files (not sure if xml declaration needed)
$XML_PATH_SET_PER_ENV/entites/$CLIENT/entities.ent
<!ENTITY COMPANY_ID "9800">
<!ENTITY PARENT_ID "98100">
<!ENTITY ACCOUNT_NAME "THE SUN PEOPLE">
<!ENTITY ACCOUNT_AB "TSP">
or $XML_PATH_SET_PER_ENV/entites/$CLIENT/entities.ent
<!ENTITY COMPANY_ID "7900">
<!ENTITY PARENT_ID "98500">
<!ENTITY ACCOUNT_NAME "FRUITS VEGGIES N MORE">
<!ENTITY ACCOUNT_AB "FVNM">
or $XML_PATH_SET_PER_ENV/entites/$CLIENT/entities.ent
<!ENTITY COMPANY_ID "84500">
<!ENTITY PARENT_ID "861675">
<!ENTITY ACCOUNT_NAME "THE SUN PEOPLE">
<!ENTITY ACCOUNT_AB "TSP">
Then within any XML file, I wish to pull in a specific entities.ent
as needed:
doc.xml
<?xml version="1.0" standalone="no" ?>
<!DOCTYPE TEST [
<!ENTITY % get_em SYSTEM "entities.ent" >
%get_em;
]>
<TEST>
<COMPANY_ID>&COMPANY_ID;</COMPANY_ID>
</TEST>
However, before getting to my stated goal, I struggling first to get this simple doc.xml
to work:
$ ls -lrt doc.xml entities.ent
-rw-r--r--. 1 user other 186 Dec 28 14:33 entities.ent
-rw-r--r--. 1 user other 182 Dec 28 14:34 doc.xml
And xmllint is not happy :(
$ xmllint --noout doc.xml
doc.xml:10: parser error : Entity 'COMPANY_ID' not defined
<COMPANY_ID>&COMPANY_ID;</COMPANY_ID>
^
Upvotes: 2
Views: 1331
Reputation: 949
To get the simple test to work, just need extra options to xmllint!
$ xmllint --loaddtd --noent --dropdtd doc.xml
<?xml version="1.0" standalone="no"?>
<TEST>
<COMPANY_ID>84500</COMPANY_ID>
</TEST>
No errors!
Upvotes: 3