XML foundation

xiaoxiao2021-03-06  43

1: What is XML? This is often the first question, and you will often don't understand on the first question, because most of the textbooks answer: XML is an extensible Markup Language, an extensibility identifier language. This is a standard definition. So what is a sign language, why is it scalable? It has been a bit confused. I think we will understand this: I am very familiar with HTML. It is a tag language, remember its full name: "Hypertext Markup Language" hypertext tag language. understood? At the same time, there are many labels in HTML, similar to ,

, etc., are all specified and defined in HTML 4.0, and the XML allows you to create such a label, so it is called scalability.

Here are a few easily confusing concepts to remind everyone: 1.xml is not a markup language. It is just a meta-language used to create tag language (such as HTML). God, it is confused! Don't matter, you just know this: XML and HTML are different, and it uses a wide range of HTML, we will be carefully introduced later. 2.xml is not an alternative product of HTML. XML is not an HTML upgrade, it is just HTML supplements, and extension more features for HTML. We will continue to use HTML in a longer period of time. (However, it is worth noting that HTML upgrade version XHTML is indeed close to the adaptation XML.) 3. You cannot write a web page directly with XML. Even if the XML data is included, it is still necessary to convert to an HTML format to display on the browser.

2. Is there any benefit using XML? HTML, why still need to use XML? Because the network is now more and more extensive, only the HTML single file type is handled by the HTML single file type, and the data has been made upless, and the HTML itself is not strict, and the network information is transmitted and shared. (Think about how many designers' brain cells are hurt in browser-compatible problems.) People have long been to explore what method is used to meet the needs of various applications on the network. Using SGML is ok, but SGML is too large, complicated programming, and finally selects "weight loss" SGML - XML ​​as a data transfer and interaction of the next generation of Web. What is the benefit of using XML? To see the W3C organization (XML standard maker): XML makes more "simple and direct" on the network: Simplify the process of defining file types, simplifying the process of programming and processing SGML files, simplifying in Web Delivery and sharing. 1.xml can be widely used in any place for web; 2.xml can meet the needs of network applications; 3. Use XML will make programming simpler; 4.xml facilitate learning and creation; 5.xml code will be clear and easy to read understanding;

3. The differences between XML and HTML from XML and HTML come from SGML, which all contain tags, with similar syntax, HTML, and XML's biggest difference in: HTML is a fixed mark language, which is described in an inherent tag, display Web content. For example,

represents the first line title, there is a fixed size. Relatively, XML does not have a fixed mark, XML cannot describe the specific appearance, content, which is just the data form and structure of the content. This is a qualified difference: the web page mixed data and display, while XML separates the data and display. We look at the above example, in MyFile.htm, we only care about the page display method, we can design different interfaces, use different ways to type, but the data is stored in MyFile.xml, no change. (If you are a programmer, you will be surprised to find that this is extremely similar to the idea of ​​modular faces to objects! Is it not a program that is not a program?) This difference makes XML easy to share online applications and information sharing , Efficient, scalable. So we believe that XML is an advanced data processing method, which will allow the network to span a new realm. 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. 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.</p> <p>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, you should write this: <? XML Version = "1.0" Standalone = "no" encode = "uTF-8"?> <! Doctype filelist system "filelist.dtd"> II.DTD related terms What is DTD, we are already 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.</p> <p>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. 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.</p> <p>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. I. ximl syntax rules II. Grammar III. The syntax of the annotation of the syntax of the four.cdata. Synficial syntax of the syntax of .Namespaces Syntax. Grammatical syntax.</p> <p>Through the study of the previous three chapters, we have explained what is XML, its implementation principles, and related terms. Next, we start learning XML's grammatical specification and write your own XML document.</p> <p>I. xml syntax rule XML document and HTML's original code is similar, and it is also identified by identity. Creating an XML document must follow the following important rules: Rules 1: There must be an XML declaration statement that we have already mentioned when he learned in the next chapter. The statement is the first sentence of the XML document, its format is as follows:</p> <p>The role of the declaration is to tell the browser or other handler: This document is an XML document. The Version in the statement represents the version of the XML specification of the document. Standalone indicates whether the document comes with a DTD file. If there is, the parameter is NO; Encoding indicates the language encoding used by the document. The default is UTF-8. Rule 2: Is there a DTD file If the document is a "valid XML document" (see the last chapter), the document must have the corresponding DTD file and strictly abide by the DTD file formulation. The declaration statement of the DTD file is followed behind the XML declaration statement, the format is as follows:</p> <p>Among them: "! Doctype" means you want 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 are only used 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".</p> <p>Rules 3: Note that your case is in the XML documentation, the case is different. Because case in cases do not match the generated document error.</p> <p>Rules 4: The attribute value is quoted in the HTML code, and the attribute value can be quoted, or may not be added. For example: Word and Word can be interpreted correctly by the browser. However, in XML, it is specified that all attribute values ​​must be quoted (can be single quotes, or two quotes), otherwise it will be considered an error.</p> <p>Rules 5: All identities must have a corresponding end identity in HTML, and the identifier may not be paired, and in XML, all the identities must be paired, there is a start identifier, there must be an end ID. Otherwise it will be considered an error.</p> <p>Rules 6: All air standards must also be closed to the empty identification is the identification between the identification pair</p> <p>II. The grammatical elements of the element are consist of a pair of identifiers and the content therein. Just like this: Ajie. The name of the element and the name of the identity are the same. Identification can be further described with attributes. In XML, there is no reserved word, so you can use any words as the element name as you want. However, you must also comply with the following specification: 1. You can include letters, numbers, and other letters in the name; 2. Name cannot start with a number or "_" (underscore); 3. Name cannot be in letter XML (or XML or XML ..) At the beginning 4. The name cannot contain space 5. The name cannot be included in the middle of the ":" (colon) to make the element easier to read understanding and operation, we have some suggestions: 1. Do not use "." Because in many program languages, "." Is an object of the object, for example: font.color. The same reason "-" is also best not to use, must be used, instead of "_"; 2. The name is as short as possible. 3. The case is used to use the same standard. 4. Names can use non-English characters, such as Chinese. But some software may not be supported. (IE5 is currently supporting Chinese elements.) In addition, add a description of the property. In HTML, the property can be used to define the display format of the element, such as: Word will display Word as red. In XML, the attribute is only a description of the identity, and is independent of the display of the element content. For example, the same sentence: Word does not display Word as red. (So, some netizen will ask: How to display the text as red in XML? This requires the use of CSS or XSL, we will talk more in detail below.)</p> <p>Three. The syntax of the comment is to facilitate reading and understanding, and the additional information added to the XML document will not be interpreted or the browser is displayed. Four. CDATA's grammatical CDATA full name Character Data, translated as character data. When we write an XML document, sometimes you need to display letters, numbers, and other symbols itself, such as "<", and in XML, these characters already have special meanings, what should we do? This requires the CDATA syntax. The syntax format is as follows: For example: <! [Cdata [ajie]]> The content displayed on the page will be "ajie" five.Namespaces syntax namespaces translated into the namespace. What is the role of name space? This contradiction occurs when we use others or multiple DTD files in an XML document: This may cause data confusion. For example, in a document <Table> Wood Table </ Table> <Table> represents the table, and in another document <Table> Namelist </ Table> represents the table. If I need to handle these two documents at the same time, the name conflict will occur. We solve this problem, we introduced this concept of Namespaces. NameSpaces distinguishes the same identity as the same name is added to the identified name of an URL (URL). Namespaces also requires the beginning of the XML document, the statement of the statement is as follows: <Document XMLns: YourName = 'URL'> where youRName is the name of the namespaces, the URL is the URL of the name. Suppose the above "Table <Table>" document comes from http://www.zhuozi.com, we can declare "Document XMLns: zhuozi = 'http://www.zhuozi.com'> and then in the latter identity Use the defined namespace: <zhuozi: Table> Wood Table </ table> This two <table> distinguish. Note: Setting URL is not said that this logo really wants to read it, just as a distinguished mark.</p> <p>Six.ntity's grammatical Entity translated into "entity". It effects similar to "macro" in Word, you can also understand the touchpad in DW, you can predefine an Entity, then call multiple times in one document, or call the same entity in multiple documents. Entity can include characters, text, and so on, using Entity is the benefits of: 1. It can reduce errors, multiple identical parts in the document only need to enter it over again. 2. It improves maintenance efficiency. For example, you have 40 documents that contain Copyright's Entity, if you need to modify this Copyright, you don't need all files to modify, just change the Entity statement initially defined. XML defines two types of Entity. One is the ordinary Entity we say here, is used in the XML document; the other is the parameter Entity, used in the DTD file. Entity definition syntax is: <! doctype filename [<! "]> For example, I want to define a copyright information: <! doctype copyright [<! Entity Copyright" CopyRight 2001, Ajie. All Rights Reserved "]> If my copyright information content and others share an XML file, I can also use external calls, syntax like this: <! Doctype copyright [<! Entity Copyright System" http://www.sample.com/copyright .xml ">]> Define the reference syntax in the document: & entity-name; for example, copyright information defined above, Writing when calling: & copyright; Complete example, you can copy down to Copyright.xml Watching example: <? XML Version = "1.0" encoding = "GB2312"?> <! Doctype copyright [<! Entity Copyright "Copyright 2001, Ajie. All Rights Reserved">]> <myfile> <title> xml </ title > <author> ajie </ author> <email> ajie@aolhoo.com </ email> <date> 20010115 </ date> & copyright; </ myfile> 5.Namespaces syntax namespaces translation as namespace. What is the role of name space? This contradiction occurs when we use others or multiple DTD files in an XML document: This may cause data confusion. For example, in a document <Table> Wood Table </ Table> <Table> represents the table, and in another document <Table> Namelist </ Table> represents the table. If I need to handle these two documents at the same time, the name conflict will occur. We solve this problem, we introduced this concept of Namespaces. NameSpaces distinguishes the same identity as the same name is added to the identified name of an URL (URL).</p> <p>Namespaces also requires the beginning of the XML document, the statement of the statement is as follows: <Document XMLns: YourName = 'URL'> where youRName is the name of the namespaces, the URL is the URL of the name. Suppose the above "Table <Table>" document comes from http://www.zhuozi.com, we can declare "Document XMLns: zhuozi = 'http://www.zhuozi.com'> and then in the latter identity Use the defined namespace: <zhuozi: Table> Wood Table </ table> This two <table> distinguish. Note: Setting URL is not said that this logo really wants to read it, just as a distinguished mark. Six.ntity's grammatical Entity translated into "entity". It effects similar to "macro" in Word, you can also understand the touchpad in DW, you can predefine an Entity, then call multiple times in one document, or call the same entity in multiple documents. Entity can include characters, text, and so on, using Entity is the benefits of: 1. It can reduce errors, multiple identical parts in the document only need to enter it over again. 2. It improves maintenance efficiency. For example, you have 40 documents that contain Copyright's Entity, if you need to modify this Copyright, you don't need all files to modify, just change the Entity statement initially defined. XML defines two types of Entity. One is the ordinary Entity we say here, is used in the XML document; the other is the parameter Entity, used in the DTD file.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-58218.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="58218" 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.056</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 = '3jptebdoEWAPWp3Mnr8W2hnNIrTsdBGctqjWDuWaDyTP77Y9Cg_2B_2FfoSpfgR4NJgthH_2FmeudBYEU7Fl8djs_2FecQ_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>