Fandom

File Formats Wiki

XSLT

261pages on
this wiki
Add New Page
Talk0 Share
XSLT
Blank

Filename extension .xsl, .xslt
Internet media type application/xslt+xml
Extended from XML
Type Stylesheet language
Standard XSLT 1.0
XSLT 2.0
File formats category - v  e   edit
Smallwikipedialogo.png Wikipedia has an article related to:

XSLT (Extensible Stylesheet Language Transformations) is a declarative, XML-based language used for the transformation of XML documents into other XML documents.

XSLT may also be used to output non-XML data, such as HTML, plain text or binary data, from an input XML document. XSLT is also used to translate XML messages between different schemas, or to format an XML document correctly.

OverviewEdit

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 processingEdit

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.

XSLT uses the halfway-to-even ("banker's") method when rounding fractional numbers to integers.

XSLT and XPathEdit

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.

SyntaxEdit

An XSLT stylesheet is an XML document containing the root node xsl:stylesheet or xsl:transform (synonymous to each other), where the xsl namespace is the XSLT namespace defined with the URI xmlns:xsl=http://www.w3.org/1999/XSL/Transform.

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> ...

PatternsEdit

A pattern is an XPath expression that matches a corresponding node in the source document.

TemplatesEdit

A template (defined by xsl:template) declaration contains rules for creating nodes and values such as text and numbers. A template declaration usually has the match attribute, which contains a pattern to match the template with. Matched nodes on the source document will be evaluated by the contents of the template element to transform into output.

External linksEdit

This page uses CC-BY-SA content from Wikipedia (authors). Smallwikipedialogo.png

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.