没有合适的资源?快使用搜索试试~ 我知道了~
XSLT学习资料代码资料上传
资源推荐
资源详情
资源评论
XSL Transformations (XSLT)
Version 1.0
W3C Recommendation 16 November 1999
Status Update (6 April 2021):
Feedback, comments, error reports on this specification should be
sent via GitHub https://github.com/w3c/qtspecs/issues or email to public-qt-
[email protected]. Readers interested in richer versions of the XSLT specification are
encouraged to refer to https://www.w3.org/TR/xslt/.
This version:
http://www.w3.org/TR/1999/REC-xslt-19991116
(available in XML or HTML)
Latest version:
http://www.w3.org/TR/xslt
Previous versions:
http://www.w3.org/TR/1999/PR-xslt-19991008
http://www.w3.org/1999/08/WD-xslt-19990813
http://www.w3.org/1999/07/WD-xslt-19990709
http://www.w3.org/TR/1999/WD-xslt-19990421
http://www.w3.org/TR/1998/WD-xsl-19981216
http://www.w3.org/TR/1998/WD-xsl-19980818
Editor:
James Clark <jjc@jclark.com>
Copyright © 1999 W3C
®
(MIT, INRIA, Keio), All Rights Reserved. W3C liability, trademark,
document use
and software
licensing rules apply.
Abstract
This specification defines the syntax and semantics of XSLT, which is a language for transforming XML
documents into other XML documents.
XSLT is designed for use as part of XSL, which is a stylesheet language for XML. In addition to XSLT,
XSL includes an XML vocabulary for specifying formatting. XSL specifies the styling of an XML
document by using XSLT to describe how the document is transformed into another XML document
that uses the formatting vocabulary.
XSLT is also designed to be used independently of XSL. However, XSLT is not intended as a
completely general-purpose XML transformation language. Rather it is designed primarily for the
kinds of transformations that are needed when XSLT is used as part of XSL.
Status of this document
This document has been reviewed by W3C Members and other interested parties and has been
endorsed by the Director as a W3C Recommendation. It is a stable document and may be used as
reference material or cited as a normative reference from other documents. W3C's role in making the
Recommendation is to draw attention to the specification and to promote its widespread
deployment. This enhances the functionality and interoperability of the Web.
2024/4/30 09:23
XSL Transformations (XSLT)
https://www.w3.org/TR/xslt-10/#section-Creating-the-Result-Tree
1/66
The list of known errors in this specification is available at http://www.w3.org/1999/11/REC-xslt-
19991116-errata.
Comments on this specification may be sent to [email protected]; archives of the comments are
available. Public discussion of XSL, including XSL Transformations, takes place on the XSL-List mailing
list.
The English version of this specification is the only normative version. However, for translations of this
document, see http://www.w3.org/Style/XSL/translations.html.
A list of current W3C Recommendations and other technical documents can be found at
http://www.w3.org/TR.
This specification has been produced as part of the W3C Style activity.
Table of contents
1 Introduction
2 Stylesheet Structure
2.1 XSLT Namespace
2.2 Stylesheet Element
2.3 Literal Result Element as Stylesheet
2.4 Qualified Names
2.5 Forwards-Compatible Processing
2.6 Combining Stylesheets
2.6.1 Stylesheet Inclusion
2.6.2 Stylesheet Import
2.7 Embedding Stylesheets
3 Data Model
3.1 Root Node Children
3.2 Base URI
3.3 Unparsed Entities
3.4 Whitespace Stripping
4 Expressions
5 Template Rules
5.1 Processing Model
5.2 Patterns
5.3 Defining Template Rules
5.4 Applying Template Rules
5.5 Conflict Resolution for Template Rules
5.6 Overriding Template Rules
5.7 Modes
5.8 Built-in Template Rules
6 Named Templates
7 Creating the Result Tree
7.1 Creating Elements and Attributes
7.1.1 Literal Result Elements
7.1.2 Creating Elements with xsl:element
7.1.3 Creating Attributes with xsl:attribute
7.1.4 Named Attribute Sets
7.2 Creating Text
7.3 Creating Processing Instructions
7.4 Creating Comments
7.5 Copying
7.6 Computing Generated Text
7.6.1 Generating Text with xsl:value-of
7.6.2 Attribute Value Templates
7.7 Numbering
7.7.1 Number to String Conversion Attributes
8 Repetition
2024/4/30 09:23
XSL Transformations (XSLT)
https://www.w3.org/TR/xslt-10/#section-Creating-the-Result-Tree
2/66
9 Conditional Processing
9.1 Conditional Processing with xsl:if
9.2 Conditional Processing with xsl:choose
10 Sorting
11 Variables and Parameters
11.1 Result Tree Fragments
11.2 Values of Variables and Parameters
11.3 Using Values of Variables and Parameters with xsl:copy-of
11.4 Top-level Variables and Parameters
11.5 Variables and Parameters within Templates
11.6 Passing Parameters to Templates
12 Additional Functions
12.1 Multiple Source Documents
12.2 Keys
12.3 Number Formatting
12.4 Miscellaneous Additional Functions
13 Messages
14 Extensions
14.1 Extension Elements
14.2 Extension Functions
15 Fallback
16 Output
16.1 XML Output Method
16.2 HTML Output Method
16.3 Text Output Method
16.4 Disabling Output Escaping
17 Conformance
18 Notation
Appendices
A References
A.1 Normative References
A.2 Other References
B Element Syntax Summary
C DTD Fragment for XSLT Stylesheets (Non-Normative)
D Examples (Non-Normative)
D.1 Document Example
D.2 Data Example
E Acknowledgements (Non-Normative)
F Changes from Proposed Recommendation (Non-Normative)
G Features under Consideration for Future Versions of XSLT (Non-Normative)
1 Introduction
This specification defines the syntax and semantics of the XSLT language. A transformation in the
XSLT language is expressed as a well-formed XML document [XML] conforming to the Namespaces in
XML Recommendation [XML Names], which may include both elements that are defined by XSLT and
elements that are not defined by XSLT. XSLT-defined elements are distinguished by belonging to a
specific XML namespace (see [2.1 XSLT Namespace]), which is referred to in this specification as the
XSLT namespace. Thus this specification is a definition of the syntax and semantics of the XSLT
namespace.
A transformation expressed in XSLT describes rules for transforming a source tree into a result tree.
The transformation is achieved by associating patterns with templates. A pattern is matched against
elements in the source tree. A template is instantiated to create part of the result tree. The result tree
is separate from the source tree. The structure of the result tree can be completely different from the
structure of the source tree. In constructing the result tree, elements from the source tree can be
filtered and reordered, and arbitrary structure can be added.
2024/4/30 09:23
XSL Transformations (XSLT)
https://www.w3.org/TR/xslt-10/#section-Creating-the-Result-Tree
3/66
A transformation expressed in XSLT is called a stylesheet. This is because, in the case when XSLT is
transforming into the XSL formatting vocabulary, the transformation functions as a stylesheet.
This document does not specify how an XSLT stylesheet is associated with an XML document. It is
recommended that XSL processors support the mechanism described in [XML Stylesheet]. When this
or any other mechanism yields a sequence of more than one XSLT stylesheet to be applied
simultaneously to a XML document, then the effect should be the same as applying a single
stylesheet that imports each member of the sequence in order (see [2.6.2 Stylesheet Import]).
A stylesheet contains a set of template rules. A template rule has two parts: a pattern which is
matched against nodes in the source tree and a template which can be instantiated to form part of
the result tree. This allows a stylesheet to be applicable to a wide class of documents that have similar
source tree structures.
A template is instantiated for a particular source element to create part of the result tree. A template
can contain elements that specify literal result element structure. A template can also contain
elements from the XSLT namespace that are instructions for creating result tree fragments. When a
template is instantiated, each instruction is executed and replaced by the result tree fragment that it
creates. Instructions can select and process descendant source elements. Processing a descendant
element creates a result tree fragment by finding the applicable template rule and instantiating its
template. Note that elements are only processed when they have been selected by the execution of
an instruction. The result tree is constructed by finding the template rule for the root node and
instantiating its template.
In the process of finding the applicable template rule, more than one template rule may have a
pattern that matches a given element. However, only one template rule will be applied. The method
for deciding which template rule to apply is described in [5.5 Conflict Resolution for Template
Rules].
A single template by itself has considerable power: it can create structures of arbitrary complexity; it
can pull string values out of arbitrary locations in the source tree; it can generate structures that are
repeated according to the occurrence of elements in the source tree. For simple transformations
where the structure of the result tree is independent of the structure of the source tree, a stylesheet
can often consist of only a single template, which functions as a template for the complete result tree.
Transformations on XML documents that represent data are often of this kind (see [D.2 Data
Example]). XSLT allows a simplified syntax for such stylesheets (see [2.3 Literal Result Element as
Stylesheet]).
When a template is instantiated, it is always instantiated with respect to a current node and a
current node list. The current node is always a member of the current node list. Many operations in
XSLT are relative to the current node. Only a few instructions change the current node list or the
current node (see [5 Template Rules] and [8 Repetition]); during the instantiation of one of these
instructions, the current node list changes to a new list of nodes and each member of this new list
becomes the current node in turn; after the instantiation of the instruction is complete, the current
node and current node list revert to what they were before the instruction was instantiated.
XSLT makes use of the expression language defined by [XPath] for selecting elements for processing,
for conditional processing and for generating text.
XSLT provides two "hooks" for extending the language, one hook for extending the set of instruction
elements used in templates and one hook for extending the set of functions used in XPath
expressions. These hooks are both based on XML namespaces. This version of XSLT does not define a
mechanism for implementing the hooks. See [14 Extensions].
NOTE:The XSL WG intends to define such a mechanism in a future version of this
specification or in a separate specification.
The element syntax summary notation used to describe the syntax of XSLT-defined elements is
described in [18 Notation].
The MIME media types text/xml and application/xml [RFC2376] should be used for XSLT stylesheets. It is
possible that a media type will be registered specifically for XSLT stylesheets; if and when it is, that
2024/4/30 09:23
XSL Transformations (XSLT)
https://www.w3.org/TR/xslt-10/#section-Creating-the-Result-Tree
4/66
media type may also be used.
2 Stylesheet Structure
2.1 XSLT Namespace
The XSLT namespace has the URI http://www.w3.org/1999/XSL/Transform.
NOTE:The 1999 in the URI indicates the year in which the URI was allocated by the W3C. It
does not indicate the version of XSLT being used, which is specified by attributes (see [2.2
Stylesheet Element] and [2.3 Literal Result Element as Stylesheet]).
XSLT processors must use the XML namespaces mechanism [XML Names] to recognize elements and
attributes from this namespace. Elements from the XSLT namespace are recognized only in the
stylesheet not in the source document. The complete list of XSLT-defined elements is specified in [B
Element Syntax Summary]. Vendors must not extend the XSLT namespace with additional elements
or attributes. Instead, any extension must be in a separate namespace. Any namespace that is used
for additional instruction elements must be identified by means of the extension element mechanism
specified in [14.1 Extension Elements].
This specification uses a prefix of xsl: for referring to elements in the XSLT namespace. However, XSLT
stylesheets are free to use any prefix, provided that there is a namespace declaration that binds the
prefix to the URI of the XSLT namespace.
An element from the XSLT namespace may have any attribute not from the XSLT namespace,
provided that the expanded-name of the attribute has a non-null namespace URI. The presence of
such attributes must not change the behavior of XSLT elements and functions defined in this
document. Thus, an XSLT processor is always free to ignore such attributes, and must ignore such
attributes without giving an error if it does not recognize the namespace URI. Such attributes can
provide, for example, unique identifiers, optimization hints, or documentation.
It is an error for an element from the XSLT namespace to have attributes with expanded-names that
have null namespace URIs (i.e. attributes with unprefixed names) other than attributes defined for the
element in this document.
NOTE:The conventions used for the names of XSLT elements, attributes and functions are
that names are all lower-case, use hyphens to separate words, and use abbreviations only if
they already appear in the syntax of a related language such as XML or HTML.
2.2 Stylesheet Element
<xsl:stylesheet
id = id
extension-element-prefixes = tokens
exclude-result-prefixes = tokens
v e r s i o n = number>
<!-- Content: (xsl:import*, top-level-elements) -->
</xsl:stylesheet>
<xsl:transform
id = id
extension-element-prefixes = tokens
exclude-result-prefixes = tokens
v e r s i o n = number>
<!-- Content: (xsl:import*, top-level-elements) -->
</xsl:transform>
A stylesheet is represented by an xsl:stylesheet element in an XML document. xsl:transform is allowed
as a synonym for xsl:stylesheet.
An xsl:stylesheet element must have a version attribute, indicating the version of XSLT that the
stylesheet requires. For this version of XSLT, the value should be 1.0. When the value is not equal to
1.0, forwards-compatible processing mode is enabled (see [2.5 Forwards-Compatible Processing]).
The xsl:stylesheet element may contain the following types of elements:
2024/4/30 09:23
XSL Transformations (XSLT)
https://www.w3.org/TR/xslt-10/#section-Creating-the-Result-Tree
5/66
剩余65页未读,继续阅读
资源评论
李周华
- 粉丝: 0
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- elasticsearch-spring-boot-starter.7z
- Anti-Cheat Toolkit 2023 v2023.2.5
- 使用堆栈数据结构解迷宫问题
- SoftFloat-3e.zip
- Easy Save - 3.5.6
- 基于tensorflow的目标检测系统源码+部署教程文档+全部数据+训练好的模型(高分项目)
- 基于Python皮肤电信号的情绪识别算法源码+模型+PPT+详细文档+全部数据资料.zip
- 基于Python皮肤电信号的情绪识别算法源码+模型+PPT+详细文档+全部数据资料.zip
- 区块链毕业设计 基于区块链的慈善募捐平台的智能合约源码+详细文档+全部资料(高分项目).zip
- 区块链毕业设计 基于区块链的慈善募捐平台的智能合约源码+详细文档+全部资料(高分项目).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功