Mapping flat XML data into structured XML

Home Page Forums BizTalk 2004 – BizTalk 2010 Mapping flat XML data into structured XML

Viewing 2 reply threads
  • Author
    Posts
    • #17854

      I have XML that is organized in a flat format, and I need to map it into logical XML nodes.

      The data is structured like:
      Name      Joe
      Address  123 Anywhere
      Phone     555-1212
      Name      Sam
      Address  33 E West
      Phone     555-2121

      And the source XML looks like:
      <Root>
        <Record>
          <Column0>Name</Column0>
          <Column1>Address</Column1>
          <Column2>Phone</Column2>
        </Record>
        <Record>
          <Column0>Joe</Column0>
          <Column1>123 Anywhere</Column1>
          <Column2>555-1212</Column2>
        </Record>
        <Record>
          <Column0>Sam</Column0>
          <Column1>33 E West</Column1>
          <Column2>555-2121</Column2>
        </Record>
      </Root>

      I need to map the source XML to XML of the form:

      <Root>
        <Users>
          <User>
            <Name>Joe</Name>
            <Address>123 Anywhere</Address>
            <Phone>555-1212</Name>
          </User>
          <User>
            <Name>Sam</Name>
            <Address>33 E West</Address>
            <Phone>555-2121</Name>
          </User>
        </Users>
      </Root>

      I have attempted using the equality and value mapping functoids to conditionally build the resulting user node, but I the aggregation of the multiple record iterations is not being captured correctly and I end up with:

      <Root>
        <Users>
          <User>
            <Name>Joe</Name>
          </User>
          <User>
            <Address>123 Anywhere</Address>
          </User>
          <User>
            <Phone>555-1212</Name>
          </User>
          <User>
            <Name>Sam</Name>
          </User>
          <User>
            <Address>33 E West</Address>
          </User>
          <User>
            <Phone>555-2121</Name>
          </User>
        </Users>
      </Root>

      Then I tried using the table looping and table extractor functoids, but have not been able to have it produce valid XML.  Any help will be greatly appreciated.

      Thanks,

      Robby
       

    • #17882

      Robby,

      are the elements correct in your output schema?

      Try the following examples as you can download and refer to them to see how they are built:

      http://msdn2.microsoft.com/en-us/biztalk/aa937647.aspx

       

      Hope this helps. 

      • #17885

        Henry,

        Thanks for your reply.  Yes, the elemens are correct in my output schema.  I took a look at the table looping functoid example and the looping functoid example.  I attempted to use both of those for my particular problem, but the issue I keep running up against is that the transformations (mappings) occur in an iterative fashion where it is assumed that everything you need in the target node is provided at that instance.  With my issue, the assembling of the target nodes requires information from multiple source nodes.

        I was able to get the desired results by using the index functoid.  I have described the problem and my solution in a blog posting http://blogs.fpoint.com/?p=106.  I am not convinced that my solution is a preferred way to achieve this, and would greatly appreciate if it could be looked at to determine if it is an okay way to use the mapper.

        Thanks,

        Robby Powell

    • #17886

      Robby –

      Link <Record> to the Looping functoid and then link that to <User>

      The results you are getting look like maybe you have Column0, Column1 and Column2 linked to the looping functoid.

      -wa 

       

Viewing 2 reply threads
  • The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.