<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:fo="http://www.w3.org/1999/XSL/Format"
	version="2.0">
<xsl:param name="vendorName"/>
<xsl:template name="normalize">
   <xsl:param name="input"/>
   <xsl:value-of select="$input"/>
</xsl:template>
<xsl:template match="maps">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

	<fo:layout-master-set>

    <fo:simple-page-master master-name="all"
		page-height="11.5in" page-width="8.5in"
        margin-top="0.5in" margin-bottom="0.5in"
        margin-left="0.75in" margin-right="0.75in">
		<fo:region-body margin-top="0.0in" margin-bottom="0.75in"/>
		<fo:region-before extent="0.5in"/>
		<fo:region-after extent="0.5in"/>
	</fo:simple-page-master>
	
	    <fo:simple-page-master master-name="schemainfo"
			page-height="11.5in" page-width="8.5in"
	        margin-top="1in" margin-bottom="1in"
	        margin-left="0.75in" margin-right="0.75in">
			<fo:region-body margin-top="0.5in" margin-bottom="0.75in"/>
			<fo:region-before extent="0.2in"/>
			<fo:region-after extent="0.5in"/>
	</fo:simple-page-master>
	
	    <fo:simple-page-master master-name="Title"
			page-height="11.5in" page-width="8.5in"
	        margin-top="1in" margin-bottom="1in"
	        margin-left="0.75in" margin-right="0.75in">
			<fo:region-body margin-top="3.5in" margin-bottom="0.75in"/>
			<fo:region-before extent="4.0in"/>
			<fo:region-after extent="0.5in"/>
	</fo:simple-page-master>
	</fo:layout-master-set>

<fo:page-sequence master-reference="Title">
<!-- Title Page of Mapping Information -->

	<fo:static-content flow-name="xsl-region-before">
		<fo:block font-family="arial" font-size="40pt" text-align="center" wrap-option="wrap"> 
			Mapping Information Document
	        </fo:block>
	</fo:static-content>
	
	<fo:static-content flow-name="xsl-region-after">
		<fo:table>
			<fo:table-column column-width="50%" />							<fo:table-column column-width="50%" />
			<fo:table-body>																		
			  <fo:table-row>
		   	    <fo:table-cell padding="2pt">
				<fo:block text-align="left" font-size="10pt" font-family="serif" line-height="1em + 2pt" font-style="italic">												
				</fo:block>
			    </fo:table-cell>
			    <fo:table-cell padding="2pt">
			    	<fo:block text-align="right" font-size="10pt" font-family="serif" line-height="1em + 2pt" font-style="italic">
				&#xA9;<xsl:value-of select="$vendorName"/></fo:block>
			    </fo:table-cell>
			  </fo:table-row>
		         </fo:table-body>
		</fo:table>
	</fo:static-content>
	
	<fo:flow flow-name="xsl-region-body">
		<fo:block text-align="start" font-size="12pt" font-family="sans-serif">	
		<xsl:apply-templates select="mappingInformation"/>	
		</fo:block>
	</fo:flow>
</fo:page-sequence>

<fo:page-sequence master-reference="schemainfo">

<fo:static-content flow-name="xsl-region-before">
	<fo:table>
		<fo:table-column column-width="100%" />
		<fo:table-body>
			<fo:table-row>
				<fo:table-cell padding="2pt">
				<fo:block text-align="left" font-size="10pt" font-family="serif" line-height="1em + 2pt" font-style="italic">
				 Schema Information
				</fo:block>
				</fo:table-cell>
			</fo:table-row>
		</fo:table-body>
	</fo:table>
</fo:static-content>

<fo:static-content flow-name="xsl-region-after">
	<fo:table>
	  <fo:table-column column-width="50%" />
	  <fo:table-column column-width="50%" />
	   <fo:table-body>
	     <fo:table-row>
	       <fo:table-cell padding="2pt">
	         <fo:block text-align="left" font-size="10pt" font-family="serif" line-height="1em + 2pt">
	         <fo:page-number />
	         </fo:block>
		</fo:table-cell>
		<fo:table-cell padding="2pt">
	 	  <fo:block text-align="right" font-size="10pt" font-family="serif" line-height="1em + 2pt" font-style="italic">
	 	  &#xA9;<xsl:value-of select="$vendorName"/>
	 	 </fo:block>
	 	</fo:table-cell>
	     </fo:table-row>
	   </fo:table-body>
	 </fo:table>
</fo:static-content>

<fo:flow flow-name="xsl-region-body">
<fo:block>
	<xsl:apply-templates select="sourceRoots"/>
	<fo:leader leader-pattern="rule" leader-length="15cm" rule-style="solid" rule-thickness="0pt" />
	<xsl:apply-templates select="targetRoots"/>
</fo:block>
</fo:flow>

</fo:page-sequence>

<fo:page-sequence master-reference="all">

<!-- header with running maps entries -->

<fo:static-content flow-name="xsl-region-after">
	<fo:table>
	  <fo:table-column column-width="50%" />
	  <fo:table-column column-width="50%" />
	   <fo:table-body>
	     <fo:table-row>
	       <fo:table-cell padding="2pt">
	         <fo:block text-align="left" font-size="10pt" font-family="serif" line-height="1em + 2pt">
	         <fo:page-number />
	         </fo:block>
		</fo:table-cell>
		<fo:table-cell padding="2pt">
	 	  <fo:block text-align="right" font-size="10pt" font-family="serif" line-height="1em + 2pt" font-style="italic">
	 	  &#xA9;<xsl:value-of select="$vendorName"/>
	 	 </fo:block>
	 	</fo:table-cell>
	     </fo:table-row>
	   </fo:table-body>
	 </fo:table>
</fo:static-content>
      
<fo:flow flow-name="xsl-region-body">
<fo:block>
<xsl:apply-templates select="variables"/>
<xsl:apply-templates select="globalParameters"/>
<xsl:apply-templates select="functions"/>
<xsl:apply-templates select="xslTemplates"/>
<fo:leader leader-pattern="rule" leader-length="15cm" rule-style="solid" rule-thickness="0pt" />
<fo:block text-align="center" background-color="#99cc00" line-height="20pt" border="1pt solid gray">
	Mapping Information
</fo:block>
<fo:block text-align="start" font-size="7pt" font-family="sans-serif"  wrap-option="wrap">		
<fo:table border-collapse="collapse" text-align="left" >
	  <fo:table-column column-width="13%" />
	  <fo:table-column column-width="18%" />
	  <fo:table-column column-width="18%" />
	  <fo:table-column column-width="13%" />
	  <fo:table-column column-width="16%" />
	  <fo:table-column column-width="11%" />
	  <fo:table-column column-width="11%" />
	  <fo:table-body>
		<fo:table-row overflow="visible">    
		  
		  <fo:table-cell padding="1.5pt" border="1pt solid gray"  background-color="#eeeeee">
		  	          <fo:block>TARGET NAME</fo:block>
		  </fo:table-cell>
		  
		  <fo:table-cell padding="1.5pt" border="1pt solid gray"  background-color="#eeeeee">
	          <fo:block>TARGET FIELD</fo:block>
		  </fo:table-cell>
		  
		  <fo:table-cell padding="1.5pt" border="1pt solid gray" background-color="#eeeeee">
		  <fo:block>MAPPING FIELD</fo:block>
		  </fo:table-cell>
			
		  <fo:table-cell padding="1.5pt" border="1pt solid gray" background-color="#eeeeee">
		  <fo:block> FOR EACH </fo:block>
		  </fo:table-cell>
		  
		  <fo:table-cell padding="1.5pt" border="1pt solid gray" background-color="#eeeeee">
		  <fo:block> SORTING RULES </fo:block>
		  
		  <fo:table border-collapse="collapse" background-color="#ccccff" border="1pt solid gray">
		    <fo:table-column column-width="34%"/>
		    <fo:table-column column-width="33%"/>
		    <fo:table-column column-width="33%"/>
			<fo:table-body>
		    	  <fo:table-row>
				<fo:table-cell padding="1pt" border="1pt solid gray">
		  		<fo:block> Source Element </fo:block>
		  		</fo:table-cell>
		  		
		  		<fo:table-cell padding="1pt" border="1pt solid gray">
		  		<fo:block> Data Type </fo:block>
		  		</fo:table-cell>
		  		
		  		<fo:table-cell padding="1pt" border="1pt solid gray">
				<fo:block> Order </fo:block>
		  		</fo:table-cell>
		  	  </fo:table-row>
		  	</fo:table-body>
			</fo:table>	
		  </fo:table-cell>
		  
			
		  <fo:table-cell padding="1.5pt" border="1pt solid gray" background-color="#eeeeee">
		  <fo:block> COMMENTS </fo:block>
		  </fo:table-cell>
		      
		  <fo:table-cell padding="1.5pt" border="1pt solid gray" background-color="#eeeeee">
		  <fo:block> LOCAL VARIABLES </fo:block>
		  <fo:table border-collapse="collapse" background-color="#ccccff" border="1pt solid gray">
		  	  <fo:table-column column-width="50%"/>
		  	  <fo:table-column column-width="50%"/>
		  	  <fo:table-body>
		  	  <fo:table-row>
		  	  	      <fo:table-cell padding="1pt" border="1pt solid gray">
		  	  	        <fo:block> Variable Name </fo:block>
		  	  	      </fo:table-cell>
		  	           <fo:table-cell padding="1pt" border="1pt solid gray">
		  	  	        <fo:block> Value </fo:block>
		  	  	       </fo:table-cell>
		  	    </fo:table-row>
		  	   </fo:table-body>
			</fo:table>	
		  </fo:table-cell>
	       </fo:table-row>
	</fo:table-body>
     </fo:table>
  </fo:block>
<xsl:apply-templates select="map"/>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>

<xsl:template match="variables">
<fo:block text-align="center" background-color="#99cc00" line-height="20pt" border="1pt solid gray">
	Global Variables
</fo:block>
	<fo:table border-collapse="collapse" background-color="#ccccff">
	  <fo:table-column column-width="50%"/>
	  <fo:table-column column-width="50%"/>
	  <fo:table-body>
	    <fo:table-row>
	      <fo:table-cell padding="2pt" border="1.5pt solid gray">
	        <fo:block> Variable Name </fo:block>
	      </fo:table-cell>
         <fo:table-cell padding="2pt" border="1.5pt solid gray">
	        <fo:block> Value </fo:block>
	       </fo:table-cell>
	    </fo:table-row>
	   </fo:table-body>
	</fo:table>	
	<xsl:apply-templates select="variable"/>
</xsl:template>

<xsl:template match="Sorting">
<xsl:apply-templates select="Sort"/>
</xsl:template>

<xsl:template match="Sort">
<fo:block text-align="start" >
<fo:table>
	  <fo:table-column column-width="33%"/>
	  <fo:table-column column-width="25%"/>
	  <fo:table-column column-width="42%"/>
	  <fo:table-body>
	    <fo:table-row>
	      <fo:table-cell padding="1.5pt" border="1pt solid gray">
	        <fo:block hyphenate="true">
	        	<xsl:value-of select="SourceElement"/>
                </fo:block>
	      </fo:table-cell>
	      
              <fo:table-cell padding="1.5pt" border="1pt solid gray">
	        <fo:block hyphenate="true">
	        	<xsl:value-of select="DataType"/>
	        </fo:block>
	       </fo:table-cell>
	       
              <fo:table-cell padding="1.5pt" border="1pt solid gray">
	        <fo:block hyphenate="true">
	        <xsl:value-of select="Order"/>
	        </fo:block>
	       </fo:table-cell>
	       
	    </fo:table-row>
	   </fo:table-body>
	</fo:table>	
</fo:block>
</xsl:template>

<xsl:template match="localVariables">
<xsl:apply-templates select="localVariable"/>
</xsl:template>

<xsl:template match="localVariable">
<fo:block text-align="start" >
<fo:table>
	  <fo:table-column column-width="50%"/>
	  <fo:table-column column-width="50%"/>
	  <fo:table-body>
	    <fo:table-row>
	      <fo:table-cell padding="1.5pt" border="1pt solid gray">
	        <fo:block hyphenate="true">
	        	<xsl:call-template name="removeDollar">
                        <xsl:with-param name="source" select="lname"/>
                	</xsl:call-template>
                </fo:block>
	      </fo:table-cell>
              <fo:table-cell padding="1.5pt" border="1pt solid gray">
	        <fo:block hyphenate="true">
	        <xsl:call-template name="normalize">
                     <xsl:with-param name="input" select="lvalue"/>
                 </xsl:call-template>
	        </fo:block>
	       </fo:table-cell>
	    </fo:table-row>
	   </fo:table-body>
	</fo:table>	
</fo:block>
</xsl:template>

<xsl:template match="functions">
<fo:leader leader-pattern="rule" leader-length="15cm" rule-style="solid" rule-thickness="0pt" />
<fo:block text-align="center" background-color="#99cc00" line-height="20pt" border="1pt solid gray">
	Custom Methods
</fo:block>
	<fo:table border-collapse="collapse" background-color="#ccccff">
	  <fo:table-column column-width="20%"/>
	  <fo:table-column column-width="25%"/>
	  <fo:table-column column-width="30%"/>
	  <fo:table-column column-width="25%"/>
	  <fo:table-body>
	    <fo:table-row>
	      
	      <fo:table-cell padding="2pt" border="1.5pt solid gray">
	        <fo:block> Alias Name </fo:block>
	      </fo:table-cell>
	      
              <fo:table-cell padding="2pt" border="1.5pt solid gray">
	        <fo:block> Class Name </fo:block>
	      </fo:table-cell>
	       
              <fo:table-cell padding="2pt" border="1.5pt solid gray">
	        <fo:block>Method Name</fo:block>
	      </fo:table-cell>

              <fo:table-cell padding="2pt" border="1.5pt solid gray">
	        <fo:block> Paramaters </fo:block>
	      </fo:table-cell>
	       
	    </fo:table-row>
	   </fo:table-body>
	</fo:table>
	<xsl:apply-templates select="function"/>
</xsl:template>


<xsl:template match="xslTemplates">
<xsl:if test="template">
<fo:leader leader-pattern="rule" leader-length="15cm" rule-style="solid" rule-thickness="0pt" />
<fo:block text-align="center" background-color="#99cc00" line-height="20pt" border="1pt solid gray">
	XSL Templates
</fo:block>
	<fo:table border-collapse="collapse" background-color="#ccccff">
	  <fo:table-column column-width="1in"/>
	  <fo:table-column column-width="6in"/>
	  <fo:table-body>
	    <fo:table-row>    
	      
	      <fo:table-cell padding="2pt" border="1.5pt solid gray">
	        <fo:block> Template Name </fo:block>
	      </fo:table-cell>
	      
	      <fo:table-cell padding="2pt" border="1.5pt solid gray">
	      	        <fo:block> Template Definition </fo:block>
	      </fo:table-cell>
	      
	    </fo:table-row>
	   </fo:table-body>
	</fo:table>
	<xsl:apply-templates select="template"/>
	</xsl:if>
</xsl:template>

<xsl:template match="template">
<fo:block text-align="start" font-size="10pt" font-family="sans-serif">
	<fo:table border-collapse="collapse" text-align="left" >
	  <fo:table-column column-width="1in"/>
	  <fo:table-column column-width="6in"/>

	<fo:table-body >
	  <fo:table-row >
	    <fo:table-cell padding="1.5pt" border="1.5pt solid gray"  background-color="#FFFFFF">
	    		<fo:block hyphenate="true">
	    		<xsl:call-template name="getTemplateName">
			<xsl:with-param name="source" select="."/>
                    	</xsl:call-template>
	    		</fo:block>
	      </fo:table-cell>
	      
	      <fo:table-cell padding="1.5pt" border="1.5pt solid gray"  background-color="#FFFFFF">
	      	    	<fo:block hyphenate="true">
	      		<xsl:value-of select="."/>
	      	    	</fo:block>
	      </fo:table-cell>
	  </fo:table-row>
	 </fo:table-body>
	</fo:table>
 </fo:block>
</xsl:template>

<!-- Variable template display start-->
<xsl:template match="variable">
<fo:block text-align="start" font-size="10pt" font-family="sans-serif">
	
	<fo:table border-collapse="collapse"   text-align="left" >
	  <fo:table-column column-width="50%" />
	  <fo:table-column column-width="50%" />
	<fo:table-body >
	  <fo:table-row >
	    <fo:table-cell padding="1.5pt" border="1.5pt solid gray"  background-color="#FFFFFF">
	    		<fo:block  hyphenate="true">
	    		<xsl:call-template name="removeDollar">
                        <xsl:with-param name="source" select="name"/>
                    	</xsl:call-template>
                    	</fo:block>
	      </fo:table-cell>
	      
	      <fo:table-cell padding="1.5pt" border="1.5pt solid gray"  background-color="#FFFFFF">
		<fo:block hyphenate="true">
		<xsl:call-template name="normalize">
                     <xsl:with-param name="input" select="value"/>
                 </xsl:call-template>
		</fo:block>
	      </fo:table-cell>
	    </fo:table-row>
	 </fo:table-body>
	</fo:table>
 </fo:block>
</xsl:template>

<!-- Variable Template display end-->

<xsl:template match="globalParameters">
<xsl:apply-templates select="keys"/>	
<xsl:apply-templates select="contextVariables"/>
</xsl:template>

<xsl:template name="extractName">
          <xsl:param name="source"/>
          <xsl:variable name="fullName" select="substring-before($source,' match')"/>
          <xsl:variable name="pName" select="substring-after($fullName,&apos;name=&quot;&apos;)"/>
          <xsl:variable name="Name" select="substring-before($pName,&apos;&quot;&apos;)"/>
          <xsl:value-of select="$Name"/>
</xsl:template>

<xsl:template name="extractMatch">
          <xsl:param name="source"/>
          <xsl:variable name="fullMatch" select="substring-before($source,&apos; use&apos;)"/>
          <xsl:variable name="pMatch" select="substring-after($fullMatch,&apos;match=&quot;&apos;)"/>
          <xsl:variable name="Match" select="substring-before($pMatch,&apos;&quot;&apos;)"/>
          <xsl:value-of select="$Match"/>
</xsl:template>

<xsl:template name="extractUse">
          <xsl:param name="source"/>
          <xsl:variable name="pUse" select="substring-after($source,&apos;use=&quot;&apos;)"/>
          <xsl:variable name="Use" select="substring-before($pUse,&apos;&quot;&apos;)"/>
          <xsl:value-of select="$Use"/>
</xsl:template>

<xsl:template name="contextvarValue">
          <xsl:param name="source"/>
          <xsl:variable name="pValue" select="substring-after($source,',')"/>
          <xsl:variable name="Value" select="substring-before($pValue,')')"/>
          <xsl:value-of select="$Value"/>
</xsl:template>

<xsl:template name="contextvarName">
          <xsl:param name="source"/>
          <xsl:variable name="pName" select="substring-after($source,'set-context(')"/>
          <xsl:variable name="qName" select="substring-before($pName,',')"/>
          <xsl:variable name="slength" select="string-length($qName)"/>
          <xsl:variable name="Name" select="substring($qName,2,$slength - 2)"/>
          <xsl:value-of select="$Name"/>
</xsl:template>

<xsl:template name="removeDollar">
          <xsl:param name="source"/>
          <xsl:choose>
             <xsl:when test="starts-with( $source, &apos;$&apos;)">
                 <xsl:variable name="slength" select="string-length($source)"/>
				<xsl:variable name="Result" select="substring($source,2,$slength)"/>
				<xsl:call-template name="normalize">
                     <xsl:with-param name="input" select="$Result"/>
                 </xsl:call-template>
             </xsl:when>
             <xsl:otherwise>
             	<xsl:call-template name="normalize">
                     <xsl:with-param name="input" select="$source"/>
                 </xsl:call-template>
             </xsl:otherwise>
         </xsl:choose> 
</xsl:template>

<xsl:template name="removeText">
          <xsl:param name="source"/>
          <xsl:variable name="Result" select="substring-after($source,'/')"/>
          <xsl:value-of select="$Result"/>
</xsl:template>

<xsl:template name="textwrap">
<xsl:param name="text"/>
<xsl:param name="width"/>
<xsl:value-of select="concat(substring($text, 1, $width),' ')"/>

  <xsl:variable name="rest" select="substring($text, $width+1)" />
  <xsl:if test="string-length($rest) &gt; 0">
    <xsl:call-template name="textwrap">
      <xsl:with-param name="text" select="$rest" />
      <xsl:with-param name="width" select="$width" />
    </xsl:call-template>
  </xsl:if>
</xsl:template>

<xsl:template name="getTemplateName">
          <xsl:param name="source"/>
          <xsl:variable name="fName" select="substring-before($source,'&quot;>')"/>
          <xsl:variable name="Name" select="substring-after($fName,'=&quot;')"/>
          <xsl:value-of select="$Name"/>
</xsl:template>


<xsl:template match="keys">
<xsl:if test="key">
<fo:leader leader-pattern="rule" leader-length="15cm" rule-style="solid" rule-thickness="0pt" />
<fo:block text-align="center" background-color="#99cc00" line-height="20pt" border="1.5pt solid gray">
	Keys
</fo:block>
	<fo:table border-collapse="collapse" background-color="#ccccff">
	  <fo:table-column column-width="35%"/>
	  <fo:table-column column-width="35%"/>
	  <fo:table-column column-width="30%"/>
	  <fo:table-body>
	    <fo:table-row>
	    
	      <fo:table-cell padding="2pt" border="1.5pt solid gray">
	        <fo:block> Name </fo:block>
	      </fo:table-cell>
	      
	      <fo:table-cell padding="2pt" border="1.5pt solid gray">
	         <fo:block> Match </fo:block>
	      </fo:table-cell>
	      
	      <fo:table-cell padding="2pt" border="1.5pt solid gray">
	         <fo:block> Use </fo:block>
	      </fo:table-cell>
	    </fo:table-row>

	    <xsl:for-each select="key">
	    <fo:table-row >
	    <fo:table-cell padding="1.5pt" border="1.5pt solid gray"  background-color="#FFFFFF">
	  	<fo:block hyphenate="true"> 
	  		<xsl:call-template name="extractName">
                        <xsl:with-param name="source" select="."/>
                	</xsl:call-template>
                </fo:block>
	    </fo:table-cell>
	  
	    <fo:table-cell padding="1.5pt" border="1.5pt solid gray"  background-color="#FFFFFF">
	  	<fo:block hyphenate="true">
	  		<xsl:call-template name="extractMatch">
                        <xsl:with-param name="source" select="."/>
                    	</xsl:call-template>
                </fo:block>
	    </fo:table-cell>
	  
	    <fo:table-cell padding="1.5pt" border="1.5pt solid gray"  background-color="#FFFFFF">
	  	<fo:block hyphenate="true">
	  		<xsl:call-template name="extractUse">
                        <xsl:with-param name="source" select="."/>
                	</xsl:call-template>
                </fo:block>
	    </fo:table-cell>
	  </fo:table-row>
	  </xsl:for-each>
	 </fo:table-body>
	</fo:table>
</xsl:if>
</xsl:template>

<xsl:template match="contextVariables">

<xsl:if test="contextVariable">
<fo:leader leader-pattern="rule" leader-length="15cm" rule-style="solid" rule-thickness="0pt" />
<fo:block text-align="center" background-color="#99cc00" line-height="20pt" border="1pt solid gray">
Global Context Variables
</fo:block>

	<fo:table border-collapse="collapse" background-color="#ccccff">
	  <fo:table-column column-width="50%"/>
	  <fo:table-column column-width="50%"/>
	  <fo:table-body>
	    <fo:table-row>
	      <fo:table-cell padding="2pt" border="1.5pt solid gray">
	        <fo:block> Variable Name </fo:block>
	      </fo:table-cell>
	      
	      <fo:table-cell padding="2pt" border="1.5pt solid gray">
	      	        <fo:block> Value </fo:block>
	      </fo:table-cell>
	    </fo:table-row>
	    
	    <xsl:for-each select="contextVariable">
	    <fo:table-row >
	      <fo:table-cell padding="1.5pt" border="1.5pt solid gray"  background-color="#FFFFFF">
	    	<fo:block hyphenate="true">
	    		<xsl:call-template name="contextvarName">
                        <xsl:with-param name="source" select="."/>
                	</xsl:call-template>
                </fo:block>
	    	 </fo:table-cell>
	    	      
	      <fo:table-cell padding="1.5pt" border="1.5pt solid gray"  background-color="#FFFFFF">
		<fo:block hyphenate="true">
			<xsl:call-template name="contextvarValue">
                        <xsl:with-param name="source" select="."/>
                	</xsl:call-template>
                </fo:block>
	      </fo:table-cell>
	  </fo:table-row>
	  </xsl:for-each>
	</fo:table-body>
</fo:table>
</xsl:if>
</xsl:template>

<!-- Functions display start-->
<xsl:template match="function">
<fo:block text-align="start" font-size="10pt" font-family="sans-serif">
	
	<fo:table border-collapse="collapse" text-align="left" >
	  <fo:table-column column-width="20%"/>
	  <fo:table-column column-width="25%"/>
	  <fo:table-column column-width="30%"/>
	  <fo:table-column column-width="25%"/>
	<fo:table-body >
	  <fo:table-row >
	    <fo:table-cell padding="1.5pt" border="1.5pt solid gray"  background-color="#FFFFFF">
	    		<fo:block hyphenate="true">
	    		<xsl:value-of select="alias"/>
	    		</fo:block>
	      </fo:table-cell>
	      
	      <fo:table-cell padding="1.5pt" border="1.5pt solid gray"  background-color="#FFFFFF">
	      	    	<fo:block hyphenate="true">
	      	    	<xsl:value-of select="class"/>
	      	    	</fo:block>
	      </fo:table-cell>
	      
	      <fo:table-cell padding="1.5pt" border="1.5pt solid gray"  background-color="#FFFFFF">
	      	    	<fo:block hyphenate="true">
	      	    	<xsl:value-of select="method"/>
	      	    	</fo:block>
	      </fo:table-cell>
	      
	      <fo:table-cell padding="1.5pt" border="1.5pt solid gray"  background-color="#FFFFFF">
	      	    	<fo:block hyphenate="true">
	      	    	<xsl:value-of select="params"/>
	      	    	</fo:block>
	      </fo:table-cell>
	  </fo:table-row>
	 </fo:table-body>
	</fo:table>
 </fo:block>
</xsl:template>



<!-- Functions display end-->

<xsl:template match="map">

<fo:block text-align="start" font-size="7pt" font-family="sans-serif"  wrap-option="wrap">		
<fo:table border-collapse="collapse" text-align="left" >
  	 <fo:table-column column-width="13%" />
	  <fo:table-column column-width="18%" />
	  <fo:table-column column-width="18%" />
	  <fo:table-column column-width="13%" />
	  <fo:table-column column-width="16%" />
	  <fo:table-column column-width="11%" />
	  <fo:table-column column-width="11%" />
  
  <fo:table-body >

    <fo:table-row overflow="visible">    
    <fo:table-cell padding="1.5pt" wrap-option="wrap" border="1pt solid gray"  background-color="#fffacd">
                <fo:block hyphenate="true">
                <xsl:call-template name="normalize">
                     <xsl:with-param name="input" select="targetName"/>
                 </xsl:call-template>
                </fo:block>
      </fo:table-cell>
    <fo:table-cell padding="1.5pt" wrap-option="wrap" border="1pt solid gray"  background-color="#fffacd">
            <fo:block hyphenate="true">
            <xsl:call-template name="normalize">
                     <xsl:with-param name="input" select="dest"/>
                 </xsl:call-template>
            </fo:block>
      </fo:table-cell>
      
      <fo:table-cell padding="1.5pt" wrap-option="wrap" border="1pt solid gray" background-color="#fffacd">
      	    <fo:block hyphenate="true">
	    <xsl:call-template name="normalize">
                     <xsl:with-param name="input" select="mapValue"/>
                 </xsl:call-template>
       	    </fo:block>
      </fo:table-cell>

      <fo:table-cell padding="1.5pt" border="1pt solid gray" background-color="#fffacd">
      	<fo:block hyphenate="true">
	      <xsl:call-template name="normalize">
                     <xsl:with-param name="input" select="forEach"/>
                 </xsl:call-template>
	</fo:block>
      </fo:table-cell>
      
      <fo:table-cell padding="1.5pt" border="1pt solid gray" background-color="#fffacd">
        <fo:block><xsl:apply-templates select="Sorting"/></fo:block>
      </fo:table-cell>

      <fo:table-cell padding="1.5pt" border="1pt solid gray" background-color="#fffacd">
        <fo:block hyphenate="true">
        <xsl:call-template name="normalize">
                     <xsl:with-param name="input" select="comments"/>
                 </xsl:call-template>
        </fo:block>
      </fo:table-cell>
      
      <fo:table-cell padding="1.5pt" border="1pt solid gray" background-color="#fffacd">
              <fo:block><xsl:apply-templates select="localVariables"/></fo:block>
      </fo:table-cell>
    </fo:table-row>
  </fo:table-body>
</fo:table>
</fo:block>
</xsl:template>

<xsl:template match="mappingInformation">
	<fo:table>
	  <fo:table-column column-width="1.7in" />
	  <fo:table-column column-width="5in" />
		<fo:table-body>
			<!--<fo:table-row overflow="visible">    
			    <fo:table-cell padding="2pt" border="1pt solid gray"  background-color="#eeeeee">
			        <fo:block> Mapping Version </fo:block>
		  	    </fo:table-cell>
  		        <fo:table-cell padding="2pt" border="1pt solid gray" align="start">
  		            <fo:block align="start">
				<xsl:value-of select="mappingVersion"/>
			    </fo:block>
			    </fo:table-cell>
			</fo:table-row>-->	
					
			<fo:table-row overflow="visible">    
			   <fo:table-cell padding="2pt" border="1pt solid gray"  background-color="#eeeeee">
				<fo:block> Mapping Name </fo:block>
			   </fo:table-cell>
			   <fo:table-cell padding="2pt" border="1pt solid gray">
				<fo:block hyphenate="true">
					<xsl:value-of select="mappingName"/>			
				</fo:block>
			   </fo:table-cell>
			</fo:table-row>				
	
			<fo:table-row overflow="visible">    
			<fo:table-cell padding="2pt" border="1pt solid gray"  background-color="#eeeeee">
			    <fo:block> Mapping Description </fo:block>
			</fo:table-cell>
			<fo:table-cell padding="2pt" border="1pt solid gray">
			    <fo:block hyphenate="true">
				<xsl:value-of select="mappingDescription"/>		
			    </fo:block>
			</fo:table-cell>
			</fo:table-row>	
							
			<fo:table-row overflow="visible">    
			    <fo:table-cell padding="2pt" border="1pt solid gray"  background-color="#eeeeee">
		            <fo:block> Creation Date </fo:block>
		            </fo:table-cell>
			    <fo:table-cell padding="2pt" border="1pt solid gray">
		            <fo:block hyphenate="true">
		            <xsl:apply-templates select="mappingCreationDate"/>
			    </fo:block>
			    </fo:table-cell>
			</fo:table-row>	
			
			<fo:table-row overflow="visible">    
			    <fo:table-cell padding="2pt" border="1pt solid gray"  background-color="#eeeeee">
			    <fo:block> Last Modified On </fo:block>
			    </fo:table-cell>
			    <fo:table-cell padding="2pt" border="1pt solid gray">
			    <fo:block hyphenate="true">
			    <xsl:apply-templates select="mappingModifiedDate"/>
			    </fo:block>
			    </fo:table-cell>
			</fo:table-row>				
	
			<fo:table-row overflow="visible">    
			    <fo:table-cell padding="2pt" border="1pt solid gray"  background-color="#eeeeee">
			    <fo:block> Created By </fo:block>
			    </fo:table-cell>
			    <fo:table-cell padding="2pt" border="1pt solid gray">
			    <fo:block hyphenate="true">
		            <xsl:apply-templates select="mappingOwner"/>			    
			    </fo:block>
			    </fo:table-cell>
			</fo:table-row>	
	
			<fo:table-row overflow="visible">    
			    <fo:table-cell padding="2pt" border="1pt solid gray"  background-color="#eeeeee">
			    <fo:block> Last Modified By </fo:block>
			    </fo:table-cell>
		            <fo:table-cell padding="2pt" border="1pt solid gray">
			    <fo:block hyphenate="true">
		            <xsl:apply-templates select="mappingLastModifiedBy"/>
			    </fo:block>
			    </fo:table-cell>
			</fo:table-row>	
			
			<fo:table-row overflow="visible">    
			  <fo:table-cell padding="2pt" border="1pt solid gray"  background-color="#eeeeee">
			  <fo:block> Group Owner </fo:block>
			  </fo:table-cell>
			  <fo:table-cell padding="2pt" border="1pt solid gray">
			  <fo:block hyphenate="true">
			  <xsl:apply-templates select="mappingOwnerGroup"/>
			  </fo:block>
			  </fo:table-cell>
			</fo:table-row>	
		</fo:table-body>
	</fo:table>
</xsl:template>


<xsl:template match="sourceRoots">
<fo:block text-align="center" background-color="#99cc00" line-height="20pt" border="1pt solid gray">
	Source Schemas
</fo:block>
	<fo:table border-collapse="collapse" background-color="#ccccff">
	  <fo:table-column column-width="33%"/>
	  <fo:table-column column-width="33%"/>
	  <fo:table-column column-width="34%"/>
	  <fo:table-body>
	    <fo:table-row>
	      <fo:table-cell padding="2pt" border="1.5pt solid gray">
	        <fo:block> Schema Name </fo:block>
	      </fo:table-cell>
		   <fo:table-cell padding="2pt" border="1.5pt solid gray">
	        <fo:block> Schema ID </fo:block>
	      </fo:table-cell>
         <fo:table-cell padding="2pt" border="1.5pt solid gray">
	        <fo:block> Schema Root </fo:block>
	       </fo:table-cell>
	    </fo:table-row>
	   </fo:table-body>
	</fo:table>	
	<xsl:apply-templates select="sourceRoot"/>
</xsl:template>

<xsl:template match="sourceRoot">
	<fo:table border-collapse="collapse" background-color="#ccccff">
	  <fo:table-column column-width="33%"/>
	  <fo:table-column column-width="33%"/>
	  <fo:table-column column-width="34%"/>
	  <fo:table-body>
	    <fo:table-row>
	    <fo:table-cell padding="1.5pt" border="1.5pt solid gray"  background-color="#FFFFFF">
	    		<fo:block hyphenate="true">
	  			  <xsl:call-template name="normalize">
                     <xsl:with-param name="input" select="schemaName"/>
                 </xsl:call-template>
			</fo:block>
	      </fo:table-cell>
	      <fo:table-cell padding="1.5pt" border="1.5pt solid gray"  background-color="#FFFFFF">
		<fo:block hyphenate="true">
		<xsl:call-template name="normalize">
            <xsl:with-param name="input" select="schemaID"/>
        </xsl:call-template>
		</fo:block>
	      </fo:table-cell>
	      <fo:table-cell padding="1.5pt" border="1.5pt solid gray"  background-color="#FFFFFF">
		<fo:block hyphenate="true">
		<xsl:call-template name="normalize">
            <xsl:with-param name="input" select="name"/>
        </xsl:call-template>
		</fo:block>
	      </fo:table-cell>
	    </fo:table-row>
	   </fo:table-body>
	</fo:table>	
</xsl:template>

<xsl:template match="targetRoots">
<fo:block text-align="center" background-color="#99cc00" line-height="20pt" border="1pt solid gray">
	Target Schemas
</fo:block>
	<fo:table border-collapse="collapse" background-color="#ccccff">
	  <fo:table-column column-width="25%"/>
	  <fo:table-column column-width="25%"/>
  	  <fo:table-column column-width="25%"/>
	  <fo:table-column column-width="25%"/> 
	  <fo:table-body>
	    <fo:table-row>
	      <fo:table-cell padding="2pt" border="1.5pt solid gray">
	        <fo:block> Schema Name </fo:block>
	      </fo:table-cell>
		  <fo:table-cell padding="2pt" border="1.5pt solid gray">
	        <fo:block> Schema ID </fo:block>
	      </fo:table-cell>
	      
         <fo:table-cell padding="2pt" border="1.5pt solid gray">
	        <fo:block> Schema Root </fo:block>
	       </fo:table-cell>
	       
	 <fo:table-cell padding="2pt" border="1.5pt solid gray">
	 	        <fo:block> Stream Name </fo:block>
	       </fo:table-cell>
	    </fo:table-row>
	   </fo:table-body>
	</fo:table>	
	<xsl:apply-templates select="targetRoot"/>
</xsl:template>

<xsl:template match="targetRoot">
	<fo:table border-collapse="collapse" background-color="#ccccff">
	  <fo:table-column column-width="25%"/>
	  <fo:table-column column-width="25%"/>
  	  <fo:table-column column-width="25%"/>
	  <fo:table-column column-width="25%"/>   
	  <fo:table-body>
	    <fo:table-row>
	    
	    <fo:table-cell padding="1.5pt" border="1.5pt solid gray"  background-color="#FFFFFF">
	    		<fo:block hyphenate="true">
	    		<xsl:call-template name="normalize">
                     <xsl:with-param name="input" select="schemaName"/>
                 </xsl:call-template>
	    		</fo:block>
	      </fo:table-cell>
	       <fo:table-cell padding="1.5pt" border="1.5pt solid gray"  background-color="#FFFFFF">
	    		<fo:block hyphenate="true">
	    		<xsl:call-template name="normalize">
                     <xsl:with-param name="input" select="schemaID"/>
                 </xsl:call-template>
	    		</fo:block>
	      </fo:table-cell>
	      <fo:table-cell padding="1.5pt" border="1.5pt solid gray"  background-color="#FFFFFF">
			<fo:block hyphenate="true">
			<xsl:call-template name="normalize">
                     <xsl:with-param name="input" select="name"/>
                 </xsl:call-template>
			</fo:block>
	      </fo:table-cell>
	      
	       <fo:table-cell padding="1.5pt" border="1.5pt solid gray"  background-color="#FFFFFF">
	      		<fo:block hyphenate="true">
	      		<xsl:call-template name="normalize">
                     <xsl:with-param name="input" select="stream"/>
                 </xsl:call-template>
	      		</fo:block>
	      </fo:table-cell>
	    </fo:table-row>
	   </fo:table-body>
	</fo:table>	
</xsl:template>

</xsl:stylesheet>
