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

📄 0169-0171.html

📁 Presenting XML.rar,详细介绍有关XML的知识
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "html.dtd"><HTML><HEAD><TITLE>Presenting XML:Linking with 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=09 //--><!--  PAGES=0147-0178 //--><!--  UNASSIGNED1 //--><!--  UNASSIGNED2 //--><P><CENTER><A HREF="0165-0168.html">Previous</A> | <A HREF="../ewtoc.html">Table of Contents</A> | <A HREF="0172-0174.html">Next</A></CENTER></P><A NAME="PAGENUM-169"><P>Page 169</P></A><P>This linking element can now be placed inside the entry forpine.</P><P>Notice that it isn't necessary to add any extra attributes to therelated-term-group element, because the additional information is declared, in fixedform, in the DTD.</P><P>The example contains a mixture of locators (therelated-term elements) and data content. As far asXML-LINK is concerned, only the data content (theword pine) counts as the inline resource for the link. The other elements aresimply treated as part of the linking mechanism.</P><H3><A NAME="ch09_ 24">Addressing</A></H3><P>As you have already seen, XML's HREF attribute specifications are designedto be interoperable with HTML. They consist of a URL, optionally followedby ? and a query, or followed by # (or |) and a fragmentidentifier. The interpretation of this fragment identifier depends on the type of resource that isreferenced by the URL.</P><P>This strategy means that you can express links from XML documents toany non-XML resource (image files, HTML pages, Java applets, and so on)using exactly the same URL syntax that you would use from an HTML page.However, XML provides support for more sophisticated addressing within thetarget resource in cases when that resource is an XML document. BecauseXML's addressing strategy is interoperable with HTML's, you can use thisspecial addressing from within HTML pages to address parts of XML documents.</P><H4><A NAME="ch09_ 25">Locator Syntax for XML Resources</A></H4><P>XML interprets the general conventions for URLs in a scheme-specificmanner when the target of the link is an XML resource.</P><P>The URL part, if present, is treated as a standard URL and identifies thecontaining resource that is the target of the link (that is, the document,normally). If no URL is given, the document in which the link is contained is taken tobe the containing resource. This is exactly what HTML browsers do withHTML URLs.</P><P>Any fragment identifier is treated as anXPointer. If an XPointer is provided, the target resource is asub-resource of the containing resource.</P><A NAME="PAGENUM-170"><P>Page 170</P></A><P>This fragment identifier is preceded by aconnector, which can be one of the following:</P><UL><LI>     The # connector is a standard HTML-style connector.<LI>     The | connector is an XML-specific connector.</UL><P>These two types of connectors indicate how and where the fragment is tobe located and processed.</P><P>The # connector asks for all of the containing resource to be delivered tothe client, which then has the job of locating the fragment for itself. (This isexactly the same behavior that you see for # fragments in HTML links.)</P><P>The | connector means that the server does not necessarily need to deliverthe whole containing resource to the client. An XML-aware browser could,for example, query the server to find out how large the containing resource is.If this resource is larger than a certain size, the browser could ask the serverto locate just the required fragment and deliver only that part of the resource.</P><H4><A NAME="ch09_ 26">XPointers Made Easy</A></H4><P>The simplest fragment identifier supported by XML involves putting aName (in the specialized XML sense defined in Chapter 5, &quot;The XMLApproach&quot;) after the Connector, as in this example:</P><!--  CODE SNIP //--><PRE>&lt;LINK HREF=&quot;http://www.sq.com/overview.xml#sect1&quot;/&gt;</A></PRE><!--  END CODE SNIP //--><P>Here, the fragment identifier sect1 is a shorthand for the XPointer:</P><!--  CODE SNIP //--><PRE>ID(sect1)</PRE><!--  END CODE SNIP //--><P>It specifies that the target sub-resource is the element in the containingresource (www.sq.com/overview.xml) with ID =&quot;sect1&quot;.</P><P>This neatly kills two birds with one stone! From an HTML perspective, itlooks the same as the following familiar syntax:</P><!--  CODE SNIP //--><PRE>&lt;A HREF=&quot;http://www.sq.com/index.htm#section1&quot;&gt;</A></PRE><!--  END CODE SNIP //--><TABLE BGCOLOR="#FFFF99"><TR><TD>Warning:</TD></TR><TR><TD><BLOCKQUOTE>The XML and HTML conventions are not exactly the same.In HTML, the target sub-resource is normally the&lt;A&gt; element with a NAME attribute equal to the specified value. In XML, the target isany element with an attribute of type ID whose value is equal to the required value. Youshould</BLOCKQUOTE></TD></TR></TABLE><A NAME="PAGENUM-171"><P>Page 171</P></A><TABLE BGCOLOR="#FFFF99"><TR><TD></TD></TR><TR><TD><BLOCKQUOTE>also be aware that XML attributes do not have to be calledID in order to be of type ID, although it is certainly considered bad form to give them anyother name.<BR><BR>HTML 4.0 now supports fragment identifiers that reference attributes oftype ID, bringing it into line with XML practice. However, this is a recentchange, and most HTML fragment identifiers will still reference&lt;A&gt; elements.</BLOCKQUOTE></TD></TR></TABLE><P>From an XML perspective, this shorthand encourages use of the IDmechanism for addressing. This is a good thing for two reasons:</P><UL><LI>    The XML language specification guarantees that ID values areunique within each valid XML document. This rules out the possibility oftwo identically named targets within a single document (which ispossible with the HTML approach).<LI>     Because IDs are arbitrary names, they are unlikely to be changed asthe document is updated over time. This means that they are morelikely to remain valid targets than the other addressing mechanisms,which involve various kinds of counting through the structure of thedocument.</UL><P>You should recall one thing at this point from the general review ofHTML and XML. XML elements are different from HTML because they alwayshave a well-defined scope. This affects linking. When you link to a part of anHTML document, as in the following code, you are in effect jumping to a specificpoint within that document:</P><!--  CODE SNIP //--><PRE>&lt;A HREF=&quot;otherdoc.htm#section4&quot;&gt;See also Section 4.&lt;/A&gt;</PRE><!--  END CODE SNIP //--><P>This is often the point where Section 4 starts.</P><P>The following equivalent XPointer link to a specified part of an XMLdocument points to an element with an ID equal tosection4:</P><!--  CODE SNIP //--><PRE>&lt;LINK HREF=&quot;otherdoc.xml#section4&quot;&gt;See also Section 4.&lt;/LINK&gt;</PRE><!--  END CODE SNIP //--><P>You might reasonably expect this to be a chunk, consisting of everythingin Section 4.</P><P>The fact that the fragment identifier references a well-defined chunk,rather than just a point within the document, makes it possible for you to grabthe target of the link (Section 4) and deliver it as a document fragment:</P><!--  CODE SNIP //--><PRE>&lt;INCLUDE HREF=&quot;otherdoc.xml|=section4&quot;/&gt;</PRE><!--  END CODE SNIP //--><P><CENTER><A HREF="0165-0168.html">Previous</A> | <A HREF="../ewtoc.html">Table of Contents</A> | <A HREF="0172-0174.html">Next</A></CENTER></P></TD></TR></TABLE></BODY></HTML>

⌨️ 快捷键说明

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