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

📄 0196-0199.html

📁 Presenting XML.rar,详细介绍有关XML的知识
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "html.dtd"><HTML><HEAD><TITLE>Presenting XML:The XML Style Mechanism: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=10 //--><!--  PAGES=0179-0200 //--><!--  UNASSIGNED1 //--><!--  UNASSIGNED2 //--><P><CENTER><A HREF="0192-0195.html">Previous</A> | <A HREF="../ewtoc.html">Table of Contents</A> | <A HREF="0200-0200.html">Next</A></CENTER></P><A NAME="PAGENUM-196"><P>Page 196</P></A><TABLE BGCOLOR="#FFFF99"><TR><TD>Note:</TD></TR><TR><TD><BLOCKQUOTE>Too much use of this facility would be counterproductive. It wouldbe quite possible to end up in a position where users' markup was once againfull of attributes specifying formatting&#151;one of the problems we set out tosolve! However, it is reassuring to know that XML will supportuser-specified formatting.</BLOCKQUOTE></TD></TR></TABLE><P>Take as another example the note elements in this book. Various types ofnotes make it into the book: straightforward notes and notes as tips andwarnings. Some other notes you never see&#151;comments I made for my own referencewhile writing. I use the TYPE attribute to specify what type of note eachnote element is, as shown in the following:</P><!--  CODE //--><PRE>&lt;note&gt;A plain ol' note.&lt;/note&gt;&lt;note type=&quot;warning&quot;&gt;A warning!&lt;/note&gt;&lt;note type=&quot;hidden&quot;&gt;For my eyes only ...&lt;/note&gt;</PRE><!--  END CODE //--><P>My style sheet to output the book for delivery to Sams.net has to takeaccount of these differences.</P><P>This is what I came up with. It uses a procedure calledSTANDARD-NOTE, which is called up by the element construction rule fornote:</P><!--  CODE SNIP //--><PRE>(element NOTE (STANDARD-NOTE))</PRE><!--  END CODE SNIP //--><P>Sound familiar?</P><P>The STANDARD-NOTE procedure looks like this:</P><!--  CODE //--><PRE>(define (STANDARD-NOTE)  (if (attribute-string &quot;type&quot; (current-node))    (if (string=? (attribute-string &quot;type&quot; (current-node)) &quot;hidden&quot;)      (empty-sosofo)      (BOXED-PARAGRAPH (attribute-string &quot;type&quot; (current-node))))    (BOXED-PARAGRAPH &quot;note&quot;)))</PRE><!--  END CODE //--><P>This procedure says the following:</P><UL><LI>          If theTYPE attribute is specified and its value is hidden, discardthis note.<LI>          If theTYPE attribute is specified and its value is anything else,output this note as a boxed paragraph, with the value of theTYPE attribute as the heading.<LI>          If theTYPE attribute isn't specified, output this note as a boxedparagraph with &quot;note&quot; as the heading.</UL><A NAME="PAGENUM-197"><P>Page 197</P></A><P>Even if you are a programmer, you might find the logic of this procedurea little less than obvious unless you are familiar with Lisp-type languages.Again, the point is not to provide a tutorial in the XS language, but to give youan idea of its possibilities. If you want to understand what is going on here,the following might help.</P><P>The if expression takes three arguments: a test, a consequent(then), and an alternate (else&quot;). If the test is true, the consequent is evaluated and its valueis returned; otherwise, the alternate is evaluated and its value is returned.For example, the following returns yes because the test expression is true (3 isgreater than 2):</P><!--  CODE SNIP //--><PRE>(if (&gt; 3 2) `yes `no)</PRE><!--  END CODE SNIP //--><P>My STANDARD-NOTE procedure contains two if expressions; the second oneis the consequent of the first.</P><P>(empty-sosofo) is a built-in command that stands for &quot;empty specificationof sequence of flow objects.&quot; It means, in effect, &quot;discard this node and all ofits child nodes.&quot; The ability to discard selected parts of the document'stree structure makes it possible, for example, to present an XML documentwith confidential information suppressed:</P><!--  CODE //--><PRE>(define (CHECK-SECRET)  (if (attribute-string &quot;class&quot; (current-node))    (if (string=? (attribute-string &quot;class&quot; (current-node)) &quot;secret&quot;)      (empty-sosofo)      (process-children))))</PRE><!--  END CODE //--><H4><A NAME="ch10_ 25">The Core Query Language</A></H4><P>The XS language includes expressions that give you access to many of theproperties of element nodes in the grove that represents your XML document.These are called, collectively, the core querylanguage.</P><P>For example, the expression (current-node) returns the element you arecurrently trying to process. You can use that expression to access the propertiesof the current node:</P><!--  CODE SNIP //--><PRE>(attribute-string &quot;type&quot; (current-node))</PRE><!--  END CODE SNIP //--><P>This node returns a string if the current node has aTYPE attribute whose value has been specified. Otherwise, it returns the valuefalse.</P><A NAME="PAGENUM-198"><P>Page 198</P></A><P>You also can access the properties of the parent of the current node or anyof its ancestors:</P><!--  CODE SNIP //--><PRE>(gi (parent (current-node))</PRE><!--  END CODE SNIP //--><P>This procedure call returns the gi (element type name) of the currentelement's parent.</P><H3><A NAME="ch10_ 26">Summary</A></H3><P>In this chapter, I discussed a difficult topic: the XS style sheet mechanism.</P><P>I began by reviewing the arguments for having a separate style sheetmechanism, including the following:</P><UL><LI>          The simplification of markup when formatting instructionsare removed from it<LI>          The consistency achieved by applying formatting as a separate exercise<LI>          The ability to produce multiple products from each XML document<LI>          The need for some general means of controlling the formattingof generic XML</UL><P>You saw how a simple &quot;Hello world!&quot; paragraph might be formatted byan XS style specification. In the process of doing this, you discovered that XSworks by converting the XML document to be formatted into a grove. It thenscans that grove and merges it with the style specification.</P><P>You found that the result is another kind of tree structure&#151;a flow objecttree&#151;which is a nested structure of flow objects. Everything that will appear inthe result, even data characters, is converted to a flow object. Each flow objecthas characteristics, which determine how it will be rendered in the formatted result.</P><P>The flow object tree is a slightly abstract representation of the paginatedresult you are after. It requires the cooperation of a back-end processor to turn itinto a formatted result. Depending on the delivery format chosen, this can be afixed (read-only) or a revisable result.</P><A NAME="PAGENUM-199"><P>Page 199</P></A><P>In your encounters with the XS language, you discovered that it has three levels:</P><UL><LI>          The core expression language&#151;a dialect of Scheme, which is thebasis for the whole language and provides some built-in low-level expressions<LI>          The core query language, which provides access to informationabout XML document-type objects in the grove<LI>          The XS style language proper, which provides high-levelcommands specifically designed to support the production of a flow object tree</UL><P>Finally, I started to explore the immense power and flexibility that XSwill offer&#151;just as soon as we can get a grip on the XS language!</P><P><CENTER><A HREF="0192-0195.html">Previous</A> | <A HREF="../ewtoc.html">Table of Contents</A> | <A HREF="0200-0200.html">Next</A></CENTER></P></TD></TR></TABLE></BODY></HTML>

⌨️ 快捷键说明

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