locked
Mapping multiple element nodes to repeating records RRS feed

  • Question

  • This should be a very simple issue:

    in this image http://www.drewoconnor.com/AMO/question.jpg you can see that i have weight and BMI mapped to the same element node within a looping record. How do I make these two items appear as looping items within a single patient?

    It does not seem to be a looping table or looping functiod - both make all the results appear at the end of the file and not within their respective patient.

    thanks for the help,

    Drew
    Monday, February 22, 2010 10:27 PM

Answers

  • I'd consider the Xslt Script funcoid and using <xsl:for-each> operator to loop.

    It is not clear what you want. Could you, please, add an exaple of the source and target data?
    Leonid Ganeline [BizTalk MVP] Biztalkien blog
    • Marked as answer by ScubaDrew Tuesday, February 23, 2010 1:04 PM
    Monday, February 22, 2010 10:47 PM
    Moderator
  • Based on description in the original post and map screen shot, here is my understanding about input and output instances of xml (ignored non-mapped nodes for the sake of simplicity).

    Drew, Please validate this and let us know if this is not the way you have your xml.

    Input:
    <BIO>
    <Header />

    <BIO_Child2>
    <ssn>11111</ssn>
    <last>last1</last>
    <first>first1</first>
    <record_date>01-01-2010</record_date>
    <dob>01-10-1972</dob>
    <gender>M</gender>
    <weight>170</weight>
    <bmi>24</bmi>
    </BIO_Child2>

    <BIO_Child2>
    <ssn>11111</ssn>
    <last>last1</last>
    <first>first1</first>
    <record_date>02-01-2010</record_date>
    <dob>01-10-1972</dob>
    <gender>M</gender>
    <weight>165</weight>
    <bmi>23</bmi>
    </BIO_Child2>

    <BIO_Child2>
    <ssn>2222</ssn>
    <last>last2</last>
    <first>first2</first>
    <record_date>01-10-2010</record_date>
    <dob>03-10-1975</dob>
    <gender>F</gender>
    <weight>145</weight>
    <bmi>25</bmi>
    </BIO_Child2>

    <BIO_Child2>
    <ssn>2222</ssn>
    <last>last2</last>
    <first>first2</first>
    <record_date>02-10-2010</record_date>
    <dob>03-10-1975</dob>
    <gender>F</gender>
    <weight>135</weight>
    <bmi>22</bmi>
    </BIO_Child2>

    </BIO>


    Output:

    <ImportResults>

    <Import>
    <Patient>
    <ssn>11111</ssn>
    <last>last1</last>
    <first>first1</first>
    <dob>01-10-1972</dob>
    <gender>M</gender>
    </Patient>
    <Results>

    <NumericResult>
    <CaptureDate>01-01-2010</CaptureDate>
    <Value>170;24</Value>
    </NumericResult>

    <NumericResult>
    <CaptureDate>02-01-2010</CaptureDate>
    <Value>165;23</Value>
    </NumericResult>
    </Results>

    </Import>

    <Import>
    <Patient>
    <ssn>2222</ssn>
    <last>last2</last>
    <first>first2</first>
    <dob>03-10-1975</dob>
    <gender>F</gender>
    </Patient>
    <Results>

    <NumericResult>
    <CaptureDate>01-10-2010</CaptureDate>
    <Value>145;25</Value>
    </NumericResult>

    <NumericResult>
    <CaptureDate>02-10-2010</CaptureDate>
    <Value>135;22</Value>
    </NumericResult>

    </Results>
    </Import>

    </ImportResults>


    I think, Custom XSLT using <xsl:for-each> may be the way to get desided output as Leonid suggested.

    HTH,

    Please mark it as answer by clicking on "Propose As Answer", if it helps
    • Marked as answer by ScubaDrew Tuesday, February 23, 2010 1:04 PM
    Tuesday, February 23, 2010 4:39 AM

All replies

  • I'd consider the Xslt Script funcoid and using <xsl:for-each> operator to loop.

    It is not clear what you want. Could you, please, add an exaple of the source and target data?
    Leonid Ganeline [BizTalk MVP] Biztalkien blog
    • Marked as answer by ScubaDrew Tuesday, February 23, 2010 1:04 PM
    Monday, February 22, 2010 10:47 PM
    Moderator
  • I think you should be able to do this without resorting to an XSLT script functoid. Just use the looping functoid. Can you post an example of the input message and desired output message?
    Tuesday, February 23, 2010 12:19 AM
  • Based on description in the original post and map screen shot, here is my understanding about input and output instances of xml (ignored non-mapped nodes for the sake of simplicity).

    Drew, Please validate this and let us know if this is not the way you have your xml.

    Input:
    <BIO>
    <Header />

    <BIO_Child2>
    <ssn>11111</ssn>
    <last>last1</last>
    <first>first1</first>
    <record_date>01-01-2010</record_date>
    <dob>01-10-1972</dob>
    <gender>M</gender>
    <weight>170</weight>
    <bmi>24</bmi>
    </BIO_Child2>

    <BIO_Child2>
    <ssn>11111</ssn>
    <last>last1</last>
    <first>first1</first>
    <record_date>02-01-2010</record_date>
    <dob>01-10-1972</dob>
    <gender>M</gender>
    <weight>165</weight>
    <bmi>23</bmi>
    </BIO_Child2>

    <BIO_Child2>
    <ssn>2222</ssn>
    <last>last2</last>
    <first>first2</first>
    <record_date>01-10-2010</record_date>
    <dob>03-10-1975</dob>
    <gender>F</gender>
    <weight>145</weight>
    <bmi>25</bmi>
    </BIO_Child2>

    <BIO_Child2>
    <ssn>2222</ssn>
    <last>last2</last>
    <first>first2</first>
    <record_date>02-10-2010</record_date>
    <dob>03-10-1975</dob>
    <gender>F</gender>
    <weight>135</weight>
    <bmi>22</bmi>
    </BIO_Child2>

    </BIO>


    Output:

    <ImportResults>

    <Import>
    <Patient>
    <ssn>11111</ssn>
    <last>last1</last>
    <first>first1</first>
    <dob>01-10-1972</dob>
    <gender>M</gender>
    </Patient>
    <Results>

    <NumericResult>
    <CaptureDate>01-01-2010</CaptureDate>
    <Value>170;24</Value>
    </NumericResult>

    <NumericResult>
    <CaptureDate>02-01-2010</CaptureDate>
    <Value>165;23</Value>
    </NumericResult>
    </Results>

    </Import>

    <Import>
    <Patient>
    <ssn>2222</ssn>
    <last>last2</last>
    <first>first2</first>
    <dob>03-10-1975</dob>
    <gender>F</gender>
    </Patient>
    <Results>

    <NumericResult>
    <CaptureDate>01-10-2010</CaptureDate>
    <Value>145;25</Value>
    </NumericResult>

    <NumericResult>
    <CaptureDate>02-10-2010</CaptureDate>
    <Value>135;22</Value>
    </NumericResult>

    </Results>
    </Import>

    </ImportResults>


    I think, Custom XSLT using <xsl:for-each> may be the way to get desided output as Leonid suggested.

    HTH,

    Please mark it as answer by clicking on "Propose As Answer", if it helps
    • Marked as answer by ScubaDrew Tuesday, February 23, 2010 1:04 PM
    Tuesday, February 23, 2010 4:39 AM
  • Hi,

    In some of the cases, to get the desired result using Looping functoid is very complex and require lot of effort. So I would suggest you to go for the scripting functoid and write custom script to get the result. Also using Custom script you will have more flexibility.

    PS: There might be some performance impact while using Scripting functoid.

    Regards,
    Abhijit


    Abhijit Mahato Please "Mark as Answer" if Post has Answered the Question
    Tuesday, February 23, 2010 6:08 AM
  • Rajesh, impressive! That is exactly what I am looking for. 

    Thank you all for the quick replies, I apologize I had some matters to attend to and am just able to reply now.

    I'm unfamiliar with the Custom XSLT but will begin researching it now and try and impliment today.

    I'll report back if I'm unable to accomplish this task with the information you've all provided. 

    Thank you Rajesh,  Mark, and Leonid!

    Drew


    Tuesday, February 23, 2010 1:06 PM
  • So I'm very close, but my Custom XSLT will not stay within the "patient" for-each loop. It gets it's own for-each loop, and this does not produce the desired output. 

    Here is the generated XSL:

    <DateOfBirth>
                  <xsl:value-of select="$var:v1" />
                </DateOfBirth>
                <Gender>
                  <xsl:value-of select="gender/text()" />
                </Gender>
              </Patient>
            </xsl:for-each>
            <xsl:for-each select="xxx_BIO_Child2">
              <Results>
    <NumericResult>
     <xsl:variable name="var:v4" select="string(record_date/text())" /> 
     <xsl:variable name="var:v5" select="userVB:CaptureDate($var:v4)" />
      <CaptureDate>
       <xsl:value-of select="$var:v5" />
      </CaptureDate>
      <Value>
       <xsl:value-of select="weight/text()" />
      </Value>
      <ResultIdentifier>
       <xsl:text>5</xsl:text>
      </ResultIdentifier>
     </NumericResult>
    </Results>
            </xsl:for-each>
    Here is the MAP. I've tried a number of different looping connectors etc and cannot get the custom xslt scriptoid to produce its code in the main for-each loop.


    Thanks,

    Drew
    Tuesday, February 23, 2010 5:04 PM
  • Sunday, February 28, 2010 10:00 PM