A legal document must complyDTDThe specified constraint. In addition, its basic elements must be specified in the document type declaration. List8-1Description andDTDA valid document must be as follows:
<Greeting>
Various random text but no Markup
</Greeting>
A legal document cannot be like this:
<Greeting>
<Sometag> various random text </sometag>
<Someemptytag/>
</Greeting>
It cannot be like this:
<Greeting>
<Greeting> various random text </greeting>
</Greeting>
This document must be placed in<Greeting>Start tag and<1 greeting>It is composed of the characters that can be parsed between the ending mark. Unlike a document that only has a complete structure, legal documents cannot use any tag. Any tag used must be inDTD. In additionDTDAllowed. In the list8-1Medium,<Greeting>A tag can only be used as the start of a basic element and cannot be nested.
Let's assume that8-2Make some changes<Foo>And</Foo>Replace<Greeting>And</Greeting>Tag, such as list8-3. List8-3It is legal. It is a fully structuredXMLDocument, but it does not conform to the document type description andDTD.
Non-conformingDTDInvalid ruleHello XML
<? XML version = "1.0" standalone = "yes"?>
<? XML-stylesheet type = "text/CSS" href = "greeting.css"?>
<! Doctype greeting [
<! Element greeting (# pcdata)>
]>
<Foo>
Hello XML!
</Foo>
Not all documents must be legal, and not all syntax analysisProgramCheck the validity of the document. In fact, mostWebBrowsers includeIE5 andMozillaDoes not check the validity of the document.
Read the syntax analysis program that checks ValidityDTDAnd check whether the document meetsDTDThe specified rule. If yes, the analysis program transfers the dataXMLApplications (suchWebBrowser and database ). If the analysis program finds an error, it reports an error. If you manually writeXML, The validity of the document should be checked before posting to ensure that the reader will not encounter errors.
InWebThere are dozens of different syntax analysis programs for legitimacy check. Most of them are free of charge. Most products exist in the form of library files, so that programmers can combine them into their own programs. These product user interfaces (if any) are poor. This type of analysis program includesIBMOfAlphaWorks 'xml for Java,MicrosoftAndDatachannelOfXjparserAndSilfideOfSXP.
XML for Java:Http://www.alphaworks.ibm.com/Tech/XML
Xjparser:Http://www.datachannel.com/xml_resources/
SXP:Http://www.loria.fr/projets/XSilfide/EN/sxp/