📄 0081-0084.html
字号:
<!DOCTYPE HTML PUBLIC "html.dtd"><HTML><HEAD><TITLE>Presenting XML:The XML Approach: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=05 //--><!-- PAGES=0067-0084 //--><!-- UNASSIGNED1 //--><!-- UNASSIGNED2 //--><P><CENTER><A HREF="0077-0080.html">Previous</A> | <A HREF="../ewtoc.html">Table of Contents</A> | <A HREF="../ch06/0085-0088.html">Next</A></CENTER></P><A NAME="PAGENUM-81"><P>Page 81</P></A><H3><A NAME="ch05_ 22">Comments</A></H3><P>Comments can be used to annotate your XML documents. They take theform <!--, followed by the text of the comment. They are terminated by thesequence -->. Here is an example:</P><!-- CODE SNIP //--><PRE><!-- This is a comment. --></PRE><!-- END CODE SNIP //--><P>Comments can be of any length. The only restriction on their content isthat they cannot contain any pair of hyphens, except for the ones at the startand end of the comment. Like CDATA sections, comments can contain the& and < characters with impunity: Markup is not interpreted within comments.</P><P>In addition to appearing in your XML documents, comments can be usedto document the Document Type Definitions that control their structure. Inthese cases, it is particularly useful to be able to include markup freely:</P><!-- CODE SNIP //--><PRE><!-- Declarations for <head> & <body>: --></PRE><!-- END CODE SNIP //--><P>Comments should be used with a certain amount of caution. They do notform part of the document's character data, and an XML processor is notrequired to let an application access the text of comments. Thus, comments areguaranteed to be good only as a guide for a human reader who is looking atthe source of an XML document or DTD. Information that might berequired when processing XML documents (for example, who last revised thedocument and when they revised it) is much better held asmarkup.</P><H3><A NAME="ch05_ 23">Processing Instructions</A></H3><P>Processing instructions (jocularly known as PIs) contain instructions forapplications that will process an XML document. PIs start with the sequence<? plus a Name, and they are terminated by?>. Here is an example:</P><!-- CODE SNIP //--><PRE><?XML version="1.0"?></PRE><!-- END CODE SNIP //--><P>The Name (in this case, XML) is called the PItarget. The PI target indicates which application is meant to take notice of the processing instruction.XML itself uses PIs for a variety of purposes. For this reason, it reserves for itsown</P><A NAME="PAGENUM-82"><P>Page 82</P></A><P>use all Names beginning with the letters XML. However, apart from thisminor restriction, the PI mechanism can be used to feed processinginformation to any application that is working with the XML document. Here is anexample:</P><!-- CODE SNIP //--><PRE><?TAGLINK xref "TEI-P3"?></PRE><!-- END CODE SNIP //--><P>PIs are not part of the document's character data, but (unlike comments)they must be passed through to the application.</P><P>If required, the Name at the start of a PI can be formally declared as a <BR>NOTATION. See Chapter 8 for details of how to declarenotations.</P><H3><A NAME="ch05_ 24">Logical and Physical Structure</A></H3><P>You're getting close to finding out what an XML document is, but firstyou have to understand some key XML concepts: logical and physicalstructures, and the relationship between them.</P><P>The logical structure of an XML document is indicated by the markup thatit contains. This markup indicates the declarations, processing instructions,elements, comments and so on that the document contains. The idea oflogical markup should be familiar to you from looking at the source of HTMLpages. Chapter 6, "Logical Structures in XML Documents," goes into the fulldetail of the logical structure within XML documents, and Chapter 8 looks atthe logical structure of the XML DTD.</P><P>Physical structure is a new concept, and a very powerful one. The idea isthat you can break an XML document into any number of bits,or entities. In the XML world, an entity means a physical storage unit. Most of the time,this physical storage unit is just a file on disc, but XML takes care not to limitentities to being files. For example, you might choose to store chunks of XMLin a database. The idea is that your XML-aware system will have anentity manager that knows how to deliver the required piece of XML on request.This might involve going online to the Internet, querying a database, or justpicking up a file from the local system.</P><P>The entity in which an XML document starts (and ends) is called theroot or document entity. Chapter 7 looks at the issue of physical XML structuresin more detail.</P><A NAME="PAGENUM-83"><P>Page 83</P></A><P>The logical and physical structure of an XML document must besynchronous. Broadly speaking, this means that they must nest. Elements must beginand end in the same entity, but they can refer to other entities within theircontent. Each entity must contain complete, not partial, logical structures.Therefore, you have some additional containers representing physical structure,as shown in Figure 5.1.<BR></P><A HREF="javascript:displayWindow('images/ch05fg01.jpg',229,198)"><IMG SRC="images/tn_ch05fg01.jpg"></A><BR>Figure 5.1.<BR>Synchronous logical and physical structures.<BR><P>You will learn more about the relationship between logical and physicalstructures in XML in Chapter 7.</P><H4><A NAME="ch05_ 25">Summary</A></H4><P>In this chapter, you learned the underlying basics of XML. First, Ireviewed and explained the mission statement and design goals that underlie XML.These show you very clearly that the designers of XML are working hard toproduce a standard that is as simple and valuable as possible. You saw how somelessons learned the hard way with SGML are being applied to make XMLmore useful and accessible.</P><A NAME="PAGENUM-84"><P>Page 84</P></A><P>I then reviewed some very basic aspects of XML, which will underpin therest of Part II, "XML in Detail."</P><P>First, you saw how characters are represented in XML, and you learnedthe distinction between character data and markup. Understanding thisdistinction is central to a proper appreciation of how XML works. You learnedabout CDATA sections, which are a handy way of entering text that contains manyspecial markup characters, and you learned about XML's rules for dealing withany white space that is placed around markup to make it more readable.</P><P>Next, you learned how to add comments to XML documents and how tosend instructions to your applications via processing instructions.</P><P>Finally, you found that XML documents have both a logical structure anda physical structure, and that these two structures have to fit together in awell-organized manner.</P><P>This chapter has simply set the scene. Chapter 6, "Logical Structures inXML Documents," discusses the logical structure of XML documents. Chapter7, "Physical Structures in XML Documents," gives full details of thephysical structure of documents. Finally, Chapter 8, "Keeping It Tidy: The XMLRule Book," describes how XML provides its own rule book, so that XMLdocuments are genuinely self-describing.</P><P><CENTER><A HREF="0077-0080.html">Previous</A> | <A HREF="../ewtoc.html">Table of Contents</A> | <A HREF="../ch06/0085-0088.html">Next</A></CENTER></P></TD></TR></TABLE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -