📄 0027-0029.html
字号:
<!DOCTYPE HTML PUBLIC "html.dtd"><HTML><HEAD><TITLE>Presenting XML:Enter XML: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=02 //--><!-- PAGES=0019-0036 //--><!-- UNASSIGNED1 //--><!-- UNASSIGNED2 //--><P><CENTER><A HREF="0023-0026.html">Previous</A> | <A HREF="../ewtoc.html">Table of Contents</A> | <A HREF="0030-0032.html">Next</A></CENTER></P><A NAME="PAGENUM-27"><P>Page 27</P></A><P>In this example, the body text is divided into divisions.div1 is a level-1 division, within which div2 is a level-2 subdivision, and so on:</P><!-- CODE //--><PRE><document> <body> <div1> <!-- level-1 division --> <head>Beginnings</head> <p>In the beginning ... </p> <div2> <!-- level-2 division --> <head>Part of the beginning</head> <p>As part of our discussion ...</p> </div2> <!-- end of level-2 division --> </div1> <!-- end of level-1 division --> </body></document></PRE><!-- END CODE //--><P>Being able to describe a heading as "immediately inside adiv1 element" means that you don't need to have, as HTML does, six different element typesfor headings. Instead, the single element typehead is provided, and it is used for headings at any level. It is still possible to distinguish the different levelsof headings using their context.</P><P>Having a full context for every piece of text in an XML document is alsoa great help when searching. You can look for a given word anywhere inthe document, only inside headings, or even only inside level-1 headings.This added precision for retrieval is particularly important for XMLapplications whose information content is precisely defined and tightly controlled, butit can still be a major bonus within more textualapplications.</P><H4><A NAME="ch02_ 12">Create Your Own Applications</A></H4><P>A central feature of XML is that it lets you define your own informationstructures. This doesn't mean that you personally will have to learn how todesign your own DTDs. Most users of XML won't even be aware that they areusing a DTD.</P><P>In practice, the creation of new XML applications will probably be done asa community venture for specific types of information work. There is reallyno benefit in creating a different DTD for every document. If a communityor industry adopts a common DTD for its documents, it is effectivelyadopting a common information standard, which means that informationinterchange and cross-document searching become feasible.</P><A NAME="PAGENUM-28"><P>Page 28</P></A><P>The key point about this flexibility is that standard XML-aware softwarewill be able to work with your custom XML application without any specialhelp. At present, if you load a document full of non-HTML tags into a Webbrowser, it won't complain but it won't do much with the document either. WithXML you will be able to control how your document looks and how its linkswork, even though your tagset is unique in yourapplication.</P><H4><A NAME="ch02_ 13">Valid and Well-Formed Documents</A></H4><P>If you declare a DTD at the head of your XML document and then followall the rules it prescribes, you will have a valid XMLdocument. Better than that, you will also have avalid SGML document. This means that your document is future-proof, because it conforms to an International Standard markupconvention. It can be used in any environment that understands SGML—notjust the Web.</P><P>At another level XML introduces the concept ofwell-formed documents, which are structurally sound but need not be valid. All elements are neatlynested, and all entities referenced by the document are properly declared.However, no check is made that the document's logical structure matches the rulesgiven in the DTD. In fact, the DTD can be dispensed with completely incertain circumstances. A required markupdeclaration (RMD) can be used to indicate whether the DTD must be read in order to process a well-formed XML <BR>document.</P><P>I don't think that much information will actually be created and managedas well-formed XML, except in the simplest of applications. Whenauthoring XML documents, it is actually easier to work with a DTD than withoutone, because the presence of a DTD allows XML editing software to give theauthor more help. For example, when the author wants to insert a newelement, an XML-aware editor presents a drop-down list containing only thoseelement types that are allowed by the DTD in the current context.</P><P>However, the concept of a well-formed XML document provides a legal,convenient, self-contained delivery format for XML-encoded information.For many downstream applications, such as display or indexing, a DTD-lesswell-formed XML document is perfectly adequate. It therefore removes theneed to transmit a potentially large DTD in cases where the client applicationreceiving an XML-encoded stream has no use for one.</P><A NAME="PAGENUM-29"><P>Page 29</P></A><H4><A NAME="ch02_ 14">Entities: Documents in Chunks</A></H4><P>XML supports some practical aspects of document management with itsconcept of entities. Entities are sequences of characters or bit patterns, heldwithin an XML document or external to it.</P><P>I introduce entities in my brief introduction to SGML in Chapter 1, whereI show how they can be used to represent external resources, such asillustrations, with an added notation to indicate their type. XML supports thisapproach, and it calls such resources external binaryentities.</P><P>In addition, XML offers two types of entities that can be used to helpmanage your XML documents.</P><P>External text entities are simply resources (usually, but not necessarily,files) containing XML markup. External text entities allow you to build yourXML documents in chunks. For example, this book is being written one chapterat a time, and each chapter is a separate text entity. When the time comes tomake the whole book into a single XML document, all I need to do is declareeach chapter as an external text entity and make reference to them all in thecorrect order.</P><P>In addition to allowing documents to be written by a number ofdifferent people, external text entities allow information reuse. A standard warning,for example, could be marked up in XML and held in a file, ready to bepasted into all new customer documentation.</P><P>The ability to build up a document in chunks can also be useful when partsof it are in a different character set. Each part can be isolated and placed in aseparate entity with its own encoding rules.</P><P>XML also supports the idea of internal entities, which are shorthand for apiece of XML markup that is held within the document. Internal entities can beused for standard phrases, expansions of abbreviations, and even for singlecharacters (such as the trademark symbol, ‰).</P><P>I describe XML entities in more detail in Chapter 7, "Physical Structuresin XML Documents."</P><P><CENTER><A HREF="0023-0026.html">Previous</A> | <A HREF="../ewtoc.html">Table of Contents</A> | <A HREF="0030-0032.html">Next</A></CENTER></P></TD></TR></TABLE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -