Forum Stats

  • 3,769,600 Users
  • 2,252,990 Discussions
  • 7,875,117 Comments

Discussions

URGENT: Complex Tranformation Scenario.

user570355
user570355 Member Posts: 88
edited Oct 4, 2008 10:41AM in BPEL
Gurus, I have the following transformation sceanrio:
Need to know few approaches how it could be done.

I have a source XML schema which holds GL Account information. More specifically, it holds a row in GL_Code_Combinations table. It has a list of segment columns as follows:

<xs:element name="segment1" minOccurs="0" nillable="true">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="25"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="segment2" minOccurs="0" nillable="true">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="25"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
and so on...

I have a target XML schema which is used to hold the same information, however, the XML schema strucuture on this side is very generic. It uses an array of GLElement elements.
E.g.
<xsd:complexType name="GLAccountType">
<xsd:sequence>
<xsd:element ref="GLElement" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>

Now each GLElement is used to hold one segment.

Now I want to transform my source document to target. But no clue.
The difficulty here is,
1) Simple for-each is not feasible here. Because on source end, i do not have array of elements, but a list of different elements. So can't iterate over them using an index.

2) The number of segments used varies depending on the ChartOfAccounts used. So, in some documents let's say only 1 to 5 segments are used and in some other let's say 1 to 7. Now in this cases, segments 2 and 3 may be null since they are allowed to have null values. So "first null encounter" can not be a test to determine the number of elements used.

I can work out details myself. Need to know few approaches.
Thanks in advance for any help you can provide.

Best regards-
Ashish.
Tagged:

Answers

  • 642905
    642905 Member Posts: 46
    In fact i am also having a very very similar scenario and looking for pointers. I have one more additional requirement though , i want the element name in the above example segment1 , segment2 etc too in the transformation ie the output xml for me would be name=segment1, value='X' (what ever value).
  • user570355
    user570355 Member Posts: 88
    Well, for that additional requirement, I guess you could use local-name or name function available in the Node-set functions list under component palette in Tranformation design window.

    There are workarounds in my case:
    Prepare your query in such a way that the resultant schema will try to emulate your target schema structure. However, it is not a garceful way of achieving what i want.

    -Ashish.
  • 642905
    642905 Member Posts: 46
    I will check this local-name function , but i will not be able to modify my schema to match the resultant schema , so i would need some other way.

    Thanks
    -Pradip
  • user570355
    user570355 Member Posts: 88
    Pradip, if number of segments is going to be fixed in your case, then probably you can use insert-after operation of assign activity.
    For each such segment, perform insert-after under assign activity once and then try to assign the values.

    However, this is not usable if number of segments varies as in my case.

    Thanks-
    Ashish.
  • 642905
    642905 Member Posts: 46
    Hi
    Can you please post an example / mail an example to me or point me to some docs. It would be very useful for me.

    Thanks
    -Pradip
This discussion has been closed.