XML实体包括不显示 [英] XML entity include not displaying

查看:78
本文介绍了XML实体包括不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在xml中包含一个实体,但是似乎没有显示。我对XML还是很陌生,所以如果我在研究中发现的不是最佳实践,那么我很乐于接受更改。

I am attempting to include an entity within my xml, however, it doesn't seem to be displaying. I'm very new to XML, so if what I've found in my research isn't best practice, I'm more than open to changing.

XML to包括

<resume>
    <personal_info>
        <birthdate>07/08/1988</birthdate>
    </personal_info>
    <jobs>
        <job>
            <company>Radio Shack</company>
            <title>Sales Representative</title>
            <startdate>01/01/2011</startdate>
            <enddate>02/02/2011</enddate>
            <duration>1.5yrs</duration>
            <sortdate>20110101</sortdate>
        </job>
        <job>
            <company>Radio Shack2</company>
            <title>Sales Representative</title>
            <startdate>01/01/2013</startdate>
            <enddate>02/02/2013</enddate>
            <duration>1.5yrs</duration>
            <sortdate>20130202</sortdate>
        </job>
    </jobs>
</resume>

包含的XML

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE downloadWord SYSTEM "resume.dtd"[
<!ENTITY resume SYSTEM "resume.xml">
]>
<thing>
&resume;
</thing>

DTD

<!ELEMENT thing (resume)>
<!ELEMENT resume (personalinfo, jobs)>
<!ELEMENT personalinfo (birthdate)>
<!ELEMENT birthdate (#PCDATA)>
<!ELEMENT jobs (company,title,startdate,enddate,duration,sortdate)>
<!ELEMENT company (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT startdate (#PCDATA)>
<!ELEMENT enddate (#PCDATA)>
<!ELEMENT duration (#PCDATA)>
<!ELEMENT sortdate (#PCDATA)>


推荐答案

后的单词DOCTYPE 必须是文档根元素(用代替 downloadWord c>):

The word that comes after DOCTYPE must be the document root element (replace downloadWord with thing):

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE thing SYSTEM "resume.dtd"[
    <!ENTITY resume SYSTEM "resume.xml">
]>
<thing>
    &resume;
</thing>

该文件应包含文件(这将导致验证错误,因为文档与DTD不匹配要修复DTD,使其与实例匹配(您可能想做相反的事情):

That should include the file (which will cause validation errors, since the document doesn't match the DTD. To fix the DTD so it matches the instance (you might want to do the opposite):

第2行:更改 personalinfo 转换为 personal_info

<!ELEMENT resume (personal_info, jobs)>

第5行:将职位替换为职位

<!ELEMENT job (company,title,startdate,enddate,duration,sortdate)>

添加此换行符

<!ELEMENT jobs (job+)>

这是最终的简历。 dtd DTD验证上面的文件:

This is the final resume.dtd DTD which validates the file above:

<!ELEMENT thing (resume)>
<!ELEMENT resume (personal_info, jobs)>
<!ELEMENT personal_info (birthdate)>
<!ELEMENT birthdate (#PCDATA)>
<!ELEMENT jobs (job+)>
<!ELEMENT job (company,title,startdate,enddate,duration,sortdate)>
<!ELEMENT company (#PCDATA)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT startdate (#PCDATA)>
<!ELEMENT enddate (#PCDATA)>
<!ELEMENT duration (#PCDATA)>
<!ELEMENT sortdate (#PCDATA)>

这篇关于XML实体包括不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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