XML Easy Learning Manual (3) Terminology of XML

xiaoxiao2021-03-06  105

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 Easy Learning Manual </ Title> <Author> ajie@boolhoo.com <email> ajie@aolhoo.com </ email> < Date> 20010115 </ date> </ myfile></p> <p>The XML document contains three parts: 1. An XML document declaration; 2. A definition of document type; 3. Content created with XML ID.</p> <p>For example: <? XML Version = "1.0"?> <! Doctype filelist system "filelist.dtd"></p> <p><filelist> <myfile> <title> Quick Start of XML </ Title> <author> ajie </ author> </ myfile> ... </ filelist> Where the first line <? Xml Version = "1.0 ">> Is a declaration of an XML document. The second line shows that this document is used to define document types with fileList.dtd, and the third line is below the content body part. Let's understand the terminology related to XML documents:</p> <p>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: <author> ajie </ author> The only difference is: In HTML, the identifier is fixed, and in XML, identify Need you to create yourself.</p> <p>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: <author> ajie </ author> wherein <author> is identified. 3.attribute: What is the property? Look at this HTML code: <font color = "red"> Word </ font>. Where COLOR is one of the properties of Font. The attribute is a further description and description of the identity, and one identity may have multiple properties, such as the properties of the Font, there is Size. The properties in XML are the same as attributes in HTML, each attribute has its own name and value, and the property is part of the identity. Example: <author sex = "female"> Ajie </ author> XML Properties is also known, we recommend that you try not to use attributes, and change the property to child elements, such as the above code can be changed: <authoror > AJIE <sex> female </ sex> </ author> The reason is that attribute is not easy to expand and operate.</p> <p>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"?></p> <p>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.</p> <p>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)</p> <p>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: <! Doctype type-of-doc system / public "dtd-name"> 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"?> <! Doctype filelist system "filelist.dtd"></p> <p>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 ">> <myfile> <title> XML Easy Learning Manual </ Title> <author> ajie </ author> </ myfile> We can insert the following code after the first line: <! doctype myfile [<! Element Title (#pcdata)> <! Element Author (#pcdata)> <! Entity Copyright "Copyright 2001, Ajie.">]></p> <p>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 <! Element myfile (title, author)> <! Element Title (#Pcdata)> <! Element Author (#pcdata)></p> <p>Then in the XML document, insert after the first line: <! Doctype myfile system "myfile.dtd"></p> <p>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.</p> <p>Let's take a look at the terminology related to DTD:</p> <p>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.</p> <p>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"?> <Filelist> <myfile> <title> ... </ title> <author> ... </ author> </ myfile> </ filelist> above The three-stage structure is arranged as a "tree", of which <filelist> is the root element. In XML and DTD files, the first definition is root element. 3.Parent Element / Child Element Element The parent element refers to an element containing other elements, and the elements being included are called their child elements. Look at the "Tree" of the top, where <myfile> is the parent element, <title>, <author> is its child element, and <myfile> is the child element of <fileList>. I am also called "page elements" as the last level of elements that contain any child elements.</p> <p>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.</p> <p>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!</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-95731.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="95731" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.036</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'DPXSb1lBtPV0hI4rtWHKZ8ohP_2FyWvlvyP9_2F10HOHm9K_2FXQNFMl0Sgx5gfqHvkqNXKBmU5zbV94iC_2FKXfy_2Bd3uw_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>