none
Custom XSLT for Biztalk Maps RRS feed

  • Question

  • Hi,

    I have a input xml file and the output xml file. The input message is multi-part message.

    I have to create a custom xslt to convert input xml to output xml. The xslt should give an xml output. I have an another xslt to take this output as input and create the output in html form.

    Is there any way to convert the existing xslt (which give html output) to the xslt which has to create xml output.

    Thanks,

    Lakshmi

    Monday, June 30, 2014 4:27 AM

Answers

  • xslt is meant for transformations from input to output,

    when you take a xsl file, it works with reference to input file, but however Xslt does not know about the entire xml file, it just works and navigates through the xpath statements given in xslt file. 

    what you are asking is a reverse process, So, no you cannot convert it.

    The xlst that you have will convert the output xml to a HTML output, but you never know how the output xml has been created based on what logic at first.

    even if you try to convert it by removing the html tags sections etc from the xslt you have, it will not create output xml, because your existing xslt was only meant for transforming output xml to html, it does not know how the output xml was created at first, so it does not contain xpath queries init to create proper output xml you are expecting.

    i suggest you to construct  a new xslt for generating the output xml rather than trying to convert it in reverse process.


    Please mark the post as answer if this answers your question. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    • Edited by Ravindar Thati Monday, June 30, 2014 4:56 AM
    • Marked as answer by Laxme Tuesday, July 1, 2014 4:36 AM
    Monday, June 30, 2014 4:38 AM
  • Hi Lakshmi,

    You can the HTML-XSLT (used to output HTML ) as reference for outputting XML in BizTalk but there is no easy way to achieve it with help of any tool. Especially around the XPaths which can going to be similar.

    For instance, following an XSLT for outputting HTML

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://biztalk.orderapp.schemas.OrderResponse">
    
    	<xsl:template match="/">
    		<html>
    			<body>
    				<TABLE BORDER="0" cellspacing="2" cellpadding="2" width="90%">
    					<TR>
    						<TD colspan="8" align="center">
    							<H1>Order Confirmation</H1>
    						</TD>
    
    					</TR>
    					<TR>
    						<TD colspan="2">
    							<B>Order no : </B>
    						</TD>
    						<TD colspan="6" align="left">
    							<xsl:value-of select="ns0:OrderHeader/ns0:OrderNumber/text()"/>
    						</TD>
    					</TR>
    				</TABLE>
    
    			</body>
    		</html>
    	</xsl:template>
    
    </xsl:stylesheet>

    And following an XSLT for outputting XML in BizTalk. You can see the similarities in XPATH and difference around the places they have been used to output HTML and XML.

    <?xml version="1.0" encoding="UTF-16"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:ns0="http://biztalk.orderapp.schemas.OrderResponse" xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" version="1.0">
      <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
      <xsl:template match="/">
        <xsl:apply-templates select="/s3:Registration" />
      </xsl:template>
      <xsl:template match="/ns0:OrderConfirmation">
        <ns0:OrderConfirmation>     
            <OrderNoo>
              <xsl:value-of select="ns0:OrderHeader/ns0:OrderNumber/text()" />
            </OrderNo>      
        </ns0:Output>
      </xsl:template>
    </xsl:stylesheet>


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    • Marked as answer by Laxme Tuesday, July 1, 2014 4:36 AM
    Monday, June 30, 2014 11:18 AM

All replies

  • xslt is meant for transformations from input to output,

    when you take a xsl file, it works with reference to input file, but however Xslt does not know about the entire xml file, it just works and navigates through the xpath statements given in xslt file. 

    what you are asking is a reverse process, So, no you cannot convert it.

    The xlst that you have will convert the output xml to a HTML output, but you never know how the output xml has been created based on what logic at first.

    even if you try to convert it by removing the html tags sections etc from the xslt you have, it will not create output xml, because your existing xslt was only meant for transforming output xml to html, it does not know how the output xml was created at first, so it does not contain xpath queries init to create proper output xml you are expecting.

    i suggest you to construct  a new xslt for generating the output xml rather than trying to convert it in reverse process.


    Please mark the post as answer if this answers your question. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    • Edited by Ravindar Thati Monday, June 30, 2014 4:56 AM
    • Marked as answer by Laxme Tuesday, July 1, 2014 4:36 AM
    Monday, June 30, 2014 4:38 AM
  • Hi Lakshmi,

    You can the HTML-XSLT (used to output HTML ) as reference for outputting XML in BizTalk but there is no easy way to achieve it with help of any tool. Especially around the XPaths which can going to be similar.

    For instance, following an XSLT for outputting HTML

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://biztalk.orderapp.schemas.OrderResponse">
    
    	<xsl:template match="/">
    		<html>
    			<body>
    				<TABLE BORDER="0" cellspacing="2" cellpadding="2" width="90%">
    					<TR>
    						<TD colspan="8" align="center">
    							<H1>Order Confirmation</H1>
    						</TD>
    
    					</TR>
    					<TR>
    						<TD colspan="2">
    							<B>Order no : </B>
    						</TD>
    						<TD colspan="6" align="left">
    							<xsl:value-of select="ns0:OrderHeader/ns0:OrderNumber/text()"/>
    						</TD>
    					</TR>
    				</TABLE>
    
    			</body>
    		</html>
    	</xsl:template>
    
    </xsl:stylesheet>

    And following an XSLT for outputting XML in BizTalk. You can see the similarities in XPATH and difference around the places they have been used to output HTML and XML.

    <?xml version="1.0" encoding="UTF-16"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:ns0="http://biztalk.orderapp.schemas.OrderResponse" xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" version="1.0">
      <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
      <xsl:template match="/">
        <xsl:apply-templates select="/s3:Registration" />
      </xsl:template>
      <xsl:template match="/ns0:OrderConfirmation">
        <ns0:OrderConfirmation>     
            <OrderNoo>
              <xsl:value-of select="ns0:OrderHeader/ns0:OrderNumber/text()" />
            </OrderNo>      
        </ns0:Output>
      </xsl:template>
    </xsl:stylesheet>


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    • Marked as answer by Laxme Tuesday, July 1, 2014 4:36 AM
    Monday, June 30, 2014 11:18 AM
  • To answer you specific question, sure, to can skip the middle step, but there is no tool or automated way to do this.  It's a development effort just like creating the xslt to begin with.

    However, why do you need to write a custom xslt for the first part?  Why can't you use the Mapper?  Yes, it will require an Orchestration, but don't worry about 'performance'.

    Monday, June 30, 2014 12:27 PM
    Moderator