cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping problem!!

Former Member
0 Kudos

My source and target "Structures" are similar, following is the xsd...


<?xml version="1.0" encoding="ISO-8859-1"?>

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:testmap.com" targetNamespace="urn:testmap.com">
	<xsd:element name="shipment" type="shipment" />
	<xsd:complexType name="shipment">
		<xsd:annotation>
			<xsd:appinfo source="http://sap.com/xi/TextID">
			c03352d0204a11dc80c80002556a8e03
			</xsd:appinfo>
		</xsd:annotation>
		<xsd:sequence>
			<xsd:element name="Header">
				<xsd:annotation>
					<xsd:appinfo source="http://sap.com/xi/TextID">
					a0437870204911dc84170019b9313caf
					</xsd:appinfo>
				</xsd:annotation>
				<xsd:complexType>
					<xsd:sequence>
						<xsd:element name="InvoiceNo" type="xsd:string">
							<xsd:annotation>
								<xsd:appinfo source="http://sap.com/xi/TextID">
								a0437871204911dcc8bc0019b9313caf
								</xsd:appinfo>
							</xsd:annotation>
						</xsd:element>
						<xsd:element name="OrderNo" type="xsd:string">
							<xsd:annotation>
								<xsd:appinfo source="http://sap.com/xi/TextID">
								a0437872204911dca6c60019b9313caf
								</xsd:appinfo>
							</xsd:annotation>
						</xsd:element>
						<xsd:element name="Date" type="xsd:string">
							<xsd:annotation>
								<xsd:appinfo source="http://sap.com/xi/TextID">
								a0437873204911dc82e80019b9313caf
								</xsd:appinfo>
							</xsd:annotation>
						</xsd:element>
					</xsd:sequence>
				</xsd:complexType>
			</xsd:element>
			<xsd:element name="Sequence" minOccurs="0" maxOccurs="unbounded">
				<xsd:annotation>
					<xsd:appinfo source="http://sap.com/xi/TextID">
					a0437874204911dccc790019b9313caf
					</xsd:appinfo>
				</xsd:annotation>
				<xsd:complexType>
					<xsd:sequence>
						<xsd:element name="Currency" type="xsd:string">
							<xsd:annotation>
								<xsd:appinfo source="http://sap.com/xi/TextID">
								a0437875204911dc97050019b9313caf
								</xsd:appinfo>
							</xsd:annotation>
						</xsd:element>
						<xsd:element name="OrderNo" type="xsd:string">
							<xsd:annotation>
								<xsd:appinfo source="http://sap.com/xi/TextID">
								a0437876204911dc8b720019b9313caf
								</xsd:appinfo>
							</xsd:annotation>
						</xsd:element>
						<xsd:element name="SeqNo" type="xsd:string">
							<xsd:annotation>
								<xsd:appinfo source="http://sap.com/xi/TextID">
								a0437877204911dcb9590019b9313caf
								</xsd:appinfo>
							</xsd:annotation>
						</xsd:element>
					</xsd:sequence>
				</xsd:complexType>
			</xsd:element>
			<xsd:element name="LineItem" minOccurs="0" maxOccurs="unbounded">
				<xsd:annotation>
					<xsd:appinfo source="http://sap.com/xi/TextID">
					a0437878204911dcbbf60019b9313caf
					</xsd:appinfo>
				</xsd:annotation>
				<xsd:complexType>
					<xsd:sequence>
						<xsd:element name="SeqNo" type="xsd:string">
							<xsd:annotation>
								<xsd:appinfo source="http://sap.com/xi/TextID">
								a0437879204911dca83e0019b9313caf
								</xsd:appinfo>
							</xsd:annotation>
						</xsd:element>
						<xsd:element name="ItemNo" type="xsd:string">
							<xsd:annotation>
								<xsd:appinfo source="http://sap.com/xi/TextID">
								a043787a204911dca6d40019b9313caf
								</xsd:appinfo>
							</xsd:annotation>
						</xsd:element>
						<xsd:element name="Cost" type="xsd:string">
							<xsd:annotation>
								<xsd:appinfo source="http://sap.com/xi/TextID">
								a043787b204911dcb5dc0019b9313caf
								</xsd:appinfo>
							</xsd:annotation>
						</xsd:element>
					</xsd:sequence>
				</xsd:complexType>
			</xsd:element>
		</xsd:sequence>
	</xsd:complexType>
</xsd:schema>

<b>I am receiving following xml from source service :-</b>


<?xml version="1.0" encoding="UTF-8"?>

<ns0:shipment xmlns:ns0="urn:testmap.com">
   <Header>
      <InvoiceNo>100</InvoiceNo>
      <OrderNo>ord1</OrderNo>
      <Date>2005-23-02</Date>
   </Header>
   <Sequence>
      <Currency>USD</Currency>
      <OrderNo>ord1</OrderNo>
      <SeqNo>1</SeqNo>
   </Sequence>
   <LineItem>
      <SeqNo>1</SeqNo>
      <ItemNo>1</ItemNo>
      <Cost>23</Cost>
   </LineItem>
   <LineItem>
      <SeqNo>1</SeqNo>
      <ItemNo>2</ItemNo>
      <Cost>54</Cost>
   </LineItem>
   <Sequence>
      <Currency>USD</Currency>
      <OrderNo>ord1</OrderNo>
      <SeqNo>2</SeqNo>
   </Sequence>
   <LineItem>
      <SeqNo>2</SeqNo>
      <ItemNo>1</ItemNo>
      <Cost>900</Cost>
   </LineItem>
   <LineItem>
      <SeqNo>2</SeqNo>
      <ItemNo>2</ItemNo>
      <Cost>478</Cost>
   </LineItem>
</ns0:shipment>

And I "<b>need</b>" to convert it to:-


<?xml version="1.0" encoding="UTF-8"?>

<ns0:shipment xmlns:ns0="urn:testmap.com">
   <Header>
      <InvoiceNo>100</InvoiceNo>
      <OrderNo>ord1</OrderNo>
      <Date>20052302</Date>
   </Header>
   <Sequence>
      <Currency>USD</Currency>
      <OrderNo>ord1</OrderNo>
      <SeqNo>1</SeqNo>
   </Sequence>
   <LineItem>
      <SeqNo>1</SeqNo>
      <ItemNo>1</ItemNo>
      <Cost>23</Cost>
   </LineItem>
   <LineItem>
      <SeqNo>1</SeqNo>
      <ItemNo>2</ItemNo>
      <Cost>54</Cost>
   </LineItem>
   <Sequence>
      <Currency>USD</Currency>
      <OrderNo>ord1</OrderNo>
      <SeqNo>2</SeqNo>
   </Sequence>
   <LineItem>
      <SeqNo>2</SeqNo>
      <ItemNo>1</ItemNo>
      <Cost>900</Cost>
   </LineItem>
   <LineItem>
      <SeqNo>2</SeqNo>
      <ItemNo>2</ItemNo>
      <Cost>478</Cost>
   </LineItem>
</ns0:shipment>

I added date transformation function in GUI map(date function works fine!!)

But XI's graphical mapping has <b>changed</b> structure to:-


<?xml version="1.0" encoding="UTF-8"?>
<ns0:shipment xmlns:ns0="urn:testmap.com">
<Header>
	<InvoiceNo>100</InvoiceNo>
	<OrderNo>ord1</OrderNo>
	<Date>20052302</Date>
</Header>
<Sequence>
	<Currency>USD</Currency>
	<OrderNo>ord1</OrderNo>
	<SeqNo>1</SeqNo>
</Sequence>
<Sequence>
	<Currency>USD</Currency>
	<OrderNo>ord1</OrderNo>
	<SeqNo>2</SeqNo>
</Sequence>
<LineItem>
	<SeqNo>1</SeqNo>
	<ItemNo>1</ItemNo>
	<Cost>23</Cost>
</LineItem><LineItem>
	<SeqNo>1</SeqNo>
	<ItemNo>2</ItemNo>
	<Cost>54</Cost>
</LineItem>
<LineItem>
	<SeqNo>2</SeqNo>
	<ItemNo>1</ItemNo>
	<Cost>900</Cost>
</LineItem>
<LineItem>
	<SeqNo>2</SeqNo>
	<ItemNo>2</ItemNo>
	<Cost>478</Cost>
</LineItem>
</ns0:shipment>

Pls observe that XI has converted it in such a way that <b>all Sequence elements appear first</b> and <b>then all LineItem elements</b>, whereas that is not our "requirement".

I guess this is due to XI's internal queue mechanism and I guess XSLT or java mapping would be required to get the structure that I need.

Does anyone has any available XSLT/Java coding for this?

Appreciate your help and points would be rewarded to all helpful answers

Accepted Solutions (1)

Accepted Solutions (1)

justin_santhanam
Active Contributor
0 Kudos

Hello,

I have imported your XSD into the Mapping editor and executed the mapping. I can suggest you one thing, but I don't know whether its feasible for you or not. I'll tell my suggestion , see you have created Data type as Header, Sequence and Line Item in the same level. Is it possible for you to create Header, Sequence and Line Item as the Sub-element of Sequence. It will solve your problem.

Header

-


Sequence

-


Line Item.

Provide your feedback on this.

Best regards,

raj.

Former Member
0 Kudos

thanks Raj,

I thought about that but it's not possible for us to change the way target xml should look like to target service(customer).I mean target service requires the xml to be created in a way where Header, sequence and LineItem are at same level

Former Member
0 Kudos

Your target structure is not valid to your XSD. The Sequence elements cannot be separated by other elements. The only way is to put Sequence and LineItem under a dummy node. Then use some post scripts to remove the start/end tags of dummy node.

justin_santhanam
Active Contributor
0 Kudos

Hi,

Please speak with the customer and ask them whether its valid structure. As kenny suggested , even I too doubt its valid structure or not. Please wait for out friends replies and decide further.

Best regards,

raj

Answers (0)