Java Reference
In-Depth Information
Referencing variables
Once a variable has been created, you can reference it using XPath expressions. Prefix the
variable name with a dollar sign to access its data. Perhaps the best way to understand the path
referencing of data within a variable is to see an example. Say that you have the following
type defined:
<xsd:complexType name="Book">
<xsd:sequence>
<xsd:attribute name="title" type="xsd:string" minOccurs="1"/>
<xsd:element name="author" type="my:Author" minOccurs="1"/>
</xsd:sequence>
</xsd:complextType>
<xsd:complexType name="Author">
<xsd:sequence>
<xsd:element name="firstName" type="xsd:string"/>
<xsd:element name="lastName" type="xsd:string"/>
</xsd:sequence>
</xsd:complextType>
Given a BPEL variable like this:
<variables>
<variable name="aCookbook" messageType="my:Book"/>
</variables>
You could find out the last name of the author using an expression like this, skipping the ele-
ment name:
$aCookbook/author/lastName
An alternative syntax that you'll sometimes see is the more verbose built-in function
bpel:getVariableProperty("variableName", "propertyQName") . This is a BPEL
XPath extension that can be used to get data from a global property.
You can use full XPath expressions to reference variables. For example, rather than pointing
directly to a physical path down the tree, you can use indexes within your expressions to find
matching elements.
Say that you have a schema that defines a Books complex type that in turn holds a collection
of Book complex types. Each Book (as in the schema example above) has a title attribute.
You could reference the third title in the collection of Books like this:
//your bpel variable:
<bpel:variable name="Books" type="soa:Books" />
//this expression gets the third title:
Search WWH ::




Custom Search