XSLT文件:
<?xml version="1.0"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:saxon="http://saxon.sourceforge.net/"
xmlns:System="ext://java.lang.System">
<!--========================================-->
<!-- get variable from OS environment. -->
<!--========================================-->
<xsl:variable name="v_env" select="System:getenv('TEMP')" />
<!--===============================================-->
<!-- get variable from Java System Properties. -->
<!--===============================================-->
<xsl:variable name="v_prop" select="System:getProperty('os.name')" />
<xsl:template match="/">
env[TEMP] = <xsl:value-of select="$v_env"/>
props[os.name] = <xsl:value-of select="$v_prop"/>
</xsl:template>
</xsl:stylesheet>
测试方法:
执行结果:
<?xml version="1.0" encoding="UTF-8"?>
env[TEMP] = C:\Users\myaccount\AppData\Local\Temp
props[os.name] = Windows 7