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

📄 0165-0168.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="0162-0164.html">Previous</A> | <A HREF="../ewtoc.html">Table of Contents</A> | <A HREF="0169-0171.html">Next</A></CENTER></P><A NAME="PAGENUM-165"><P>Page 165</P></A><P>Or you could step away from the actual paragraphs, and make theconnection between them somewhere near the start of the document, like this:</P><!--  CODE //--><PRE>&lt;EXTENDED-LINK ROLE=&quot;sibling&quot;&gt;&lt;LOCATOR HREF=&quot;#para.1&quot; TITLE=&quot;overview&quot;/&gt;&lt;LOCATOR HREF=&quot;#para.3&quot; TITLE=&quot;detail&quot;/&gt;&lt;/EXTENDED-LINK&gt;...&lt;P ID=&quot;para.1&quot;&gt;In general terms ... &lt;/P&gt;&lt;P ID=&quot;para.2&quot;&gt; ... &lt;/P&gt;&lt;P ID=&quot;para.3&quot;&gt;Specifically, ...&lt;/P&gt;</PRE><!--  END CODE //--><P>This means that the connection between paragraph 1 and paragraph 3 isnow made elsewhere. (In fact, it doesn't even have to be in the same document,as you will see!) Now the markup of the text is simpler, because it isn'tcluttered with linking information. Because the out-of-line link associates the twoparagraphs in a neutral way, it can be traversed with equal ease in eitherdirection&#151;so it becomes a bi-directional link.</P><P>Of course, for this magic to happen, the software must work a bit harder.An XML application must search for extended links, and work out where theend-points of each one fall. In this case, it then marks a link from paragraph1 pointing at paragraph 3, and it marks a second link pointing back theother way. From the user's point of view, each of these links then behaves inexactly the same way as the equivalent simple link would behave.</P><P>To take the thesaurus application as another example, extended linkswould be a very clean method of grouping related terms together:</P><!--  CODE //--><PRE>&lt;related-term-group&gt;&lt;related-term HREF=&quot;pine.xml&quot; TITLE=&quot;pine&quot;/&gt;&lt;related-term HREF=&quot;beech.xml&quot; TITLE=&quot;beech&quot;/&gt;&lt;related-term HREF=&quot;oak.xml&quot; TITLE=&quot;oak&quot;/&gt;&lt;related-term HREF=&quot;willow.xml&quot; TITLE=&quot;willow&quot;/&gt;&lt;/related-term-group&gt;</PRE><!--  END CODE //--><P>In this case, the link contains four locators. It states that when you arepositioned at any of the four documents mentioned(&quot;pine.xml&quot;, &quot;beech.xml&quot;,&quot;oak.xml&quot;, or &quot;willow.xml&quot;), you have a potential link to any of the otherthree documents. This is much more concise than having three simple links outof each of the four documents, and it is much easier to maintain. (Thinkabout what happens when you want to add or remove an entry from therelated group!)</P><A NAME="PAGENUM-166"><P>Page 166</P></A><P>The XML processor might have to search for extended links in a numberof places. The XML-Link specification tries to make the processor's life easierby specifying exactly where the links are likely to be found. I talk aboutlink groups in the &quot;Extended Link Groups&quot; section, later in this chapter.</P><P>So, how exactly are extended links specified? Let's go back over theparagraph-to-paragraph link and see what's there. The out-of-line link is constructedfrom two types of elements, called EXTENDED andLOCATOR.</P><H4><A NAME="ch09_ 21">EXTENDED Elements</A></H4><P>You might be surprised to learn that anEXTENDED link element doesn't point or link to anywhere at all. It simply groups together a bunch ofLOCATOR elements, and by so doing it indicates thattogether they form an extended link:</P><!--  CODE SNIP //--><PRE>&lt;EXTENDED&gt;&lt;LOCATOR .../&gt;&lt;LOCATOR .../&gt;&lt;/EXTENDED&gt;</PRE><!--  END CODE SNIP //--><P>You can use the attributes of your EXTENDED link element to state how the <BR>LOCATOR elements within it will behave by default. You can give it aROLE and a TITLE, and you can specify behaviors, as in the following case:</P><!--  CODE SNIP //--><PRE>&lt;EXTENDED-LINK ROLE=&quot;sibling&quot; TITLE=&quot;see also&quot;&gt;</PRE><!--  END CODE SNIP //--><BR><TABLE BGCOLOR="#FFFF99"><TR><TD></TD></TR><TR><TD><BLOCKQUOTE>Remember that an EXTENDED link element doesn't have to be an elementwith an element type of extended. It is any element that has anXML-LINK attribute with the value&quot;EXTENDED&quot;. So, once again, you can declare as many typesof extended link groups as your application requires.</BLOCKQUOTE></TD></TR></TABLE><P>The related-term-group element type for the thesaurus example mighthave the following element and attribute list declaration:</P><!--  CODE //--><PRE>&lt;!ELEMENT related-term-group    (related-term)+&gt;&lt;!ATTLIST related-term-group    XML-LINK CDATA #FIXED &quot;EXTENDED&quot;    ROLE CDATA #FIXED &quot;RT&quot;    TITLE CDATA #IMPLIED    SHOW (EMBED|REPLACE|NEW) &quot;REPLACE&quot;    ACTUATE (AUTO|USER) &quot;USER&quot;    BEHAVIOR CDATA #IMPLIED&gt;</PRE><!--  END CODE //--><A NAME="PAGENUM-167"><P>Page 167</P></A><P>This declaration enforces the role&quot;RT&quot; as a default for all locators withinrelated-term-group, and it leaves all other linking attributes with theirdefault behavior.</P><TABLE BGCOLOR="#FFFF99"><TR><TD>Note:</TD></TR><TR><TD><BLOCKQUOTE>In the example, the content model forrelated-term-group states that it can contain onlyrelated-term elements. However, the XML-Link specification doesn't limit the content anEXTENDED element type can have, as long as anyLOCATOR elements are its immediate children. AnEXTENDED element can contain a mixture of differentLOCATOR element types or LOCATOR elements interspersed with character data and other subelements.</BLOCKQUOTE></TD></TR></TABLE><H4><A NAME="ch09_ 22">LOCATOR Elements</A></H4><P>Each LOCATOR element defines one resource that is participating in anextended link.</P><P>Just like simple links, each LOCATOR element can be qualified by aROLE or TITLE, and its behavior can be specified bySHOW, ACTUATE, and BEHAVIOR attributes. If any one of these attributes is not specified, its value will beinherited from the value of the corresponding attribute in its parentEXTENDED element.</P><P>In the extended link example, you have two locator elements:</P><!--  CODE SNIP //--><PRE>&lt;LOCATOR HREF=&quot;#para.1&quot; TITLE=&quot;overview&quot;/&gt;&lt;LOCATOR HREF=&quot;#para.3&quot; TITLE=&quot;detail&quot;/&gt;</PRE><!--  END CODE SNIP //--><P>However, in principle, any number of LOCATOR elements could be in this link.</P><P>If you have the following three linked paragraphs, the XML processormarks all three as being resources of a hyperlink, just as before:</P><!--  CODE //--><PRE>&lt;LOCATOR HREF=&quot;#para.1&quot; TITLE=&quot;overview&quot;/&gt;&lt;LOCATOR HREF=&quot;#para.3&quot; TITLE=&quot;detail 1&quot;/&gt;&lt;LOCATOR HREF=&quot;#para.9&quot; TITLE=&quot;detail 2&quot;/&gt;</PRE><!--  END CODE //--><P>But when a user clicks on one of these links&#151;for instance, the oneanchored at paragraph 3&#151;things will be rather different. Now you have twopotential targets: paragraph 1 and paragraph 9. How the processor deals with thissituation depends on the information available. In the absence of anyspecific guidance, it might just offer the user a menu, giving theTITLE of each target to help the user choose. However, theBEHAVIOR attribute of the EXTENDED link element or of itsLOCATOR subelements might give application-specific</P><A NAME="PAGENUM-168"><P>Page 168</P></A><P>guidance on what to do. Alternatively, the ROLE attribute of one or moreof these elements could indicate to an XML application how thismultidirectional link should be interpreted.</P><P>The related-term element for thesauri might be defined as follows in the DTD:</P><!--  CODE //--><PRE>&lt;!ELEMENT related-term EMPTY&gt;&lt;!ATTLIST related-term    XML-LINK CDATA #FIXED &quot;LOCATOR&quot;    ROLE CDATA #FIXED &quot;RT&quot;    HREF CDATA #REQUIRED    TITLE CDATA #IMPLIED    SHOW (EMBED|REPLACE|NEW) &quot;REPLACE&quot;    ACTUATE (AUTO|USER) &quot;USER&quot;    BEHAVIOR CDATA #IMPLIED&gt;</PRE><!--  END CODE //--><P>This again enforces the role &quot;RT&quot;, while leaving all other linking attributeswith their default behavior.</P><H4><A NAME="ch09_ 23">Inline Extended Links</A></H4><P>Extended links also have the three attributesINLINE, CONTENT-TITLE, and CONTENT-ROLE. Within an extended link, the INLINE attribute allows youto say that the linking element is one of the resources of the link. This is arelatively painless way of expressing two-way extended links, because thefamiliar approach of embedding one end of the link in a source document is stillemployed. The related-term-group element could be made into an inlineextended link, with the inline related term being given as character datawithin the related-term-group element itself. These are the changes to thedeclarations for related-term-group:</P><!--  CODE //--><PRE>&lt;!ELEMENT related-term-group        (#PCDATA | related-term)*&gt;&lt;!ATTLIST related-term-group        XML-LINK CDATA #FIXED &quot;EXTENDED&quot;        INLINE CDATA #FIXED &quot;TRUE&quot;        CONTENT-ROLE CDATA #FIXED &quot;RT&quot;        ...&gt;</PRE><!--  END CODE //--><P>The following is the example with the first of the related terms(pine) now given as the content of an inline extended link:</P><!--  CODE //--><PRE>&lt;related-term-group&gt;pine&lt;related-term HREF=&quot;beech.xml&quot;/&gt;&lt;related-term HREF=&quot;oak.xml&quot;/&gt;&lt;related-term HREF=&quot;willow.xml&quot;/&gt;&lt;/related-term-group&gt;</PRE><!--  END CODE //--><P><CENTER><A HREF="0162-0164.html">Previous</A> | <A HREF="../ewtoc.html">Table of Contents</A> | <A HREF="0169-0171.html">Next</A></CENTER></P></TD></TR></TABLE></BODY></HTML>

⌨️ 快捷键说明

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