📄 0269-0272.html
字号:
<!DOCTYPE HTML PUBLIC "html.dtd"><HTML><HEAD><TITLE>Presenting XML:Creating an XML Museum Information 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=14 //--><!-- PAGES=0263-0282 //--><!-- UNASSIGNED1 //--><!-- UNASSIGNED2 //--><P><CENTER><A HREF="0263-0268.html">Previous</A> | <A HREF="../ewtoc.html">Table of Contents</A> | <A HREF="0273-0275.html">Next</A></CENTER></P><A NAME="PAGENUM-269"><P>Page 269</P></A><P>The SPECTRUM headings give rise to the following model forobject:</P><!-- CODE //--><PRE>!ELEMENT OBJECT ((RECORD-INFORMATION| AMENDMENT-HISTORY| OBJECT-IDENTIFICATION| OBJECT-DESCRIPTION| OBJECT-PRODUCTION| OBJECT-COLLECTION| REFERENCES...| LOSS| DISPOSAL)*)></PRE><!-- END CODE //--><P>Note that the content model for object states that these groups ofinformation are optional, repeatable, and can occur in any order.</P><P>This design approach means that any museum object record will be validagainst this DTD, no matter how simple or complex it might be. Putting itanother way, the DTD is descriptive rather than prescriptive.</P><P>You need to apply a similar approach for the level-2 elements. Thefollowing is the declaration for theobject-identification element, within which your Brief description concept will appear:</P><!-- CODE //--><PRE><!ELEMENT OBJECT-IDENTIFICATION ((OBJECT-NUMBER| OTHER-NUMBER| BRIEF-DESCRIPTION| COMMENTS| OBJECT-NAME| TITLE)*)></PRE><!-- END CODE //--><P>You might have spotted that the list of subelements (six in all) is shorterthan the list of 15 concepts in Figure 14.3. What has happened? If you checkout the full list, you will see that the "missing" entries are all concepts thatqualify a concept that you have included. For example, "Other number type" isdefined as "A description of an Other number assigned to an object." In the"Use" section it says "Record once only for each Othernumber."</P><H4><A NAME="ch14_ 6">Using XML to Enforce the Rules</A></H4><P>The SPECTRUM rule gives you a chance to be more prescriptive and toensure that your interchange format supports SPECTRUM by enforcingany mandatory requirements it might lay down. How do you ensure that thereis always only one "other number type" for each "other number"?</P><A NAME="PAGENUM-270"><P>Page 270</P></A><P>You can make other-number-type a subelement ofother-number. This ensures that it cannot be delivered independently ofother-number. There are two ways you can express the rule forother-number.</P><P>The first is to say that the actual "other number" appears as characterdata, with an optional "type" subelement. In XML thismixed content model has to be declared in the following way:</P><!-- CODE SNIP //--><PRE><!ELEMENT OTHER-NUMBER(#PCDATA | OTHER-NUMBER-TYPE)*></PRE><!-- END CODE SNIP //--><P>With this approach, a lender's number might be recorded as follows:</P><!-- CODE SNIP //--><PRE><other-number>PXM 92/35<other-number-type>lender</other-number-type></other-number></PRE><!-- END CODE SNIP //--><P>The second approach, which you could use if you wanted to ensure thateach "other number" had exactly one "type," is to declare aTYPE attribute. The other-number element would then have a simpler content model and an attributelist, as in the following example:</P><!-- CODE SNIP //--><PRE><!ELEMENT OTHER-NUMBER (#PCDATA)><!ATTLIST OTHER-NUMBERTYPE CDATA #IMPLIED></PRE><!-- END CODE SNIP //--><P>With this approach, a lender's number would be recorded more simplyas follows:</P><!-- CODE SNIP //--><PRE><other-number TYPE="lender">PXM 92/35</other-number></PRE><!-- END CODE SNIP //--><P>If you felt that SPECTRUM is mandating an "other number type" foreach "other number," you could easily achieve this by making theTYPE attribute #REQUIRED instead of #IMPLIED.</P><P>By the time you have finished analyzing the SPECTRUM framework, youwill have a DTD with many more than two levels. For example, theobject-name element will contain anobject-name-author that will in turn contain a potentially detailed entry about a person or organization.</P><P>One advantage that XML brings is that you only have to declare theperson element, with all its complex subelements, once. You can then useperson as often as required within the overall structure, which avoids redundancywithin the DTD. Next you should look at how you might avoid redundancy inthe actual data records that are interchanged using thisDTD.</P><A NAME="PAGENUM-271"><P>Page 271</P></A><H4><A NAME="ch14_ 7">Entity Relationships with XML-Link</A></H4><P>Earlier, I demonstrated that some common concepts such as person, place,and date appeared "wrongly" at the top level in SPECTRUM and relegatedthem to their proper place within the structure. However, if you think aboutthe reality of the information that is going to be transferred, it is clear thatthere will be some redundancy in this approach.</P><P>The same person—for example, a donor who has given many objects tothe museum—can be mentioned within many of the object records. Each timehe is mentioned, his details will be the same. Is there a way to avoid thisredundancy? One method involves using XML-Link to support a simple typeof entity-relational modeling.</P><P>Think back to how the information is probably stored in the museum'sin-house database. Assuming it has a relational design, the details of eachperson (like the donor) will be normalized into a separate "table." The "acquiredfrom" rows will link that person to each object that he donated, without any needto repeat the name, address, and so on. You can do that too in XML; in fact,there are two ways of doing it!</P><P>In both cases you need to separate (ornormalize) the personal information. Then use XML's linking facilities to make the required connections.</P><P>You need a place in your data delivery structure to put the personal data,which will involve some changes to the top level of the DTD. One simple way ofdoing it is to rename object-set to something more neutral, such asSPECTRUM-set, and allow person as well as object entries within it, as follows:</P><!-- CODE SNIP //--><PRE><!ELEMENT SPECTRUM-SET ((OBJECT | PERSON)*)></PRE><!-- END CODE SNIP //--><P>When declaring the person element, providing it with anID attribute is important. An ID attribute will make it easy to use XML links to point atthe person elements. The following is an example:</P><!-- CODE SNIP //--><PRE><!ATTLIST PERSON ID ID #REQUIRED></PRE><!-- END CODE SNIP //--><P>The simpler of the two approaches will probably be adequate. Thesimpler approach involves one-way links from the object records to the relevantperson entries.</P><A NAME="PAGENUM-272"><P>Page 272</P></A><P>You need to provide a person-link element type, as an alternative to afully embedded person element. The person-link will have the standardattributes of an XML simple link, such as the following:</P><!-- CODE //--><PRE><!ELEMENT PERSON-LINK EMPTY><!ATTLIST PERSON-LINK XML-LINK CDATA #FIXED "SIMPLE" ROLE CDATA #IMPLIED HREF CDATA #REQUIRED TITLE CDATA #IMPLIED SHOW (EMBED|REPLACE|NEW) "EMBED" ACTUATE (AUTO|USER) "AUTO" BEHAVIOUR CDATA #IMPLIED></PRE><!-- END CODE //--><TABLE BGCOLOR="#FFFF99"><TR><TD>Note:</TD></TR><TR><TD><BLOCKQUOTE>The default values of the SHOW andACTUATE attributes have been changed so that, by default, the linked personal details will beembedded automatically within the relevant object record.</BLOCKQUOTE></TD></TR></TABLE><P>The following declares a person authority record:</P><!-- CODE //--><PRE><person ID="BROWN_H"><name><forename>Harold</forename><surname>Brown</surname></name>...</person></PRE><!-- END CODE //--><P>The following uses a person-link to point to theperson authority record:</P><!-- CODE //--><PRE><object><object-production><person-link ROLE="designer" HREF="BROWN-H"/>...</PRE><!-- END CODE //--><P>The preceding code states that the person Harold Brown was involved in <BR>the production of the object in the role of a designer. In other words, he <BR>designed it!</P><TABLE BGCOLOR="#FFFF99"><TR><TD>Note:</TD></TR><TR><TD><BLOCKQUOTE>All XML links have the built-in ROLE attribute, which is the perfectplace to put another SPECTRUM concept: Person's association. This is definedas "the way in which a Person is associated with a particularobject."</BLOCKQUOTE></TD></TR></TABLE><P><CENTER><A HREF="0263-0268.html">Previous</A> | <A HREF="../ewtoc.html">Table of Contents</A> | <A HREF="0273-0275.html">Next</A></CENTER></P></TD></TR></TABLE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -