XML easy learning Manual (4) one of the terms of XML

Source: Internet
Author: User
Chapter 3 Glossary of XML: Introduction 1. terms related to the XML document II. Introduction to terms related to DTD the biggest headache for beginners of XML is that there are a lot of new terms to understand. As XML itself is a brand new technique, it is constantly developing and changing the terms of Chapter 3 XML.

 


Outline:



Introduction

1. Terms Related to XML documents

2. related terms of DTD




Introduction




The biggest headache for beginners of XML is that there are a lot of new terms to understand. XML itself is also a brand new technique that is constantly evolving and changing. organizations and major network companies (such as Microsoft, IBM, and SUN) are constantly introducing their own insights and standards, therefore, it is not surprising that the new concept is everywhere. However, there is a lack of authoritative institutions or organizations in China to officially name these terms. most of the XML-related Chinese textbooks you see are translated by the authors themselves, some are accurate and some are incorrect, which further hinders our understanding and learning of these concepts.




The description of XML terms that you will see below is also the author's understanding and translation. A Jie is based on the XML standard and relevant formal clarification documents announced by W3C. It can ensure that these understandings are accurate, at least not wrong. If you want to further explore and understand, I listed the source and link of related resources in the last part of this article, you can visit directly. Okay, let's turn to the subject:


1. Terms Related to XML documents

What is an XML document? Understand the original HTML code file. the XML document is the original XML code file written with the XML identifier. XML files are plain text files in ASCII format. you can use Notepad to create and modify files. The suffix of the XML document is. XML, for example, myfile. xml. You can also open the. xml file directly in IE5.0 or a later browser, but what you see is the 'XML original code' without displaying the page content. You can save the following code as myfile. xml:






XML easy learning manual

Ajie

Ajie@aolhoo.com

20010115


The XML document contains three parts:

1. an XML document declaration;

2. a Document Type Definition;

3. Identify the created content in XML.


Example:








QUICK START OF XML

Ajie



......



The first line Is the declaration of an XML document. The second line clarifies that this document uses filelist. dtd to define the document type. The third line is the content body section.
We will understand the terms related to the XML document:


1. Element ):

Elements are the smallest unit of HTML documents, which is also the same in XML. An element is defined by an identifier, including the start and end identifiers and the content, just like this: ajie


The only difference is that in HTML, the identifier is fixed, and in XML, the identifier needs to be created by yourself.


2. Tag)

An identifier is used to define an element. In XML, the identifiers must be presented in pairs and the data is copied in the middle. The name of the identifier is the same as that of the element. For example, an element:

Ajie

It is the identifier.


3. Attribute ):

What is an attribute? Look at this HTML code: word. Color is one of the attributes of font.

An attribute further describes and clarifies an identifier. an identifier can have multiple attributes, such as the font attribute and size. The attributes in XML are the same as those in HTML. each attribute has its own name and value. attributes are part of the identifier. Example:

Ajie

The attributes in XML are also defined by yourself. we recommend that you try not to apply the attributes but change the attributes to sub-elements. for example, the code above can be changed to the following:

Ajie

<***> Female



The reason is that attributes are not easy to expand and controlled by programs.


4. Declaration (Declaration)

There is an XML declaration in the first line of all XML documents. This statement indicates that this document is an XML document that complies with the XML version specification. An XML statement is like this:


5. DTD (file type definition)

DTD is used to define elements, attributes, and relationships between elements in an XML document.

The DTD file can be used to check whether the structure of the XML document is accurate. However, creating an XML document does not necessarily require a DTD file. The specific clarification of the DTD file will be listed separately below.


6. Well-formed XML (XML with a good pattern)

A document that follows the XML syntax and complies with the XML specification is called a 'good pattern '. If all your identifiers strictly follow the XML specification, your XML document does not necessarily need a DTD file to define it.

A document with a good structure must begin with an XML declaration, for example:



Specifically, you must clarify the XML version that the document complies with. Currently, it is 1.0. Secondly, it clarifies that the document is 'standaled' and does not need a DTD file to verify whether the identity is valid. third, specify the language encoding used in the document. The default is UTF-8, if the application is Chinese, you need to set it to GB2312.

A well-structured XML document must have a root element, that is, the first element created after the declaration. other elements are child elements of the root element and belong to a group of root elements.

The content of a well-structured XML document must comply with the XML syntax when writing. (We will explain the XML syntax in the next chapter)


7. Valid XML (Valid XML)

An XML document that follows the XML syntax and complies with the corresponding DTD file specifications is called a valid XML document. Be careful when comparing 'well-formed XML' and 'valid
XML, the biggest difference between them is that a complete compliance with XML specifications, one has its own 'file Type Definition (DTD )'.

Compare and analyze the XML document with its DTD file to see if the process conforms to the DTD rules is called validation ). This process is usually handled by a software named parser.

A valid XML document must also begin with an XML declaration, for example:



Different from the preceding example, in the standalone (independent) attribute, 'no' is set here. because it must be applied with the corresponding DTD, the DTD file is defined as follows:



Where:

'! DOCTYPE 'indicates that you want to define a DOCTYPE;

'Type-of-Doc' is the name of the document type, which is defined by you and is generally the same as the DTD file name;

The 'System/public' parameter only uses one of the two parameters. SYSTEM refers to the URL of the private DTD file of the document application, while PUBLIC refers to the URL where the document calls a public dtd file.

The 'dtd-name' is the URL and name of the dtd file. The suffix of all DTD files is '. dtd '.

We should use the following example to write it as follows:





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.