Ravindar, Biztalk Developer and Administrator

Just another BizTalk blog

Using EXSLT in BizTalk

we need to create a xml that has EXSLT assembly like for example below

<?xml version="1.0" encoding="utf-8"?>
<ExtensionObjects>
    <ExtensionObject
     Namespace="http://exslt.org/dates-and-times"
     AssemblyName="Mvp.Xml,
     Version=2.3.0.0, Culture=neutral,
     PublicKeyToken=6ead800d778c9b9f"
     ClassName="Mvp.Xml.Exslt.ExsltDatesAndTimes"/>
</ExtensionObjects>

and now if you want to you EXSLT date funtion in your custom xslt, then mention like below

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:S1="http://ExtendedMapping.Schema1"
                xmlns:S2="http://ExtendedMapping.Schema2"
                xmlns:exslt="http://exslt.org/dates-and-times"
                version="1.0">
 
    <xsl:template match="/">
        <S2:Root>
            <Field>
                <xsl:value-of select="exslt:dateTime()"/>
            </Field>
        </S2:Root>
    </xsl:template>
</xsl:stylesheet>

And to loop through each distict node (faster grouping) in fast way,
you can use Distinct() function of EXSLT like below

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:set="http://exslt.org/sets">
  <xsl:output indent="yes"/>
  <xsl:key name="countryKey" match="orders" use="ID"/>
  <xsl:template match="root">
    <table border="1">
      <tr>
        <th>Order ID</th>
        <th>Ship City</th>
      </tr>
      <xsl:for-each select="set:distinct(orders/ID)/..">
        <tr>
          <th colspan="2">
            <xsl:value-of select="ID/text()"/>
          </th>
        </tr>
        <xsl:for-each select="key('countryKey',ID)">
          <tr>
            <td>
              <xsl:value-of select="@OrderID"/>
            </td>
            <td>
              <xsl:value-of select="@ShipCity"/>
            </td>
          </tr>
        </xsl:for-each>
      </xsl:for-each>
    </table>
  </xsl:template>
</xsl:stylesheet> 

and don’t forget to read below URLs
http://www.richardhallgren.com/how-the-extend-a-custom-xslt-in-biztalk-using-exslt-and-the-mvpxml-project/

http://msdn.microsoft.com/en-us/library/aa302297.aspx#xmlindexing_topic3

January 22, 2012 Posted by | Biztalk Server | Leave a comment

For loop in xslt

   <xsl:template name="for.loop">  
   <!-- for loop templates starts here-->  
     
     <!-- for loop index variable-->  
     <xsl:param name="i" />  
     
     <!-- for loop end variable-->  
     <xsl:param name="count" />  
    
     <!--begin_: Line_by_Line_Output -->  
     <xsl:if test="$i <= $count">  
       <!-- This $i variable gives the increment value -->  
       <xsl:value-of select="$i"/>  
     </xsl:if>  
     
     <!--begin_: RepeatTheLoopUntilFinished-->  
     <xsl:if test="$i <= $count">  
       <xsl:call-template name="for.loop">  
         <xsl:with-param name="i">  
           <xsl:value-of select="$i + 1"/>  
         </xsl:with-param>  
         <xsl:with-param name="count">  
           <xsl:value-of select="$count"/>  
         </xsl:with-param>  
       </xsl:call-template>  
     </xsl:if>  
  </xsl:template>  

Source from http://blog.logiclabz.com/xml-xslt/for-loop-in-xslt.aspx

January 18, 2012 Posted by | Uncategorized | Leave a comment