IT学习网(ITxuexi.com) - 打造中国最好的IT学习平台!

IT学习网

当前位置: 主页 > 基础教程 > XML相关教程 > XML >

XML 的有效性验证

时间:2009-03-01 23:45来源: 作者:admin 点击:

XML with correct syntax is Well Formed XML.
使用正确的语法可以使XML的格式标准化。

XML validated against a DTD is Valid XML.
经过DTD验证的XML是有效的XML。


Well Formed XML Documents
格式标准的XML文档

A "Well Formed" XML document has correct XML syntax.
格式标准的XML文档包含正确的XML语法规则。

A "Well Formed" XML document is a document that conforms to the XML syntax rules that were described in the previous chapters:
正如前几章中所提到过的那样,符合XML语法规则的XML才能算是格式标准的XML:

  • XML documents must have a root element
    XML文件必须有根元素
  • XML elements must have a closing tag
    XML元素必须有结束标签
  • XML tags are case sensitive
    XML标签区分字母大小写
  • XML elements must be properly nested
    XML元素必须嵌套合理
  • XML attribute values must always be quoted
    XML属性值必须写在引号内
<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>Tove</to>

<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

Valid XML Documents
有效的XML文档

A "Valid" XML document also conforms to a DTD.
一份“有效”的XML文档还得符合 DTD 规则。

A "Valid" XML document is a "Well Formed" XML document, which also conforms to the rules of a Document Type Definition (DTD):
符合DTD规则的XML文档才是格式正确的XML文档:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE note SYSTEM "InternalNote.dtd">
<note>
<to>Tove</to>

<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

XML DTD

A DTD defines the legal elements of an XML document.
DTD详细定义了XML文件中的合法元素。

The purpose of a DTD is to define the legal building blocks of an XML document. It defines the document structure with a list of legal elements. You can read more about DTD, and how to validate your XML documents in our DTD tutorial.
DTD的目的就是定义一份XML文档中的合法区块。它定义了一系列合法元素。在我们的DTD教程中,你可以了解更多关于DTD的内容,以及验证XML文档有效性的fang。


XML Schema 
XML Schema

XML Schema is an XML based alternative to DTD.
XML Schema 是基于XML的,它是DTD的另一个替换方式。

W3C supports an alternative to DTD called XML Schema. You can read more about XML Schema in our Schema tutorial.
W3C支持DTD的另一个替换方式,我们称之为 XML Schema。在Schema 教程中,你可以学习到关于 XML Schema 的更多内容。


A General XML Validator
通用XML校验器

To help you check the syntax of your xml files, we have created this link so that you can syntax-check any XML file.
为了帮助你检查XML文件语法的正确性,我们设置了 关于XML文件语法规则校验 的链接,可能对你有所帮助。

本文来源于:IT学习网 http://www.itxuexi.com/learn/5272.html

顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片