tags:

views:

778

answers:

3

Hi, I have a structured XML file format that needs to be mapped to a flatter XML format. Ordinarily I would create a custom XSLT file for this and have the BizTalk map use it. However, I do like the idea of using the graphical maps where possible - it's all too easy to dive straight into XSLT but not so easy for those following you to quickly understand what the map's doing!

I suspect that the mapping could be acheived using the table looping function and table extractor functoid but I've tried for a couple of hours and failed :(

Note: I have no control over the source XSD - this comes from a third party. Here it 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 summarise, I need to look into Trips, grab the VehicleRegistration from Vehicle, keyed on VehicleId and copy the data across to the target schema.

Does anyone know whether / how this could be achieved using only functoids (or perhaps a little script in a scripting functoid)?

Many thanks, Rob.

A: 

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

The source schema shown above make it look like you should be able to do it just with a looping functoid given you can have multiple .

Victor
A: 

Hi Victor, sorry I don't follow you - I have provided the actual schemas?

Rob Bowman
A: 

is it possible to get a sub sample of the expected xml? how about an idea of how you expect your response 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.

ie.

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

Unless you use XSLT, i dont think you can maintain the order of the element sequence otherwise.

Victor