Designer 10.7 | webMethods Service Development Help | Building XSLT Services | Using Name/Value Pairs with an XSLT Service | Passing Name/Value Pairs from the Style Sheet to the Pipeline
 
Passing Name/Value Pairs from the Style Sheet to the Pipeline
You can write an XSLT style sheet that will create new name/value pairs and pass them to the service to put in the pipeline. You do this using an XSLT extension, which is an element that is written to support a particular function and that is not part of the standard XSLT specification.
Use the XSLT extension mechanism method named IOutputMap.put(Object name, Object value) to add name/value pairs to an output object of type IOutputMap. The IOutputMap interface (com.wm.pkg.xslt.extension.IOutputMap) defines method put().
For more information about the extension, see the webMethods WmXSLT Package Java API Reference, located in the Integration Server_directory \instances\instance_name\packages\WmXSLT\pub\doc\api directory.
*To pass name/value pairs from the XSLT style sheet to the pipeline
1. Open the XSLT style sheet.
2. Identify the IOutputMap put() method as an extension function by declaring a namespace that corresponds to the IOutputMap interface. Do this by adding the following namespace attribute within the xsl:stylesheet element:
xmlns:IOutputMap="com.wm.pkg.xslt.extension.IOutputMap"
3. Define an XSLT parameter named $output in the style sheet, as follows:
<xsl:param name="output"/>
Note:
After you define an XSLT parameter, you identify it to the XSLT processor as a variable, rather than text, by prefixing the name with a dollar sign.
Internally, the $output parameter is of type com.wm.pkg.xslt.extension.IOutputMap.
If you are using the XALAN compiling processor, you must use the xsltc:cast function to explicitly cast the $output object into com.wm.pkg.xslt.extension.IOutputMap. For example:
<xsl:variable name="outputVariable"
select="xsltc:cast('com.wm.pkg.xslt.extension.IOutputMap', $output)"/>
4. For each new name/value pair you want to add to the $output parameter, insert the following xsl:value-of element, where key identifies a name/value pair and xpath is any valid XPATH expression:
<xsl:value-of select="IOutputMap:put($output,'key',string(xpath))"/>
The style sheet passes the contents of the $output parameter to the xslParamOutput variable of the service, and the service puts the resulting document in the pipeline.
If you are using the XALAN compiling processor, you must use the outputVariable variable (described in the previous step) when adding name/value pairs to the output. For example:
<xsl:value-of select="IOutputMap:put($outputVariable,'key',
string(xpath))"/>