Deep XSL (3)---template rules and patterns (cycles)

Source: Internet
Author: User
Tags xsl
Template Depth xsl (3)
---template rules and patterns
Translation: Sun Yizhong

Template rules

Template rules are defined by xsl:template elements. " The Match property identifies the source node (set) to which the rule applies. xsl:template. For example, an XML document might contain the following:


This is a <emph>important</emph> point.


The following template rules match elements of the emph type, and another template produces a Fo:sequence formatted object whose Font-weight property is bold (bold).


<xsl:template match= "emph" >
<fo:sequence font-weight= "Bold" >
<xsl:process-children/>
</fo:sequence>
</xsl:template>


The Xsl:process-children element recursively handles the "child" node of the "parent" element.

Mode

A pattern is a string that matches an element in an XML source file. The most common pattern sets the type name of the matching element. For example, the emph pattern matches an element of type emph. More complex patterns Specify the element type of the ancestor node of the matching element. For example, the Olist/item pattern matches an element of type item and a FATHER element of olist type. Each element type in the ancestor sequence can then be followed by a series of qualifiers separated by commas. For example, List[attribute (ordered) = "yes")]/item[first-of-type ()] matches the element of the item type, the first of the elements at the same level, and the parent node type is list, and the value of the property name "ordered" is " Yes ".

This section describes the syntax and semantics of the schema in detail. The pattern of the matching element is considered to be a match pattern. The xsl:template pattern is the matching pattern. A pattern can also be used to select a series of nodes; Such a pattern is considered to be a selection pattern. In a selection mode, there is a current node that provides a contextual selection. The pattern selects a matching list of source nodes. These nodes are sorted by file. The patterns in Xsl:process, Xsl:for-each and xsl:value-of are all selection modes.



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

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.