XSL Transformations
Encyclopedia
XSLT is a declarative
, XML
-based language used for the transformation
of XML documents. The original document is not changed; rather, a new document is created based on the content of an existing one. The new document may be serialized
(output) by the processor in standard XML syntax or in another format, such as HTML
or plain text. XSLT is most often used to convert data between different XML schema
s or to convert XML data into web page
s or PDF
documents.
documents for display as a web page
. The transformation may happen dynamically either on a client or on a server, or it may be done as part of the publishing process. It is also used to create output for printing or direct video display, typically by transforming the original XML into XSL Formatting Objects
to create formatted output which can then be converted to a variety of formats, including PDF
, PostScript
and PNG. XSLT can also translate XML messages between different XML schema
s, or make changes to documents within the scope of a single schema, for example by removing the parts of a message that are not needed.
(W3C). The most recent version is XSLT 2.0, which reached W3C recommendation
status on 23 January 2007. As of 2010, however, XSLT 1.0 is still widely used, as there are no products that support XSLT 2.0 running in the browser, nor on some important server environments such as LAMP
.
Originally, XSLT was part of the W3C's Extensible Stylesheet Language
(XSL) development effort of 1998–1999, a project that also produced XSL Formatting Objects and the XML Path Language, XPath
. The editor of the first version was James Clark
. XSLT 1.0 was published as a Recommendation by the W3C on 16 November 1999. After an abortive attempt to create a version 1.1 in 2001, the XSL working group joined forces with the XQuery
working group to create XPath 2.0
, with a richer data model and type system based on XML Schema. XSLT 2.0, developed under the editorship of Michael Kay
, was built on this foundation in 2002–2006.
As a language
, XSLT is influenced by functional languages
, and by text-based pattern matching languages in the tradition of SNOBOL
and awk
. Its most direct predecessor was ISO DSSSL, a language that performed the same function for full SGML that XSLT performs for XML (Some members of the standards committee that developed XSLT, including James Clark, had previously worked on DSSSL.) Unlike DSSSL, however, XSLT code uses the syntax of its target language, XML, which means that it can also be viewed as a Turing-complete template processor
.
Most of this article is applicable to both XSLT versions; any differences are noted in the text.
The XSLT processor ordinarily takes two input documents—an XML source document, and an XSLT stylesheet—and produces an output document. The XSLT stylesheet contains a collection of template rules: instructions and other directives that guide the processor in the production of the output document.
expressions
that directly represent their evaluated form: the result tree, which is the basis of the processor's output.
The processor follows a fixed algorithm: assuming a stylesheet has already been read and prepared, the processor builds a source tree from the input XML document. It then starts by processing the source tree's root node, finding in the stylesheet the best-matching template for that node, and evaluating the template's contents. Instructions in each template generally direct the processor to either create nodes in the result tree, or process more nodes in the source tree in the same way as the root node. Output is derived from the result tree.
Client-side XSLT adoption has been slow due to widespread deployment of older (or alternative) browsers without XSLT support. For similar reasons, adoption of XSLT 2.0 in such environments remains limited. (See Comparison of layout engines (XML)#XSL technologies).
Nevertheless, early adopters included Microsoft Internet Explorer
6 (since 2001) and Netscape 7 (since 2002). Earlier still, Internet Explorer 5 supported XSLT’s draft specification since 1999 or earlier, although it was incompatible with the final W3C specification. Netscape 6
included partial support since 2000.
Server-side XSLT processors (a somewhat misleading term, as they don’t require a server to function; the name is intended to contrast with “client-side”) exist as both standalone products and components of other software. This includes web browsers, application servers, frameworks (such as Java and .NET), or even operating systems. For example, Windows XP
’s MSXML3
library includes an XSLT 1.0 processor. The GNOME
desktop environment 2 includes libxslt
, an open source implementation with complete support for the XSLT 1.0 specification. The libxslt library is also used by other software, such as WebKit
. Other examples include Apache’s Xalan
and Saxon XSLT
(which supports XSLT 2.0 as well).
Most early XSLT processors were interpreters. More recently, code generation is increasingly common, using portable intermediate languages (such as Java bytecode or .NET Common Intermediate Language) as the target. However, even the interpretive products generally offer separate analysis and execution phases, allowing an optimized expression tree to be created in memory and reused to perform multiple transformations. This gives substantial performance benefits in online publishing applications, where the same transformation is applied many times per second to different source documents. This separation is reflected in the design of XSLT processing APIs (such as JAXP
).
Early XSLT processors had very few optimizations. Stylesheet documents were read into Document Object Model
s and the processor would act on them directly. XPath
engines were also not optimized. Increasingly, however, XSLT processors use optimization techniques found in functional programming languages and database query languages, such as static rewriting of an expression tree (e.g., to move calculations out of loops), and lazy pipelined evaluation to reduce the memory footprint of intermediate results (and allow "early exit" when the processor can evaluate an expression such as
Future XSLT 3.0 implementation will also allow to stream on the input. It will allow implementation to have low latency between the input and the output. It is especially important when transformation are chained together in XML Pipelines, for example in XProc
.
language for identifying subsets of the source document tree, as well as for performing calculations. XPath also provides a range of functions
, which XSLT itself further augments. This reliance upon XPath adds a great deal of power and flexibility to XSLT.
XSLT 1.0 uses XPath 1.0. Similarly, XSLT 2.0 relies on XPath 2.0; both specifications were published on the same date.
, which was initially conceived as a query language for large collections of XML documents.
The XSLT 2.0 and XQuery 1.0 standards were developed by separate working groups within W3C, working together to ensure a common approach where appropriate. They share the same data model, type system, and function library, and both include XPath
2.0 as a sublanguage.
The two languages, however, are rooted in different traditions and serve the needs of different communities. XSLT was primarily conceived as a stylesheet language whose primary goal was to render XML for the human reader on screen, on the web (as web template language
), or on paper. XQuery was primarily conceived as a database query language in the tradition of SQL
.
Because the two languages originate in different communities, XSLT is stronger in its handling
of narrative documents with more flexible structure, while XQuery is stronger in its data handling, for example when performing relational joins.
registered for XSLT.
The XSLT 1.0 Recommendation (1999) says "The MIME media types
.
RFC 3023 points out potential technical problems with
Pre-1.0 working drafts of XSLT used
Its evaluation results in a new XML document, having another structure:
with the XML input file shown above results in the following XHTML
(whitespace
has been adjusted here for clarity):
This XHTML generates the output below when rendered in a web browser
.
In order for a web browser
to be able automatically to apply an XSL transformation to an XML document on display, an XML stylesheet processing instruction can be inserted into XML. So, for example, if the stylesheet in Example 2 above were available as "example2.xsl", the following instruction could be added to the original incoming XML:
(In this example,
Tutorials
Mailing lists
XSLT code libraries
Further examples
Declarative programming
In computer science, declarative programming is a programming paradigm that expresses the logic of a computation without describing its control flow. Many languages applying this style attempt to minimize or eliminate side effects by describing what the program should accomplish, rather than...
, XML
XML
Extensible Markup Language is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards....
-based language used for the transformation
XML transformation language
An XML transformation language is a programming language designed specifically to transform an input XML document into an output XML document which satisfies some specific goal.There are two special cases of transformation:...
of XML documents. The original document is not changed; rather, a new document is created based on the content of an existing one. The new document may be serialized
Serialization
In computer science, in the context of data storage and transmission, serialization is the process of converting a data structure or object state into a format that can be stored and "resurrected" later in the same or another computer environment...
(output) by the processor in standard XML syntax or in another format, such as HTML
HTML
HyperText Markup Language is the predominant markup language for web pages. HTML elements are the basic building-blocks of webpages....
or plain text. XSLT is most often used to convert data between different XML schema
XML schema
An XML schema is a description of a type of XML document, typically expressed in terms of constraints on the structure and content of documents of that type, above and beyond the basic syntactical constraints imposed by XML itself...
s or to convert XML data into web page
Web page
A web page or webpage is a document or information resource that is suitable for the World Wide Web and can be accessed through a web browser and displayed on a monitor or mobile device. This information is usually in HTML or XHTML format, and may provide navigation to other web pages via hypertext...
s or PDF
Portable Document Format
Portable Document Format is an open standard for document exchange. This file format, created by Adobe Systems in 1993, is used for representing documents in a manner independent of application software, hardware, and operating systems....
documents.
Application
Applications often use XSLT to convert XML data into HTML or XHTMLXHTML
XHTML is a family of XML markup languages that mirror or extend versions of the widely-used Hypertext Markup Language , the language in which web pages are written....
documents for display as a web page
Web page
A web page or webpage is a document or information resource that is suitable for the World Wide Web and can be accessed through a web browser and displayed on a monitor or mobile device. This information is usually in HTML or XHTML format, and may provide navigation to other web pages via hypertext...
. The transformation may happen dynamically either on a client or on a server, or it may be done as part of the publishing process. It is also used to create output for printing or direct video display, typically by transforming the original XML into XSL Formatting Objects
XSL Formatting Objects
XSL Formatting Objects, or XSL-FO, is a markup language for XML document formatting which is most often used to generate PDFs. XSL-FO is part of XSL , a set of W3C technologies designed for the transformation and formatting of XML data. The other parts of XSL are XSLT and XPath...
to create formatted output which can then be converted to a variety of formats, including PDF
Portable Document Format
Portable Document Format is an open standard for document exchange. This file format, created by Adobe Systems in 1993, is used for representing documents in a manner independent of application software, hardware, and operating systems....
, PostScript
PostScript
PostScript is a dynamically typed concatenative programming language created by John Warnock and Charles Geschke in 1982. It is best known for its use as a page description language in the electronic and desktop publishing areas. Adobe PostScript 3 is also the worldwide printing and imaging...
and PNG. XSLT can also translate XML messages between different XML schema
XML schema
An XML schema is a description of a type of XML document, typically expressed in terms of constraints on the structure and content of documents of that type, above and beyond the basic syntactical constraints imposed by XML itself...
s, or make changes to documents within the scope of a single schema, for example by removing the parts of a message that are not needed.
Origins
XSLT is developed by the World Wide Web ConsortiumWorld Wide Web Consortium
The World Wide Web Consortium is the main international standards organization for the World Wide Web .Founded and headed by Tim Berners-Lee, the consortium is made up of member organizations which maintain full-time staff for the purpose of working together in the development of standards for the...
(W3C). The most recent version is XSLT 2.0, which reached W3C recommendation
W3C recommendation
A W3C Recommendation is the final stage of a ratification process of the World Wide Web Consortium working group concerning a technical standard. This designation signifies that a document has been subjected to a public and W3C-member organization's review. It aims to standardise the Web technology...
status on 23 January 2007. As of 2010, however, XSLT 1.0 is still widely used, as there are no products that support XSLT 2.0 running in the browser, nor on some important server environments such as LAMP
LAMP (software bundle)
LAMP is an acronym for a solution stack of free, open source software, referring to the first letters of Linux , Apache HTTP Server, MySQL and PHP , principal components to build a viable general purpose web server.The GNU project is advocating people to use the term "GLAMP" since what is known as...
.
Originally, XSLT was part of the W3C's Extensible Stylesheet Language
Extensible Stylesheet Language
In computing, the term Extensible Stylesheet Language is used to refer to a family oflanguages used to transform and render XML documents....
(XSL) development effort of 1998–1999, a project that also produced XSL Formatting Objects and the XML Path Language, XPath
XPath
XPath is a language for selecting nodes from an XML document. In addition, XPath may be used to compute values from the content of an XML document...
. The editor of the first version was James Clark
James Clark (XML expert)
James Clark, is the author of groff and expat and has done much work with open-source software and XML. Born in London, and educated at Charterhouse and Merton College, Oxford, Clark has lived in Bangkok, Thailand since 1995, and is now a permanent resident...
. XSLT 1.0 was published as a Recommendation by the W3C on 16 November 1999. After an abortive attempt to create a version 1.1 in 2001, the XSL working group joined forces with the XQuery
XQuery
- Features :XQuery provides the means to extract and manipulate data from XML documents or any data source that can be viewed as XML, such as relational databases or office documents....
working group to create XPath 2.0
XPath 2.0
XPath 2.0 is the current version of the XPath language defined by the World Wide Web Consortium, W3C. It became a recommendation on 23 January 2007....
, with a richer data model and type system based on XML Schema. XSLT 2.0, developed under the editorship of Michael Kay
Michael Kay (software engineer)
Michael H. Kay FBCS is the editor of the W3C specification of the XSLT 2.0 language for performing XML transformations, and the developer of the Saxon XSLT and XQuery processing software....
, was built on this foundation in 2002–2006.
As a language
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....
, XSLT is influenced by functional languages
Functional programming
In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions, in contrast to the imperative programming style, which emphasizes changes in state...
, and by text-based pattern matching languages in the tradition of SNOBOL
SNOBOL
SNOBOL is a generic name for the computer programming languages developed between 1962 and 1967 at AT&T Bell Laboratories by David J. Farber, Ralph E. Griswold and Ivan P. Polonsky, culminating in SNOBOL4...
and awk
AWK (programming language)
The AWK utility is a data extraction and reporting tool that uses a data-driven scripting language consisting of a set of actions to be taken against textual data for the purpose of producing formatted reports...
. Its most direct predecessor was ISO DSSSL, a language that performed the same function for full SGML that XSLT performs for XML (Some members of the standards committee that developed XSLT, including James Clark, had previously worked on DSSSL.) Unlike DSSSL, however, XSLT code uses the syntax of its target language, XML, which means that it can also be viewed as a Turing-complete template processor
Template processor
A template processor is software or a software component that is designed to combine one or moretemplates with a data model to produceone or more result documents...
.
Most of this article is applicable to both XSLT versions; any differences are noted in the text.
Overview
The XSLT processing model involves:- one or more XML source documents;
- one or more XSLT stylesheet modules;
- the XSLT template processing engine (the processor); and
- one or more result documents.
The XSLT processor ordinarily takes two input documents—an XML source document, and an XSLT stylesheet—and produces an output document. The XSLT stylesheet contains a collection of template rules: instructions and other directives that guide the processor in the production of the output document.
Template rule processing
The XSLT language is declarative: rather than listing an imperative sequence of actions to perform in a stateful environment, template rules only define how to handle a node matching a particular XPath-like pattern, if the processor should happen to encounter one, and the contents of the templates effectively comprise functionalFunctional programming
In computer science, functional programming is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data. It emphasizes the application of functions, in contrast to the imperative programming style, which emphasizes changes in state...
expressions
Expression (programming)
An expression in a programming language is a combination of explicit values, constants, variables, operators, and functions that are interpreted according to the particular rules of precedence and of association for a particular programming language, which computes and then produces another value...
that directly represent their evaluated form: the result tree, which is the basis of the processor's output.
The processor follows a fixed algorithm: assuming a stylesheet has already been read and prepared, the processor builds a source tree from the input XML document. It then starts by processing the source tree's root node, finding in the stylesheet the best-matching template for that node, and evaluating the template's contents. Instructions in each template generally direct the processor to either create nodes in the result tree, or process more nodes in the source tree in the same way as the root node. Output is derived from the result tree.
Processor implementations
XSLT processor implementations fall into two main categories: client-side and server-side.Client-side XSLT adoption has been slow due to widespread deployment of older (or alternative) browsers without XSLT support. For similar reasons, adoption of XSLT 2.0 in such environments remains limited. (See Comparison of layout engines (XML)#XSL technologies).
Nevertheless, early adopters included Microsoft Internet Explorer
Internet Explorer
Windows Internet Explorer is a series of graphical web browsers developed by Microsoft and included as part of the Microsoft Windows line of operating systems, starting in 1995. It was first released as part of the add-on package Plus! for Windows 95 that year...
6 (since 2001) and Netscape 7 (since 2002). Earlier still, Internet Explorer 5 supported XSLT’s draft specification since 1999 or earlier, although it was incompatible with the final W3C specification. Netscape 6
Netscape 6
Netscape 6 was the name of Netscape Communications Corporation's proprietary cross-platform internet suite from versions 6.0–6.2.3. It superseded Netscape Communicator 4.8 and was replaced by the simply-named Netscape...
included partial support since 2000.
Server-side XSLT processors (a somewhat misleading term, as they don’t require a server to function; the name is intended to contrast with “client-side”) exist as both standalone products and components of other software. This includes web browsers, application servers, frameworks (such as Java and .NET), or even operating systems. For example, Windows XP
Windows XP
Windows XP is an operating system produced by Microsoft for use on personal computers, including home and business desktops, laptops and media centers. First released to computer manufacturers on August 24, 2001, it is the second most popular version of Windows, based on installed user base...
’s MSXML3
MSXML
Microsoft XML Core Services is a set of services that allow applications written in JScript, VBScript, and Microsoft development tools to build Windows-native XML-based applications...
library includes an XSLT 1.0 processor. The GNOME
GNOME
GNOME is a desktop environment and graphical user interface that runs on top of a computer operating system. It is composed entirely of free and open source software...
desktop environment 2 includes libxslt
Libxslt
Libxslt is the XSLT C library developed for the GNOME project. It provides an implementation of XSLT 1.0, plus most of the EXSLT set of processor-portable extensions functions and some of Saxon's evaluate and expressions extensions. Libxslt is based on libxml2, which it uses for XML parsing, tree...
, an open source implementation with complete support for the XSLT 1.0 specification. The libxslt library is also used by other software, such as WebKit
WebKit
WebKit is a layout engine designed to allow web browsers to render web pages. WebKit powers Google Chrome and Apple Safari and by October 2011 held over 33% of the browser market share between them. It is also used as the basis for the experimental browser included with the Amazon Kindle ebook...
. Other examples include Apache’s Xalan
Xalan
Xalan is a popular open source software library from the Apache Software Foundation, originally created by IBM under the name LotusXSL, that implements the XSLT 1.0 XML transformation language and the XPath 1.0 language. The Xalan XSLT processor is available for both the Java and C++ programming...
and Saxon XSLT
Saxon XSLT
Saxon is an XSLT and XQuery processor created by Michael Kay. There are open-source and also closed-source commercial versions. Versions exist for Java and .NET.The current version, as of December 2010, is 9.3.- Versions :...
(which supports XSLT 2.0 as well).
Performance
XSLT processor performance has steadily improved as the technology has matured, although the very first processor, James Clark's xt, was unbeaten for several years.Most early XSLT processors were interpreters. More recently, code generation is increasingly common, using portable intermediate languages (such as Java bytecode or .NET Common Intermediate Language) as the target. However, even the interpretive products generally offer separate analysis and execution phases, allowing an optimized expression tree to be created in memory and reused to perform multiple transformations. This gives substantial performance benefits in online publishing applications, where the same transformation is applied many times per second to different source documents. This separation is reflected in the design of XSLT processing APIs (such as JAXP
Java API for XML Processing
The Java API for XML Processing, or JAXP , is one of the Java XML programming APIs. It provides the capability of validating and parsing XML documents...
).
Early XSLT processors had very few optimizations. Stylesheet documents were read into Document Object Model
Document Object Model
The Document Object Model is a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents. Aspects of the DOM may be addressed and manipulated within the syntax of the programming language in use...
s and the processor would act on them directly. XPath
XPath
XPath is a language for selecting nodes from an XML document. In addition, XPath may be used to compute values from the content of an XML document...
engines were also not optimized. Increasingly, however, XSLT processors use optimization techniques found in functional programming languages and database query languages, such as static rewriting of an expression tree (e.g., to move calculations out of loops), and lazy pipelined evaluation to reduce the memory footprint of intermediate results (and allow "early exit" when the processor can evaluate an expression such as
following-sibling::*[1]
without a complete evaluation of all subexpressions). Many processors also use tree representations that are significantly more efficient (in both space and time) than general-purpose DOM implementations.XSLT and Streaming
XSLT 1.0 and XSLT 2.0 were all designed to allow XML Streaming of the output of the processing. It means that you had to read the whole input in memory before doing any processing of the XML. This behavior is particularly useful to certify "stability" on the document.Future XSLT 3.0 implementation will also allow to stream on the input. It will allow implementation to have low latency between the input and the output. It is especially important when transformation are chained together in XML Pipelines, for example in XProc
XProc
XProc is a W3C Recommendation to define an XML transformation language to define XML Pipelines.Below is an example abbreviated XProc file: This is a pipeline that consists of two atomic steps, XInclude and Validate...
.
XSLT and XPath
XSLT relies upon the W3C's XPathXPath
XPath is a language for selecting nodes from an XML document. In addition, XPath may be used to compute values from the content of an XML document...
language for identifying subsets of the source document tree, as well as for performing calculations. XPath also provides a range of functions
Subroutine
In computer science, a subroutine is a portion of code within a larger program that performs a specific task and is relatively independent of the remaining code....
, which XSLT itself further augments. This reliance upon XPath adds a great deal of power and flexibility to XSLT.
XSLT 1.0 uses XPath 1.0. Similarly, XSLT 2.0 relies on XPath 2.0; both specifications were published on the same date.
XSLT and XQuery compared
XSLT capabilities overlap with XQueryXQuery
- Features :XQuery provides the means to extract and manipulate data from XML documents or any data source that can be viewed as XML, such as relational databases or office documents....
, which was initially conceived as a query language for large collections of XML documents.
The XSLT 2.0 and XQuery 1.0 standards were developed by separate working groups within W3C, working together to ensure a common approach where appropriate. They share the same data model, type system, and function library, and both include XPath
XPath
XPath is a language for selecting nodes from an XML document. In addition, XPath may be used to compute values from the content of an XML document...
2.0 as a sublanguage.
The two languages, however, are rooted in different traditions and serve the needs of different communities. XSLT was primarily conceived as a stylesheet language whose primary goal was to render XML for the human reader on screen, on the web (as web template language
Web template
A web template is a tool used to separate content from presentation in web design, and for mass-production of web documents. It is a basic component of a web template system.Web templates can be used to set up any type of website...
), or on paper. XQuery was primarily conceived as a database query language in the tradition of SQL
SQL
SQL is a programming language designed for managing data in relational database management systems ....
.
Because the two languages originate in different communities, XSLT is stronger in its handling
of narrative documents with more flexible structure, while XQuery is stronger in its data handling, for example when performing relational joins.
XSLT media types
As of 2009, there is no MIME/Internet media typeInternet media type
An Internet media type, originally called a MIME type after MIME and sometimes a Content-type after the name of a header in several protocols whose value is such a type, is a two-part identifier for file formats on the Internet.The identifiers were originally defined in RFC 2046 for use in email...
registered for XSLT.
The XSLT 1.0 Recommendation (1999) says "The MIME media types
text/xml
and application/xml
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 media type may also be used." It goes on to use text/xml
in an example of how to embed a stylesheet with the xml-stylesheet
processing instructionProcessing Instruction
A Processing Instruction is an SGML and XML node type, which may occur anywhere in the document, intended to carry instructions to the application....
.
RFC 3023 points out potential technical problems with
text/*
types in general, and proposes application/xslt+xml
as an ideal media type for XSLT. The XSLT 2.0 Recommendation (January 2007) includes a formal application to register this media type. However, at the time of writing (January 2009) the process of registration has not yet been completed, and RFC 3023 warns that "... this media type should not be used until such registration has been completed."Pre-1.0 working drafts of XSLT used
text/xsl
in their embedding examples, and this type was implemented and continues to be promoted by Microsoft in Internet Explorer and MSXML. It is also widely recognized in the xml-stylesheet
processing instruction by other browsers. In practice, therefore, users wanting to control transformation in the browser using this processing instruction are obliged to use this unregistered media type.XSLT examples
Sample of incoming XML documentExample 1 (transforming XML to XML)
This XSLT stylesheet provides templates to transform the XML document:Its evaluation results in a new XML document, having another structure:
Example 2 (transforming XML to XHTML)
Processing the following example XSLT filewith the XML input file shown above results in the following XHTML
XHTML
XHTML is a family of XML markup languages that mirror or extend versions of the widely-used Hypertext Markup Language , the language in which web pages are written....
(whitespace
Whitespace (computer science)
In computer science, whitespace is any single character or series of characters that represents horizontal or vertical space in typography. When rendered, a whitespace character does not correspond to a visual mark, but typically does occupy an area on a page...
has been adjusted here for clarity):
This XHTML generates the output below when rendered in a web browser
Web browser
A web browser is a software application for retrieving, presenting, and traversing information resources on the World Wide Web. An information resource is identified by a Uniform Resource Identifier and may be a web page, image, video, or other piece of content...
.
In order for a web browser
Web browser
A web browser is a software application for retrieving, presenting, and traversing information resources on the World Wide Web. An information resource is identified by a Uniform Resource Identifier and may be a web page, image, video, or other piece of content...
to be able automatically to apply an XSL transformation to an XML document on display, an XML stylesheet processing instruction can be inserted into XML. So, for example, if the stylesheet in Example 2 above were available as "example2.xsl", the following instruction could be added to the original incoming XML:
(In this example,
text/xsl
is technically incorrect according to the W3C specifications, but it is the only media type that is widely supported across current (2009) browsers.)See also
- XProcXProcXProc is a W3C Recommendation to define an XML transformation language to define XML Pipelines.Below is an example abbreviated XProc file: This is a pipeline that consists of two atomic steps, XInclude and Validate...
- a W3C Standard pipeline language which can be used to combine XSLT transformations together with other operations like XQueryXQuery- Features :XQuery provides the means to extract and manipulate data from XML documents or any data source that can be viewed as XML, such as relational databases or office documents....
, XIncludeXIncludeXInclude is a generic mechanism for merging XML documents, by writing inclusion tags in the "main" document to automatically include other documents or parts thereof. The resulting document becomes a single composite XML Information Set...
or HTTP requests - XSLT elementsXSLT elementsXSLT defines many elements to describe the transformations that should be applied to a document. This article lists some of these elements...
- a list of some commonly used XSLT structures - XML transformation languageXML transformation languageAn XML transformation language is a programming language designed specifically to transform an input XML document into an output XML document which satisfies some specific goal.There are two special cases of transformation:...
- any computer language designed specifically to transform an input XML document into an output XML document that satisfies some specific goal - Extensible Stylesheet LanguageExtensible Stylesheet LanguageIn computing, the term Extensible Stylesheet Language is used to refer to a family oflanguages used to transform and render XML documents....
- a family of languages of which XSLT is a member - XQuery and XSLT compared
- XSL formatting objectsXSL Formatting ObjectsXSL Formatting Objects, or XSL-FO, is a markup language for XML document formatting which is most often used to generate PDFs. XSL-FO is part of XSL , a set of W3C technologies designed for the transformation and formatting of XML data. The other parts of XSL are XSLT and XPath...
or XSL-FO - An XML-based language for documents, usually generated by transforming source documents with XSLT, consisting of objects used to create formatted output - Identity transformIdentity transformThe identity transform is a data transformation that copies the source data into the destination data without change.The identity transformation is considered an essential process in creating a reusable transformation library. By creating a library of variations of the base identity...
- a starting point for filter chains that add or remove data elements from XML trees in a transformation pipeline - Apache CocoonApache CocoonApache Cocoon, usually just called Cocoon, is a web application framework built around the concepts of pipeline, separation of concerns and component-based web development. The framework focuses on XML and XSLT publishing and is built using the Java programming language...
- a JavaJava (programming language)Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...
-based framework for processing data with XSLT and other transformers. - Context FrameworkContext FrameworkThe Context Framework is an open source component based web frameworkfor the Java platform and it has similarities with Apache Wicket and .- Design :The goal of Context is to create a flexible and lightweight framework based on XSLT-templating language...
- a JavaJava (programming language)Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...
-based web framework using XSLT as sole templating language. - OmnimarkOmniMarkOmniMark is a fourth-generation programming language used mostly in the publishing industry. It is a proprietary software product of Stilo International.-Usage:...
- another structured text processing language (and a proprietary software) - Xs3pXs3pxs3p is an XSLT stylesheet that generates XHTML documentation from XML Schema Definition language schema.xs3p requires an XSLT processor like Xalan from Apache Software Foundation...
- is an XSLT stylesheet that generates XHTML documentation from XML Schema Definition language (XSD) schema.
Further reading
- XSLT by Doug Tidwell, published by O’Reilly (ISBN 0-596-00053-7)
- XSLT Cookbook by Sal Mangano, published by O’Reilly (ISBN 0-596-00974-7)
- XSLT 2.0 Programmer's Reference by Michael Kay (ISBN 0-764-56909-0)
- XSLT 2.0 and XPath 2.0 Programmer's Reference by Michael Kay (ISBN 978-0-470-19274-0)
- XSLT 2.0 Web Development by Dmitry Kirsanov (ISBN 0-13-140635-3)
- XSL Companion, 2nd Edition by Neil Bradley, published by Addison-Wesley (ISBN 0-201-77083-0)
- XSLT and XPath on the Edge (Unlimited Edition) by Jeni Tennison, published by Hungry Minds Inc, U.S. (ISBN 0-7645-4776-3)
- XSLT & XPath, A Guide to XML Transformations by John Robert Gardner and Zarella Rendon, published by Prentice-Hall (ISBN 0-13-040446-2)
- XSL-FO by Dave Pawson, published by O'Reilly (ISBN 978-0-596-00355-5)
External links
Documentation- XSLT 1.0 W3C Recommendation
- XSLT 2.0 W3C Recommendation
- XSLT Frequently Asked Questions
- Zvon XSLT 1.0 Reference
- XSL Concepts and Practical Use by Norman Walsh
- What kind of language is XSLT?
- XSLT and Scripting Languages
- schema-aware.com - examples of schema-aware XSLT
- XSLT - MDC Docs by Mozilla Developer Network
Tutorials
- Tutorial from developerWorks by IBMIBMInternational Business Machines Corporation or IBM is an American multinational technology and consulting corporation headquartered in Armonk, New York, United States. IBM manufactures and sells computer hardware and software, and it offers infrastructure, hosting and consulting services in areas...
(1 hour) - Zvon XSLT Tutorial
- Quick tutorial
- W3Schools XSLT Tutorial
Mailing lists
XSLT code libraries
- EXSLT is a widespread community initiative to provide extensions to XSLT.
- FXSL is a library implementing support for Higher-order functionHigher-order functionIn mathematics and computer science, higher-order functions, functional forms, or functionals are functions which do at least one of the following:*take one or more functions as an input*output a function...
s in XSLT. FXSL is written in XSLT itself. - The XSLT Standard Library xsltsl, provides the XSLT developer with a set of XSLT templates for commonly used functions. These are implemented purely in XSLT, that is they do not use any extensions. xsltsl is a SourceForge project.
- Kernow A GUI for Saxon that provides a point and click interface for running transforms.
- xslt.js – Transform XML with XSLT JavaScript library that transforms XML with XSLT in the browser.
Further examples
- XSLT Examples using JavaScript based on wiki examples and w3schools XSLT on the Client
- How to use XSLT with PHP : Shows how to create a PHP class to convert a PHP array and an XSLT style-sheet into html.
- XSLT Resource Links from Symphony CMS (based on XSLT)