cancel
Showing results for 
Search instead for 
Did you mean: 

how to create FCC if my xml contains full of attributes?

venkatanarayana_vagu
Active Participant
0 Kudos

Hello all,

Suppose if my xml contains full of attributes as given an example xml. How to create the recordset structure for the xml?

mlns:md="http:// noname/xi/Demo">

<Publisher>Demo</md:Publisher>

<Source>Demo</md:Source>

<md:Description>Demo</md:Description>

<md:Creator>Demo</md:Creator>

<md:Date>2007-08-31</md:Date>

<md:Time>13:49:34</md:Time>

<md:Identifier>EAHARPCTX13</md:Identifier>

<Value flag1="1" date="2005-06-01" flag2="1" percentFlag2="100.00">0.114</Value>

<Value flag1="1" date="2005-06-02" flag2="1" percentFlag2="100.00">0.11</Value>

How to proceed please ignite me on this.

Edited by: Venkat Babu on Jul 7, 2008 11:49 AM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Venkat,

Assuming you have a non-XML source file, you can use a workaround like this -

Use File Content Conversion to create both elements and attributes as elements i.e. your FCC converted structure would look something like -

<Parent_node>
<subnode1>value1</subnode1>
<attribute11>attribute_value</attribute11>
<attribute12>attribute_value</attribute12>
<subnode2>value2</subnode2>
<attribute21>attribute_value</attribute21>
<attribute22>attribute_value</attribute22>
<subnode3>value3</subnode3>
<attribute31>attribute_value</attribute31>
   u2026....
   u2026....
</Parent_node>

Now, in the message mapping, use a two step mapping. In the first mapping, convert the attribute elements to actual attributes using graphical mapping and appropriate data types/message types (In the data type you can define both elements and attributes, see [this link|http://www.riyaz.net/blog/index.php/2008/05/20/xipi-convert-flat-file-to-deeply-nested-xml-structures-using-only-graphical-mapping/]). Thus you will have the desired structure with your elements and attributes. Then in the second mapping do the actual mapping to convert the source to target structure.

To see how to use two-step mapping within interface mapping see [this link|http://www.riyaz.net/blog/index.php/2008/05/20/xipi-convert-flat-file-to-deeply-nested-xml-structures-using-only-graphical-mapping/].

Hope this helps.

Regards,

Riyaz

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Venkat,

If I understood your question correctly, then this morning I had exactly the same question as you. Since I couldn't find any information online, I decided to experiment with a test program. I found out that working with attributes is almost the same as working with elements. Here is my test:

In the source message, Type and Value are attributes that contain values (the Element element does not contain any value). The mapping program checks if the "Type" attribute equals "N"; if so, then the value of the attribute "Value" is mapped to the "Result" element in the target message (otherwise, the whole source element is ignored). Below is also a small sample test file you can use to see the program in action.

MT_Source

Element 1..unbounded

Type optional xsd:string

Value optional xsd:string

MT_Target

Result 1..unbounded xsd:string

Mapping steps for "Result"

(unfortunately no graphics)

Use the equalsS function to compare Type (with context changed to MT_Source) with a constant "N".

Put the result from the above into the if argument of an ifWithoutElse.

Put Value (with context changed to MT_Source) in the else argument.

Put the of the ifWithoutElse result into Result.

This is what the Text preview should look like:

/ns0:MT_Target/Result=ifWithoutElse([keepss=false]stringEquals(/ns0:MT_Source/Element/@Type=, const([value=N])), /ns0:MT_Source/Element/@Value=)

And here is the XML test data:

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

<ns0:MT_Source xmlns:ns0="urn:chplanet-ca:examples">

<Element Type="A" Value="z"/>

<Element Type="N" Value="5"/>

<Element Type="O" Value="@"/>

</ns0:MT_Source>

Change the namespace above to your own, then import this file in the test tab and play with the values to see the different results.

I hope it helps.

Carlos

venkatanarayana_vagu
Active Participant
0 Kudos

Hi Carlos,

Thanx for the practical one. But in that example you taken the source Element_1 as not element but for target side Result_1 is the element.

But in my case both source and target should have the element and subelements should have lot of attributes, in that case is this test will work?

Also important is you didn't mention any thing about FCC recordset structure description. Is it same as elements scenario or any thing need to add more?

Edited by: Venkat Babu on Jul 8, 2008 6:22 AM