此DTD声明的措词正确吗? [英] Is this DTD declaration correctly phrased?

查看:80
本文介绍了此DTD声明的措词正确吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

XML和DTD的新手,试图做一个作业,借以给我DDT,但我需要写出XML内容并进行解析。

New to XML and DTD, trying to do a homework whereby I was given the DTD but I need to write out the XML content and parse it.

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

<!ELEMENT ConutryList (CountryReccord) +>
<!ATTLIST CountryList
  xmlns CDATA #FIXED ' '>

<!ELEMENT CountryRecord (name,alpha-2,alpha-3,country-code,iso_3166-2,region,sub-region,intermediate-region,region-code,sub-region-code,
intermediate-region-code,capital-city,currency,currency-code, population)>

<!ATTLIST CountryRecord
  xmlns CDATA #FIXED ' '>

<CountryList>
  <CountryRecord>
  <name> Afganistan </name>
  <alpha-2> AF </alpha-2>
  <country-code> AFG </country-code>
  <iso_3166-2>
  <region>
  <sub-region>
  <intermediate-region>
  <region-code>
  <sub-region-code>
  <intermediate-region-code>
  <capital-city>
  <currency>
  <currency-code>
  <population>
  </CountryRecord>
</CountryList>

我的编码格式正确吗?我对此不太确定,不敢重新启动一切。我正在处理大量清单。

Is this my format of coding correct? I am very unsure of it, scared to have to restart everything. There is a huge list im working on it. Any help would be appreciated!

推荐答案

这里有很多错误,很难知道从哪里开始。我很快注意到的前四个是(a)DTD必须在DOCTYPE声明中,(b)实例中必须有一个alpha-3元素,(c)CountryRecord需要具有xmlns属性(DTD是(d)大多数子元素没有结束符。

There are so many things wrong here it's hard to know where to start. The first four I noticed very quickly are (a) the DTD needs to be in a DOCTYPE declaration, (b) there needs to be an alpha-3 element in the instance, (c) CountryRecord needs to have an xmlns attribute (DTDs are not namespace aware, and treat namespace declarations as ordinary attributes) (d) most of the child elements have no closing end tag.

但是退后一步,更深层次的事情是错误的,这就是您获取信息和解决问题的方法。您不应该在StackOverflow上问这个问题。您应该阅读教科书,使教程中的示例生效,并在编写任何代码之前学习概念和原则。当事情不起作用时,您应该查看错误消息,并以它们为指导来找出问题所在。

But step back, and something deeper is wrong, and that's your approach to getting information and solving problems. You shouldn't be asking this on StackOverflow. You should be reading textbooks, getting examples in tutorials to work, learning the concepts and principles before you write any code; and when things don't work, you should be looking at the error messages and using them as guidance to find out what's wrong.

这篇关于此DTD声明的措词正确吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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