One: XML constraint concept
XML constraints: You can write a document to constrain the writing specification of an XML file.
XML language format is more rigorous, it is impossible for programmers to write freely, so must have constraints.
Second: Common XML constraint techniques
1:dtd,document type definition
2: Verifying the legitimacy of XML files
A: Using the Parse tool
B: Using IDE tools, such as: Eclipse
Books.html
1 <?XML version= "1.0"?>2 <!DOCTYPE Bookstore SYSTEM "BOOK.DTD">3 <Bookstore>4 < Book>5 <name>Thinking in Java</name>6 <author>Tom</author>7 < Price>105.0</ Price>8 </ Book>9 < Book>Ten <name>Thinking in C</name> One <author>Jack</author> A < Price>85.0</ Price> - </ Book> - </Bookstore>
Books.dtd
1 <! ELEMENT Bookstore (book+) > 2 <! ELEMENT Book (name,author,price) > 3 <! ELEMENT name (#PCDATA) > 4 <! ELEMENT author (#PCDATA) > 5 <! ELEMENT Price (#PCDATA) >
Javaweb Learning Summary VIII (XML constraints <DTD and schema>)