⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 0010-0013.html

📁 Presenting XML.rar,详细介绍有关XML的知识
💻 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="0007-0009.html">Previous</A> | <A HREF="../ewtoc.html">Table of Contents</A> | <A HREF="0014-0017.html">Next</A></CENTER></P><A NAME="PAGENUM-10"><P>Page 10</P></A><H4><A NAME="ch01_ 10">SGML as a Metalanguage</A></H4><P>SGML doesn't enforce any particular set of element types on its users.Instead, it empowers users by providing them with a means to declare their ownelement types. Therefore, SGML is better described as ametalanguage&#151;a language for defining markup languages. Each time SGML is used to solve a certain typeof problem, that is known as an SGML application.</P><P>This flexibility is achieved by letting SGML users define what is allowedin each document. This is achieved by providing a set of rules, collectivelyknown as the document type definition, or DTD. The DTD states (among otherthings) the following:</P><UL><LI>     The element types allowed within the document<LI>     The characteristics of each element type, including its allowedattributes and the content it can have<LI>     The notations that can be encountered within the document<LI>     The entities that can be encountered within the document</UL><P>The DTD is actually part of each SGML document. Part of the DTD(the external DTD subset) is normally held in a separate file, but it is still treatedas though it forms part of the document. This means that SGML documentsare self-describing, because they carry their own structuring rules around withthem.</P><TABLE BGCOLOR="#FFFF99"><TR><TD>Note:</TD></TR><TR><TD><BLOCKQUOTE>This doesn't mean that SGML documents contain everything youmight ever need to know about them. Some things, such as the semantics ofelements and attributes and the conventions for the correct entry of data withincertain elements, cannot be expressed within the formal SGML syntax. All you cando is put these rules into SGML comments within the document, ordocument them separately.</BLOCKQUOTE></TD></TR></TABLE><H3><A NAME="ch01_ 11">HTML as an SGML Application</A></H3><P>Even if you have used HTML coding extensively, many of the concepts inthat description of SGML might not be familiar to you. Yet HTML is perhapsthe most widely known SGML application that exists. How can this be?</P><A NAME="PAGENUM-11"><P>Page 11</P></A><H4><A NAME="ch01_ 12">Syntax Conventions</A></H4><P>For a start, HTML uses SGML syntax. You have start-tags, end-tags, andattribute specifications. The following code, taken from a random Web page,is a fragment of perfectly valid SGML:</P><!--  CODE //--><PRE>&lt;body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot; link=&quot;#054BBB&quot;vlink=&quot;#054BBB&quot; background=&quot;/Images/backshadow2.gif&quot;&gt;&lt;a name=&quot;top&quot;&gt;&lt;/a&gt;&lt;img src=&quot;/Images/bump.gif&quot; border=0 width=50 height=5 align=left&gt;</PRE><!--  END CODE //--><H4><A NAME="ch01_ 13">DTD Design Approach</A></H4><P>Two HTML DTDs are &quot;proper&quot; SGML and are officially supported byW3C: HTML 2.0 and HTML 3.2. These define sets of elements suited to thejob that the HTML application was originally designed to support&#151;onlinedisplay of pages of textual information, interspersed with images, withhyperlinks within and between these pages.</P><P>The design of the HTML DTDs has been influenced by the demands ofonline display. Several of the element types are included purely to support visualfeatures of the resulting Web page, such as the following examples:</P><UL><LI>     br is a line break.<LI>     hr is a horizontal rule.</UL><P>Other elements are provided solely as switches for the current font style,such as the following examples:</P><UL><LI>    tt is typewriter text.<LI>     b is bold.<LI>    i is italic.</UL><P>In each of these elements, the start-tag switches on the feature and theend-tag switches it off again:</P><!--  CODE SNIP //--><PRE>&lt;b&gt;Very important:&lt;/b&gt; switch off before disconnecting.</PRE><!--  END CODE SNIP //--><P>In other words, HTML (in particular HTML 2.0) tends to use theSGML markup to hold full details about the style in which the page is to bepresented. As you have already seen, this brings the advantage of self-containedHTML pages (with no need for a separate style sheet) and the disadvantage ofinflexibility. Each page has a single, predetermined presentationstyle.</P><A NAME="PAGENUM-12"><P>Page 12</P></A><P>It is also clear that the designers of the HTML DTDs were eager to useSGML's minimization facilities to the full. This is a good strategy because it cangreatly reduce the amount of markup you need to add to a Web page. The mostobvious example is end-tag omission&#151;the practice of excluding an end-tagand allowing the SGML system to infer its presence. As an example, thep (paragraph) element type is declared as follows in the HTML 2.0 DTD:</P><!--  CODE SNIP //--><PRE>&lt;!ELEMENT p - O (%text)*&gt;</PRE><!--  END CODE SNIP //--><P>The - O bit of that declaration states that the&lt;p&gt; start-tag has to be provided each time, but the&lt;/p&gt; end-tag can be omitted if you like. The(%text)* is a shorthand and states that text and various low-level elements are allowedinside each paragraph. Because paragraphs cannot occur inside paragraphs inthis DTD, starting a new paragraph is sufficient to tell an SGML system thatthe previous one must have come to an end.</P><H4><A NAME="ch01_ 14">Internal and External Hyperlinking</A></H4><P>One aspect of HTML that doesn't owe much to SGML is thehyperlinking mechanism. The syntax of the Uniform ResourceLocator (URL) was designed to work with the Web's underlying HTTP protocol. Most URLs inHTML documents appear as the href attribute of thea element type:</P><!--  CODE //--><PRE>&lt;A HREF=&quot;/cgi-bin/redirect.cgi?location=http%3A%2F%2Fwww%2&quot;&gt;&lt;A HREF=&quot;http://www.w3c.org/&quot;&gt;&lt;a href=&quot;#top&quot;&gt;</PRE><!--  END CODE //--><P>All attributes in HTML that can contain a URL are of the character datatype. No attempt is made to use SGML's ENTITY orENTITIES attribute type for external hyperlinking. Nor is there any use of the concept of notations,which might have been used to distinguish different image types, video andaudio clips, and so on.</P><P>Similarly, internal links are implemented by using thename attribute of the a element type to label an a element as the potential target of a link:</P><!--  CODE SNIP //--><PRE>&lt;a name=&quot;top&quot;&gt;</PRE><!--  END CODE SNIP //--><P>However, in principle, the SGML ID - IDREF mechanism could just aseasily have been used.</P><A NAME="PAGENUM-13"><P>Page 13</P></A><P>The HTML approach to hyperlinking is simpler and requires lessformality than the alternatives that SGML might have offered. As you have seen,in SGML external entities are referred to via an entity declaration at the startof the SGML document. So, if the href attribute was of typeENTITY instead of CDATA, the link to W3C's home page would have to start with an entitydeclaration at the start of the document:</P><!--  CODE SNIP //--><PRE>&lt;!ENTITY w3c SYSTEM &quot;http://www.w3c.org/&quot;&gt;</A></PRE><!--  END CODE SNIP //--><P>This would then allow the a element to include a reference to the entity&quot;w3c&quot;:</P><!--  CODE SNIP //--><PRE>&lt;a href=&quot;w3c&quot;&gt;</PRE><!--  END CODE SNIP //--><P>Clearly, this is more work and is easier to get wrong.</P><P>ID attribute values must conform to the SGMLName syntax, which limits the characters and symbols they can contain.ID values have to be unique within their document; otherwise, the document is invalid. Similarly,IDREF values must point to an ID that actually exists.</P><P>URLs provide a very elegant means of referring to another page and then toa specific point within that page. You only have to concatenate an externalreference and an internal one within the href attribute value, and the job is done:</P><!--  CODE SNIP //--><PRE>&lt;a href=&quot;http://www.w3c.org/index.htm#section2&quot;&gt;</A></PRE><!--  END CODE SNIP //--><P>This declaration finds the a element with name equal to&quot;section2&quot; within the page with a URL of<A HREF="http://www.w3c.org/index.htm">&quot;http://www.w3c.org/index.htm&quot;.</A></P><H4><A NAME="ch01_ 15">SGML Conformance</A></H4><P>In practice, much of this discussion is pretty academic. Many HTMLapplications make no attempt to ensure that the pages they produce are valid SGML.</P><P>For a start, every valid SGML document needs to start with adocument type declaration, which specifies the DTD to which it conforms and mightlook like this:</P><!--  CODE SNIP //--><PRE>&lt;!DOCTYPE HTML public &quot;-//W3C//DTD HTML 3.2//EN&quot;&gt;</PRE><!--  END CODE SNIP //--><P>This is a reference to the standard HTML 3.2 DTD, with no localdeclarations. Without a document type declaration, you cannot begin todecide whether an HTML page is valid SGML, because you have no idea whichtype of HTML it is trying to conform to.</P><P><CENTER><A HREF="0007-0009.html">Previous</A> | <A HREF="../ewtoc.html">Table of Contents</A> | <A HREF="0014-0017.html">Next</A></CENTER></P></TD></TR></TABLE></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -