fn:system-property

Returns the value of a system property.

system-property($arg as xs:string) ➔ xs:string

Arguments

 

$arg

xs:string

The name of the system property required

Result

xs:string

Namespace

http://www.w3.org/2005/xpath-functions

Links to W3C specifications

XSLT 3.0 Specification

Saxon availability

Available in XSLT 2.0 and later versions. Available in all Saxon editions.

Notes on the Saxon implementation

As well as the standard system properties defined in the XSLT namespace, SaxonJ will return the value of a Java system property (e.g. as set using -X on the Java VM invocation) if the name is unprefixed. It does NOT return the values of operating system environment variables.

More specifically, if the argument is a name in no namespace, that is, if the name is unprefixed, then the name is taken to refer to a Java system property, and the value of that property is returned if it exists. For example, on a Windows platform, system-property('file.separator') returns "\". This can be used to obtain information from the environment, and is especially useful in conjunction with use-when conditional compilation.

Generally, if system-property() is executed at compile-time, then the results pertain to the compile-time environment, but if executed at run-time, the results pertain to the run-time environment. For example, the result of system-property('xsl:product-version') may be different if a SEF file compiled using one Saxon release is executed under another. Evaluation is always at compile-time if the function call appears in a static expression (for example in [xsl:]use-when). Where the function call appears in a dynamic expression (for example in <xsl:if test="....">), it may be evaluated statically if the argument is a string literal, but only if the stylesheet is not being compiled for execution in a different target environment. You can force run-time execution by declaring the property name as the default value of a stylesheet parameter (for example <xsl:param name="p" select="'xsl:product-version'"/>) and invoking the function as system-property($p).

For some properties, the result is configuration-dependent: