📄 0033-0035.html
字号:
<!DOCTYPE HTML PUBLIC "html.dtd"><HTML><HEAD><TITLE>Presenting XML:Enter 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=02 //--><!-- PAGES=0019-0036 //--><!-- UNASSIGNED1 //--><!-- UNASSIGNED2 //--><P><CENTER><A HREF="0030-0032.html">Previous</A> | <A HREF="../ewtoc.html">Table of Contents</A> | <A HREF="0036-0036.html">Next</A></CENTER></P><A NAME="PAGENUM-33"><P>Page 33</P></A><P>that feature of CSS1. However, this is likely to change. The CSS1specification states an expectation that it will become more generic: "CSS1 hassome HTML-specific parts (e.g., the special status of theCLASS and ID attributes) but should easily be extended to apply to other DTDs as well." Suchchanges will clearly make CSS a more attractive style sheet mechanism for XML <BR>documents.</P><P>XML provides its own means of specifying style sheets (termedXS). Apart from having the advantage of being designed to work with any XML documentstructure, XS is massively more powerful than CSS1.</P><H4><A NAME="ch02_ 22">Influences on the Design of XS</A></H4><P>XS is still at an early stage of development. As of this writing, there is notan initial W3C working draft for it. However, it is clear that XS will be basedon the DSSSL (Document Style and Semantics Specification Language)Standard, ISO/IEC 10179:1996.</P><P>DSSSL is a standard that supports the transformation and display ofSGML documents. The transformation aspect of DSSSL isn't supported in XS,and the style sheet part has been pruned down to the bareessentials.</P><H4><A NAME="ch02_ 23">How XS Works</A></H4><P>XS is designed to control the output of an XML document to the screen,the printed page, or any other two-dimensional display device.</P><P>It is essentially a data-driven style mechanism. When an XML document isto be displayed, one or more XS style sheets will be called into action. Thesemight be specified in the XML document or selected by the user.</P><P>The processing of the XML document is determined by scanning theXML document's structure and merging it with the formattingspecification derived from the active style sheets. These instructions are then used to createthe flow objects, such as paragraphs and tables, which determine the layout of thedocument. This merging process produces a tree structure of flow objects: theflow object tree.</P><P>Each flow object has characteristics, such asfont-name, font-size, and font-posture, that can be specified explicitly or inherited from flow objectsfurther up the flow object tree.</P><A NAME="PAGENUM-34"><P>Page 34</P></A><H4><A NAME="ch02_ 24">What's in an XS Style Sheet?</A></H4><P>XS has an extremely flexible core expressionlanguage, based on Scheme. This is a complete programming language, with facilities for doing calculations,testing conditions, and so on. It can be used to build up complex instructionsfor the processing of individual elements or even characters within an XML <BR>document.</P><P>At a higher level, XS supports constructionrules that declare, in effect, what to do with an element. More precisely, they state what flow objects are to becreated, and what characteristics each flow object is to have. For example, anelement construction rule for the p element might specify that a paragraphflow object is to be added to the flow object tree, with these characteristics:</P><!-- CODE SNIP //--><PRE>font-size: 12ptfirst-line-start-indent: 20ptquadding: left</PRE><!-- END CODE SNIP //--><P>This will cause the characters in the paragraph to be 12-point font size, witha 20-point indent at the start of the first line. The paragraph will be leftjustified.</P><P>Typically, the low-level formatting instructions will be declared asfunctions. This means that the top-level instructions can be made much clearer to areader, as in this example:</P><!-- CODE SNIP //--><PRE>(element NOTE (STANDARD-NOTE))(element EG (MONOSPACED-TEXT))(element CODE (UNDERLINED-PHRASE))</PRE><!-- END CODE SNIP //--><H4><A NAME="ch02_ 25">What XS Offers</A></H4><P>Because the core expression language is so powerful, it is possible to usenearly any aspect of an XML document's structure to control how it appears.Most construction rules are pitched at the element level, but you can easilyrefine their behavior by testing properties of the element, such as its attributesand their values or its ancestor elements.</P><P>Although by default the whole document will be displayed in its originalorder, the core expression language actually gives you access to the fulldocument structure at any point. Therefore, you can rush off and grab a related pieceof text from elsewhere in the document. For example, you can create avirtual</P><A NAME="PAGENUM-35"><P>Page 35</P></A><P>table of contents from the chapter headings, and place it at the start ofyour displayed document. It is also easy to suppress parts of the document thatyou do not want to display at a certain time.</P><P>The mathematical functions in the core expression language make it easyto express font sizes, spacing, and so on in relative rather than absoluteterms. This means that you can write style sheets in which the user can blow upthe whole display in a consistent manner by overriding the base font size.</P><P>The XS specification is covered in more detail in Chapter 10, "The XMLStyle Mechanism."</P><H3><A NAME="ch02_ 26">The XML Processor</A></H3><P>The XML Language Specification includes a description of how a beastcalled the XML processor is expected to behave. This is a program that readsXML documents and checks whether they are valid and well-formed.</P><P>The general idea is that the XML processor will have no ambitions of itsown; it will simply pass information about the XML document to anapplication that is doing something interesting with it on behalf of an end-user. Thiscould take the form of a one-way brain-dump from the XML processor to theapplication, but it is more likely that there will be a conversation between thetwo. As of this writing, the active XML developers are working on a standardAPI for XML processors.</P><P>XML processors will be relatively simple pieces of software, which meansthat it will be quite feasible to add XML-awareness to existing software. Thisopens up a whole range of interesting possibilities. The obvious job to do first isto add XML support to existing Web browsers (and both of the majorplayers have indicated that they are looking into this). Beyond that, there are inmy opinion potential major benefits (both to users and to the softwarevendors themselves) of word processing software using XML to structuredocuments. Then you could have object-oriented databases with built-in XMLsupport, and more. I'll discuss this in more detail in the next chapter.</P><P>I discuss the XML processor in more detail in Chapter 11, "The XMLPro-cessor."</P><P><CENTER><A HREF="0030-0032.html">Previous</A> | <A HREF="../ewtoc.html">Table of Contents</A> | <A HREF="0036-0036.html">Next</A></CENTER></P></TD></TR></TABLE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -