In-depth XSL (3) --- template rules and patterns

Source: Internet
Author: User
Tags xsl

In-depth XSL (3)
--- Template rules and modes
Translation: Sun Yi
Template rules
Template rules are defined by the xsl: template element. The "match" attribute identifies the source node (SET) of the rule application. xsl: template. For example, an XML document may contain the following content:
This is an <emph> important </emph> point.
The following template rules match the elements of the emph type, and another template generates an fo: sequence format object, whose font-weight attribute is bold ).
<Xsl: template match = "emph">
<Fo: sequence font-weight = "bold">
<Xsl: process-children/>
</Fo: sequence>
</Xsl: template>
Xsl: the process-children element recursively processes the child nodes of the parent element.
Mode
A pattern is a string used to match an element in an XML source file. the most common pattern specifies the type name of the matching element. for example, the emph pattern matches elements of the emph type. the more complex pattern specifies the element type of the "ancestor" node of the matching element. for example, the olist/item pattern matches an element of the item type and the parent element is of the olist type. each element type in the "ancestor" sequence can be followed by a series of delimiters separated by commas. for example, list [attribute (ordered) = "yes")]/item [first-of-type ()] matches the element of the item type, the first element at the same level, the parent node type is list, and the attribute name "ordered" is "yes ".
This section describes the syntax and semantics of the pattern in detail. the pattern of matching elements is considered as match pattern ). xsl: The template pattern is the matching pattern. A mode can also be used to select a series of nodes. This mode is considered as select pattern ). in a selection mode, there is a current node to provide the frontend and backend relationships for selection. this mode selects a matched column of source nodes. these nodes are sorted by files. the modes in xsl: process, xsl: for-each and xsl: value-of are select modes.
------------------------------------------------------------------------------

Related Article

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.