Basic XML concept analysis (1) sax, Dom, DTD, and schema

Source: Internet
Author: User

Dom, sax, DTD, and XML Schema are easy to mix concepts. Author: rainwater Date: reprinted. Please keep it here. The first few concepts of learning XML are the easiest to confuse and you cannot figure out what is going on. Here, we will analyze the four important concepts of Dom, sax, DTD, and schema in XML to solve the problem. Dom and sax are two main APIs used to manipulate XML documents in applications. They are explained as follows: Dom, that is, Document Object Model. Chinese is called Document Object Model. Dom is a standard Document Object Model defined by W3C. Programming Language This is an unrelated model used for memory storage and hierarchical document operations. When the XML document is parsed according to the DOM model, a corresponding DOM tree is constructed in the memory, which can be used for traversing between different nodes. However, the DOM tree must be constructed before traversal. Therefore, processing large XML documents consumes a lot of memory and consumes a lot of resources. In particular, you only need to operate Composition A small part of the archive has a low aging rate. Sax, short for Simple API for XML, is called XML simple application. Program Interface. It is a de facto standard. Unlike Dom, it uses an event-driven model. Every time a start or end tag, attribute, or command is encountered during XML parsing, the program generates an event for corresponding processing. Therefore, you do not need to parse the entire document before operating the document. In fact, each part of the document can be parsed at the same time. Therefore, Sax is more suitable for operating large documents than Dom. DTD and Schema are tools used to define the structure of XML documents. They are used to define the structure of the XML document, and verify whether the XML document meets the specified structure. DTD, that is, document type define, which is a Chinese document type definition. It is a subset of the standard notification Markup Language (SGML) DTD. An xml dtd defines the element architecture, element tag, and attributes of an XML document. When creating an XML document, you usually need to follow the DTD specification. In turn, you can verify the document's DTD to verify the correctness of the XML document. DTD cannot define some necessary restrictions, such as the number of occurrences of elements and data types. Therefore, DTD is more suitable for document-centered XML content. Schema. Unlike DTD, it is also based on XML. XML Schema also supports namespaces to define more complex data types and structures than DTD. XML Schema supports a series of simple data types, such as strings, decimals, and integers, and defines the number of times an element appears. Therefore, XML schema is more suitable for data-centric documents. Currently, more and more applications prefer to use XML schema to define and verify XML documents.

 

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.