Web Analytics

See also ebooksgratis.com: no banners, no cookies, totally FREE.

CLASSICISTRANIERI HOME PAGE - YOUTUBE CHANNEL
Privacy Policy Cookie Policy Terms and Conditions
XSL Transformations - Wikipedia, the free encyclopedia

XSL Transformations

From Wikipedia, the free encyclopedia

XSL Transformations
File extension: .xsl, .xslt
MIME type: application/xslt+xml[1]
Developed by: World Wide Web Consortium
Type of format: Stylesheet language
Extended from: XML
Standard(s): 1.0 (Recommendation),
2.0 (Recommendation)
Diagram of the basic elements and process flow of Extensible Stylesheet Language Transformations.
Diagram of the basic elements and process flow of Extensible Stylesheet Language Transformations.

Extensible Stylesheet Language Transformations (XSLT) is an XML-based language used for the transformation of XML documents.

XSLT is designed to transform XML documents into other XML documents. The original document is not changed; rather, a new document is created based on the content of an existing one.[2] The new document may be serialized (output) by the processor in standard XML syntax or in another format, such as HTML or plain text.[3] XSLT is most often used to convert data between different XML schemas or to convert XML data into HTML or XHTML documents for web pages, or into an intermediate XML format that can be converted to PDF documents.

As a language, XSLT's origins lie in functional language,[4] and in text-based pattern matching languages in the tradition of SNOBOL and awk. Its most direct predecessor was DSSSL, a language that performed the same function for SGML that XSLT performs for XML. XSLT can also be considered as a template processor.

XSLT is Turing complete.[5][6][7][8]

Contents

[edit] Origins

XSLT is developed by the W3C. The current version is XSLT 2.0, which reached the status of a W3C Recommendation from the W3C on 23 January 2007. At the time of writing, however, XSLT 1.0 is more widely deployed.

XSLT was part of the Extensible Stylesheet Language (XSL) development effort within W3C during 19981999, which also produced XSL Formatting Objects (XSL-FO) and the XML Path Language, XPath. The editor of the first version (and in effect the chief designer of the language) 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 much 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 between 20022006.

Most of this article is applicable to both XSLT versions; any differences are noted in the text.

[edit] 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.

Technically, the term document here means a tree conforming to the XPath data model. In practice these documents will often be files containing lexical XML, but the specifications are careful not to rule out other representations, for example in-memory trees or streams of events.

The XSLT processor ordinarily takes two input files[9] – an XML source document, and an XSLT stylesheet – and produces an output document. The XSLT stylesheet contains the XSLT program text (or ‘source code’ in other languages) and is itself an XML document that describes a collection of template rules: instructions and other hints that guide the processor toward the production of the output document.

[edit] 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 which 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.

[edit] Processor implementations

XSLT processor implementations fall into two main categories: server-side, and client-side.

Although client-side XSLT processing has been available in Microsoft's Internet Explorer since 1999 (or even earlier, but in a form that was incompatible with the W3C specifications), adoption has been slower because of the widespread deployment of older and alternative browsers without XSLT support. For similar reasons, adoption of XSLT 2.0 in such environments is likely to be some years away.

XSLT processors may be delivered as standalone products, or as components of other software including web browsers, application servers, frameworks such as Java and .NET, or even operating systems. For example, Windows XP comes with the MSXML3 library, which includes an XSLT processor. Earlier versions may be upgraded and there are many alternatives, see the External Links section.

[edit] Performance

The performance of XSLT processors has steadily improved as the technology has become more mature, although the very first processor, James Clark's xt, was unbeaten for several years.

Most of the earlier XSLT processors were interpreters; in more recent products, 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.[10] This separation is reflected in the design of XSLT processing APIs such as JAXP (Java API for XML Processing).

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 the kind of optimization techniques found in functional programming languages and database query languages, notably static rewriting of the expression tree for example to move calculations out of loops, and lazy pipelined evaluation to reduce the use of memory for 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 much more efficient (in both space and time) than general purpose DOM implementations.


[edit] 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 2.0 relies on XPath 2.0; both specifications were published on the same date. Similarly, XSLT 1.0 works with XPath 1.0.

[edit] Examples

Sample of incoming XML document

<?xml version="1.0" ?>
<persons>
  <person username="JS1">
    <name>John</name>
    <family_name>Smith</family_name>
  </person>
  <person username="MI1">
    <name>Nancy</name>
    <family_name>Davolio</family_name>
  </person>
</persons>

[edit] Example 1 (transforming XML to XML)

This XSLT stylesheet provides templates to transform the XML document:

<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/> 

<xsl:template match="/">
       <root> <xsl:apply-templates/> </root>
</xsl:template>

<xsl:template match="//person">
        <name username="{@username}">
           <xsl:value-of select="name" />
        </name>
</xsl:template>

</xsl:stylesheet>

Its evaluation results in a new XML document, having another structure:

<?xml version="1.0" encoding="UTF-8"?>
<root>
      <name username="JS1">John</name>
      <name username="MI1">Nancy</name>
</root>

[edit] Example 2 (transforming XML to XHTML)

Example XSLT Stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match="/persons">
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head> <title>xsl wiki ex.</title> </head>
        <body>
                <h1>Persons</h1>
                <ul> 
                <xsl:apply-templates select="person">
                        <xsl:sort select="family_name" />
                </xsl:apply-templates>
                </ul>
        </body>
        </html>        
</xsl:template>

<xsl:template match="person">
        <li>
                <xsl:value-of select="family_name"/>, 
                <xsl:value-of select="name"/>           
        </li>        
</xsl:template>

</xsl:stylesheet>

XHTML output that this would produce (whitespace has been adjusted here for clarity):

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head> <title>xsl wiki ex.</title> </head>
<body>
        <h1>Persons</h1>
        <ul>
           <li>Davolio, Nancy</li>
           <li>Smith, John</li>
        </ul>
</body>
</html>
Image:xslt_ex2.gif
How the XHTML appears when rendered in a web browser.


[edit] References

  1. ^ http://www.w3.org/TR/xslt20/#xslt-mime-definition
  2. ^ http://www.w3.org/TR/xslt#section-Introduction
  3. ^ See e.g., http://www.w3.org/TR/xslt#output, specifying alternate output methods.
  4. ^ Dimitre Novatchev. Higher-Order Functional Programming with XSLT 2.0 and FXSL. ExtremeMarkupLanguages. Retrieved on January 18, 2007.
  5. ^ Kepser, Stephan. (2004).
  6. ^ A Simple Proof for the Turing-Completeness of XSLT and XQuery. International Digital Enterprise Alliance.
  7. ^ http://www.unidex.com/turing/utm.htm
  8. ^ http://www.refal.net/~korlukov/tm/
  9. ^ In this context, "document" and "file" refers to a file, a string, or any other recognizable input stream, not just a fixed file.
  10. ^ Saxon: Anatomy of an XSLT processor - An article describing the implementation and optimization details of a popular Java-based XSLT processor.

[edit] See also

[edit] External links

For implementations, see XML template engine.
Documentation
XSLT 1.0 W3C Recommendation
XSLT 2.0 W3C Recommendation
Zvon XSLT 1.0 Reference
XSL Concepts and Practical Use by Norman Walsh
Tutorial from developerWorks by IBM (1 hour)
Zvon XSLT Tutorial
XSLT Tutorial by W3 Schools
Quick tutorial
What kind of language is XSLT?
XSLT and Scripting Languages
Mailing lists
The XSLT mailing list hosted by Mulberrytech
Blogs
A commentary, news, and evangelism weblog devoted to XSLT
Books
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 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) (ISBN 0-7645-4776-3) by Jeni Tennison, published by Hungry Minds Inc, U.S. (ISBN 0-7645-4776-3)
XSLT & XPath, A Guide to XML Transformations (ISBN 0-13-040446-2) by John Robert Gardner and Zarella Rendon, published by Prentice-Hall (ISBN 0-13-040446-2)
XSLT code libraries
EXSLT is a widespread community initiative to provide extensions to XSLT.
FXSL is a library implementing support for Higher-order functions in XSLT. FXSL is written in XSLT itself.

Static Wikipedia (no images)

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - en - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu -

Static Wikipedia 2007 (no images)

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - en - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu -

Static Wikipedia 2006 (no images)

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu

Static Wikipedia February 2008 (no images)

aa - ab - af - ak - als - am - an - ang - ar - arc - as - ast - av - ay - az - ba - bar - bat_smg - bcl - be - be_x_old - bg - bh - bi - bm - bn - bo - bpy - br - bs - bug - bxr - ca - cbk_zam - cdo - ce - ceb - ch - cho - chr - chy - co - cr - crh - cs - csb - cu - cv - cy - da - de - diq - dsb - dv - dz - ee - el - eml - en - eo - es - et - eu - ext - fa - ff - fi - fiu_vro - fj - fo - fr - frp - fur - fy - ga - gan - gd - gl - glk - gn - got - gu - gv - ha - hak - haw - he - hi - hif - ho - hr - hsb - ht - hu - hy - hz - ia - id - ie - ig - ii - ik - ilo - io - is - it - iu - ja - jbo - jv - ka - kaa - kab - kg - ki - kj - kk - kl - km - kn - ko - kr - ks - ksh - ku - kv - kw - ky - la - lad - lb - lbe - lg - li - lij - lmo - ln - lo - lt - lv - map_bms - mdf - mg - mh - mi - mk - ml - mn - mo - mr - mt - mus - my - myv - mzn - na - nah - nap - nds - nds_nl - ne - new - ng - nl - nn - no - nov - nrm - nv - ny - oc - om - or - os - pa - pag - pam - pap - pdc - pi - pih - pl - pms - ps - pt - qu - quality - rm - rmy - rn - ro - roa_rup - roa_tara - ru - rw - sa - sah - sc - scn - sco - sd - se - sg - sh - si - simple - sk - sl - sm - sn - so - sr - srn - ss - st - stq - su - sv - sw - szl - ta - te - tet - tg - th - ti - tk - tl - tlh - tn - to - tpi - tr - ts - tt - tum - tw - ty - udm - ug - uk - ur - uz - ve - vec - vi - vls - vo - wa - war - wo - wuu - xal - xh - yi - yo - za - zea - zh - zh_classical - zh_min_nan - zh_yue - zu