Skip to Content
author's profile photo Former Member
Former Member

Challenging Message Mapping Question

Hi,

I have a source XML:

<root>

<record>

<itemA>

<id>1</id>

</itemA>

<itemB>

</itemB>

<itemA>

<id>2</id>

</itemA>

<itemA>

<id>3</id>

</itemA>

<itemB>

</itemB>

</record>

</root>

And, the target needs to look like:

<root>

<record>

<itemA>

<id>1</id>

</itemA>

<itemB>

<id>1</id>

</itemB>

<itemA>

<id>2</id>

</itemA>

<itemA>

<id>3</id>

</itemA>

<itemB>

<id>3</id>

</itemB>

</root>

In summary:

1. (easy) an element "itemB/id" needs to be created only when "itemB" exists. In the target XSD, "itemB/id" is optional.

2. (hard or impossible) the value of "itemB/id" is equal to the "itemA/id" right before it in the source XML.

Is this possible?

Thanks in advance for any help,

Bill

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Sep 08, 2006 at 01:51 PM

    hi,

    what if you would take values to one array (assuming you have SP14 - global array) in UDF

    and then in the table you'd have:

    A has a value 1

    B exits context change

    A has a value 2

    B does not exit nothing in the array

    A has a value 3

    so you would end up with

    an array like:

    1

    context

    2

    3

    then based on this I believe you could

    create correct context changes in RECORD tag

    (you can check the array - <b>if a context exists

    fill itemB it with i = i -1</b> )

    and fill them correctly in <itemA> and <itemB>

    I didn't test it but maybe it could be possible ?

    Regards,

    michal

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 08, 2006 at 01:51 PM

    Really weird XML...

    Can you give me your XSD of your XML?

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 08, 2006 at 02:04 PM

    Hi William ,

    Please confirm your data types .

    If you have data types like this-

    Source Data type

    =================

    <recordSet>1..1

    <record> 1..unbounded

    <itemA> 0..1

    <id> 0..1

    <itemB>0..1

    <id> 0..1

    Target Data type

    ==================

    <recordSet>1..1

    <record> 1..unbounded

    <itemA> 0..1

    <id> 0..1

    <itemB>0..1

    <id> 0..1

    Then you can attain the target structure mapping you expected ..

    Sample test data with source and target message types..

    Please confirm this ..

    Source Structure -

    =================

    <root>

    <recordSet>

    <record>

    <itemA>

    <id>1</id>

    </itemA>

    <itemB>

    </itemB>

    </record>

    <record>

    <itemA>

    <id>2</id>

    </itemA>

    </record>

    <record>

    <itemA>

    <id>3</id>

    </itemA>

    <itemB>

    </itemB>

    </record>

    </recordSet>

    </root>

    Target Structure -

    =================

    <root>

    <recordSet>

    <record>

    <itemA>

    <id>1</id>

    </itemA>

    <itemB>

    <id>1</id>

    </itemB>

    </record>

    <record>

    <itemA>

    <id>2</id>

    </itemA>

    </record>

    <record>

    <itemA>

    <id>3</id>

    </itemA>

    <itemB>

    <id>3</id>

    </itemB>

    </record>

    </recordSet>

    </root>

    Please let me know if you need any further information

    Nanda

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Nanda,

      Unfortunately, <itemA> and <itemB> are not grouped together by <record>. Pls see the original post.

      I admit, this XML document does not conform to the spirit of the XML standard. It contains structure/hiearchial information which cannot be determined just by looking at the XSD.

      But, this is the document created by the source system, with that embedded information. And, it cannot be changed.

      Regards,

      Bill

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.