DocToDOM function In an Assign Statement Examples

You can use these examples as models to see how DocToDom functions in an Assign Statement.

In the following example, the nodes returned are attached to process data at the root node:


<assign to="." from="DocToDOM(PrimaryDocument)"></assign>

In the following example, additional XPath (Test1) executes against the document to return only the nodes that exist under Test1. The result is then attached to process data, under the message_test node:


<assign to="message_test" from=" DocToDOM(PrimaryDocument)/Test1"></assign>

In following example, validation is turned off and enables the DTD to load:


<assign to="." from="DocToDOM(PrimaryDocument, 'false','false')"/>

The following BPML example shows the assign statement:


<process name="DocToDOM">
  <sequence>
   <assign to="." from="DocToDOM(PrimaryDocument)"></assign>
  </sequence>
</process>

This function runs an XPath query against the process data DOM and saves the node into a workflow document:


DOMToDoc(xpath expression [, document_name, standalone, root_name, encoding, 
systemURL, dtdName, publicURL ])

The following parameters are shown in the previous example:

  • XPath expression – XPath query to execute against the process data DOM tree. Required.
  • documentName – Name of the workflow document. The default value is Document. Optional.
  • standAlone – Value indicating whether this document is a single document (stands alone). Default value is no. Optional.
  • rootName – Name of the document element that stores the result of the XPath query. This entire node is written to the workflow document. If a name is not provided, the document element stores the root node returning from the XPath query. Optional.
  • encoding – String value that builds the encoding section of the XML header and specifies the encoding type of the workflow document. If an encoding is not provided, the default parameter is UTF-8. Optional.

The next set of parameters rebuilds the DOCTYPE element that was lost after executing the XPath query:

  • systemURL – Value of the system URL. Optional.
  • dtdName – Value of the DTD name. If a value for this parameter is specified, the publicURL parameter is ignored. Optional.
  • publicURL – Value of the public URL. If a value for this parameter is specified, the DtdName parameter is ignored. Optional.

The following example shows the use of the DOMToDoc function in an assign statement:


<assign to="message_test" from="DOMToDoc(Testplan)"></assign>

The XPath specified in the following example identifies the nodes that exist below the root node. Therefore, do not specify the root element in your XPath expression:


<Root>
 <Testplan>
  <Test1>some data</Test1>
 </Testplan>
</Root>

If you want to return the text in the Test1 node then my XPath will be:


DOMToDoc(Testplan/Test1/text())  Correct.
DOMToDoc(//Root/Testplan/Test1/text())  Wrong.  Don't specify the root node in the 
xpath query.