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

📄 0055-0059.html

📁 Presenting XML.rar,详细介绍有关XML的知识
💻 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="0051-0054.html">Previous</A> | <A HREF="../ewtoc.html">Table of Contents</A> | <A HREF="0060-0063.html">Next</A></CENTER></P><A NAME="PAGENUM-55"><P>Page 55</P></A><H4><A NAME="ch04_ 4">Parsers</A></H4><P>What is a parser? It's a piece of software whose job description is to checkthat an XML document is valid or, failing that, well-formed. Not veryinteresting to the average user, perhaps, but a vital part of the picture ifvalidity and well-formedness are to have any real meaning in the XML world.</P><P>Any software package that is XML-aware will have a parser built into it inthe form of an XML processor. (See Chapter 11, &quot;The XML Processor.&quot;) As aminimum, the XML processor checks the XML documents you are about towork on, and checks them again when you have finished. Ideally, it isinteractive; any errors you introduce are reported and can be sorted out while you work.</P><P>You also can get standalone XML parsers, which are important if you takethe plain text editor route for your XML authoring. When you havefinished working on an XML document in an uncontrolled environment (onethat doesn't know about XML tagging conventions), you should always run anXML parser on it to check that it is still valid.</P><P>The most widely used parser for SGML and XML is nsgmls, part of theSP suite written by James Clark. This parser does a reliable job of checkingthe validity of any XML document. However, it isn't the friendliest ofprograms because it runs from the DOS command line. I have written a Windowsfront-end for nsgmls called RUNSP, which runs the program for you. If anyerrors occur in the document or the DTD, it opens up an editing window withthe errors highlighted. Figure 4.2 shows RUNSP in action, pointing out anerror in this chapter. (I mistyped the HEAD end-tag.) Both the SP suite andRUNSP are freeware.</P><P>In addition, there is a rapidly growing number of XML parsers, withmany written in Java. Those that are available as of this writing are describedin Chapter 16.</P><A NAME="PAGENUM-56"><P>Page 56</P></A><A HREF="javascript:displayWindow('images/ch04fg02.jpg',288,204)"><IMG SRC="images/tn_ch04fg02.jpg"></A><BR>Figure 4.2.<BR>RUNSP checking for errors in an SGML document.<BR><H4><A NAME="ch04_ 5">DTD Editors and Browsers</A></H4><P>One part of the XML system that must be included, to keep everything inorder, is the DTD. Someone (probably not you) has to write that DTD. Youcan create a DTD with a plain text editor, but once again software can cometo the aid of the DTD designer.</P><P>The process of developing a DTD for a new application can be complexand time-consuming. You are really analyzing the information requirements ofa particular sphere of activity and writing a set of rules that always must befollowed. If you make those rules too tight, they might not allow perfectlyvalid pieces of information. If the rules are too lax, they might encouragesloppy practices that interfere with the operation of your application.</P><P>Therefore, it is important to control the process of developing a DTD andto make sure that the element types in the DTD are well documented.DTD creation tools can help with this process, particularly when a number ofpeople are working together on the design of the DTD.</P><P>DTD browsing tools can help users visualize the types of documentstructures that the DTD will support. They can show all the possible subelements ofa</P><A NAME="PAGENUM-57"><P>Page 57</P></A><P>particular element type graphically. This is much more fun than readingthe DTD itself! Figure 4.3 shows a view of the HTML 2.0 DTD beingbrowsed by Corel's Visual DTD tool. In this figure, the subelements that areallowed within paragraphs (the p element type) are shown. In addition to the 13element types (a, img, br, and so on), character data is allowed. This isindicated by the icon at the top, above a.</P><A HREF="javascript:displayWindow('images/ch04fg03.jpg',288,204)"><IMG SRC="images/tn_ch04fg03.jpg"></A><BR>Figure 4.3.<BR>The visual view of the HTML 2.0 DTD.<BR><H4><A NAME="ch04_ 6">Style Sheet Editors</A></H4><P>The XS style language is based on Scheme, which is a dialect of LISP. Inone sense, it is very simple&#151;and it is certainly powerful. However, codingwith this language requires high-level skills. It won't be easy to write style sheetsof any sophistication without some help. See Chapter 10, &quot;The XML StyleMechanism,&quot; for a description of the style language.</P><P>An XS style sheet authoring package would know about the primitivecomponents of the XS language and might let you create procedures to carryout common tasks such as outputting a paragraph or one item in a bulletedlist. These low-level procedures could then be called up and used to display oneor more element types.</P><A NAME="PAGENUM-58"><P>Page 58</P></A><P>Because no one has yet produced commercially available software of thistype (even for the DSSSL standard, on which XS is based), it is not so easy tobe sure how it would work. Obviously, it would be nice to have anenvironment in which you design a report format interactively, dragging and droppingcomponents onto a form. However, the way XS works makes it hard to seehow you could visualize your report in this way, because the report generationis driven by the content of each XML document, not by the spec.</P><P>Probably, you would have an actual document on screen, with thecapability to associate styles with elements in that document. If you changed the styleof any element, the whole display would be updated, which means that youwould need to test your developing XS style sheet against a number of documentsin order to be sure that it worked acceptably.</P><P>I'll give you an example of a proprietary SGML style sheet mechanism. Thisis the interactive style editing support provided by Panorama Pro. In Figure4.4, I changed the font family for paragraphs (thep element type) to Arial.<BR><A HREF="javascript:displayWindow('images/ch04fg04.jpg',288,204)"><IMG SRC="images/tn_ch04fg04.jpg"></A><BR>Figure 4.4.<BR>An interactive style sheet editor.<BR><P>In the immediate future, XML editors will probably support CSS stylesheets in a similar way to Panorama Pro.</P><A NAME="PAGENUM-59"><P>Page 59</P></A><H4><A NAME="ch04_ 7">Link Management Tools</A></H4><P>Linking is the third major element in the XML specification. (See Chapter9, &quot;Linking with XML,&quot; for a description of XML-Link.) Linking couldalso benefit from software support in the following three situations:</P><UL><LI>    Authoring XML documents<LI>     Specialized link management<LI>     Browsing XML documents</UL><P>In the first case, I expect standard XML-aware authoring software tosupport the creation (and traversal) of XML's simple links. These are, after all,firmly based on the HREF links that are supported by HTML authoring packages,so no additional software should be required.</P><P>On the other hand, special software probably will be needed to supportXML's extended links. Because these need not be physically located at any of theplaces that they link together, and need not even be in the same document,managing extended links is clearly a different scale of problem.</P><P>Extended links offer an exciting range of possibilities for two-way andmulti-way linking, for link farms containing links within and between a whole setof documents, and so on. It is likely that software to support extended linkswill take a specific approach, rather than trying to offer a general-purposesolution. Several different approaches could be offered.</P><P>It is reasonable to expect that any XML-capable browser will be able totraverse both simple and extended links, although the implementation details forextended links can again be expected to vary. (Browsing of XML documentsis covered more fully later in this chapter.)</P><H3><A NAME="ch04_ 8">Conversion</A></H3><P>I started by talking about authoring XML documents from scratch, and Icovered the software that might be helpful in that task. I said that this is onlypart of the picture. Then, I discussed software for dealing with DTDs, stylesheets, and links. Now let's look at another way to actually create XMLdocuments, which is to convert them from some other format to XML.</P><P><CENTER><A HREF="0051-0054.html">Previous</A> | <A HREF="../ewtoc.html">Table of Contents</A> | <A HREF="0060-0063.html">Next</A></CENTER></P></TD></TR></TABLE></BODY></HTML>

⌨️ 快捷键说明

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