XML grammar 4-7

xiaoxiao2021-03-06  84

Chapter 4 XML Syntax

The grammatical namespaces translated into a name space. 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

Wood Table
represents the table, and in another document
Namelist 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: where youRName is the name of the namespaces, the URL is the URL of the name. Suppose the above "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: Wood Table This two
distinguish. Note: Setting URL is not said that this logo really wants to read it, just as a distinguished mark.

HTML in the following example cannot be HTML or HTML name Name name six.entity syntax 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: For example, I want to define a copyright information: If my copyright information content and others share an XML file, I can also use external calls, syntax like this: ]> 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 </ title > <author> ajie </ author> <email> ajie@aolhoo.com </ email> <date> 20010115 </ date> & copyright; </ myfile> seven.dtd grammar</p> <p>DTD is a must file with the "Effective XML Document", we define the rules and interrelationships of elements and identities in the document through the DTD file. How to build a DTD file? Let us learn together:</p> <p>Set element</p> <p>The element is the basic component of the XML document. You have to define an element in the DTD and then use it in the XML document. The definition of the element is: <! Element description (#pcdata, definition) *></p> <p>Description:</p> <p>"<! Element" is an element's statement that you want to define an element;</p> <p>Declare "description", is the name of the element;</p> <p>"(#Pcdata, definition) *>" is the usage rule of this element. Rules define the contents and mutual relationships that the elements can be included. The following table summary lists the rules of the elements:</p> <p>2. Elemental rule table:</p> <p>Symbol Meaning Example #pcdata Contains Character or Text Data <MyFile (#pcdata)> Element MyFile Contains a text data #pcdata, element-name contains text and other child elements <myfile (# pcdtata, title)> MyFile element must contain text and Tosis child elements, use commas Separate <MyFile (Title, Author, Email)> MyFile Elements must be included in order | Use "|" or <myfile (title | Author | email)> MyFile Element Title or Author or Email child must be included. Name can only use the <myfile> MyFile element must contain the title child element, and can only be used once. Name? Use the <myfile (Title, Author, Email?)> MyFile element must contain the title child element, and can only be used once; can contain or do not include Author and Email child elements, but if used, only once. Name Use at least once or multiple <myfile (Title , Author?, email "must contain a title child element, and use at least once; next to follow the Author child element, or not to follow; finally must contain Email child elements And only once. Name * Using once, multiple, or at all, <myfile (title *)> MyFile elements can contain one, multiple or not containing the title child element () set group, can nescen <myfile (#pcdata | title) * > Element MyFile contains one or more text or title child elements. <Myfile ((title *, author ?, email) * | comment> MyFile element must contain some content, content or a comment; or multiple groups, groups contain: one, multiple or no title chub elements Then it is one or there is no Author child element, and then it is a necessary Email sub-element.</p> <p>In addition, we can also define attributes for the element, because we do not recommend the use of properties, which is not detailed here. Finally, let's summarize some of the previous four chapters, write a simple instance containing DTD, XML, and Script, which is easy to understand: 1. Put the following files as MyFile.dtd <! Element myfile (title, author)> <! Element Title (#pcdata)> <! Element Author (#pcdata)> 2. Then build XML document myfile.xml: <? Xml version = "1.0" encoding = "gb2312"> <! Doctype myfile system "Myfile .dtd "> <myfile> <title> XML Easy Learning Manual </ Title> <Author> Ajie </ Author> </ myfile> 3. Establishing HTML Document MyFile.html <HTML> <HEAD> <script language =" JavaScript "for =" window "Event =" online "> var xmldoc = new activ.xmldom"); xmldoc.async = "false"; xmldoc.load ("myfile.xml"); nodes = xmldoc.documentelement. ChildNodes; title.innerText = nodes.Item (0) .text; author.innertext = nodes.item (1) .text; </ script> <title> Tune XML data in HTML </ title> </ head> < body bgcolor = "# FFFFFF"> <b> title: </ b> <span id = "title"> </ span> <br> <b> author: </ b> <span id = "author"> < / span> <br> </ body> </ html> 4. Open myFile.html with IE5.0 or above. You can see the effect. Ok, until today's fourth chapter, we have some basic understanding of XML. The fifth chapter I will explain the successful example of an XML practical application to show the power of XML. Let's take a look at the next chapter: XML instance analysis.</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-106842.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="106842" 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.042</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 = 'MdjP7kXb_2FTLq1MuHNK_2BkibV4AzTwavElaFmBzet9GvW6sLenVLirpxAuvm01PKoY4oh_2FrqS_2BasjRGcLx1bUzng_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>