0109-0112.html
来自「Presenting XML.rar,详细介绍有关XML的知识」· HTML 代码 · 共 437 行
HTML
437 行
<!DOCTYPE HTML PUBLIC "html.dtd"><HTML><HEAD><TITLE>Presenting XML:Physical Structures in XML Documents:EarthWeb Inc.-</TITLE><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"><SCRIPT><!--function displayWindow(url, width, height) { var Win = window.open(url,"displayWindow",'width=' + width +',height=' + height + ',resizable=1,scrollbars=yes');}//--></SCRIPT></HEAD><BODY BGCOLOR="#FFFFFF" VLINK="#DD0000" TEXT="#000000" LINK="#DD0000" ALINK="#FF0000"><TD WIDTH="540" VALIGN="TOP"><!-- <CENTER><TABLE><TR><TD><FORM METHOD="GET" ACTION="http://search.itknowledge.com/excite/cgi-bin/AT-foldocsearch.cgi"><INPUT NAME="search" SIZE="20" VALUE=""><BR><CENTER><INPUT NAME="searchButton" TYPE="submit" VALUE="Glossary Search"></CENTER><INPUT NAME="source" TYPE="hidden" VALUE="local" CHECKED> <INPUT NAME="bltext" TYPE="hidden" VALUE="Back to Search"><INPUT NAME="sp" TYPE="hidden" VALUE="sp"></FORM></TD><TD><IMG SRC="http://www.itknowledge.com/images/dotclear.gif" WIDTH="15" HEIGHT="1"></TD><TD><FORM METHOD="POST" ACTION="http://search.itknowledge.com/excite/cgi-bin/AT-subscriptionsearch.cgi"><INPUT NAME="search" SIZE="20" VALUE=""><BR><CENTER><INPUT NAME="searchButton" TYPE="submit" VALUE=" Book Search "></CENTER><INPUT NAME="source" TYPE="hidden" VALUE="local" CHECKED> <INPUT NAME="backlink" TYPE="hidden" VALUE="http://search.itknowledge.com:80/excite/AT-subscriptionquery.html"><INPUT NAME="bltext" TYPE="hidden" VALUE="Back to Search"><INPUT NAME="sp" TYPE="hidden" VALUE="sp"></FORM></TD></TR></TABLE></CENTER> --><!-- ISBN=1575213346 //--><!-- TITLE=Presenting XML//--><!-- AUTHOR=Richard Light//--><!-- PUBLISHER=Macmillan Computer Publishing//--><!-- IMPRINT=Sams//--><!-- CHAPTER=07 //--><!-- PAGES=0109-0122 //--><!-- UNASSIGNED1 //--><!-- UNASSIGNED2 //--><P><CENTER><A HREF="../ch06/0107-0108.html">Previous</A> | <A HREF="../ewtoc.html">Table of Contents</A> | <A HREF="0113-0116.html">Next</A></CENTER></P><A NAME="PAGENUM-109"><P>Page 109</P></A><H3><A NAME="ch07_ 1">CHAPTER 7</A></H3><H2>Physical Structures <BR>in XML Documents</H2><B>by Richard Light</B><P>In Chapter 5, "The XML Approach," you learned thatXML documents have two types of structures: a logicalstructure and a physical structure. The logical structure, which wascovered in Chapter 6, "Logical Structures in XMLDocuments," relates to the markup that the document contains. Thischapter examines in more detail the physical structuresassociated with XML documents.</P><P>An XML document can consist of one or more virtualstorage units. These storage units are calledentities. Each entity has a name and a content. The general idea is that byquoting the name, you receive the corresponding content, whichcan be anything from a single character to a large file.</P><A NAME="PAGENUM-110"><P>Page 110</P></A><H3><A NAME="ch07_ 2">Internal and External Entities</A></H3><P>Internal entities have a value that is given directly in the entity declaration:</P><!-- CODE SNIP //--><PRE><!ENTITY XML "Extensible Markup Language"></PRE><!-- END CODE SNIP //--><P>This entity declaration maps the name XML to the content"Extensible Markup Language". No separate storage unit is involved.</P><P>External entities, by contrast, refer in their declarations to a storage unit bymeans of a SYSTEM or PUBLIC identifier:</P><!-- CODE SNIP //--><PRE><!ENTITY chapter1 SYSTEM "chap1.xml"></PRE><!-- END CODE SNIP //--><P>This associates the name chapter1 with the URL"chap1.xml". An XML processor must read the file referenced by that URL in order to find out thecontent of that entity.</P><P>The format for PUBLIC identifiers includes aPUBLIC name before the SYSTEM name:</P><!-- CODE SNIP //--><PRE><!ENTITY image1 PUBLIC "-//RBL//NONSGML Illustration 1//EN" "images/illus1.gif" NDATA gif></PRE><!-- END CODE SNIP //--><P>PUBLIC identifiers provide a mechanism for describing an entity, but donot specify any particular storage location. This can be very useful when aparticular entity is already widely available. An XML processor may be able todetermine, by matching the PUBLIC identifier against a catalog of resources available locally, that it does not need to fetch a new copy of this entity because itis already available.</P><H3><A NAME="ch07_ 3">Text and Binary Entities</A></H3><P>External entities can be either text or binary.</P><P>A text entity contains text data, which is considered to form part of theXML document. When you insert a reference to a text entity, it is treated asthough its content actually appears in the text of your document at that point.For example, the entity XML declared as</P><!-- CODE SNIP //--><PRE><!ENTITY XML "Extensible Markup Language"></PRE><!-- END CODE SNIP //--><P>means that references to the entity XML should be replaced by the phrase <BR>"Extensible Markup Language". Then the markup</P><!-- CODE SNIP //--><PRE><p>We are going to learn about physical structures in &XML;.</p></PRE><!-- END CODE SNIP //--><A NAME="PAGENUM-111"><P>Page 111</P></A><P>is equivalent to the following:</P><!-- CODE SNIP //--><PRE><p>We are going to learn about physical structures inExtensible Markup Language.</p></PRE><!-- END CODE SNIP //--><P>A binary entity is basically anything that isn't meant to be treated as thoughit is XML-encoded. In that sense, the name is misleading: A binary entitycould be a plain text file, for example.</P><P>Each binary entity has to have an associatednotation. A notation describes a type of resource (which is usually just a file type, such asBMP, GIF, or JPG). In fact, having a notation is the one thing that distinguishes a binary entityfrom a text entity. Notation information forms part of the entity declaration inthe DTD, like this:</P><!-- CODE SNIP //--><PRE><!ENTITY my.picture SYSTEM "mypic.bmp" NDATA BMP></PRE><!-- END CODE SNIP //--><P>This line declares that the entitymy.picture is in the BMP notation. Put more simply, it is a BMP file.</P><P>The notation information tells an XML processor what sort of beast theentity is and, therefore, allows the processor to decide what to do with it. Forexample, if an entity contains mathematical equations using theTeX notation, an XML browser might call a helper application to format the equationsand then display the result inline within the document. On the other hand, anentity with a notation of Word6.0 would probably cause an XML browser to callup Word and hand it the relevant file.</P><TABLE BGCOLOR="#FFFF99"><TR><TD>Note:</TD></TR><TR><TD><BLOCKQUOTE>It is possible, and is not an error, for XML documents tocontain references to notations not supported by any application on the systemwhere the XML application is running. This means that you might encounterXML documents containing references to entities that your system cannotprocess. This is similar to the situation that occurs when an HTML browserencounters a MIME-type for which no helper application has beenset up.</BLOCKQUOTE></TD></TR></TABLE><H3><A NAME="ch07_ 4">Entity References</A></H3><P>You insert an entity into your XML documents by using&, followed by the Name of the entity, followed by;, as in the following example:</P><!-- CODE SNIP //--><PRE>&pub-status;Fernand L&eacute;ger</PRE><!-- END CODE SNIP //--><A NAME="PAGENUM-112"><P>Page 112</P></A><P>Before you can make use of an entity, you have to declare it. Chapter 8,"Keeping It Tidy: The XML Rule Book," describes the form that entitydeclarations take in XML. You must give the entity name exactly as declared, because itis case-sensitive. If the Name you give doesn't match a declared entity, theresulting XML document will not be well-formed.</P><P>XML also prohibits recursion: If an entity contains a recursive reference toitself, directly or indirectly, the resulting XML document is notwell-formed. (If this were not so, an XML processor would go on inserting the entityinto itself until it fell over!)</P><P>If the entity in question is a text entity, the entity reference will refer tothe content of that entity.</P><P>It is important to note that binary entities should not be inserted into textin this way. Binary entities can be referred to only in the values of attributesof type ENTITY or ENTITIES. If you use an entity reference to refer to a binaryentity, your XML document will not be well-formed.</P><TABLE BGCOLOR="#FFFF99"><TR><TD>Warning:</TD></TR><TR><TD><BLOCKQUOTE>You can't tell by looking at entity references in your XMLdocument whether they refer to internal or external entities. Nor can you tellwhether they refer to text or binary entities. This information is held in the DTDas part of the entity declaration. See Chapter 8 for more details ofentity declarations.</BLOCKQUOTE></TD></TR></TABLE><H3><A NAME="ch07_ 5">Parameter Entity References</A></H3><P>A variation on the entity reference is the parameter entityreference. This starts with % instead of &, but it is otherwise identical. Here is an example:</P><!-- CODE SNIP //--><PRE>%ISOLat2;</PRE><!-- END CODE SNIP //--><P>Parameter entity references cannot be used within XML documents. Theyare reserved for use within the DTD.</P><TABLE BGCOLOR="#FFFF99"><TR><TD>Note:</TD></TR><TR><TD><BLOCKQUOTE>To be precise, parameter references can be used within theinternal subset of the DTD, which is part of the prolog at the start of theXML document, as well as in the external DTD subset. But theycannot be used within the document element that follows the internal DTD subset.</BLOCKQUOTE></TD></TR></TABLE><P><CENTER><A HREF="../ch06/0107-0108.html">Previous</A> | <A HREF="../ewtoc.html">Table of Contents</A> | <A HREF="0113-0116.html">Next</A></CENTER></P></TD></TR></TABLE></BODY></HTML>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?