XML to Object Transformer Reference
You can use an XML to Object transformer to transform XML data to a Java Object (also referred to as Java Bean graphs) using XStream.
Minimum Configuration: The name of the XStream driver class.
An XML-to-Object transformer transforms XML data using the specified XStream driver class.
In addition to the properties common to all transformers, you can also specify class aliases and converters.
Configuring XML to Object
Tabs:
-
General - Specify or browse to the XStream driver class:
-
Advanced - Optionally configure the properties standard to all transformers, plus add or change class aliases and class converters.
-
Use the Aliases pane to create, edit, or delete aliases for specific classes.
-
Use the Converters pane to create, edit, or delete class converters.
-
Code Example
The following example converts XML to Object passed to Groovy for processing. The results are logged.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core
http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/xml
http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/http
http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/scripting
http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration"/>
<flow name="Catalog_DownloaderFlow1" >
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
<mulexml:xml-to-object-transformer doc:name="XML to Object"/>
<scripting:component doc:name="Groovy">
<scripting:script engine="Groovy" file="myScript.groovy"/>
</scripting:component>
<logger level="INFO" doc:name="Logger"/>
</flow>
</mule>