on 10-16-2007 5:29 AM
I have a recursive structure involved mapping requirement. here is the issue simplified...
Source is a details about person which has a element called father which itself is of the type person. Target is just a list or person with n father attribute. Target has to have all the persons, father and father's father with no limitation. Below are the XSDs and XML for source and target. I know I can do this in java or abap mapping or even xslt, but is it possible to achieve this in the mapping too? Any help will be appreciated and rewarded.
No where in the forum or blog I could find a sample mapping.
<b>Sorry for the long post</b>
Thanks
<b>Source XML</b>
<?xml version="1.0" encoding="UTF-8"?>
<ns0:PersonsMT xmlns:ns0="http://xyz.com/scratchpad">
<Persons>
<Person>
<Name>Smith</Name>
<Height>22</Height>
<Father>
<Name>Paul</Name>
<Height>23</Height>
<Father>
<Name>Sr Paul</Name>
<Height>23</Height>
<Father/>
</Father>
</Father>
</Person>
<Person>
<Name>Brad</Name>
<Height>22</Height>
<Father>
<Name>Luke</Name>
<Height>23</Height>
<Father/>
</Father>
</Person>
</Persons>
</ns0:PersonsMT>
<b>Expected output:</b>
<?xml version="1.0" encoding="UTF-8"?>
<ns0:PersonsListOutputMT xmlns:ns0="http://xyz.com/scratchpad">
<Persons>
<Person>
<Name>Smith</Name>
<Height>22</Height>
</Person>
<Person>
<Name>Paul</Name>
<Height>23</Height>
</Person>
<Person>
<Name>Sr Paul</Name>
<Height>23</Height>
</Person>
<Person>
<Name>Brad</Name>
<Height>22</Height>
</Person>
<Person>
<Name>Luke</Name>
<Height>23</Height>
</Person>
</Persons>
</ns0:PersonsListOutputMT>
<b>Source Schema:</b>
<i>Message Type: PersonsMT</i>
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://xyz.com/scratchpad" targetNamespace="http://xyz.com/scratchpad">
<xsd:element name="PersonsMT" type="PersonsDT" />
<xsd:complexType name="PersonDT">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">
34bfd3107ba111dcc4e600188b447e47
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="Name" type="xsd:string">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">
56bf53607b7d11dca285000f1ffb32b9
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="Height" type="xsd:string">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">
56bf53617b7d11dcc38a000f1ffb32b9
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="Father" type="PersonDT">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">
56bf53627b7d11dccc3d000f1ffb32b9
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="PersonsDT">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">
34bd89227ba111dcc2fa00188b447e47
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="Persons" maxOccurs="unbounded">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">
9915e6707b7d11dcadc7000f1ffb32b9
</xsd:appinfo>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Person" type="PersonDT">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">
9915e6717b7d11dc8f84000f1ffb32b9
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
<b>Target Schema:</b>
<i>Message Type: PersonsListOutputMT</i>
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://xyz.com/scratchpad" targetNamespace="http://xyz.com/scratchpad">
<xsd:element name="PersonsListOutputMT" type="PersonListOutputDT" />
<xsd:complexType name="PersonListOutputDT">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">
380defd37ba511dcb27400188b447e47
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="Persons" maxOccurs="unbounded">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">
edfc5ae07b9e11dca41b001422795f21
</xsd:appinfo>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Person">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">
edfc5ae17b9e11dcb186001422795f21
</xsd:appinfo>
</xsd:annotation>
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Name">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">
edfc5ae27b9e11dc9e93001422795f21
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="Height">
<xsd:annotation>
<xsd:appinfo source="http://sap.com/xi/TextID">
edfc5ae37b9e11dcb5e1001422795f21
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
Message was edited by:
xi_ted
Message was edited by:
xi_ted
Hi,
Can you please cheack your generated source and target WSDL. According to me, you need some modification in that. You can generate xd using xmlspy.
context will be the problem in graphical mapping as well as xslt. So best is to go for java mapping for this.
In graphical mapping you can generate required target provided you know max hirarchy for father. In that case its possible to use graphical mapping.
-Kavita
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
in message mapping this can be achieved by duplicating target structures in mapping. duplicate target "Person".
the first node to be mapped to source "Person"
secnd to source father with appropriate context.
jus try this... hope it helps.
regards,
latika.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.