The DTD FOR XML constraints

Source: Internet
Author: User

XML constraint technology:    DTD constraint: syntax is relatively simple and function is relatively simple.    schema constraints: The syntax is relatively complex and functions are relatively powerful. (namespace)

DTD constrained import DTD mode:
Internal Import <! DOCTYPE Note [  <! ELEMENT Note (to,from,heading,body) >  <! ELEMENT to      (#PCDATA) >  <! ELEMENT from    (#PCDATA) >  <! ELEMENT heading (#PCDATA) >  <! ELEMENT body    (#PCDATA) >]>
external import of    local file system    :<! DOCTYPE Note SYSTEM "Note.dtd" >     External import of public:<! DOCTYPE root element Public "HTTP://GZ.ITCAST.CN/ITCAST.DTD" >
DTD syntax    constraint tag         <! Element name category >  or <! Element elements name (element content) >     Category:        empty tag: null. Indicates that the element must be an empty element.        Normal string: (#PCDATA). Indicates that the content of an element must be a normal string (cannot contain child tags).        
(element content): Order problem:<! element name (child element name 1, child element name 2,.....) >: Number of sub-labels in order problem: Tags: must and only appear 1 times. Label+: Labels appear at least 1 times*: 0 or N times.  Label? :0or 1 times. Constraint Properties<! Attlist element Name Property Name property type default Value >Default Value: #REQUIRED property value is required #IMPLIED property is not required #FIXED The Value property is not required, but the property value is a fixed property type: A CDATA that controls the value of a property: normal String (En1|en2|..) : Indicates that it must be one of the value IDs: Indicates that the attribute value must be unique in an XML document. Value cannot start with a number

Code:

Create a new Note.dtd file  : <! ELEMENT Note (from?,to+,heading*,body+) >  <! ELEMENT to      empty>  <! ELEMENT from    (#PCDATA) >  <! ELEMENT heading (#PCDATA) >  <! ELEMENT body    (#PCDATA) >  <! Attlist to ID ID #REQUIRED >
Create a new note.xml<?xml version= "1.0"? ><! DOCTYPE Note SYSTEM "note.dtd" ><note>  <to id= "A1" ></to>  <to id= "A2" ></to>  <to id= "A3" ></to>  

The DTD FOR XML constraints

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.