Chapter 5: XSLT Elements


Overview

This chapter provides an alphabetical list of reference entries, one for each of the XSLT elements. Each entry gives:

  • A short description of the purpose of the element

  • Changes in 2.0: A quick summary of changes to this element since XSLT 1.0

  • Format: A pro forma summary of the format, defining where the element may appear in the stylesheet, what its permitted attributes are, and what its content (child elements) may be

  • Effect: A definition of the formal rules defining how this element behaves

  • Usage: A section giving usage advice on how to exploit this XSLT element

  • Examples: Coding examples of the element, showing the context in which it might be used. (where appropriate, the Usage and Examples sections are merged into one)

  • See also: Cross-references to other related constructs

The Format section for each element includes a syntax skeleton designed to provide a quick reminder of the names and types of the attributes and any constraints on the context. The format of this is designed to be intuitive: It only gives a summary of the rules, because you will find these in full in the Position, Attributes, and Content sections that follow.

There are a number of specialized terms used in this chapter, and it is worth becoming familiar with them before you get in too deeply. There are fuller explanations in Chapters 2 and 3, and the following descriptions are really intended just as a quick memory-jogger.

For a more comprehensive definition of terms, refer to the glossary.

Term

Description

attribute value template

An attribute whose value may contain expressions nested with curly braces, for example «url="../ { $href } " » . The term template here has nothing to do with any other kind of template in XSLT.

 

Embedded expressions may only be used in an attribute value (or are only recognized as such) if the attribute is one that is explicitly designated as an attribute value template. Attribute value templates are described in more detail in Chapter 3, page 116

document order

An ordering of the nodes in the source tree that corresponds to the order in which the corresponding items appeared in the source XML document: An element precedes its children, and the children are ordered as they appeared in the source

expression

Many XSLT elements have attributes whose value is an expression. This always means an XPath expression: a full definition of XPath Expressions is given in XPath 2.0 Programmer's Reference, and a summary is given in Appendix A. An expression returns a value, which may be any sequence of items (nodes, atomic values, or a mixture of the two). These data types are described fully in Chapter 2.

Extension instructions

Any element used in a sequence: specifically , an XSLT instruction, a literal result element, or an extension element. The <xsl:if> element is an instruction, but <xsl: strip-space > isn't, because <xsl:if> appears in a sequence constructor and <xsl:strip-space> doesn't. Extension instructions are described in Chapter 3, page 105

literal result element

An element in the stylesheet, used in a sequence constructor, which is copied to the output document: for example (if you are generating HTML) <p> or <td> . Literal result elements are described in Chapter 3, page 106

pattern

Some XSLT elements have attributes whose value must be a pattern. The syntax of patterns is defined in Chapter 6. A pattern is a test that can be applied to nodes to see if they match. For example, the pattern «title » matches all <title> elements, and the Pattern «text() » matches all text nodes

lexical QName

An XML name , optionally qualified by a namespace prefix. Examples of lexical QNames with no prefix are « color » and «date-due » . Examples of prefixed QNames are «xsl:choose » and «html:table » . The adjective lexical is used to distinguish a QName in this form from a value of type xs:QName , which contains a namespace URI and a local name. Where the lexical QName has a prefix, this must always match a namespace declaration that is in scope at the place in the stylesheet where the QName is used. For more information on namespaces see Chapter 2, page 53

stylesheet

In general, references to the stylesheet mean the principal stylesheet module plus all the stylesheet modules incorporated into it using <xsl:include> and <xsl:import> elements. When I want to refer to one of these components individually, I call it a stylesheet module

sequence constructor

A sequence of instructions and literal result elements contained within (that is, that are children of) another XSLT element. Many XSLT elements, such as <xsl:template> , <xsl:if> , and <xsl:variable> , have a sequence constructor as their content.

SequenceType

A number of XSLT elements take an «as » attribute whose value is a SequenceType. This is a sequence type descriptor such as «xs:integer* » , or «node()? » , or «element(part,*) » . The syntax for sequence type descriptors is outlined in Chapter 4 of this book, and is given in full in Chapter 9 of XPath 2.0 Programmer's Reference

template rule

An <xsl:template> element that has a match attribute

temporary tree

The value of a variable established using an <xsl:variable> element that contains a sequence constructor, for example

 <xsl:variable>A<b>very</b> nice language</xsl:variable>. 

This construct was referred to in the XSLT 1.0 specification as a result tree fragment. In XSLT 2.0, however, the term result tree fragment is no longer used, reflecting the fact that the restrictions on use of temporary trees have been relaxed , making them much more versatile

XSLT element

Any of the standard elements in the XSLT namespace listed in this chapter, for example <xsl:template> or <xsl:if>

The elements in this chapter are listed alphabetically rather than on functional lines, for ease of reference. This is fine when you know what you are looking for, but if you are using this book as your introduction to XSLT, it does create the problem that related things won't be found together. And if you try to read sequentially, you'll start with <xsl:analyze-string> , which is not one of the instructions that you are likely to use every day of the week.

So here's an attempt at some kind of ordering and grouping, to suggest which entries you might look at first if you're new to the subject:

Grouping

Elements

Elements used to define template rules and functions and control the way they are invoked

<xsl:template>

<xsl: apply-imports >

<xsl:apply-templates>

<xsl:call-template>

<xsl:function>

<xsl: next -match>

Elements defining the structure of the stylesheet

<xsl:stylesheet>

<xsl:include>

<xsl:import>

<xsl:import-schema>

Elements used to create nodes

<xsl:element>

<xsl:attribute>

<xsl:comment>

<xsl:document>

<xsl:namespace>

<xsl:processing-instruction>

<xsl:text>

<xsl:value-of>

Elements used to define variables and parameters

<xsl:variable>

<xsl:param>

<xsl: with-param >

Elements used to copy information from the source document to the result

<xsl:copy>

<xsl:copy-of>

Elements used for conditional processing and iteration

<xsl:if>

<xsl:choose>

<xsl:when>

<xsl: otherwise >

<xsl:for-each>

<xsl:for-each- group >

Elements to control sorting, searching, and numbering

<xsl:perform- sort >

<xsl:sort>

<xsl:number>

<xsl:key>

<xsl:decimal-format>

Elements used to control the output of the stylesheet

<xsl:output>

<xsl:result-document>

<xsl: character-map >

<xsl:output-character>

This covers all the most commonly used elements; the rest can only really be classified as 'miscellaneous'.




XSLT 2.0 Programmer's Reference
NetBeansв„ў IDE Field Guide: Developing Desktop, Web, Enterprise, and Mobile Applications (2nd Edition)
ISBN: 764569090
EAN: 2147483647
Year: 2003
Pages: 324

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net