Extensible Stylesheet Language (XSL)(2)
Components of XSL
XSL is actually a family of three tools produced by the W3C's XSL Working Group: XPath, XSLT and XSF-FO.
* XPath, or XML Path Language, is used to specify the parts of an XML document that will be transformed by XSL Transformations (XSLT). XPath interprets an XML document as a hierarchical tree of nodes, which can include elements, attributes or text. The hierarchical tree is called the source-node tree.
* XSLT describes how to filter or convert (transform) XML documents into other types of XML documents, including XSL Formatting Object (XSL-FO) files. An XSLT stylesheet contains a set of template rules for transforming a source tree by matching a pattern against elements in the source tree. When a match is found, the rules are used to create a new node in the result tree. The result tree's structure can be completely different from that of the source tree because elements can be filtered and reordered and arbitrary structure added. An XSLT stylesheet is like a sophisticated search-and-replace routine.
* XSL-FOs are instructions that define exactly how a document will be formatted for a specific medium or device. For a document to be printed, formatting objects can include characters, blocks of text, images, tables, borders, master pages and the like.
XSL-FO specifies various layout rules (e.g., where page breaks can occur) and requirements (e.g., placement of footnotes), but the XSL-FO file itself doesn't determine exactly where each element is positioned. That' s done by a separate formatting engine that interprets the file.
XSL-FO isn't restricted to printed pages and on-screen appearance; it can also specify audio reproduction, for example. Confusingly, XSL-FO is sometimes referred to as XSL.
Why XSL?
XSL is designed for repetitive situations where documents are dynamically generated and formatted on demand, not for documents that require a creative professional to modify the layout, content and typography to get an acceptable (albeit static) result. XSL is thus an ideal fit for documents that have to be output in a variety of formats and on many different types of devices, ranging from printers and computer screens to handhelds and phones.
(The End)
时文选读
可扩展版式语言( XSL)(2)
XSL的组成
实际上, XSL家族有三个工具,分别是由W3C的XSL工作组编制的XPath,、XSLT和XSF-FO。
* XPath,即XML通道语言,用来指定将由XSL转换工具(XSLT)转换的XML文档的部分。XPath用节点的层次树解释XML文档,它可以包括元素、属性或文本。层次树也叫做源节点树。
* XSLT描述如何对XML文档进行过滤或转换成其他类型的XML文档,包括XSL格式化对象(XSL-FO)文件。XSLT版式包含一组转换源树用的模板规则,它是通过将模式与源树中的元素进行匹配来完成转换的。如果匹配,规则就用于生成结果树中的新节点。结果树的结构可以与源树完全不同,因为元素可以被过滤和重新排序,还能加入任意的结构。XSLT版式类似于复杂的搜索和替代子程序。
* XSL-FO是确切定义文档如何为指定的介质或设备而格式化的指令。对于要打印的文档,格式化对象可以包括字符、文本、图像、表格、边框、主页等等。
XSL-FO规定各种不同的排版规则(如何处分页)和要求(如放置脚注),但XSL-FO文件本身不确切决定每个元素的位置。那是由解释该文件的独立的格式化引擎完成。
XSL-FO并不仅仅局限于打印页面和屏幕显示,它还能重现声音。令人混淆的是,XSL-FO有时也指XSL。
为什么用 XSL?
XSL 设计用于重复性的场合,其中文档是动态生成,格式按需产生, XSL 不适合于需要由创作人员修改版式、内容和印刷式样等以保证结果能被接受(虽然是静态的)的文档。因此, XSL 非常适合必须以各种不同的格式和在多种不同设备(从打印机、计算机屏幕到手持设备和电话)上输出的文档。