BizTalk Looping Functoid

I have a structured XML file format that needs to be mapped to a flatter XML format. I usually create a custom XSLT file for this and use its BizTalk map. However, I love the idea of ​​using graphics cards where possible - it's too easy to dive right into XSLT, but not so easy for those following you to quickly understand what the card does!

I suspect the matching can be achieved using the table cyclize function and the functoid table extractor, but I tried for a couple of hours and couldn't :(

Note. I have no control over the original XSD - it comes from the third person. Here he is:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"  attributeFormDefault="unqualified">
<xs:element name="VehicleTrips">
    <xs:annotation>
        <xs:documentation>Comment describing your root element</xs:documentation>
    </xs:annotation>
    <xs:complexType>
        <xs:sequence maxOccurs="unbounded">
            <xs:element name="Vehicle">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="VehicleID"/>
                        <xs:element name="VehicleRegistration"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
            <xs:element name="Trips">
                <xs:complexType>
                    <xs:sequence maxOccurs="unbounded">
                        <xs:element name="VehicleId"/>
                        <xs:element name="Distance"/>
                        <xs:element name="Duration"/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
</xs:element>

      

... and here's the target XSD:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Trips">
    <xs:annotation>
        <xs:documentation>Comment describing your root element</xs:documentation>
    </xs:annotation>
    <xs:complexType>
        <xs:sequence maxOccurs="unbounded">
            <xs:element name="VehicleRegistration"/>
            <xs:element name="Distance"/>
            <xs:element name="Duration"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>

      

To summarize, I need to examine Trips, grab VehicleRegistration from Vehicle, keyed to VehicleId, and copy the data to the target schema.

Does anyone know if this can be achieved using just functoids (or maybe a little script in the scripting functionality)?

Thanks a lot Rob.

+1


source to share


2 answers


It looks like it can be done using a loop and a boolean equal functoid. if you can provide your actual schemas or just a subsample of the data then it would be easier to figure out.



The original circuit shown above makes it look like you should only be able to do this with the looping functionality, which may have several.

0


source


Is it possible to get a subroutine of the expected xml? how about an idea of ​​what you expect your answer file to look like. Do you expect to have multiple sequences of elements under the root? I think it would be easier if your target schema had a different root node.

t.



<Trips>
   <Trip>
      <Registration />
      <Distance />
      <Duration />
   </Trip>
</Trips>

      

Unless you're using XSLT, I don't think you can preserve the order of the sequence of elements otherwise.

0


source







All Articles