Deep XSL (1) (Turn)

Source: Internet
Author: User
Tags format define object contains xmlns xsl xsl stylesheet domain
Deep XSL (1)
---Constructing a result tree overview
Translation: Sun Yizhong

XSL is the language that expresses the style sheet (stylesheet). Each stylesheet describes the rules that render a class of XML source documents. The process of rendering consists of two parts: first, the resulting tree is created by the source tree; second, the resulting tree is interpreted and displayed in the display, Paper or in the format of other media such as voice output. The first step is to construct the result tree, which combines the pattern with the template (template). Pattern matches the elements in the source tree. The template is instantiated to produce a partial result tree. The result tree is detached from the source tree. The resulting tree can be structured differently from the source tree. In the construction of the result tree, the source tree may be filtered and reordered, and any structure can be added. The second step, formatting, is to implement the construction of the result tree with the formatted thesaurus specified in the XSL document. Formally, this thesaurus is an XML name domain (namespace). Each element type in the glossary corresponds to a formatted object class. A formatted object class expresses a particular format representation. For example, a block ( Block) To format an object class to represent a section of content into one line. Each attribute of the glossary corresponds to a formatting attribute. The formatted object class has a special set of formatting attributes that better controls how the formatted object class behaves; For example, to control the indentation of rows before or after each row of the collection, Line spacing. A formatted object can have content, and its formatting performance is applied to its contents.

XSL can be used as a generic XML transport without the need for a result tree. For example, XSL can be used to translate XML into well-formed HTML, which is XML that uses HTML-defined element types and attributes. When the result tree is formatted with a thesaurus, The following XSL implementation must be able to interpret the result tree based on the semantics of the formatted thesaurus defined in the file, and it can also materialize the result tree as XML, but there is no need to do so.

A style sheet contains a set of rules for a template. There are two parts to a template rule: a template (template) that matches the pattern of nodes in the source tree and instantiated the result tree of the component after instantiation. It allows a style sheet to be used for a large class of documents that have a similar source tree structure. A template contains elements that specify the element structure of the text result. A template can also contain instruction elements that produce a result tree fragment. When a template is instantiated, Executes each instruction and replaces it with the resulting tree fragment. An instruction can select and process elements of a descendant. By looking up the applicable template rules and then instantiating their templates, the elements of the descendants are processed to produce a result tree fragment. The element is processed only if the command being executed is selected. More than one template rule may match the schema of a given element. However, only the rules for a template are applied. The method of deciding which rule to use is described in "conflicting decisions on template rules." XSL uses the XML name Domain (namespaces) to differentiate elements that are part of the XSL Processor directive and the tree structure that prescribes literal results. The directive element belongs to the XSL Name field. prefix xsl in the document: represents an element in an XSL name field. An XSL stylesheet contains an xsl: Stylesheet is a steady element. This element can contain xsl:template elements to specify the rules for the template. The following example is a simple XSL stylesheet that constructs a result tree for a sequence of para elements that contain emphasis elements. result-ns= "fo" property indicates that a tree using a formatted object thesaurus is being constructed. The para element becomes a block formatted object with a font size of 10pt, preceded by a space of 12pt.

<xsl:stylesheet xmlns:xsl= "http://www.w3.org/TR/WD-xsl" xmlns:fo= "Http://www.w3.org/TR/WD-xsl/FO" Fo ">
<xsl:template match= "/" >
<fo:page-sequence font-family= "serif" >
<xsl:process-children/>
</fo:page-sequence>
</xsl:template>
<xsl:template match= "Para" >
<fo:block font-size= "10pt" space-before= "12pt" >
<xsl:process-children/>
</fo:block>
</xsl:template>
</xsl:stylesheet>

The Xsl:stylesheet element can also contain elements imported by the other XSL style sheets, define the elements of the macro, define the elements of the global constants, and identify the elements that the source attribute is marked with an individual element.


---------------------------------------------------------------------------

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.