Test the validity of DTD

Source: Internet
Author: User

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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.