system-property


system-property

The system-property() function returns information about the processing environment.

For example, with a processor that implements XSLT version 2.0, the expression «system-property ('xsl:version') » returns 2.0 .

Changes in 2.0

Several new system properties have been defined in XSLT 2.0.

The result of the function is now always a string. In XSLT 1.0 (although the spec was not a hundred percent clear on the point) the «xsl:version » system property was returned as a number.

Signature

Argument

Data Type

Meaning

name

xs:string

Specifies the name of the system property required. The value of the string should be in the form of a lexical QName that identifies a system property. If there is no system property with this name, the function returns a zero-length string.

Result

xs:string

The value of the requested system property.

Effect

The supplied argument is converted into an expanded name using the namespace declarations in scope for the stylesheet element that contains the call on system-property() .

There are several system properties that every implementation must support. These are all in the XSLT namespace, and are listed as follows . The first three were available in XSLT 1.0, the others are new in XSLT 2.0.

System Property

Value

xsl:version

A number giving the version of XSLT implemented by the processor. For conformant XSLT processors, this will be 1.0 or 2.0. For processors that provide a partial implementation, or an implementation of intermediate working drafts, other versions may be returned. It's a good idea to write your stylesheet on the assumption that new XSLT versions may be introduced in the future.

xsl:vendor

A string identifying the vendor of the XSLT processor. In practice it will sometimes also identify the product name, but the actual value is implementation defined. For Microsoft's MSXML3 product, the value is simply «Microsoft » .

xsl:vendor-url

A string: the URL of the vendor's Web site. For example, MSXML3 returns « http://www.microsoft.com »

xsl:product

This property is new in XSLT 2.0. It is intended to identify the product name of the XSLT processor, for example «Xalan » or «Saxon » .

xsl:product-version

This property is new in XSLT 2.0. It is intended to identify which version of the XSLT processor is being used, for example «7.6.5 » . If there are several variants of a product (for example Xalan-C and Xalan-J), it is up to the implementer whether the variant is returned as part of the product name or as part of the product version.

xsl:is-schema-aware

This property returns the string «yes » or «no » , depending on whether the XSLT 2.0 processor is schema aware or not.

xsl:supports-serialization

This property returns the string «yes » or «no » , depending on whether the XSLT 2.0 processor supports serialization or not.

xsl:supports- backwards - compatibility

This property returns the string «yes » or «no » , depending on whether the XSLT 2.0 processor supports running in backwards-compatibility mode. A processor that does not support this mode will report an error if «version= " 1.0 " » is specified. In the early life of XSLT 2.0 it is likely that all implementations will support this mode, but the Working Group felt that once XSLT 2.0 has become fully established in the market, vendors should be allowed to make a commercial decision as to whether or not their customers still needed this feature.

Any additional system properties returned by this function are implementer defined. Any implementer-defined properties should be in a namespace specific to the vendor.

Usage

The system-property() function can be used to determine details about the processor running the stylesheet, either for display purposes (for example, to produce a comment in the generated output), or to apply conditional logic.

Generally, it is best to avoid using this function to test whether particular features are available, unless there is no other way of doing so. The functions function-available() and element-available() and the <xsl:fallback> instruction often serve this need better, and the forwards-compatibility features described on page 124, in Chapter 3 can be used to ensure that a stylesheet can work with processors that implement an older dialect of XSLT.

However, there are some cases where testing «system-property ('xsl:version') » is the only practical way of discovering whether a feature is available. For example, the XSLT 2.0 working draft introduces the ability to use a tree-valued variable (or a result tree fragment, as it is known in XSLT 1.0) as a document node, in contexts such as <xsl:for-each> and <xsl:apply-templates> . Since this feature does not introduce any new functions or XSLT elements, the only practical way to test whether it is available is to check the XSLT version supported.

Examples

The following code outputs a documentary comment into the generated HTML.

  <HTML>   <xsl:comment>   Generated using XSLT stylesheet abc.xsl   using <xsl:value-of select="system-property('xsl:product')"/>   version <xsl:value-of select="system-property('xsl:product-version')"/>   </xsl:comment>   . . .  

See Also

  • element-available() page 542.

  • function-available() on page564.

  • <xsl:fallback> on page 271 in Chapter 5.




XSLT 2.0 Programmer's Reference
NetBeansв„ў IDE Field Guide: Developing Desktop, Web, Enterprise, and Mobile Applications (2nd Edition)
ISBN: 764569090
EAN: 2147483647
Year: 2003
Pages: 324

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net