看some posts和others,我接近我正在寻找的东西,但还没有。
总体目标
将XML ENTITY文件 s 包含在其他XML文件 s 中,并从环境变量获取SYSTEM的URI!
示例XML ENTITY文件(不确定是否需要xml declaration)
$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">
或$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">
或$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">
然后在任何XML文件中,我希望根据需要提取特定的entities.ent
:
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>
然而,在达到我的既定目标之前,我首先努力让这个简单doc.xml
工作:
$ 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
xmllint不高兴:(
$ xmllint --noout doc.xml
doc.xml:10: parser error : Entity 'COMPANY_ID' not defined
<COMPANY_ID>&COMPANY_ID;</COMPANY_ID>
^
答案 0 :(得分:2)
要使简单测试起作用,只需要xmllint的额外选项!
$ xmllint --loaddtd --noent --dropdtd doc.xml
<?xml version="1.0" standalone="no"?>
<TEST>
<COMPANY_ID>84500</COMPANY_ID>
</TEST>
没有错误!