这个 dtd 适合 xml 文件吗?

发布于 2024-10-07 12:31:58 字数 1427 浏览 0 评论 0原文

我有这个 xml 文件:

data_out.xml

<?xml version="1.0" ?> 
<!DOCTYPE allproperty SYSTEM "data_out.dtd">
<allproperty>
    <aproperty>
      <postcode>ha15rs</postcode> 
      <price>250</price> 
      <imagefilename>home2.gif</imagefilename> 
      <visits>2</visits> 
    </aproperty>
    <aproperty>
      <postcode>ha36gs</postcode> 
      <price>150</price> 
      <imagefilename>home3.gif</imagefilename> 
      <visits>1</visits> 
    </aproperty>
    <aproperty>
      <postcode>ha27se</postcode> 
      <price>300</price> 
      <imagefilename>home4.gif</imagefilename> 
      <visits>4</visits> 
    </aproperty>
    <aproperty>
      <postcode>ha4678</postcode> 
      <price>200</price> 
      <imagefilename>home5.gif</imagefilename> 
      <visits>5</visits> 
    </aproperty>
</allproperty>

DTD 文件

data_out.dtd

<!ELEMENT aproperty (postcode,price,imagefilename,visits)>
<!ELEMENT postcode (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT imagefilename (#PCDATA)>
<!ELEMENT visits (#PCDATA)>

当我检查“说 allproperty 未声明”时,我不断收到错误

I have this xml file:

data_out.xml

<?xml version="1.0" ?> 
<!DOCTYPE allproperty SYSTEM "data_out.dtd">
<allproperty>
    <aproperty>
      <postcode>ha15rs</postcode> 
      <price>250</price> 
      <imagefilename>home2.gif</imagefilename> 
      <visits>2</visits> 
    </aproperty>
    <aproperty>
      <postcode>ha36gs</postcode> 
      <price>150</price> 
      <imagefilename>home3.gif</imagefilename> 
      <visits>1</visits> 
    </aproperty>
    <aproperty>
      <postcode>ha27se</postcode> 
      <price>300</price> 
      <imagefilename>home4.gif</imagefilename> 
      <visits>4</visits> 
    </aproperty>
    <aproperty>
      <postcode>ha4678</postcode> 
      <price>200</price> 
      <imagefilename>home5.gif</imagefilename> 
      <visits>5</visits> 
    </aproperty>
</allproperty>

a DTD file

data_out.dtd

<!ELEMENT aproperty (postcode,price,imagefilename,visits)>
<!ELEMENT postcode (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT imagefilename (#PCDATA)>
<!ELEMENT visits (#PCDATA)>

I keep getting a error when I do check "saying the allproperty is not declared"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倾城月光淡如水﹏ 2024-10-14 12:31:58

您还必须在 DTD 中声明 allproperly

<!ELEMENT allproperty (aproperty+)>
<!ELEMENT aproperty (postcode,price,imagefilename,visits)>
<!ELEMENT postcode (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT imagefilename (#PCDATA)>
<!ELEMENT visits (#PCDATA)>

You have to declare allproperly in the DTD as well

<!ELEMENT allproperty (aproperty+)>
<!ELEMENT aproperty (postcode,price,imagefilename,visits)>
<!ELEMENT postcode (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT imagefilename (#PCDATA)>
<!ELEMENT visits (#PCDATA)>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文