locked
Problem on using XSLT in the map RRS feed

  • Question

  • Hi,

    Here is my map,

    for each LINLoop1 will have a InvoiceLineItem and order by source field LIN01. Following is the XSLT code i used and save in test.txt

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    xmlns:var="http://schemas.microsoft.com/BizTalk/2006/var"
    exclude-result-prefixes="msxsl var" version="1.0">
    <xsl:output omit-xml-declaration="yes" indent="yes" method="xml" version="1.0"/>
    <xsl:template match="/">
    <CommericalInvoice>
    <xsl:for-each select="EFACT_d98a_INVOIC/LINLoop1">
    <xsl:sort select="LIN/@LIN01"/>
    <InvoiceLineItem>
    <LineItemNumberID>
    <xsl:value-of select="LIN/@LIN01"/>
    </LineItemNumberID>
    <ShippingMark>
    <xsl:value-of select="LIN/C212/@C21201"/>
    </ShippingMark>
    </InvoiceLineItem>
    </xsl:for-each>
    </CommericalInvoice>
    </xsl:template>
    </xsl:stylesheet>

    after i set Custom XSL Path=test.txt in Grid Properties

    Input data:

    <LINLoop1>
    <LIN LIN01="2">
      <C212 C21201="BJ"/>
    </LIN>
    <LIN LIN01="1">
      <C212 C21201="XM"/>
    </LIN>
    <LIN LIN01="3">
      <C212 C21201="SZ"/>
    </LIN>
    </LINLoop1>

    output data:

    <CommercialInvoice>
    <InvoiceLineItem>
    <LineItemNumberID>
    1
    </LineItemNumberID>
    <ShippingMark>
    XM
    </ShippingMark>
    </InvoiceLineItem>
    <InvoiceLineItem>

    <LineItemNumberID>
    2
    </LineItemNumberID>
    <ShippingMark>
    BJ
    </ShippingMark>
    </InvoiceLineItem>

    <InvoiceLineItem>
    <LineItemNumberID>
    3
    </LineItemNumberID>
    <ShippingMark>
    SZ
    </ShippingMark>
    </InvoiceLineItem>

    </CommercialInvoice>

    but expected output data like:

    <CommercialInvoice>
    <PaymentDueDateTime>
    2011-09-09T11:12:40
    </PaymentDueDateTime>
    <InvoiceLineItem>
    <LineItemNumberID>
    1
    </LineItemNumberID>
    <ShippingMark>
    XM
    </ShippingMark>
    </InvoiceLineItem>
    <InvoiceLineItem>

    <LineItemNumberID>
    2
    </LineItemNumberID>
    <ShippingMark>
    BJ
    </ShippingMark>
    </InvoiceLineItem>

    <InvoiceLineItem>
    <LineItemNumberID>
    3
    </LineItemNumberID>
    <ShippingMark>
    SZ
    </ShippingMark>
    </InvoiceLineItem>

    </CommercialInvoice>

    when get rid of file : test.txt for Custom XSL Path in Grid Properties, can get output data correctly like below,

    <CommercialInvoice>
    <PaymentDueDateTime>
    2011-09-09T11:12:40
    </PaymentDueDateTime>
    </CommercialInvoice>

    Anyone can help me to solve this issue? Thanks.

    Friday, September 9, 2011 9:52 AM

Answers

  • I was advising you to incorporate the code for creating the PaymentDueDateTime in your XSLT. The easiest way to get this code could be to keep the Custom XSLT path empty and then validate map it would give you the required XSLT code for generating this node in destination and then incorporate that code in you text.txt as shown below:

    <xsl:template match="/">
    	<CommericalInvoice>
    		<PaymentDueDateTime>
    	               ...
    		</PaymentDueDateTime>
    		<xsl:for-each select="EFACT_d98a_INVOIC/LINLoop1">
    			<xsl:sort select="LIN/@LIN01"/>
    		...
    </CommericalInvoice>
    </xsl:template>



    Don't forget to mark the post as answer or vote as helpful if it does, Regards -Rohit Sharma (http://rohitbiztalk.blogspot.com)
    Thursday, September 15, 2011 4:57 AM
    Moderator

All replies

  • Custom XSLT Path Grid property

    If you specify custom XSLT by using this property, it completely replaces any XSLT that would normally be generated by the map. In other words, if this property is set, any links and functoids in the grid are irrelevant.

    See this link for details.

     

    So you need to take care of the other required mapping in this XSLT which you can easily generate by first clearing the Custom XSLT Path and then right click map and select Validate Map which would generate the XSLT for map use it in you custom XSLT to get the right output.


    Don't forget to mark the post as answer or vote as helpful if it does, Regards -Rohit Sharma (http://rohitbiztalk.blogspot.com)
    Friday, September 9, 2011 10:41 AM
    Moderator
  • Have you tried the Looping Functoid?
    Cheers,
    Bali
    MCTS: BizTalk Server 2010,BizTalk Server 2006 and WCF
    Blog: http://dpsbali-biztalkweblog.blogspot.com
    -----------------------------------------------------
    Mark As Answer or Vote As Helpful if this helps.
    Saturday, September 10, 2011 6:29 AM
  • i have tried loop functoid, but loop functioid cannot sort

    Thursday, September 15, 2011 2:26 AM
  • Do you mean i need to modify XSLT based on generated XSLT after selecting Validate Map? However, i try to put the code in above test.txt input the generated XSLT, code doesn't work.

    code list below,

    <xsl:template match="/">
    <CommericalInvoice>
    <xsl:for-each select="EFACT_d98a_INVOIC/LINLoop1">
    <xsl:sort select="LIN/@LIN01"/>
    <InvoiceLineItem>
    <LineItemNumberID>
    <xsl:value-of select="LIN/@LIN01"/>
    </LineItemNumberID>
    <ShippingMark>
    <xsl:value-of select="LIN/C212/@C21201"/>
    </ShippingMark>
    </InvoiceLineItem>
    </xsl:for-each>
    </CommericalInvoice>
    </xsl:template>

    Thursday, September 15, 2011 2:40 AM
  • I was advising you to incorporate the code for creating the PaymentDueDateTime in your XSLT. The easiest way to get this code could be to keep the Custom XSLT path empty and then validate map it would give you the required XSLT code for generating this node in destination and then incorporate that code in you text.txt as shown below:

    <xsl:template match="/">
    	<CommericalInvoice>
    		<PaymentDueDateTime>
    	               ...
    		</PaymentDueDateTime>
    		<xsl:for-each select="EFACT_d98a_INVOIC/LINLoop1">
    			<xsl:sort select="LIN/@LIN01"/>
    		...
    </CommericalInvoice>
    </xsl:template>



    Don't forget to mark the post as answer or vote as helpful if it does, Regards -Rohit Sharma (http://rohitbiztalk.blogspot.com)
    Thursday, September 15, 2011 4:57 AM
    Moderator
  • check this blog post for grouping and sorting examples and this one by Stephen which has sample code that you can download.
    Regards,
    Bali
    MCTS: BizTalk Server 2010,BizTalk Server 2006 and WCF
    Blog: http://dpsbali-biztalkweblog.blogspot.com
    -----------------------------------------------------
    Mark As Answer or Vote As Helpful if this helps.
    Thursday, September 15, 2011 6:07 AM
  • I modified generated XSLT after validating map and save, then test map. However, the code i added has no effect on output file.  So , i tried to incorporate all mapping logic in XSLT in test.txt as below and fill in Custom XSLT path, i can get expected output. But  i think the method all mapping logic will be implemented in XSLT is complex. Only those special logic in XSLT and other by functioid will be more easier.

    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    xmlns:var="http://schemas.microsoft.com/BizTalk/2006/var"
    exclude-result-prefixes="msxsl var" version="1.0">
    <xsl:output omit-xml-declaration="yes" indent="yes" method="xml" version="1.0"/>
    <xsl:template match="/">
    <CommericalInvoice>
    <PaymentDueDateTime>
    2011-09-15T15:15:40
    </PaymentDueDateTime>
    <xsl:for-each select="EFACT_d98a_INVOIC/LINLoop1">
    <xsl:sort select="LIN/@LIN01"/>
    <InvoiceLineItem>
    <LineItemNumberID>
    <xsl:value-of select="LIN/@LIN01"/>
    </LineItemNumberID>
    <ShippingMark>
    <xsl:value-of select="LIN/C212/@C21201"/>
    </ShippingMark>
    </InvoiceLineItem>
    </xsl:for-each>
    </CommericalInvoice>
    </xsl:template>
    </xsl:stylesheet>

    Besides, if all mapping logic is done in XSLT, there is no namespace (screenshot below) in output

    Thursday, September 15, 2011 7:48 AM
  • Dear DPS Bali,

    I have read the example and don't think it can solve my issue. Thank you all the same.

     

    Thursday, September 15, 2011 8:25 AM
  • "But  i think the method all mapping logic will be implemented in XSLT is complex."

     

    Then you can use the scripting functoid with inline XSLT to implement the logic you currently have in test.txt as shown here.


    Don't forget to mark the post as answer or vote as helpful if it does, Regards -Rohit Sharma (http://rohitbiztalk.blogspot.com)
    Thursday, September 15, 2011 8:51 AM
    Moderator
  • Ideally, you should use a scripting functoid and choose inline XSLT call Template for your requirement.

    Shankar

    Friday, September 16, 2011 1:36 PM
  • I think Rohit is rigt.

    If you need to output the <PaymentDueDateTime> you have to generate it in your Xslt code. Otherwise how you get it without generating?


    Leonid Ganeline [BizTalk MVP] BizTalk: Sample: Context Routing and Throttling with orchestration
    Monday, September 19, 2011 2:45 AM
    Moderator