Nav
You are viewing an older version of this section. Click here to navigate to the latest version.

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.

Important: Mule uses XStream 1.4.2. The XML-to-object transformer is vulnerable to CVE-2013-7285. A remote attacker can send messages to an XML to Object transformer and can achieve remote code execution (RCE). For more information, contact MuleSoft Customer Support.   

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:

    XML2Object

  • Advanced - Optionally configure the properties standard to all transformers, plus add or change class aliases and class converters.

    XML2ObjectAdv

    • 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-to-object-ref.png


         
      
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?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>