none
BizTalk XSLT RRS feed

  • Question

  • Hi All,

    How to write XSLT for the below tags broker & duqs tags as the output:

    Do we need to use xsl for-each or xsl template? Please suggest...

    Tha output of the map is as below:

    <aggregateQuoteRequest>
        <userid>Hari</userid>
        <password>woRdPass</password>
        <broker results="1">Hastings</broker>
        <broker results="1">Fors-Amx</broker>
        <broker results="1">Virgininc</broker>
        <broker results="2">Landg</broker>
        <broker results="2">Land-ess</broker>
        <broker results="1">Teso-Value</broker>
        <broker results="1">Tesc-Standard</broker>
        <broker results="1">Tesc-Finest</broker>
        <broker results="1">Insur-Pink</broker>
        <broker results="1">Likwise</broker>
        <broker results="1">Reew</broker>
        <broker results="1">Insured</broker>
        <broker results="1">CoveredDirect</broker>
        <broker results="1">QLDKS</broker>
        <broker results="1">Beddsford</broker>
        <broker results="1">InterInsurance</broker>
        <broker results="1">InterInsuranceNew</broker>
        <broker results="1">IGValue</broker>
        <broker results="2">Masterquoter</broker>
        <broker results="2">Renew-pyrid</broker>
       <policyType>HC</policyType>
     <duqs>
            <question number="517">2</question>
            <question number="518">2</question>
            <question number="521">N</question>
            <question number="232">N</question>
            <question number="10034">2</question>
            <question number="10035">1</question>
            <question number="10036">N</question>
            <question number="10026">Owner</question>
            <question number="10027">DH</question>
            <question number="10030">Brick</question>
            <question number="10031">Tile</question>
            <question number="10042">Y</question>
            <question number="10044">N</question>
            <question number="10046" />
            <question number="553">5</question>
            <question number="554">5</question>
          </duqs>
    </aggregateQuoteRequest>

    Thanks in advance...

    DHB.

     
    Wednesday, September 5, 2012 4:19 AM

Answers

  • Hi Hari,
    As Leonide stated, to write an XSLT, you should provide the Input and the Output expected. 

    In general, the difference between XSLT Call Template vs foreach is similar to an inline c# code vs a function call

    1.Reusability :
     XSLT template is used when you have to call the same set of code repeatedly.

    2.Technical workarounds:
     In XSLT, you can update a variable twice. Using an XSLT Template and the recursion concept, we can update the value of a variable.This is also a place where XSLT templates would be used.

    3.Performance:
    Also keep in mind, if the its just a single line that has to be used at many places, its better to have it inline than to call it as a template.

    So, if this is looping is just at one place and I am sure seeing from your output that there is a single field with different outputs for a repeated field in the input, 

    I would suggest a foreach.

    Thanks.
    Sriram N

    Please mark this as a nswer if it helps.


    Sriram N http://srirambiztalks.wordpress.com/

    Wednesday, September 5, 2012 8:05 AM

All replies

  • Can you give us the input Xml? It is not possible to write Xslt without it.

    Leonid Ganeline [BizTalk MVP] BizTalkien: Advanced Questions

    Wednesday, September 5, 2012 6:59 AM
    Moderator
  • Hi Leonid,

    Thanks for the reply. We are using an Old Project which mapped all fields using the Classes.

    Now we are using BizTalk to attain that same functionality using more of XSLT code.

    The Old Class is giving the above Output at run time, so in the input there is no broker node or result.

    For testing purpose... we want a XSLT which can give the Output same as above...

    We are not sure whether it is a loop or to use for-each or we have to use XSLT template...

    So... what to do... please suggest.

    OR ELSE...

    please suggest the XSLT as below output...

    <aggregateQuoteRequest>

     <broker results="1">Hastings</broker>
       
    <broker results="1">Fors-Amx</broker>

    <duqs>
           
    <question number="517">2</question>
           
    <question number="518">2</question>
           
    <question number="521">N</question>
     </duqs>

    </aggregateQuoteRequest>

    Which I will test as a sample as the XSLT in scripting functoid & get clarification from the client.

    Thanks in advance...

    DHB.

    Wednesday, September 5, 2012 7:52 AM
  • Hi Hari,
    As Leonide stated, to write an XSLT, you should provide the Input and the Output expected. 

    In general, the difference between XSLT Call Template vs foreach is similar to an inline c# code vs a function call

    1.Reusability :
     XSLT template is used when you have to call the same set of code repeatedly.

    2.Technical workarounds:
     In XSLT, you can update a variable twice. Using an XSLT Template and the recursion concept, we can update the value of a variable.This is also a place where XSLT templates would be used.

    3.Performance:
    Also keep in mind, if the its just a single line that has to be used at many places, its better to have it inline than to call it as a template.

    So, if this is looping is just at one place and I am sure seeing from your output that there is a single field with different outputs for a repeated field in the input, 

    I would suggest a foreach.

    Thanks.
    Sriram N

    Please mark this as a nswer if it helps.


    Sriram N http://srirambiztalks.wordpress.com/

    Wednesday, September 5, 2012 8:05 AM