- Context Framework
- DOM
- DSSSL
- GNOME
- HTML
- HTTP
- IBM
- Identity transform
- Internet Explorer
- Internet media type
- ISO
- libxslt
- MSXML
- Netscape 6
- Netscape 7
- Omnimark
- PostScript
- Programming language
- Saxon XSLT
- Serialization
- SGML
- SNOBOL
- SQL
- Stylesheet language
- Subroutine
- template processor
- the web
- Tree data structure
- Turing-complete
- W3C
- W3C recommendation
- web browser
- web page
- web template
- WebKit
- Windows XP
- Xalan
- XHTML
- XInclude
- XML
- XML Pipelines
- XML schema
- XML Schema (W3C)
- XML Streaming
- XPath
- XPath 2.0
- XProc
- XQuery
- Xs3p
- XSL-FO
- XSLT elements
- Order: Reorder
- Duration: 8:17
- Published: 17 Mar 2011
- Uploaded: 03 Dec 2011
- Author: JeremyMorganDotCom
- Order: Reorder
- Duration: 4:30
- Published: 01 Feb 2008
- Uploaded: 01 Dec 2011
- Author: videocode2
- Order: Reorder
- Duration: 6:40
- Published: 05 Jun 2007
- Uploaded: 14 Nov 2011
- Author: NikiDevgood
- Order: Reorder
- Duration: 8:19
- Published: 25 Jul 2011
- Uploaded: 17 Oct 2011
- Author: EducatorVids
- Order: Reorder
- Duration: 9:06
- Published: 25 Nov 2009
- Uploaded: 27 Aug 2010
- Author: ThinkingCamp
- Order: Reorder
- Duration: 6:50
- Published: 05 Jun 2007
- Uploaded: 11 Dec 2010
- Author: NikiDevgood
- Order: Reorder
- Duration: 5:25
- Published: 09 Jan 2011
- Uploaded: 22 Nov 2011
- Author: WonderLaura67
- Order: Reorder
- Duration: 17:18
- Published: 23 Jun 2011
- Uploaded: 02 Sep 2011
- Author: PETERTEACH
- Order: Reorder
- Duration: 8:30
- Published: 11 Sep 2010
- Uploaded: 19 Oct 2011
- Author: metamanager
- Order: Reorder
- Duration: 4:33
- Published: 18 Dec 2010
- Uploaded: 29 Sep 2011
- Author: vasanthrajach
- Order: Reorder
- Duration: 2:33
- Published: 18 Sep 2009
- Uploaded: 17 Jul 2010
- Author: securitycompasslabs
- Order: Reorder
- Duration: 2:00
- Published: 26 May 2009
- Uploaded: 29 Dec 2009
- Author: rivervalleytv
- Order: Reorder
- Duration: 4:02
- Published: 11 Apr 2008
- Uploaded: 22 May 2011
- Author: richardmullins44
- Apache Cocoon
- Context Framework
- DOM
- DSSSL
- GNOME
- HTML
- HTTP
- IBM
- Identity transform
- Internet Explorer
- Internet media type
- ISO
- libxslt
- MSXML
- Netscape 6
- Netscape 7
- Omnimark
- PostScript
- Programming language
- Saxon XSLT
- Serialization
- SGML
- SNOBOL
- SQL
- Stylesheet language
- Subroutine
- template processor
- the web
- Tree data structure
- Turing-complete
- W3C
- W3C recommendation
- web browser
- web page
- web template
- WebKit
- Windows XP
- Xalan
- XHTML
- XInclude
- XML
- XML Pipelines
- XML schema
- XML Schema (W3C)
- XML Streaming
- XPath
- XPath 2.0
- XProc
- XQuery
- Xs3p
- XSL-FO
- XSLT elements
size: 5.5Kb
size: 2.2Kb
size: 1.3Kb
size: 7.0Kb
size: 5.7Kb
size: 5.7Kb
size: 7.6Kb
size: 5.0Kb
name | XSLT |
---|---|
extension | .xsl, .xslt |
mime | application/xslt+xml |
owner | World Wide Web Consortium |
screenshot | |
genre | Stylesheet language |
extendedfrom | XML |
standard | 1.0 (Recommendation),2.0 (Recommendation) }} |
title | XSL Transformations |
---|---|
status | Published |
year started | 1997 |
editors | James Clark (1.0), Michael Kay (2.0) |
base standards | XML |
related standards | XSL, XSL-FO, XPath |
abbreviation | XSLT |
domain | XML transformation |
website | 2.0 }} |
Application
Applications often use XSLT to convert XML data into HTML or XHTML 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 schemas, 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 Consortium (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.
Concept
Overview
The XSLT processing model involves: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 functional 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.
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 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).
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).
Early XSLT processors had very few optimizations. Stylesheet documents were read into Document Object Models 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 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.
XSLT and XPath
XSLT relies upon the W3C's XPath 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.
XSLT and XQuery compared
XSLT capabilities overlap with XQuery, 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.
XSLT media types
As of 2009, there is no MIME/Internet media type 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 instruction.
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 document
Example 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 file 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, 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
References
Further reading
External links
; Documentation; Tutorials
; Mailing lists
; XSLT code libraries
; Further examples
Category:Declarative programming languages Category:Functional languages Category:Markup languages Category:Transformation languages Category:World Wide Web Consortium standards Category:XML-based programming languages Category:XML-based standards
ca:Extensible Stylesheet Language Transformations cs:XSLT da:XSLT de:XSL Transformation es:Extensible Stylesheet Language Transformations eu:XSLT fa:تبدیلات اکساسال fr:Extensible Stylesheet Language Transformations ko:XSLT id:Extensible Stylesheet Language Transformations is:XSLT it:XSL Transformations lt:XSLT hu:Extensible Stylesheet Language Transformations ms:XSLT nl:Extensible Stylesheet Language Transformations ja:XSL Transformations no:XSLT pl:XSL Transformations pt:XSLT ru:XSLT simple:XSLT fi:XSLT sv:XSLT tr:XSLT uk:XSL Transformations vi:XSLT bat-smg:XSLT zh:XSLTThis text is licensed under the Creative Commons CC-BY-SA License. This text was originally published on Wikipedia and was developed by the Wikipedia community.