Misplaced Pages

XSLT

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.

XSLT ( Extensible Stylesheet Language Transformations ) is a language originally designed for transforming XML documents into other XML documents, or other formats such as HTML for web pages , plain text , or XSL Formatting Objects . These formats can be subsequently converted to formats such as PDF , PostScript, and PNG . Support for JSON and plain-text transformation was added in later updates to the XSLT 1.0 specification.

#487512

38-455: As of August 2022, the most recent stable version of the language is XSLT 3.0, which achieved Recommendation status in June 2017. XSLT 3.0 implementations support Java, .NET, C/C++, Python, PHP and NodeJS. An XSLT 3.0 JavaScript library can also be hosted within the web browser. Modern web browsers also include native support for XSLT 1.0. For an XSLT document transformation, the original document

76-425: A 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. The <output> element can optionally take

114-401: 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

152-412: A file, these two work together as follows: mime.types associates an extension with a MIME type, while mailcap associates a MIME type with a program. In UNIX-type systems, the mime.types file is usually located at /etc/ mime.types and/or $ HOME/ .mime.types and the format is simply that each line is a space-delimited list of a MIME type, followed by zero or more extensions. For example,

190-474: A media format, but it may or must also contain other content, such as a tree prefix, producer, product or suffix, according to the different rules in registration trees. All media types should be registered using the IANA registration procedures. For the efficiency and flexibility of the media type registration process, different structures of subtypes can be registered in registration trees that are distinguished by

228-405: A media type. XDG specifications implemented by Linux desktop environments continue to use the term "MIME type". A media type consists of a type and a subtype , which is further structured into a tree . A media type can optionally define a suffix and parameters : As an example, an HTML file might be designated text/html; charset=UTF-8 . In this example, text is the type, html

266-424: A registration done by a third party. The personal or vanity tree includes media types associated with non publicly available products or experimental media types. It uses the prs. tree prefix. Examples are audio/prs.sid , image/prs.btif . The unregistered tree includes media types intended exclusively for use in private environments and only with the active agreement of the parties exchanging them. It uses

304-527: Is Turing-complete , making it theoretically capable of arbitrary computations. XSLT is influenced by functional languages , and by text-based pattern matching languages like SNOBOL and AWK . Its most direct predecessor is DSSSL , which did for SGML what XSLT does for XML. The XSLT processor takes one or more XML source documents, plus one or more XSLT stylesheets, and processes them to produce one or multiple output documents. In contrast to widely implemented imperative programming languages like C , XSLT

342-427: Is declarative . The basic processing paradigm is pattern matching. 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:

380-401: Is defined by RFC 1524 "A User Agent Configuration Mechanism for Multimedia Mail Format Information" but is not defined as an Internet standard. It is supported by most Unix systems. Lines can be comments starting with the # character, or a mime-type followed by how to handle that mime type. An associated file is the mime.types file, which associates filename extensions with a MIME type . If

418-432: 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

SECTION 10

#1732782453488

456-406: Is not changed; rather, a new document is created based on the content of an existing one. Typically, input documents are XML files, but anything from which the processor can build an XQuery and XPath Data Model can be used, such as relational database tables or geographical information systems . While XSLT was originally designed as a special-purpose language for XML transformation, the language

494-680: Is the data model shared by the XPath 2.0, XSLT 2.0, XQuery , and XForms programming languages. It is defined in a W3C recommendation . Originally, it was based on the XPath 1.0 data model which in turn is based on the XML Information Set . The XDM consists of flat sequences of zero or more items which can be typed or untyped, and are either atomic values or XML nodes (of seven kinds: document, element, attribute, text, namespace, processing instruction, and comment). Instances of

532-500: Is the subtype, and charset=UTF-8 is an optional parameter indicating the character encoding. Types, subtypes, and parameter names are case-insensitive. Parameter values are usually case-sensitive, but may be interpreted in a case-insensitive fashion depending on the intended use. The "type" part defines the broad use of the media type. As of November 1996, the registered types were: application , audio , image , message , multipart , text and video . By July 2024,

570-716: The x. tree prefix. Examples are application/x.foo , video/x.bar . Media types in this tree cannot be registered. This type was originally defined in RFC 1590 (published in September 1993) using the x- or X- prefix. RFC 2048 (published in November 1996) introduced the x. prefix, but discouraged use of the unregistered tree, as new personal and vendor trees with relaxed registration requirements are now available. The current RFC 6838 (published in January 2013) maintains

608-668: The Internet , and also used on Linux desktop systems. The Internet Assigned Numbers Authority (IANA) is the official authority for the standardization and publication of these classifications. Media types were originally defined in Request for Comments RFC   2045 (MIME) Part One: Format of Internet Message Bodies (Nov 1996) in November 1996 as a part of the MIME (Multipurpose Internet Mail Extensions) specification, for denoting type of email message content and attachments; hence

646-573: 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. In June 2014, Debbie Lockett and Michael Kay introduced an open-source benchmarking framework for XSLT processors called XT-Speedo. XQuery and XPath Data Model The XQuery and XPath Data Model (XDM)

684-454: The IESG, be registered in the standards tree with its unprefixed subtype. application/x-www-form-urlencoded is an example of a widely deployed type that ended up registered with the x- prefix. Suffix is an augmentation to the media type definition to additionally specify the underlying structure of that media type, allowing for generic processing based on that structure and independent of

722-485: The MIME type is properly set, this is unnecessary, but MIME types may be incorrectly set, or set to a generic type such as application/octet-stream , and mime.types allows one to fall back on the extension in these cases. Similarly, since many file systems do not store MIME type information, but instead rely on the filename extension, a mime.types file is frequently used by web servers to determine MIME type. When viewing

760-480: The XDM can optionally be XML schema-validated . Internet media type In information and communications technology , a media type , content type or MIME type is a two-part identifier for file formats and content formats . Their purpose is comparable to filename extensions and uniform type identifiers , in that they identify the intended data format. They are mainly used by technologies underpinning

798-567: The XML document: Its evaluation results in a new XML document, having another structure: 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 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

SECTION 20

#1732782453488

836-404: The attribute media-type , which allows one to set the media type (or MIME type) for the resulting output, for example: <xsl:output output="xml" media-type="application/xml"/> . The XSLT 1.0 recommendation recommends the more general attribute types text/xml and application/xml since for a long time there was no registered media type for XSLT. During this time text/xsl became

874-740: The case of 1.0 and 2.0, the XSLT and XPath specifications were published on the same date. With 3.0, however, they were no longer synchronized; XPath 3.0 became a Recommendation in April 2014, followed by XPath 3.1 in February 2017; XSLT 3.0 followed in June 2017. XSLT functionalities overlap with those of 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

912-463: The context. Industry consortia as well as non-commercial entities can register media types in the vendor tree. A registration in the vendor tree may be created by anyone who needs to interchange files associated with some software product or set of products. However, the registration belongs to the vendor or organization producing the software that employs the type being registered, and that vendor or organization can at any time elect to assert ownership of

950-540: The de facto standard. In XSLT 1.0 it was not specified how the media-type values should be used. With the release of the XSLT 2.0, the W3C recommended in 2007 the registration of the MIME media type application/xslt+xml and it was later registered with the Internet Assigned Numbers Authority . Pre-1.0 working drafts of XSLT used text/xsl in their embedding examples, and this type

988-424: The exact type's particular semantics. Media types that make use of a named structured syntax should use the appropriate IANA registered "+"suffix for that structured syntax when they are registered. Unregistered suffixes should not be used (since January 2013). Structured syntax suffix registration procedures are defined in RFC 6838. The +xml suffix has been defined since January 2001 (RFC 3023 ), and

1026-463: The original name, MIME type . Media types are also used by other internet protocols such as HTTP , document file formats such as HTML , and the XDG specifications implemented by Linux desktop environments , for similar purposes. Different internet standards or web standards bodies differ on the preferred term for this type of identifier. The IANA and IETF use the term "media type", and consider

1064-477: The processor to either create nodes in the result tree, or to process more nodes in the source tree in the same way as the root node. Finally the result tree is serialized as XML or HTML text. XSLT uses XPath to identify subsets of the source document tree and perform calculations. XPath also provides a range of functions , which XSLT itself further augments. XSLT 1.0 uses XPath 1.0, while XSLT 2.0 uses XPath 2.0. XSLT 3.0 will work with either XPath 3.0 or 3.1. In

1102-661: The registered types included the foregoing, plus font , example , model , and haptics . An unofficial top-level type in common use is chemical , used for chemical file formats . In the context of Linux desktop environments , the unofficial top-level types inode ( inodes other than normal files, such as filesystem directories , device files or symbolic links ), x-content ( removable media , such as x-content/image-dcf for DCF digital cameras ), package ( package manager packages) and x-office (generic categories of office productivity software document) are used. A subtype typically consists of

1140-434: The result tree, which is the basis of the processor's output. A typical processor behaves as follows. First, assuming a stylesheet has already been read and prepared, the processor builds a source tree from the input XML document. It then processes the source tree's root node, finds the best-matching template for that node in the stylesheet, and evaluates the template's contents. Instructions in each template generally direct

1178-410: The same recommendation, but subtypes prefixed with x- or X- are no longer considered to be members of this tree. Media types that have been widely deployed (with a subtype prefixed with x- or X- ) without being registered, should be, if possible, re-registered with a proper prefixed subtype. If this is not possible, the media type can, after an approval by both the media types reviewer and

XSLT - Misplaced Pages Continue

1216-642: 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

1254-440: The standards tree must be either associated with IETF specifications approved directly by the IESG, or registered by an IANA recognized standards-related organization. The vendor tree includes media types associated with publicly available products. It uses the vnd. tree prefix. Examples are: application/vnd.ms-excel , application/vnd.oasis.opendocument.text . The terms "vendor" and "producer" are considered equivalent in

1292-546: 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 (which say the type should be application/xslt+xml ), but it is the only media type that is widely supported across browsers as of 2009, and the situation is unchanged in 2021. Most early XSLT processors were interpreters. More recently, code generation

1330-579: The term "MIME type" to be obsolete, since media types have become used in contexts unrelated to email, such as HTTP. By contrast, the WHATWG continues to use the term "MIME type" and discourages use of the term "media type" as ambiguous, since it is used with a different meaning in connection with the CSS @media feature. The HTTP response header for providing the media type is Content-Type . The W3C has used ContentType as an XML data-type name for

1368-581: The use of tree prefixes. Currently the following trees are created: standard (no prefix), vendor ( vnd. prefix), personal or vanity ( prs. prefix), unregistered ( x. prefix). These registration trees were first defined in November 1996 (obsoleted RFC 2048 - currently RFC 6838). New registration trees may be created by IETF Standards Action for external registration and management by well-known permanent organizations (e.g. scientific societies). The standards tree does not use any tree prefix. Examples are text/javascript , image/png . Registrations in

1406-619: Was formally included in the initial contents of the Structured Syntax Suffix Registry along with +json , +ber , +der , +fastinfoset , +wbxml , and +zip in January 2013 (RFC 6839). Subsequent additions include +gzip , +cbor , +json-seq , and +cbor-seq . From the IANA registry: Mailcap (derived from the phrase "mail capability") is a type of meta file used to configure how MIME-aware applications such as mail clients and web browsers render files of different MIME-types. The mailcap format

1444-542: Was implemented and continued to be promoted by Microsoft in Internet Explorer and MSXML circa 2012. 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 were obliged to use this unregistered media type. These examples use the following incoming XML document: This XSLT stylesheet provides templates to transform

#487512