XSL introduction (2)

Source: Internet
Author: User
Tags xsl xsl file
Document directory
  • XSL (2)
XSL (2)

In the first part, I learned 7 elements and 24 other elements. Learn them one by one.

1. <XSL: Import>, <XSL: Include>, and <XSL: Apply-imports> Elements
<XSL: Import> compared with <XSL: Include>, both of them must be <XSL: stylesheet> subnodes, but the template rules defined by the former have a low priority, and must be the first child node. The functions of the two are the same. They all load another defined XSL file into the current XSL file.
<XSL: Apply-imports> specifies when and where to use the template rules.
Their syntax is:

<XSL: Import href = "Uri"/>
<XSL: Apply-templates/>

 

2. <XSL: attribute> and <XSL: Attribute-set> Elements
The former is used to add an attribute to an element, and the former is replaced by an attribute with the same name. The latter is a child node of <XSL: stylesheet>. It is used to define a set of attributes and apply them to the entire document. Syntax:

<XSL: attribute name = "attributename" namespace = "Uri"> <! -- Content: Template --> </XSL: attribute>
<XSL: Attribute-set name = "name" use-Attribute-sets = "name-list"> <! -- Content: XSL: attribute * --> </XSL: Attribute-set>

Namespace (optional) and use-Attribute-sets (optional) are used to use other predefined Attribute-set.

 

3. <XSL: param>, <XSL: Call-template>, and <XSL: With-param> Elements
<XSL: param> is used to define global parameters (Child points of <XSL: styelsheet>) or local parameters (in a template). <XSL: call-template> is used to call the specified template. <XSL: With-param> is used to call the template or use the template.Parameters are passed. It must be noted that the value of the with-Param name attribute must be consistent with the predefined value. Syntax:

<XSL: Param name = "name" select = "expression"> <! -- Content: Template --> </XSL: param>
<XSL: Call-Template Name = "templatename"> <! -- Content: XSL: With-Param * --> </XSL: Call-template>
<XSL: With-Param name = "name" select = "expression"> <! -- Content: Template --> </XSL: With-param>

The Select statements are optional. The select statements of the former are used to specify the default values, and the latter can be used to transmit values (the label content can also be used ).).

 

4. <XSL: Variable> Elements
Defines global or local variables. Once assigned, they cannot be changed. Syntax:

<XSL: variable name = "name" select = "expression"> <! -- Content: Template --> </XSL: Variable>

 

5. <XSL: Copy> and <XSL: copy-of> Elements
Both copy the current node and Its namespace, but the latter also copies the subnode and the current node attributes. Syntax:

<XSL: copy-of select = "expression"/>
<XSL: Copy use-Attribute-sets = "name-list"> <! -- Content: Template --> </XSL: Copy>

Use-Attribute-sets are optional.

 

6. <XSL: Comment> Elements
Generate a comment node in the result tree. Syntax:

<XSL: Comment> <! -- Content: Template --> </XSL: Comment>

 

7. <XSL: decimal-format> element
Defines some special characters or symbols used in the process of calling the format-number () function to convert a number to a character generator. Syntax:

<XSL: decimal-format name = "name" Decimal-separator = "char" grouping-separator = "char" infinity = "string"
Minus-Sign = "char" Nan = "string" percent = "char" per-Mille = "char" zero-digit = "char" digit = "char" pattern-separator = "char"/>

All items are optional.

 

8. <XSL: Element> Elements
Generate an element in the result tree. The syntax is as follows:

<XSL: element name = "name" namespace = "Uri" use-Attribute-sets = "namelist"> <! -- Content: Template --> </XSL: Element>

The last two attributes are optional. The values of the first two attributes can be calculated during real-time running.

 

9. <XSL: fallback> Elements
When the XSL element cannot be recognized by the processor, the backup program provided by fallback is called.

<XSL: fallback> <! -- Content: Template --> </XSL: fallback>

 

10. <XSL: Key> element
This is a top-level element that defines a key for the key function.

<XSL: key name = "name" match = "pattern" use = "expression"/>

 

11. <XSL: Message> element
Used to output information, such as error information. All other elements can appear in the content.

<XSL: Message terminate = "Yes | no"> <! -- Content: Template --> </XSL: Message>

 

12. <XSL: namespace-alias> element
It is used to replace a namespace with another one in the output.

<XSL: namespace-alias stylesheet-Prefix = "prefix | # default" result-Prefix = "prefix |" # default "/>

 

13. <XSL: number> element
It indicates the order of the current node in the source tree, or you can format a number.

<XSL: number count = "expression" level = "single | multiple | any" from = "expression" value = "expression" format = "formatstring"
Lang = "languagecode" letter-value = "alphabetic | traditional" grouping-separator = "character" grouping-size = "Number"/>

 

14. <XSL: output> element
Used to define the output format,

<XSL: output method = "XML | HTML | text | Name" version = "string" encoding = "string" omit-XML-declaration = "Yes | no"
Standalone = "Yes | no" doctype-Public = "string" doctype-system = "string" CDATA-section-elements = "namelist"
Indent = "Yes | no" media-type = "string"/>

 

15. <XSL: preserve-space> and <XSL: strip-space> Elements
The two are used to indicate that the space of the element content is still removed. Because it is retained by default, you must specify the retainer only when you remove it.

<XSL: preserve-space elements = "list-of-element-names"/>
<XSL: strip-space elements = "list-of-element-names"/>

* Wildcards are available for list-of-element-names values.

 

16. <XSL: Processing-instruction> element
It is used to write processing commands to the output, such as specifying CSS files.

<XSL: Processing-instruction name = "process-name"> <! -- Content: Template --> </XSL: Processing-instruction>

 

17. <XSL: Text> Elements
Used to output string constants.

<XSL: Text disable-output-escaping = "Yes | no"> <! -- Content: # pcdata --> </XSL: Text>

 

References:
XSLT FAQ
Http://www.dpawson.co.uk/index.html

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.