In order to provide a more consistent experience with the System Center product family, we've moved the Orchestrator blog to another blog at http://blogs.technet.com/b/orchestrator. Be sure to go there for all the latest info!
Note: The workflow sample mentioned in this article can be downloaded from the Opalis project on CodePlex: http://opalis.codeplex.com
This is a collection of Workflows that demonstrates how to parse and transform XML data using the Query XML and Apply XSLT Activities.
Launch the Workflow named ‘0.Setup’ by using Start or by running it using the Testing Console. The Workflow will create a sample XML file named ‘authors.xml’ on the C: drive. This sample XML file will be used by the Query XML example Workflows. The XML file ‘authors.xml’ has following contents:
<?xml version="1.0" encoding="ISO-8859-1"?> <authors> <author> <name>Mike Galos</name> <nationality>French</nationality> </author> <author period="modern"> <name>Eva Corets</name> <nationality>English</nationality> </author> <author> <name>Cynthia Randall</name> <nationality>Canadian</nationality> </author> <author> <name>Stefan Knorr</name> <nationality>Canadian</nationality> </author> <author period="modern"> <name>Paula Thurman</name> <nationality>English</nationality> </author> </authors>
This Workflow extracts information from an XML file and sends Opalis Platform Events to display the results. The Query XML Activity ‘XPath Query’ extracts the names from the sample XML file by using an XPath query ‘//author/name’:
The Send Platform Event Activity displays the XML query result by subscribing to the appropriate Published Data from the ‘XPath Query’ Activity:
Launch the Workflow ‘1. XPath Example’ by using Start, or by running it using the Testing Console. Check the Opalis Designer Events tab or the Testing Console log to see the resulting output:
This Workflow is similar to ‘1. XPath Example’ as it extracts information from an XML file and sends Opalis Platform Events to display the results. The Query XML Activity ‘XPath Query with Filter’ extracts the names for English authors from the sample XML file by using an XPath query ‘//author[nationality='English']/name’:
The Send Platform Event Activity displays the XML query result by subscribing to the appropriate Published Data from the ‘XPath Query with Filter’ Activity.
Launch the Workflow ‘2. XPath Example’ by using Start, or by running it using the Testing Console. Check the Opalis Designer Events tab or the Testing Console log to see the resulting output:
This Workflow is the same as the Workflow named ‘1. XPath Example’, except that the ‘Run Behavior’ properties of the Query XML Activity ‘XPath Query (FLATTEN) is configured to flatten the multi-value Published Data and return a delimited string instead that uses ‘;’ as the separation character:
Launch the Workflow ‘3. XPath Example’ by using Start, or by running it using the Testing Console. Check the Opalis Designer Events tab or the Testing Console log to see the resulting output:
Launch the Workflow named ‘0.Setup’ by using Start or by running it using the Testing Console. The Workflow will create a sample XML file named ‘authors.xml’ on the C: drive. This sample XML file will be used by the Transform XML example Workflow. The XML file ‘authors.xml’ has following contents:
<?xml version="1.0" encoding="iso-8859-1"?> <authors> <author> <name>Mike Galos</name> <nationality>French</nationality> </author> <author period="modern"> <name>Eva Corets</name> <nationality>English</nationality> </author> <author> <name>Cynthia Randall</name> <nationality>Canadian</nationality> </author> <author> <name>Stefan Knorr</name> <nationality>Canadian</nationality> </author> <author period="modern"> <name>Paula Thurman</name> <nationality>English</nationality> </author> </authors>
The Workflow also creates a sample XSL file named ‘authors.xsl’ on the C drive. This sample XSL file will also be used by the Transform XML example Workflow. The XSL file ‘authors.xsl’ has following contents:
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:for-each select="//author"> <xsl:value-of select="name"/>;<xsl:value-of select="nationality"/> </xsl:for-each> </xsl:template> </xsl:stylesheet>
This Workflow applies an XSL Tranformation to the sample XML file. The resulting text file is read and the contents displayed. The Apply XSLT is used to transform the XML data into a text file:
The Get Lines Activity reads all lines from the resulting text file ‘authors_transformed.txt’:
The Send Platform Event Activity displays the resulting output:
Launch the Workflow ‘1. Transform XML to Text’ by using Start, or by running it using the Testing Console. Check the Opalis Designer Events tab or the Testing Console log to see the resulting output:
Refer to the Query XML and Transform XML Activity Online Help.