Table of Contents

Search

  1. Preface
  2. Part 1: Using Process Developer
  3. Part 2: Creating and Modifying Processes
  4. Part 3: Functions, Events, Errors, and Correlation
  5. Part 4: Testing and Deployment
  6. Part 5: Process Central and Process Server (On-Premises)

Process Developer

Process Developer

bpel:doXslTransform(style-sheet-uri node-set)

bpel:doXslTransform(style-sheet-uri node-set)

Returns the result of an XSL transformation of a single element node set using the specified style sheet.
Parameters:
  • style-sheet-uri
    : URI for the XSL file.
  • node-set
    : XPath node set providing the source document for the transformation.
Example syntax:
bpel:doXslTransform("project:/myStylesheets/A2B.xsl", $A)
Optional parameters (must appear in pairs if specified)
  • string
    : XPath string parameter providing the qualified name of an XSLT parameter.
  • object
    : XPath object parameter providing the value for the named XSLT parameter.
Examples
The following examples show complex document transformation and iterative document construction.
Example 1. Complex Document Transformation.
A common pattern in a WS-BPEL process involves receiving an XML document from one service, converting it to a different schema to form a new request message, and sending the new request to another service. Such document conversion can be accomplished using XSLT via the
bpel:doXslTransform
function, as shown in the following example.
<variables> <variable name="A" element="foo:AElement" /> <variable name="B" element="bar:BElement" /> </variables> ... <sequence> <invoke ... inputVariable="..." outputVariable="A" /> <assign> <from> bpel:doXslTransform("urn:stylesheets:A2B.xsl", $A) </from> <to variable="B" /> </assign> <invoke ... inputVariable="B" ... /> </sequence>
In the sequence, a service is invoked, and the result (
foo:AElement)
copied to variable A. The assign activity transforms the contents of variable A to
bar:BElement
, and copies the result to variable B. Variable B is used to invoke another service. The style sheet,
A2B.xsl
, contains the XSL rules for converting documents of schema
foo:AElement
to schema
bar:BElement
.
Example 2. Iterative Document Construction.
Suppose that a document is constructed by repeatedly calling a service and accumulating the result in a variable, as shown in the following example:
<variables> <variable name="PO" element="foo:POElement" /> <variable name="OutVar" element="foo:ItemElement" /> </variables> <!-- ... PO is initialized ... --> <!-- Iteratively add more items to PO until complete --> <while> <condition>...</condition> <sequence> <!-- Fetch next chunk into OutVar --> <invoke ... inputVariable="..." outputVariable="OutVar"/> <assign> <copy> <from> <expression> bpel:doXslTransform ( "urn:stylesheets:AddToPO.xsl", $PO, "NewItem", $OutVar) </expression> </from> <to variable="PO" /> </copy> </assign> </sequence> </while>
The optional parameters given in the
doXslTransform
call specify that the XSLT parameter named
NewItem
is set with the value of the process variable
OutVar
. To allow the XSLT style sheet access to this value, it contains a global (top-level) parameter with a name matching that given in the third parameter of the function call shown above.
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" ...> <!-- NewItem variable set by WS-BPEL process; defaults to empty item --> <xsl:param name="NewItem"> <foo:itemElement /> </xsl:param> ... </xsl:transform>
The style sheet contains a template that appends the value of global parameter NewItem (the value of
OutVar
from the process instance) to the existing list of items in the PO variable.
<!-- line 1 --> <xsl:template match="foo:itemElement"> <!-- line 2 --> <xsl:copy-of select="." /> <!-- line 3 --> <xsl:if test="position()=last()"> <!-- line 4 --> <xsl:copy-of select="$NewItem" /> <!-- line 5 --> </xsl:if> <!-- line 6 --> </xsl:template>
This template copies all existing items in the source document (lines 1 & 2) and appends the contents of the XSLT parameter
NewItem
to the list of items (lines 3 & 4). It tests to see if the current node is at the end of the item list (line 3) and copies the
result-tree
fragment from the XSLT parameter
NewItem
to follow the last item (line 4).
If PO has a value of:
<foo:poElement> <foo:itemElement>item 1</foo:itemElement> </foo:poElement>
at the beginning of an iteration of the while loop and the invoke activity returns a value of
<foo:itemElement>item 2</foo:itemElement>
, evaluation of the from expression will result in a value of:
<foo:poElement> <foo:itemElement>item 1</foo:itemElement> <foo:itemElement>item 2</foo:itemElement> </foo:poElement>
When the copy operation completes, it becomes the new value of the PO variable.
Adding an XSL Style Sheet to Process Server
A style sheet that you reference in a
doXslTransform
function is automatically recognized by Process Developer and is added to a BPR archive for deployment.

0 COMMENTS

We’d like to hear from you!