XML data may be integrated by using the XML data type XML Document. By default, it stores the XML stream stringified in the audit trail.
Note
Note that the XML Data Type is deprecated and will be
removed in later releases. You can use the External Reference structured data type
instead, which is equivalent to the XML Data type, with the difference that it
supports XSD schema exclusively (no DTD specification). Please refer to section
Using External XSD Types of
chapter
Defining Structured Types for
details.
The main feature of XML data integration is support for XPath expressions in data mappings and transition conditions. While without this support one would have to provide a custom application, extracting appropriate parts from an XML document and providing it in form of Java data, workflow designers can now use arbitrary XPath expressions directly.
Note
Please note that only reading data via non-empty XPath expressions is
supported. Applying an empty OUT path to an XML data will extract the
stringified XML document content as stored in the audit trail. The whole
document content can be replaced by applying an empty IN data path,
accepting either the stringified XML document content in form of a java.lang.String,
an org.w3c.dom.Document or an org.w3c.dom.Element.
Especially useful when combining XML and Java data sinks and sources is
the existence of XPath number(), string() and boolean()
cast functions, providing the result of the XPath expression as either a java.lang.Double,
java.lang.String or java.lang.Boolean and thus allowing for
type safe data mappings. For detailed conversion rules, please consult the XPath
specification.
The xml data type is defined as follows in the workflow model:
<carnot:DataType Oid="10005" Id="plainXML" Name="XML Document" IsPredefined="true"> <carnot:Attributes> <carnot:Attribute Name="carnot:defdesk:accessPathEditor" Value="org.eclipse.stardust.engine.extensions.xml.data.XPathEditor"/> <carnot:Attribute Name="carnot:defdesk:icon" Value="/org/eclipse/stardust/engine/extensions/xml/data/icon.gif"/> <carnot:Attribute Name="carnot:engine:evaluator" Value="org.eclipse.stardust.engine.extensions.xml.data.XPathEvaluator"/> <carnot:Attribute Name="carnot:engine:validator" Value="org.eclipse.stardust.engine.extensions.xml.data.XMLValidator"/> <carnot:Attribute Name="carnot:engine:runtimeValidator" Value="org.eclipse.stardust.engine.extensions.xml.data.XMLValidator"/> </carnot:Attributes> </carnot:DataType>
Because native storage of XML data varies widely the source code for the implementation of this simple data type is included in the Stardust plugins. You can adapt it to your own storage needs. You find the example classes in the following zipped file:
Please refer to the Tutorial - Stardust SPI Programming chapter to guide you through the process of integrating or adapting custom applications.
To specify an XML document, first create a data as described in Specifying Data with type XML document,
then open the data properties dialog and select the XML
Document section.
Figure: XML Document properties
You can now choose the schema type from a list as:
NONE,XSD,WSDL(XSD Envelope) orDTD.If the chosen schema type is NONE (the default case), no XML
type checking occurs. No values for the Type Declaration URL
will be stored in the model.
In the next field fill in the Type Declaration URL,
containing a reference to a XSD, WSDL or DTD file.
With the Browse button open a list with corresponding element
names to choose from the specified XSD or WSDL document.
A checkbox is provided to mark XML document data as volatile. If you select this checkbox, the data values of the process data are removed from the Audit Trail on process completion. Please refer to section Marking Process Data as volatile of chapter Specifying Data for details on volatile data.
Figure: Marking the Data as volatile
To read the content of an XML file and pass it into the XML Document data, you have the following options:
XPath expressions could be for example:
fn:string(/Composite_1/f1):/Composite_1/f1: Due to the possibly very complex syntax of data path expressions in
non-Java data types, the transition condition expression language syntax was
slightly extended to support for data path quoting with a subscript-like
construct. Especially for XPath data paths it is recommended (and sometimes the
only choice) to use a transition condition syntax as of data[dataPath]
instead of data.dataPath.
To set up transition conditions with XPath expressions the Data ID has to be followed by squared brackets, in which the XPath expression is inserted starting with a leading slash, e.g.:
<DataID>["/<element1>/<subelement1>"] == <value>
Figure: Transition Condition using XPath Expression
At runtime a validation of XML type conformance will occur during
assignments, i.e. for data mappings or data path writes. If an XML type check
fails at runtime, an InvalidValueException will be thrown.