📄 0247-0250.html
字号:
<!DOCTYPE HTML PUBLIC "html.dtd"><HTML><HEAD><TITLE>Presenting XML:Developing an XML Memo Application: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=13 //--><!-- PAGES=0235-0262 //--><!-- UNASSIGNED1 //--><!-- UNASSIGNED2 //--><P><CENTER><A HREF="0243-0246.html">Previous</A> | <A HREF="../ewtoc.html">Table of Contents</A> | <A HREF="0251-0254.html">Next</A></CENTER></P><A NAME="PAGENUM-247"><P>Page 247</P></A><P>What can be quoted? Any part of any previous memo, for a start. Thestandard XPointer syntax gives you the ability to quote any single element orspan of elements from any XML document. XPointer links are easiest if theelement being pointed at has an ID. This allows you to use the robust and simpleID addressing mode. The following example retrieves the element withID="para3" from the document memo43.xml:</P><!-- CODE SNIP //--><PRE><quote HREF="memo43.xml#para3"></PRE><!-- END CODE SNIP //--><P>At a late stage in the process, the realization that attribute values of typeID are useful for linking suggests that perhaps your DTD should include anID on every element (except perhaps the root memo elementitself). The following is a parameter entity,a.global, which declares global attributes that can beincluded in the attribute lists of elements that already have attributes:</P><!-- CODE SNIP //--><PRE><!ENTITY % a.global "ID ID #IMPLIED"><!ATTLIST section%a.global; TYPE CDATA #IMPLIED LEVEL CDATA #IMPLIED></PRE><!-- END CODE SNIP //--><P>The following pattern of attribute list declaration can be used for elementtypes that don't have any other attributes:</P><!-- CODE SNIP //--><PRE><!ATTLIST p %a.global;></PRE><!-- END CODE SNIP //--><P>The linking requirement also suggests that it would be helpful if yourXML-aware editor could automatically assign a uniqueID to each element as it is created. Otherwise, authors of memos will have to add anID to every element or try to second-guess which parts of their memos will be worth quoting!</P><TABLE BGCOLOR="#FFFF99"><TR><TD>Note:</TD></TR><TR><TD><BLOCKQUOTE>The strategy of assigning attribute values of typeID is particularly relevant where the XML documents concerned are liable to change overtime. An element with a unique ID represents a stable target for a link, evenwhen the document of which it forms a part is edited. However, in cases likethe memo application, where a memo when written will not be updated,XML-Link's XPointers are quite capable of navigating to any specific part of amemo without needing to use IDs.</BLOCKQUOTE></TD></TR></TABLE><P>Of course, the generality of XML's links means that you can use thequote element to quote any part of any document that is available on thenetwork,</P><A NAME="PAGENUM-248"><P>Page 248</P></A><P>which might be a relevant part of a large report or policy procedure,encoded as part of a different XML application. It might be part of an HTML page.Or it could even be a Word document.</P><TABLE BGCOLOR="#FFFF99"><TR><TD>Note:</TD></TR><TR><TD><BLOCKQUOTE>Note: In the latter case, it would probably be wise to override thedefault behavior by specifyingACTUATE="USER", so that the user has to click onan icon to see the linked Word document.</BLOCKQUOTE></TD></TR></TABLE><P>These simple links have one major advantage over quotations in e-mail.They do not store the same information redundantly, perhaps several times over.</P><H4><A NAME="ch13_ 14">Advanced Linking: Out-Of-Line Links</A></H4><P>Your simple quote elements can be improved upon. Like all inline links,they point only one way. Yet, in the broader context of your memo database,you want to be able to start from any memo and see what chain of argumentflowed from it. You also want to be able to look back and see what argumentspreceded it. In the case of your sample memo, there are three links forward(which are not obvious), as well as the two links back to the previous memo.Figure 13.2 shows your sample memo being browsed by an SGML application(Panorama Pro) that supports out-of-line links. The link icons show that thisdocument indeed has five, not two, links; where two of them relate to thesame paragraph, one points back to the original memo and one points forwardto the reply.</P><TABLE BGCOLOR="#FFFF99"><TR><TD>Note:</TD></TR><TR><TD><BLOCKQUOTE>Panorama Pro doesn't currently support XML XPointer links. Theeffect in Figure 13.2 was achieved using HyTime links, one of the technologieson which XPointers are based.</BLOCKQUOTE></TD></TR></TABLE><P>To achieve two-way linking, you need to move up from simple links toextended links. These out-of-line links will be automatically bidirectional,which means that a source memo will know when it is being quoted. Thiscapability allows you to start from any memo and move in either direction, as required.</P><A NAME="PAGENUM-249"><P>Page 249</P></A><BR><A HREF="javascript:displayWindow('images/ch13fg02.jpg',288,204)"><IMG SRC="images/tn_ch13fg02.jpg"></A><BR>Figure 13.2.<BR>A sample memo with out-of-line links.<BR><P>You need a quotation element to hold the links, with the attributes of an <BR>EXTENDED element type, such as the following:</P><!-- CODE //--><PRE><!ATTLIST quotation XML-LINK CDATA #FIXED "extended" ROLE CDATA #IMPLIED TITLE CDATA #IMPLIED SHOW (EMBED|REPLACE|NEW) "REPLACE" ACTUATE (AUTO|USER) "USER" BEHAVIOR CDATA #IMPLIED></PRE><!-- END CODE //--><P>Note that the SHOW and ACTUATE attributes now have the standard defaults.I'll discuss why in a minute.</P><P>The quotation element will contain two types ofLOCATOR. One will point back to the source memo, just as the simplequote link was doing. The other will point to the place where the source was cited. The types ofLOCATOR are called source and citation. When declaring thequotation element type, you can allow any number of these locators by adding the following:</P><!-- CODE SNIP //--><PRE><!ELEMENT quotation (citation, source+)></PRE><!-- END CODE SNIP //--><A NAME="PAGENUM-250"><P>Page 250</P></A><P>Links will now be expressed by a quotation element containing acitation and one or more source elements. In order to clarify their respective roles,the two locator element types can be given an appropriate and fixedROLE attribute. They could also be given suitable defaultSHOW and ACTUATE attribute values. This attribute list declaration forcitation ensures that references back will appear in full within the text (like your simple inlinequote elements):</P><!-- CODE //--><PRE><!ATTLIST citation XML-LINK CDATA #FIXED "LOCATOR" ROLE CDATA #FIXED "citation" HREF CDATA #REQUIRED TITLE CDATA #IMPLIED SHOW (EMBED|REPLACE|NEW) "EMBED" ACTUATE (AUTO|USER) "AUTO" BEHAVIOR CDATA #IMPLIED></PRE><!-- END CODE //--><P>The following attribute list declaration forsource ensures that references forward will appear as icons that the user has to click on:</P><!-- CODE //--><PRE><!ATTLIST source XML-LINK CDATA #FIXED "LOCATOR" ROLE CDATA #FIXED "source" HREF CDATA #REQUIRED TITLE CDATA #IMPLIED SHOW (EMBED|REPLACE|NEW) "REPLACE" ACTUATE (AUTO|USER) "USER" BEHAVIOR CDATA #IMPLIED></PRE><!-- END CODE //--><TABLE BGCOLOR="#FFFF99"><TR><TD>Note:</TD></TR><TR><TD><BLOCKQUOTE>The containing quotation element doesn't have any specialdefault behavior because its child LOCATOR elements need to behave in different ways.</BLOCKQUOTE></TD></TR></TABLE><H4><A NAME="ch13_ 15">The Link Farm</A></H4><P>Where are these out-of-line quotation elements to live? If they form partof the memo in which the citation occurs, the source memo will feel nobenefit. The source memo will have no means of knowing that it is participating inan out-of-line link declared in another memo. What you need here is asingle document to act as a link farm for the memo database. Alink farm is a single place where you can gather your links together and look after them (forexample, by ensuring that they continue to connect resources that actually exist).</P><P>This document will contain nothing butquotation elements. It will have its own DTD, declaringquotation, source, and citation, as well as thefollowing links cover element to group them together:</P><!-- CODE SNIP //--><PRE><!ELEMENT links (quotation)*></PRE><!-- END CODE SNIP //--><P><CENTER><A HREF="0243-0246.html">Previous</A> | <A HREF="../ewtoc.html">Table of Contents</A> | <A HREF="0251-0254.html">Next</A></CENTER></P></TD></TR></TABLE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -