Обзор модуля EXSLT - Functions
EXSLT - Functions are those extension elements and functions that allow users to define their own functions for use in expressions and patterns in XSLT.
The functions available in XPath cover only basic functionality. While a stylesheet author can often use XSLT code to achieve a goal, it would often be simpler to use a function instead. It's impossible to predict all the functions authors might need, and it also adds portability to a stylesheet if authors can write their own functions (as long as the function implementations are understood by the XSLT processor). These could be defined in any language, but the one language that XSLT processors can all understand is XSLT, so it makes sense to define functions using XSLT instructions. However, XSLT as it stands cannot support the return of values other than result tree fragments; to write functions that return node sets and so on, we need an extension element.
XSLT processors may support any number of the extension elements and functions given in this module.
Using EXSLT will only make your stylesheet portable amongst the implementations that support EXSLT. Note that there is no requirement for XSLT processors that are compliant to XSLT to support the extensions described within EXSLT.
The namespace for EXSLT - Functions is:
Throughout this document, the prefix func is used to refer to this namespace. Any other prefix can be used within a particular stylesheet (though a prefix must be specified to enable the extension functions to be recognised as extensions).
To use these extensions, you need to declare this namespace as an extension namespace in your stylesheet. If your processor supports this module, then that's all you need to do, but if it doesn't, then you need to use a specific third-party implementation or the module stylesheet. Typically, your stylesheet will look like:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:func="http://exslt.org/functions" extension-element-prefixes="func"> <xsl:import href="func.xsl" /> ... </xsl:stylesheet>
The following extension elements are considered stable and are core to EXSLT - Functions. Processors that claim support of EXSLT - Functions support these elements.
The following extension elements are not considered stable and are not part of the core of EXSLT - Functions. Processors that claim support of EXSLT - Functions might not support these elements.
15 июня 2015 г.