cancel
Showing results for 
Search instead for 
Did you mean: 

add a root node and namespace declaration

Former Member
0 Kudos

According to the requirement,I have a large appended .txt file.

This .txt file is created by appending various xml files (without the namespace and root node).

I need to add a root node and namespace declaration to the large appended .txt file so that it can be read as .xml.

Please provide the pointers for the same.

Thanks & Regards,

Rashi

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Rashi,

While doing content conversion, fill values for Recordset Name and Recordset Namespace. The communication channel will now create a root node using Recordset Name and namespace as Recordset Namespace at runtime before sending the message to Integration engine. And do not use "ignoreRecordsetName = true" property in FCC.

And let me know how it goes.

Rewards points if useful.

Regards,

Nikhil

Former Member
0 Kudos

Hi All,

I was able to meet this requirement with the help of shell script in Run Operating System Command after message processing.

The shell script was written in a way that it added the xml declaration tag(<?xml version="1.0" encoding="UTF-8"?>) and root node(Say <ns0:MT_Result >) in the final.xml file.

After these two lines,the content of appended.txt was added.

And then I added a closing tag for the root node(In this case </ns0:MT_Result >).

The final.xml looks like below-

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

<ns0:MT_Result>

<input>

<Store>

<StoreHeader>

<StoreNbr>56</StoreNbr>

<StoreType>Retail</StoreType>

<StoreSite>2004</StoreSite>

</StoreHeader>

<Transactions>

<Transaction>

<Item>A</Item>

<ItemPrice>4</ItemPrice>

</Transaction>

<Transaction>

<Item>C</Item>

<ItemPrice>56</ItemPrice>

</Transaction>

</Transactions>

</Store>

</input>

<input>

<Store>

<StoreHeader>

<StoreNbr>56</StoreNbr>

<StoreType>Retail</StoreType>

<StoreSite>2004</StoreSite>

</StoreHeader>

<Transactions>

<Transaction>

<Item>A</Item>

<ItemPrice>4</ItemPrice>

</Transaction>

<Transaction>

<Item>C</Item>

<ItemPrice>56</ItemPrice>

</Transaction>

</Transactions>

</Store>

</input>

</ns0:MT_Result>

Regards,

Rashi

Former Member
0 Kudos

Use XSLT /Java mapping in the operation mapping before any message mapping.

The XSLT/Java mapping should add the root node and namespace. Hope this helps.

Former Member
0 Kudos

if these appended XML files are of the same stucture can u try this

when u define ur message type remove the namespace from ur message type and make sure the occurrence is unbounded

Former Member
0 Kudos

Since the structure is an external definition, I cannot change the occurence.

Former Member
0 Kudos

Since the structure is an external definition, I cannot change the occurence.

Use an XML editor like altova XML SPy or Oxygen's Opensource editor to easily edit the occurence field

Regards,

Krishna

baskar_gopalakrishnan2
Active Contributor
0 Kudos

You can implement using XSLT or java mapping. You might not able to use XMLAnonymizerbean in this case.

You might want to check for how to use java mapping

http://wiki.sdn.sap.com/wiki/display/XI/JavamappingwithDOMandSAXparsersinnewmappingAPI(PI+7.1)

Former Member
0 Kudos

My appended file looks like following.

<input>

<Store>

<StoreHeader>

<StoreNbr>56</StoreNbr>

<StoreType>Retail</StoreType>

<StoreSite>2004</StoreSite>

</StoreHeader>

<Transactions>

<Transaction>

<Item>A</Item>

<ItemPrice>4</ItemPrice>

</Transaction>

<Transaction>

<Item>C</Item>

<ItemPrice>56</ItemPrice>

</Transaction>

</Transactions>

</Store>

</input>

<input>

<Store>

<StoreHeader>

<StoreNbr>123</StoreNbr>

<StoreType>Retail</StoreType>

<StoreSite>2004</StoreSite>

</StoreHeader>

<Transactions>

<Transaction>

<Item>A</Item>

<ItemPrice>4</ItemPrice>

</Transaction>

<Transaction>

<Item>B</Item>

<ItemPrice>8</ItemPrice>

</Transaction>

<Transaction>

<Item>C</Item>

<ItemPrice>56</ItemPrice>

</Transaction>

</Transactions>

</Store>

</input>

Now according to the requirement, I need to add namespace and root node and make it like follows:

<ns0:output xmlns:ns0="http://xxx">

<input>

<Store>

<StoreHeader>

<StoreNbr>56</StoreNbr>

<StoreType>Retail</StoreType>

<StoreSite>2004</StoreSite>

</StoreHeader>

<Transactions>

<Transaction>

<Item>A</Item>

<ItemPrice>4</ItemPrice>

</Transaction>

<Transaction>

<Item>C</Item>

<ItemPrice>56</ItemPrice>

</Transaction>

</Transactions>

</Store>

</input>

<input>

<Store>

<StoreHeader>

<StoreNbr>123</StoreNbr>

<StoreType>Retail</StoreType>

<StoreSite>2004</StoreSite>

</StoreHeader>

<Transactions>

<Transaction>

<Item>A</Item>

<ItemPrice>4</ItemPrice>

</Transaction>

<Transaction>

<Item>B</Item>

<ItemPrice>8</ItemPrice>

</Transaction>

<Transaction>

<Item>C</Item>

<ItemPrice>56</ItemPrice>

</Transaction>

</Transactions>

</Store>

</input>

</ns0:output>