2. This tutorial explains how to develop a
DataWeave transformation from XML to
Java Object.
Pre-requisite:
Anypoint Studio 5.2.0
Mule ESB Runtime 3.7.1
xml input files.
Input XML File
<user>
<name>Annie</name>
<lastName>Point</lastName>
</user>
5. In the transform code I created the Object type in
the header
“ %type user = :object { class:
"testweave.User"} ”
And the payload of the transform is converted to
User Object using the transform logic as below.
{
firstName: payload.user.name,
lastName: payload.user.lastName
} as :user
6.
7. package testweave;
public class User {
private String firstName;
private String lastName;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
@Override
public String toString() {
// TODO Auto-generated method stub
return this.firstName+" "+this.lastName;
}
}