XML for data: the ability to extend XSLT with EXSLT

Source: Internet
Author: User
Tags expression extend regular expression xslt xslt processor

As has been seen in previous columns, XSLT 1.0 provides a good text-conversion capability, but it's not really perfect enough to provide good data manipulation capabilities. Objectively speaking, it never intended to do this; when you design XSLT 1.0, its creator has no way of knowing what complex usage it will have. However, the XSLT 1.0 specification does provide a mechanism for extending XSLT functionality through additional elements and functions. The relevant paragraphs in the specification are as follows:

The element extension mechanism allows the namespace to be specified as an extension namespace. When a namespace is specified as an extended namespace, and an element with the name in that namespace appears in the template, the element is considered to be an instruction rather than a literal result element. The namespace determines the semantics of the instruction. If the functionname in the Functioncall expression is not NCName (that is, if it contains a colon), then treat it as a call to an extended function. Expands the functionname into a name using the namespace declaration in the evaluation context.

This means that if the XSLT processor developer wants to add more functionality, they can do it at will-as long as the element and function names that support that feature appear in their own namespaces. One of the first achievements to take advantage of this feature is Mike Kay's Saxon XSLT processor: By including elements and attributes in the Saxon: namespaces, developers can create style sheets that perform operations on complex source documents. The disadvantage is that these stylesheets are no longer portable: they do not function properly in a Saxon processor. Similarly, some Java implementations of XSLT extend functionality by using Java: Namespaces to allow Java calls to be made directly from the stylesheet, but the stylesheet does not work on processors that do not support elements and attributes in the namespace.

What is EXSLT?

To make the XSLT extension more portable, a set of developers has created the EXSLT specification. This is an attempt to identify useful extensions to XSLT 1.0 and divide them into functional groups that can be implemented on a "menu point" basis. EXSLT work is open, and anyone who wants to make a contribution to it will be able to do so.

The EXSLT modules currently defined are:

The dates and Times provides a number of date-manipulation features, including calculating the difference between two dates, and retrieving the current date and time of the local system.

Dynamic provides a mechanism for handling dynamically generated XPath expressions to accomplish a variety of tasks, including retrieving values and selecting the minimum and maximum values.

Common provides several basic extension functions, such as the mechanism for creating multiple output files and a function that returns a string that contains the type of object passed into the function.

Functions provides a mechanism for users to define their own functions.

Math provides a simple mathematical function, such as trigonometric functions and logarithms.

Regular expressions provides regular expression processing, including a function to select a substring in a string that matches a given regular expression, and a function that replaces a matching substring with a different literal value.

Sets provides functions for node set operations, including the intersection of returning two node sets and the return of nodes that appear in one node set and not in the other.

Strings provides some very useful string manipulation functions, such as a function that puts a string into a flag element node set, and a function that connects the string values of all nodes in the Node-set.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.