📄 0007-0009.html
字号:
<!DOCTYPE HTML PUBLIC "html.dtd"><HTML><HEAD><TITLE>Presenting XML:Introducing 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=01 //--><!-- PAGES=0001-0018 //--><!-- UNASSIGNED1 //--><!-- UNASSIGNED2 //--><P><CENTER><A HREF="0001-0006.html">Previous</A> | <A HREF="../ewtoc.html">Table of Contents</A> | <A HREF="0010-0013.html">Next</A></CENTER></P><A NAME="PAGENUM-7"><P>Page 7</P></A><P>platform-independent, and extremely flexible. It is widely used forencoding structured documents ranging in size and complexity from aircraftmaintenance manuals to haiku.</P><P>Note that SGML is not a piece of software. It is simply a way ofrepresenting documents. If you want to do something useful with an SGML-encodeddocument, you need software that understands SGML and does the job youwant. Because of the size and complexity of the full SGML standard, suchsoftware tends to be relatively expensive.</P><H4><A NAME="ch01_ 7">Structured Documents</A></H4><P>SGML introduces the important concept of anend-tag to mark the end of a structural element. The initial paragraph of this chapter would look likethis when marked up in SGML:</P><!-- CODE SNIP //--><PRE><p>This book aims to tell you about XML: "eXtensible Markup Language". However, in order to understand XML you need somebackground.</p></PRE><!-- END CODE SNIP //--><P>The <p> is a start-tag (replacing the RTF\par code), and the </p> is an end-tag.</P><P>In SGML terminology, the paragraph is anelement within the document, and it has an elementtype of p (which stands for paragraph).</P><P>The presence of end-tags allows SGML to support a hierarchical view ofa document's structure. Thus, the quoted phrase within the paragraph couldbe marked up in its own right:</P><!-- CODE //--><PRE><p>This book aims to tell you about XML: <q>eXtensible Markup Language</q>. However, in order to understand XML you need somebackground.</p></PRE><!-- END CODE //--><P>Now you have a q (quotation) element inside yourp element. This process can continue upward: You can embed your paragraph inside a section, putthat section inside a chapter, and finally put the chapter into the singleelement that contains the entire book. It also can go downward: Some SGMLapplications (for example, those involved in linguistic analysis) mark up everysingle word in each document!</P><P>Notice that the quotation marks have vanished from the paragraph. Oneuseful feature of generalized markup is that it can replace specific characterslike this. Putting the quotation marks back in can be part of the style sheet'sjob. This also gives you more flexibility. You can decide to use single quotes(`), double quotes ("), or even French-style chevron (« ») quotation markswhen displaying the document.</P><A NAME="PAGENUM-8"><P>Page 8</P></A><P>In a similar way, you can leave out chapter and section numbers and letyour style sheet number them for you when the document is displayed. Thismakes it much easier to rearrange the order of chapters and sections as a bookdevelops. You don't have to renumber. You can even get your style sheet togenerate a table of contents for you (with correct page numbers) from thechapter headings in the book itself.</P><H4><A NAME="ch01_ 8">Elements with Added Value: Attributes</A></H4><P>Marking up a document's structure is a useful task, but for practicalapplications, you often need to add more information. For example, this bookhas several kinds of note boxes: plain notes, warnings, cautions, and tips.Following the principles of generalized markup, you might define a singlenote element to hold all these different types of note. But if you do that, whereand how do you indicate what type of note you have?</P><P>Recognizing that you will often want to add value to your structuralmarkup in this way, SGML provides a general facility calledattributes. These additional pieces of information appear in your start-tags. For example, awarning-type note element would be marked up like this:</P><!-- CODE SNIP //--><PRE><note type="warning">In cases of dire emergency ...</PRE><!-- END CODE SNIP //--><P>The <note> start-tag now includes an attributespecification for the attribute type.</P><P>SGML attributes can take any of 15 types of values, which can broadlybe grouped as follows:</P><UL><LI> Character data: Any sequence of characters that is valid in SGML.<LI> Entity names: References to resources outside the SGML document.<LI> IDs: A unique identifier for this element within the document.<LI> ID pointers: Cross-references within the SGML document toelements with the IDs quoted.<LI> Name-type attributes: Attributes whose values, broadly speaking,are limited to one or more words consisting only of SGMLName characters (which are letters, digits, and a small number of separatorcharacters).<LI> Notations: Attributes that specify the notation in which the contentof an element is expressed.<LI> Number-type attributes: Attributes whose values are limited to oneor more words consisting only of SGML Number characters (whichare digits).</UL><A NAME="PAGENUM-9"><P>Page 9</P></A><H4><A NAME="ch01_ 9">Entities</A></H4><P>SGML is designed to cope with real-world documents, which typicallyinclude things such as illustrations that can't possibly be marked up in SGML.They typically contain nontextual information expressed in binary format.SGML's approach to this problem is to provide the concept of anentity, which can be thought of as any sequence of characters or bit patterns that can be treatedas a unit. One common example of this is a file, although you probablydon't normally think of files that way. Several types of entities are found inSGML, but the type that is relevant for multimedia documents isthe non-SGML data entity.</P><P>You've already seen the attribute types for referring to entities. Thefollowing is how you would embed an image file into afigure element:</P><!-- CODE SNIP //--><PRE><figure entity="figure1"></PRE><!-- END CODE SNIP //--><P>Note that the attribute value"figure1" isn't a filename. Somewhere at thestart of the document, an entity declaration attaches"figure1" to a real filename and indicates thenotation in which the file is encoded:</P><!-- CODE SNIP //--><PRE><!ENTITY figure1 SYSTEM "fig1.bmp" NDATA BMP></PRE><!-- END CODE SNIP //--><P>This says that the entity name"figure1" means the file"fig1.bmp", which conforms to the BMP notation.</P><P>This method of embedding multimedia resources into SGML documentsis totally open-ended, because there is no limit on the number of notationsthat can be declared.</P><P>Another use of entities in SGML is to represent characters that are difficultto enter on the keyboard or characters that have a different representationon different platforms. Accented characters are a good example of this, asanyone who has tried to copy a document in French from a PC to a Macknows. SGML's approach is to use an entity reference to represent the character, asin the following example:</P><!-- CODE SNIP //--><PRE>Fernand L&eacute;ger</PRE><!-- END CODE SNIP //--><P>In this example, &eacute; is an entity reference for the characteré. This entity reference is treated as systemdata (SDATA), which means that it will be mapped to the correct representation of that character when the SGML documentis processed on any platform.</P><P><CENTER><A HREF="0001-0006.html">Previous</A> | <A HREF="../ewtoc.html">Table of Contents</A> | <A HREF="0010-0013.html">Next</A></CENTER></P></TD></TR></TABLE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -