📄 0051-0054.html
字号:
<!DOCTYPE HTML PUBLIC "html.dtd"><HTML><HEAD><TITLE>Presenting XML:Implementing 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=04 //--><!-- PAGES=0051-0066 //--><!-- UNASSIGNED1 //--><!-- UNASSIGNED2 //--><P><CENTER><A HREF="../ch03/0050-0050.html">Previous</A> | <A HREF="../ewtoc.html">Table of Contents</A> | <A HREF="0055-0059.html">Next</A></CENTER></P><A NAME="PAGENUM-51"><P>Page 51</P></A><H3><A NAME="ch04_ 1">CHAPTER 4</A></H3><H2>Implementing XML</H2><B>by Richard Light</B><P>At this point, you have learned the definition of XMLand examined its advantages. To finish off this introductorypart of the book, let's think in very general terms about therealities of implementing XML. Much of the discussion inthis chapter is centered on software tools, but you shouldalways remember that the software is just a means ofaccomplishing a task. This chapter doubles as a checklist of the types ofwork you might be faced with when you implement XML.</P><H3><A NAME="ch04_ 2">What Software Do You Need?</A></H3><P>It is important to remember that XML is just a standardrepresentation for structured information. Without softwarethat can understand that representation, it is not particularlyuseful.</P><A NAME="PAGENUM-52"><P>Page 52</P></A><P>In this chapter, I review the general types of software that will be requiredto support XML. In Chapter 16, "XML Software," I review the current stateof play in the real world, and describe the software initiatives that arecurrently taking XML on board.</P><P>One general point must be made about software for XML: All validXML documents are also valid SGML documents. As a result, all existing SGML-capable software should (in principle) work with valid XMLdocuments. Therefore, a pretty good installed base of software exists even before anyXML-specific software is developed.</P><TABLE BGCOLOR="#FFFF99"><TR><TD>Note:</TD></TR><TR><TD><BLOCKQUOTE>For SGML software to work with XML documents, it needs to befed—and needs to act on—the XML-specific version of a special header calledthe SGML declaration, which sets things up to support XML's use of theSGML framework. Without this declaration, DTDs designed for XML won't bevalid, and things such as the Unicode character set and the special XML syntaxfor empty elements will cause problems.</BLOCKQUOTE></TD></TR></TABLE><TABLE BGCOLOR="#FFFF99"><TR><TD>Warning:</TD></TR><TR><TD><BLOCKQUOTE>I have used SGML-based software for the figures in this chapter.See Chapter 16 for examples of XML-based offerings.</BLOCKQUOTE></TD></TR></TABLE><H3><A NAME="ch04_ 3">Authoring</A></H3><P>As a writer of Web pages, your first thought will correctly be, "How do Icreate and update XML documents?" It's a reasonable question, but authoringis actually only one aspect of a more general issue.</P><P>Broadly speaking, there are three approaches to creating XML documents:</P><UL><LI> "Do it yourself" with a plain text editor.<LI> Use specialized XML authoring tools.<LI> Use a standard word processor with plug-in XML support.</UL><P>The first option doesn't sound very appealing because it implies that youwill add all the XML markup by hand. This creates more work and is moreerror-prone than using software that gives you some help. However, thisapproach does have the advantage of being free. Suitable software is already includedwith</P><A NAME="PAGENUM-53"><P>Page 53</P></A><P>almost every machine. A surprising number of HTML pages are puttogether in this way. Some text editors (notably GNU Emacs) have SGML add-onsthat can significantly ease the task of adding markup.</P><P>Even when an XML document has been authored using some othersoftware, it is useful to know that the document can be read into and edited by atext editor. This gives you a means of making minor edits to an XMLdocument you have received, even if you don't have special XML-aware software <BR>yourself.</P><TABLE BGCOLOR="#FFFF99"><TR><TD>Warning:</TD></TR><TR><TD><BLOCKQUOTE>You should make sure that the editor you use definitely worksin plain ASCII text. Most word processors add lots of hidden stuff to theplainest-looking documents. You might need to use a "save as text" option to getthe required result. Also, XML documents created by other software mighthave few, or even no, newlines. (XML doesn't need them.) This leads to textfiles with tremendously long lines, which many editors will not be able toprocess correctly. Finally, if the XML document uses a 16-bit Unicodecharacter encoding scheme, you won't get far with an ASCII-based editor.</BLOCKQUOTE></TD></TR></TABLE><P>The second option is to use a specialized XML-aware authoring tool.These tools are similar in approach to the HTML authoring tools with whichyou are probably already familiar, such as FrontPage, HoTMetaL, and so on.This option has pluses and minuses. On the plus side, the software is very welldesigned for the job of adding XML markup. You receive help with addingelements, specifying attribute values, and so on. You won't be able to createa document that isn't valid XML. Figure 4.1 shows this section beingwritten using SoftQuad's Author/Editor SGML authoring software.</P><P>The downside is really a matter of personal preference. If you already knowa particular word processor (especially if you have spent a long timemastering it), you might not be too eager to learn a different package just to writeXML documents. On the other hand, if you pick up new software easily, or ifyou know that you will be spending a lot of your time with XML, then aspecialized package is probably a better bet for you.</P><P>The final option is, in principle, the best for the average user. Both Wordfor Windows and WordPerfect have already introduced versions that offersupport for adding SGML markup. When they do the same for XML, youshould be able to use your word processor of choice and still get proper help withXML coding.</P><A NAME="PAGENUM-54"><P>Page 54</P></A><A HREF="javascript:displayWindow('images/ch04fg01.jpg',288,204)"><IMG SRC="images/tn_ch04fg01.jpg"></A><BR>Figure 4.1.<BR>Specialized authoring software.<P><CENTER><TABLE BGCOLOR="#FFFF99"><TR><TD><B>NOTE</B></TD></TR><TR><TD><BLOCKQUOTE>It will be interesting to see how the marketplace for XMLauthoring software develops. I have already argued (in Chapter 3, "The XMLAdvantage") that there is a strong case for word processors being redesignedaround XML. The approach adopted for SGML support tends to involveassociating SGML element types with styles. Thisworks for simple DTDs, but it tends to break down when a large and complex DTD is in use. In particular,styles usually don't support the idea of nesting, which is central to howXML elements work. It should be the other way around: Store the document asa tree structure of XML elements, and then associate the styles withthose elements.</BLOCKQUOTE></TD></TR></TABLE></CENTER></P><P><CENTER><A HREF="../ch03/0050-0050.html">Previous</A> | <A HREF="../ewtoc.html">Table of Contents</A> | <A HREF="0055-0059.html">Next</A></CENTER></P></TD></TR></TABLE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -