Chapter III Terminology
outline:
Introduction Terms of the term. Xml document related terms
preface
The initial XML is the most distressed, there is a big new term concept to understand. Since XML itself is also a brand new technology, it is constantly developing and changing, all organizations and major network companies (Microsoft, IBM, Sun, etc.) are constantly launching their own insights and standards, so the new concept is not surprising. . And the lack of authoritative institutions or organizations have officially named these terms. Most of the Chinese textbooks you have seen are translated by the author's understanding, some are correct, some are wrong, more obstruction. We understand and learn from these concepts.
The explanation of XML terms will be seen below is also the understanding and translation of the author itself. Abie is based on the XML1.0 standard specification and related formal description documents released by the W3C organization. It is possible to ensure that these understandings are basically correct, at least not wrong. If you want to read and understand further, I have set out the source and link of the relevant resources in this article, you can access it directly. Ok, we transfer to the topic:
I. xML document What is the term XML document? Know the HTML original code file, the XML document is the XML original code file written by XML identity. The XML document is also an ASCII's plain text file, you can create and modify with NotePad. The suffix of the XML document is called .xml, such as MyFile.xml. You can also open the .xml file directly above the browser, but you see is "XML original code" without displaying the page content. You can save the following code to myfile.xml:
XML Version = "1.0" encoding = "GB2312"?>
The XML document contains three parts: 1. An XML document declaration; 2. A definition of document type; 3. Content created with XML ID.
For example: XML Version = "1.0"?>
1.Element: The element has been understood in HTML, it is the minimum unit that makes up the HTML document, the same in XML. One element is defined by a logo, including the start and end identity, and the content, just like this:
The 2.TAG (Identification) ID is used to define elements. In XML, the identity must be paired, surrounded by the data. The name of the identification and the name of the element is the same. For example, such an element:
4. Declaration has an XML declaration in the first line of all XML documents. This statement means that this document is an XML document that follows which XML version of the specification. An XML declaration statement is like this: XML Version = "1.0"?>
5.DTD (File Type Definition) DTD is used to define the relationship between elements, attributes, and elements in the XML document. You can detect if the structure of the XML document is correct through the DTD file. But establishing an XML document does not necessarily require a DTD file. Detailed description of the DTD file We will list separately below.
6.Well-Formed XML (Good format XML) A document complies with XML syntax rules and complies with the XML specification document called "Good Format". If all your identity strictly abide by the XML specification, your XML document does not necessarily need a DTD file to define it. Good format documents must begin with an XML declaration, for example: XML Version = "1.0" Standalone = "YES" encoding = "UTF-8"?> Where you must explain the XML version of the document, currently 1.0; second The documentation is "independent", it does not require a DTD file to verify that the identity is valid; third, to explain the language encoding used by the document. The default is UTF-8. If you use Chinese, you need to be set to GB2312. Good format XML document must have a root element, which is the first element established behind the declaration, and other elements are sub-elements of this root element, belonging to a set of roots. The XML syntax must be observed when writing the content of the XML document in a good format. (About XML grammar we will carefully explain in the next chapter)
7. Valid XML (Effective XML) A XML document complies with XML syntax rules and complies with the corresponding DTD file specification is called a valid XML document. Note that we compare "Well-Formed XML" and "Valid XML", and their biggest difference is that a fully complied with XML specification, one has its own "file type definition (DTD)". Compare the XML document and its DTD file to see if the process of complies with the DTD rule is Validation. Such a process usually processed by a software called Parser. Effective XML documents must also start with an XML declaration, for example: XML Version = "1.0" Standalone = "no" eNCode = "UTF-8"?> And the above example is different, in the Standalone property, It is set to "NO" because it must be used with the corresponding DTD, the definition method of the DTD file is as follows: where: "! Doctype" means You have to define a doctype; "type-of-doc" is the name of the document type, defined by yourself, usually the same DTD file name; "System / Public" These two parameters use only one. System is the URL of the private DTD file used by the document, and the public refers to the URL of a public DTD file. "DTD-Name" is the URL and name of the DTD file. All DTD files are named ".dtd". We still use the above examples, should be written as this: XML Version = "1.0" Standalone = "no" encode = "UTF-8"?>
Two. DTD's terminology What is DTD, and we are briefly mentioned. DTD is an effective way to ensure the correct way to format XML documents, comparing whether the XML document and DTD files are in line with the documentation, element and label use are correct. A DTD document contains: Defining rules for elements, definition rules for element relationships, properties that can be used, can be used, or symbol rules. The DTD file is also an ASCII text file, the suffix is called .dtd. For example: myfile.dtd. Why use DTD files? My understanding is that it meets network sharing and data interaction, using DTD's greatest benefits in the sharing of DTD files. (This is the PUBLIC property in the DTD in the above sentence). For example, two people in different parts of the same industry use the same DTD file to create a specification as a document, then their data is easy to exchange and share. There are other people on the Internet to supplement the data, and only need to establish a document according to the public DTD specification, they can immediately join. Currently, there is already a number of writable DTD files available. For different industries and applications, these DTD files have established universal elements and label rules. You don't need to create yourself, just join the new identity you need on the basis. Of course, if you like, you can create your own DTD, which may be more perfect with your document. Establishing your own DTD is also a very simple matter, usually only need to define 4-5 elements. There are two ways to call the DTD file: 1. DTD directly contained in the XML document You can insert some special instructions in the DOCTYPE declaration, like this: We have an XML document: Xml Version = "1.0 "Encoding =" GB2312 ">>
2. Call the independent DTD file to save the DTD document as the .dtd file, then call in the DOCTYPE declaration line, for example, save the following code to myfile.dtd
Then in the XML document, insert after the first line:
We can see that the DTD document and the call of JS in HTML are similar, and how to write specific DTD documents, we will introduce the syntax of the next chapter and the XML document.
Let's take a look at the terminology related to DTD:
1.Schema (planning) Schema is a description of the data rule. SCHEMA do two things: a. It defines the relationship between elemental data types and elements; b. It defines the type of content that elements can contain. DTD is a Schema on the XML document.
2. Document Tree (Document Tree) "Document Tree" In the first chapter, we have already mentioned that it is the image representation of the document element hierarchy. A document tree contains root elements, the root element is the top element, (is the first element after the XML declaration statement). See example: XML Version = "1.0"?>
4.Parser Parser is a tool software that checks if the XML document follows the DTD specification. XML's Parser is developed into two categories: one is "non-confirmation class paser", only detects whether the document complies with the XML syntax rules, whether the document tree is established with element identity. The other is "confirmation class paser", which not only detects document syntax, tree, but also compares whether the elements you use is complied with the specification of the corresponding DTD file. Parser can be used independently or becomes part of the editing software or browser. In the list of relevant resources later, I list some of the popular Parsers.
Ok, through the study of the third chapter, we have learned some basic terms of XML and DTD, but we still don't know how to write these documents, what kind of grammar needs to be followed, in the next chapter, will focus on writing XML The syntax of the DTD document. Please continue to browse, thank you!