Table of Contents
The implementation provides certain information about the
environment and other information. To access this, use the p:system-property() function, which is
provided as an extension to xpath functions.
This pipeline, adapted from the Xproc test suite shows them in use
CR lists them all
An input sysprop.xml file provides a template
<?xml version="1.0" encoding="utf-8"?>
<doc>
<episode value="???"/>
<language value="???"/>
<product-name value="???"/>
<product-version value="???"/>
<vendor value="???"/>
<vendor-uri value="???"/>
<version value="???"/>
<xpath-version value="???"/>
<psvi-supported value="???"/>
</doc>
Example 6.1 shows the pipeline
Example 6.1. Retrieving system properties into a template
<?xml version="1.0" encoding='utf-8'?>
<p:pipeline name="sypropTest"
xmlns:p="http://www.w3.org/ns/xproc">
<p:string-replace match="/doc/episode/@value">
<p:with-option name="replace"
select="concat('"',p:system-property('p:episode'),
'"')"/>
</p:string-replace>
<p:string-replace match="/doc/language/@value">
<p:with-option name="replace"
select="concat('"',p:system-property('p:language'),
'"')"/>
</p:string-replace>
<p:string-replace match="/doc/product-name/@value">
<p:with-option name="replace"
select="concat('"',
p:system-property('p:product-name'),
'"')"/>
</p:string-replace>
<p:string-replace match="/doc/product-version/@value">
<p:with-option name="replace"
select="concat('"',
p:system-property('p:product-version'),
'"')"/>
</p:string-replace>
<p:string-replace match="/doc/vendor/@value">
<p:with-option name="replace"
select="concat('"',
p:system-property('p:vendor'),
'"')"/>
</p:string-replace>
<p:string-replace match="/doc/vendor-uri/@value">
<p:with-option name="replace"
select="concat('"',
p:system-property('p:vendor-uri'),
'"')"/>
</p:string-replace>
<p:string-replace match="/doc/version/@value">
<p:with-option name="replace"
select="concat('"',
p:system-property('p:version'),
'"')"/>
</p:string-replace>
<p:string-replace match="/doc/xpath-version/@value">
<p:with-option name="replace"
select="concat('"',
p:system-property('p:xpath-version'),
'"')"/>
</p:string-replace>
<p:string-replace match="/doc/psvi-supported/@value">
<p:with-option name="replace"
select="concat('"',
p:system-property('p:psvi-supported'),
'"')"/>
</p:string-replace>
</p:pipeline>
Neither input nor output are explicit, both are specified from the command line, to the implementation | |
The | |
The replacement text including the quotes is obtained from the extended xpath function - the episode in this case. This returns a string which should be unique for each invocation of the pipeline processor. |
The calabash usage is as shown below
[dpawson@marge tests]$ calabash.sh -i source=sysprop.xml -o result=op.xml sysprop.xpl
The resultant output is
[dpawson@marge tests]$ cat op.xml <doc> <episode value="CB12fc1b7ff65cc123fbdc1e9db6c22ddc"/> <language value="en_US"/> <product-name value="XML Calabash"/> <product-version value="0.9.2"/> <vendor value="Norman Walsh"/> <vendor-uri value="http://xmlcalabash.com/"/> <version value="1.0"/> <xpath-version value="2.0"/> <psvi-supported value="false"/> </doc>
There are other ways of using the properties although this shows them as a complete set which may be useful.