Home  >  Article  >  Backend Development  >  XML terminology

XML terminology

黄舟
黄舟Original
2016-12-23 11:57:171581browse


Outline:



Introduction

1. Terms related to XML documents

2. Terms related to DTD



Introduction



The most troublesome thing for beginners to learn XML is that there are a lot of new terminology concepts. understand. Since XML itself is also a brand-new technology, it is constantly developing and changing. Organizations and major network companies (Microsoft, IBM, SUN, etc.) are constantly introducing their own insights and standards, so it is not surprising that new concepts are flying everywhere. . There is no authoritative institution or organization in China to officially name these terms. Most of the Chinese textbooks you see about XML are translated based on the author's own understanding. Some are correct and some are wrong, which further hinders the development of XML. Our understanding and learning of these concepts.




The explanation of XML terms you will see below is also the author’s own understanding and translation. Ajie is based on the XML1.0 standard specification released by the W3C organization and related official documentation. It can be ensured that these understandings are basically correct, at least not wrong. If you want to read and understand further, I have listed the sources and links to relevant resources at the end of this article, which you can access directly. Okay, let’s get to the point:


1. Terms related to XML documents

What is an XML document? You know the HTML source code file? An XML document is an XML source code file written with XML tags. XML documents are also ASCII plain text files that you can create and modify using Notepad. The suffix name of XML documents is .XML, for example, myfile.xml. You can also directly open the .xml file using IE5.0 or above browsers, but what you see is the "XML original code" and the page content will not be displayed. You can try saving the following code as myfile.xml:






XML Easy Learning Manual< ;/title> <br><br><author>ajie</author> <br><br><email>ajie@aolhoo.com</email> <br><br><date>20010115</date> <br><br></myfile&g t; <br/><br/> <br/>XML document contains three parts: <br/><br/>1. An XML document declaration; <br/><br/>2. A definition of the document type; <br/><br/>3. Content created with XML tags. <br/><br/><br/>Example: <br/><br/><?xml version="1.0"?> <br><br><!DOCTYPE filelist SYSTEM "filelist.dtd"> <br><br><br><filelist> <br><br><myfile> <br> <br> QUICK START OF XML The line <?xml version="1.0"?> is the declaration of an XML document. The second line indicates that this document uses filelist.dtd to define the document type. The following line is the main part of the content. <br>Let’s learn about the relevant terms in XML documents: <br><br><br>1.Element (element): <br><br>We already know something about elements in HTML. It is the smallest unit that makes up an HTML document, and it is the same in XML. An element is defined by a tag, including the start and end tags and the content inside, like this: <author>ajie</author> <br><br><br>The only difference is: in HTML, the tag is fixed, while in In XML, tags need to be created yourself. <br><br><br>2.Tag (logo) <br><br>Tag is used to define elements. In XML, tags must appear in pairs, surrounding the data. The name of the identifier is the same as the name of the element. For example, such an element: <br><br><author>ajie</author> <br><br>where <author> is the identifier. <br><br><br>3.Attribute: <br><br>What is an attribute? Look at this HTML code:<font color="red">word</font>. Among them, color is one of the attributes of font. <br><br>Attributes are further descriptions and explanations of the logo. A logo can have multiple attributes, such as the font attribute and size. Attributes in XML are the same as attributes in HTML. Each attribute has its own name and value. The attribute is part of the identifier. Example: <br><br><author sex="female">ajie</author> <br><br>Attributes in XML are also defined by yourself. We recommend that you try not to use attributes and change attributes into sub-elements. For example, the above code can Change it to this: <br><br><author>ajie <br><br><sex>female</sex> <br><br></author> <br><br>The reason is that attributes are not easy to expand and be manipulated by programs. <br><br><br>4.Declaration <br><br>In the first line of all XML documents there is an XML declaration. This declaration indicates that this document is an XML document and which XML version specification it follows. An XML declaration statement looks like this: <br><br><?xml version="1.0"?> <br><br><br>5.DTD (Document Type Definition) <br><br>DTD is used to define elements, attributes and elements in XML documents relationship between. <br><br>You can check whether the structure of the XML document is correct through the DTD file. But creating an XML document does not necessarily require a DTD file. Detailed descriptions of DTD files will be listed separately below. <br><br><br>6.Well-formed XML (well-formed XML) <br><br>A document that abides by XML syntax rules and adheres to XML specifications is called "well-formed". If all your markup strictly adheres to the XML specification, then your XML document does not necessarily need a DTD file to define it. <br><br>A well-formed document must start with an XML declaration, for example: <br><br><?xml version="1.0" standalone="yes" encoding="UTF-8"?> <br><br>where you must state that the document adheres to The XML version is currently 1.0; secondly, it indicates that the document is "independent", and it does not require a DTD file to verify whether the identification in it is valid; thirdly, it is necessary to indicate the language encoding used in the document. The default is UTF-8. If you use Chinese, you need to set it to GB2312. <br><br>A well-formatted XML document must have a root element, which is the first element created immediately after the declaration. Other elements are child elements of this root element and belong to a group of root elements. <br><br>The content of a well-formed XML document must comply with XML syntax when written. (We will explain XML syntax in detail in the next chapter) <br><br><br>7. Valid XML (valid XML) <br><br>An XML document that abides by XML syntax rules and complies with the corresponding DTD file specifications is called a valid XML document. Note that we compare "Well-formed XML" and "Valid <br>XML". The biggest difference between them is that one fully complies with the XML specification and the other has its own "Document Type Definition (DTD)". <br><br>The process of comparing and analyzing an XML document with its DTD file to see if it complies with DTD rules is called validation. This process is usually handled by a software called parser. <br><br>A valid XML document must also start with an XML declaration, for example: <br><br><?xml version="1.0" standalone="no" encode="UTF-8"?> <br><br>Different from the above example, In the standalone (independent) attribute, "no" is set here because it must be used with the corresponding DTD. The DTD file is defined as follows: <br><br><!DOCTYPE type-of-doc SYSTEM/PUBLIC "dtd- name"> <br><br>Among them: <br><br>"!DOCTYPE" means you want to define a DOCTYPE; <br><br>"type-of-doc" is the name of the document type, which is defined by you. It is usually the same as the DTD file name; <br> <br>Only use one of the two parameters "SYSTEM/PUBLIC". SYSTEM refers to the URL of the private DTD file used by the document, while PUBLIC refers to the URL of the public DTD file used by the document. <br><br>"dtd-name" is the URL and name of the DTD file. All DTD files have the suffix ".dtd". <br><br>We still use the above example, it should be written like this: <br><br><?xml version="1.0" standalone="no" encode="UTF-8"?> <br><br><!DOCTYPE filelist SYSTEM "filelist. dtd"></p> <p> The above is the content of XML terminology. For more related content, please pay attention to the PHP Chinese website (www.php.cn)! <br></p> <p> </p> <p><br></p> <p><br></p></div><div class="nphpQianMsg"><div class="clear"></div></div><div class="nphpQianSheng"><span>Statement:</span><div>The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn</div></div></div><div class="nphpSytBox"><span>Previous article:<a class="dBlack" title="XML easy learning general section" href="http://m.php.cn/faq/346237.html">XML easy learning general section</a></span><span>Next article:<a class="dBlack" title="XML easy learning general section" href="http://m.php.cn/faq/346324.html">XML easy learning general section</a></span></div><div class="nphpSytBox2"><div class="nphpZbktTitle"><h2>Related articles</h2><em><a href="http://m.php.cn/article.html" class="bBlack"><i>See more</i><b></b></a></em><div class="clear"></div></div><ul class="nphpXgwzList"><li><b></b><a href="http://m.php.cn/faq/348309.html" title="Using dom4j to parse xml in java (sample code)" class="aBlack">Using dom4j to parse xml in java (sample code)</a><div class="clear"></div></li><li><b></b><a href="http://m.php.cn/faq/348310.html" title="How does Java read XML files? Specific implementation" class="aBlack">How does Java read XML files? Specific implementation</a><div class="clear"></div></li><li><b></b><a href="http://m.php.cn/faq/348311.html" title="Java example code for generating and parsing XML format files and strings" class="aBlack">Java example code for generating and parsing XML format files and strings</a><div class="clear"></div></li><li><b></b><a href="http://m.php.cn/faq/348313.html" title="Solution to using sax to parse xml in java" class="aBlack">Solution to using sax to parse xml in java</a><div class="clear"></div></li><li><b></b><a href="http://m.php.cn/faq/348314.html" title="Java uses xpath to parse xml example sharing" class="aBlack">Java uses xpath to parse xml example sharing</a><div class="clear"></div></li></ul></div></div><div class="nphpFoot"><div class="nphpFootBg"><ul class="nphpFootMenu"><li><a href="http://m.php.cn/"><b class="icon1"></b><p>Home</p></a></li><li><a href="http://m.php.cn/course.html"><b class="icon2"></b><p>Course</p></a></li><li><a href="http://m.php.cn/wenda.html"><b class="icon4"></b><p>Q&A</p></a></li><li><a href="http://m.php.cn/login"><b class="icon5"></b><p>My</p></a></li><div class="clear"></div></ul></div></div><div class="nphpYouBox" style="display: none;"><div class="nphpYouBg"><div class="nphpYouTitle"><span onclick="$('.nphpYouBox').hide()"></span><a href="http://m.php.cn/"></a><div class="clear"></div></div><ul class="nphpYouList"><li><a href="http://m.php.cn/"><b class="icon1"></b><span>Home</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/course.html"><b class="icon2"></b><span>Course</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/article.html"><b class="icon3"></b><span>Article</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/wenda.html"><b class="icon4"></b><span>Q&A</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/dic.html"><b class="icon6"></b><span>Dictionary</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/course/type/99.html"><b class="icon7"></b><span>Manual</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/xiazai/"><b class="icon8"></b><span>Download</span><div class="clear"></div></a></li><li><a href="http://m.php.cn/faq/zt" title="Topic"><b class="icon12"></b><span>Topic</span><div class="clear"></div></a></li><div class="clear"></div></ul></div></div><div class="nphpDing" style="display: none;"><div class="nphpDinglogo"><a href="http://m.php.cn/"></a></div><div class="nphpNavIn1"><div class="swiper-container nphpNavSwiper1"><div class="swiper-wrapper"><div class="swiper-slide"><a href="http://m.php.cn/" >Home</a></div><div class="swiper-slide"><a href="http://m.php.cn/article.html" class="hover">Article</a></div><div class="swiper-slide"><a href="http://m.php.cn/wenda.html" >Q&A</a></div><div class="swiper-slide"><a href="http://m.php.cn/course.html" >Course</a></div><div class="swiper-slide"><a href="http://m.php.cn/faq/zt" >Topic</a></div><div class="swiper-slide"><a href="http://m.php.cn/xiazai" >Download</a></div><div class="swiper-slide"><a href="http://m.php.cn/game" >Game</a></div><div class="swiper-slide"><a href="http://m.php.cn/dic.html" >Dictionary</a></div><div class="clear"></div></div></div><div class="langadivs" ><a href="javascript:;" class="bg4 bglanguage"></a><div class="langadiv" ><a onclick="javascript:setlang('zh-cn');" class="language course-right-orders chooselan " href="javascript:;"><span>简体中文</span><span>(ZH-CN)</span></a><a onclick="javascript:;" class="language course-right-orders chooselan chooselanguage" href="javascript:;"><span>English</span><span>(EN)</span></a><a onclick="javascript:setlang('zh-tw');" class="language course-right-orders chooselan " href="javascript:;"><span>繁体中文</span><span>(ZH-TW)</span></a><a onclick="javascript:setlang('ja');" class="language course-right-orders chooselan " href="javascript:;"><span>日本語</span><span>(JA)</span></a><a onclick="javascript:setlang('ko');" class="language course-right-orders chooselan " href="javascript:;"><span>한국어</span><span>(KO)</span></a><a onclick="javascript:setlang('ms');" class="language course-right-orders chooselan " href="javascript:;"><span>Melayu</span><span>(MS)</span></a><a onclick="javascript:setlang('fr');" class="language course-right-orders chooselan " href="javascript:;"><span>Français</span><span>(FR)</span></a><a onclick="javascript:setlang('de');" class="language course-right-orders chooselan " href="javascript:;"><span>Deutsch</span><span>(DE)</span></a></div></div><script> var swiper = new Swiper('.nphpNavSwiper1', { slidesPerView : 'auto', observer: true,//修改swiper自己或子元素时,自动初始化swiper observeParents: true,//修改swiper的父元素时,自动初始化swiper }); </script></div></div><!--顶部导航 end--><script>isLogin = 0;</script><script type="text/javascript" src="/static/layui/layui.js"></script><script type="text/javascript" src="/static/js/global.js?4.9.47"></script></div><script src="https://vdse.bdstatic.com//search-video.v1.min.js"></script><link rel='stylesheet' id='_main-css' href='/static/css/viewer.min.css' type='text/css' media='all'/><script type='text/javascript' src='/static/js/viewer.min.js?1'></script><script type='text/javascript' src='/static/js/jquery-viewer.min.js'></script><script>jQuery.fn.wait = function (func, times, interval) { var _times = times || -1, //100次 _interval = interval || 20, //20毫秒每次 _self = this, _selector = this.selector, //选择器 _iIntervalID; //定时器id if( this.length ){ //如果已经获取到了,就直接执行函数 func && func.call(this); } else { _iIntervalID = setInterval(function() { if(!_times) { //是0就退出 clearInterval(_iIntervalID); } _times <= 0 || _times--; //如果是正数就 -- _self = $(_selector); //再次选择 if( _self.length ) { //判断是否取到 func && func.call(_self); clearInterval(_iIntervalID); } }, _interval); } return this; } $("table.syntaxhighlighter").wait(function() { $('table.syntaxhighlighter').append("<p class='cnblogs_code_footer'><span class='cnblogs_code_footer_icon'></span></p>"); }); $(document).on("click", ".cnblogs_code_footer",function(){ $(this).parents('table.syntaxhighlighter').css('display','inline-table');$(this).hide(); }); $('.nphpQianCont').viewer({navbar:true,title:false,toolbar:false,movable:false,viewed:function(){$('img').click(function(){$('.viewer-close').trigger('click');});}}); </script></body></html>