[XML Learning Notes] [2.] XML Verification

xiaoxiao2021-03-06  44

In order to make our defined XML document meaning, we usually have to define a set of grammar, such as this document contains that type of data, what is the hierarchy of this data, and so on. This allows our XML documents to verify its legitimacy through specialized tools.

There are two ways: I-DTD (Document Type Definition); II- XSD (XML Schema Definition), we look at it separately.

DTD is relatively simple and straightforward, it can easily define the affiliation between elements and elements, such as:

Element Customer-Repository (Customer )

>

Element Customer (Name, Register-Date, Visits)

>

Attlist Customer INDEX ID #Required

>

ELEMENT NAME (#pcdata)

>

Attlist name first-name cdata #Requid Last-name cdata #Required

>

Element Register-Date (#cdata)

>

Element Visits (#cdata)

>

Used to define elements, while defining whether the element contains other elements, The properties used to define elements, the specific syntax can refer to the document on http://www.w3c.org/xml/ . In order to contact our XML document and the syntax above the above, we need to add such a line of code in XML:

DOCTYPE CUSTOMER-Repository System "Customer-repository.dtd"

>

Similar to DTD, XSD is also a class of XML syntax through some rules, which is more flexible than DTD, more powerful, and is the current XML verification criterion for W3C. It defines our XML syntax by some namespaces that have defined the type of elements, such as:

<

XSD: ELEMENT

Name

= "Visits"

Type

= "XSD: Decimal"

/>

The XSD here is the namespace we have to use. Since most of the XMLs are still using DTD, the understanding of XSD is here. Interested in W3C website to understand the specific syntax.

转载请注明原文地址:https://www.9cbs.com/read-56274.html

New Post(0)