在使用$ ENV变量解析路径时,使用SYSTEM包含外部XML ENTITIES [英] Include external XML ENTITIES using SYSTEM while resolving path with $ENV variable

查看:167
本文介绍了在使用$ ENV变量解析路径时,使用SYSTEM包含外部XML ENTITIES的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查看一些帖子其他人,我接近我正在寻找,但还没有

Looking at some posts and others, I'm close to what I'm looking for, but not there yet.

总体目标

要使XML ENTITY文件 / strong>包含在其他XML文件 s 中,系统取自环境变量的URI!

To have XML ENTITY files included within other XML files, with the URI to SYSTEM taken from the an environment variable!

示例XML ENTITY文件(不确定 xml声明

$ XML_PATH_SET_PER_ENV / intites / $ CLIENT / entities.ent p>

$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 / intites / $ 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 / intites / $ CLIENT / entities.ent

<!ENTITY COMPANY_ID "84500">
<!ENTITY PARENT_ID "861675">
<!ENTITY ACCOUNT_NAME "THE SUN PEOPLE">
<!ENTITY ACCOUNT_AB "TSP">

然后在任何XML文件中,我希望拉入 code> entities.ent 根据需要:

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>

然而,在达到我所说的目标之前,我努力争取得到这个简单的 doc.xml 工作:

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

而且xmllint不开心:(



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>
                                        ^


推荐答案

要简单的测试工作,只需要额外的选项xmllint!

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>

没有错误!

这篇关于在使用$ ENV变量解析路径时,使用SYSTEM包含外部XML ENTITIES的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆