XML Schema helps you model (1)

xiaoxiao2021-03-06  41

XML Schema help you modeling (1) Author: Xiao Chai Road www.ASPCool.com

XML Schema is a recommended standard for W3C (World Wide Web Alliance), officially released in May 2001. After several years of large-scale discussions and development, it is now laid, and it is the preferred data modeling tool in the world's recognized XML environment. Since XML is a subset of SGML (standard universal label language), it also inherits SGML for modeling DTD. The advantage of using DTD is to take advantage of a large number of existing DTD tools, making it a relatively low level to develop applications. However, DTD has a lot of defects: 1. DTD is based on regular expressions, and the description ability is limited; 2. DTD has no data type support, in most application environments; 3. DTD constraint definition ability is insufficient, unable Detailed semantic restrictions on the XML instance document; 4. DTD is not structured, the cost of reuse is relatively high; 5. DTD is not using XML as a description method, and the construction of DTD does not have a standard programming interface, cannot be DTD maintenance is performed using standard programming. XML Schema is designed for the shortcomings of these DTDs, which use XML as a descriptor, which has strong description capabilities, extension capabilities, and processing maintenance. XML Schema Introduction The main purpose of XML Schema is to define a class XML document (an XML Application). Therefore, the "example document" form of the mode is often used to describe an XML document consistent with a particular XML Schema. In fact, document instances and Schema documents do not exist in the form of documents, which can exist in the form of byte streams transmitted between applications, or as a collection of database records and XML "information items". However, in order to simplify the entry, we always regard examples and patterns as documentation or files, think they always exist in the form of a document instance or a mode document. Here we will combine an example to make a simple summary of XML Schema, I hope that you can use the usage method for the initial master of this section and the specific semantics of the XML Schema document instance. XML Schema is a basic tool for web services technology, but not all features of XML Schema will be used extensively, and therefore, this article will not be introduced for the system of XML Schema. Before introducing the XML Schema syntax, first consider an XML instance document PO.xml. It describes a home product purchase order generated by home product procurement / payment applications (see Code 1).

< Name> Alice Smith 123 maple street Mill Valley ca 90952 robert smith 8 Oak Avenue Old Town pa 95819 < / Billto> Hurry, My Lawn is going wild! baby monitor 1 39.98 1999-05-21 This purchase order consists of a heel of elements PurchaseOrder and its sub-elements Shipto, BillTo, Comment, and Items. These sub-elements (except for Comment) also contain some other child elements. The leaf element is included in a number rather than any child element, such as a child element such as USPRice. Elements are called composite types if they contain sub-elements or with attributes; vice verses if only numbers, strings, or other data, etc., but are not included in the simple type. In this instance document, the composite type and some simple types are defined in the mode document that purchase the order, while the simple types of other standards are the form of simple types built in XML Schema. Introduce the contact between the purchase order instance document and the mode document before studying the purchase order mode documentation of this instance document.

An instance document actually does not necessarily need a reference mode document. Of course, in fact, many instance documents do reference the mode document, in order to make the entry make it simpler, and we choose not to reference. At the same time, it is assumed that the processor of any instance document does not receive any information from the purchase order instance document, and can also correctly purchase the order mode document. Purchase Order Mode Documents in Code 2, give the mode document for purchasing orders. Document PO.xSD Before giveing ​​an explanation, you can use XML knowledge to try to understand this mode document.

Purchase order schema for Example.com Copyright 2000 Example.com All rights reserved

Buy order mode document by a schema element and one The series of sub-elements, most sub-elements are Element, ComplexType, and SimpleType, which determines the expression and content of the elements in the instance document, everyone can be familiar with Element, C OMPLEXTYPE, SIMPLETYPE these elements, these will be several elements we have only need to use. At the same time, you can declare XMLns: XSD = "http://www.w3.org/2001/xmlschema" by using the namespace in the Schema element, making each element in the pattern document has a namespace with XML Schema Contact Name Space Prefix "XSD:". Although in the grammatical, any prefix form can be used, but the namespace prefix "XSD:" is agreed to represent the XML Schema namespace.

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

New Post(0)