Chris Pollett > Students >
Namon

    ( Print View )

    [Bio]

    [CS297Proposal]

    [Del1VML]

    [Del1SVG]

    [Del2Latex]

    [Del2MML]

    [Del3]

    [Del4]

    [CS297Report-PDF]

    [CS298Proposal]

    [CS298FinalReport-PDF]

    [CS298Presentation-PDF]

    [DemoSquareroot]

    [DemoSubscript]

    [DemoFraction]

                           

























Deliverable 3 -- Matrix Markup Language

      
Purpose: To create a DTD for matrices. Write an XSL transform to render 
this language in VML.

For this deliverable a Data Type Definition (DTD) is given for matrices
and an example document is written in this language. An XSLT document is 
then used to translate this particular XML document to a VML document 
for viewing.

The main reason for using the author's own DTD file is to 
reduce the complexity in the XSLT transformation at this beginning 
stage of the CS297 project. Eventually, MathML documents will be 
translated to VML using XSLT.

The Technical Specification for the author's matrixDTD:

1) The "matrices" element

Description:
This element is the root of the document. 

XML template:

<matrices></matrices>

2) The "matrix" element

Description:

This matrix element can cantain many nested matrices inside this matrix. 
It can contain many rows elements. This element has 2 attributes which 
are "numberOfRows" and "numberOfColumns"


<!ATTLIST matrix
	numberOfRows 	CDATA #REQUIRED
	numberOfColumns CDATA #REQUIRED
>

Attribute Descriptions:

numberOfRows is used for setting the number of rows in this matrix.
numberOfColumns is used for setting the number of columns in this 
                matrix.

3) The "row" element
Description:
This row element is used to define each row in the matrix. Row element 
can contain many columns elements.

4) The "column" element
Description:
This column element is used define each column within this row in 
   the matrix. 
This element has 1 attribute.
This column can also contain nested matrix.

<!ATTLIST column
	content CDATA #REQUIRED
>

Attribute Description
content attribute is used to hold the element to store in this column 
of the parent's row in the matrix.

An example

Below is an example matrix written in this DTD:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE histogram SYSTEM "MatrixDTD.dtd">
<?xml-stylesheet type="text/xsl" href="matrixXSL.xsl"?>

<matrices>

<matrix numberOfRows="3" numberOfColumns="6">
	
	<row>
		<column content = "x" />
		<column content = "y" />
		<column content = "12"/>
	        <column content = "y" />
		
		
	</row>
	
	<row>
		<column content = "z" />
		<column content = "" >
						<matrix numberOfRows="3" numberOfColumns="3">
							
							<row>
								<column content = "x" />
								<column content = "y" />
								<column content = "12"/>
								
							</row>
							<row>
								<column content = "z" />
								<column content = "1" />
								<column content = "8" />
								
							</row>
							
							<row>
								<column content = "90" />
								<column content = "f" />
								<column content = "g" />
							</row>
							
							
						</matrix>
		</column>
		
	
		<column content = "8" />
		<column content = "3.4" />
		<column content = "3.4" />
		<column content = "12"/>
		
	</row>
	
	<row>
		<column content = "90" />
		<column content = "f" />
		<column content = "" >
		<matrix numberOfRows="3" numberOfColumns="6">
			
			<row>
				<column content = "1.1" />
				<column content = "1.2" />
				<column content = "1.3"/>
				<column content = "1.4" />
				<column content = "1.5" />
				<column content = "1.6" />	
				
			</row>
			<row>
				<column content = "2.1" />
				<column content = "" >
						<matrix numberOfRows="3" numberOfColumns="5">
							
							<row>
								<column content = "2.2.1.1" />
								<column content = "2.2.1.2" />
								<column content = "2.2.1.3"/>
								
							</row>
							<row>
								<column content = "2.2.2.1" />
								<column content = "2.2.2.2" />
								<column content = "2.2.2.3" />
								<column content = "2.2.2.4" />
								<column content = "2.2.2.5" />

							</row>
							
							<row>
								<column content = "2.2.3.1" />
								<column content = "2.2.3.2" />
								<column content = "2.2.3.3" />
							</row>
							
							
						</matrix>
				</column>
		
	
				<column content = "2.3" />	
				<column content = "2.4" />
				<column content = "" />	
				<column content = "2.5" />	
			</row>
			
			<row>
				<column content = "3.1" />
				<column content = "3.2" />
				<column content = "3.3" />
				<column content = "3.4" />
				<column content = "3.5" />
											
			</row>
			
			
		</matrix>
		</column>
	</row>
	
	
</matrix>
</matrices>
		

This matrix when transformed by our stylesheet looks like:

Transformed matrix document

Source Code

The DTD:

<!-- "matrices" contain zero or more "matrix" elements. -->
<!ELEMENT matrices (matrix)>

<!-- "matrix" contains one or more "row" elements. -->
<!ELEMENT matrix (row+) >
<!-- "matrix" has 2 attributes which are "numberOfRows" and "numberOfColumns" -->
<!ATTLIST matrix
	numberOfRows 	CDATA #REQUIRED
	numberOfColumns CDATA #REQUIRED
>

<!-- "row" contains one ore more "column" elements. -->
<!ELEMENT row (column+) >

<!-- "column" contains zero or one "matrixInColumn element (in the future it will be able to contain another matrix) -->
<!ELEMENT column (matrix?)>
<!-- "column" has 1 attribute which is "content" (it is a matrix element in the matrix it can be either number,character variable, expression) -->
<!ATTLIST column
	content CDATA #REQUIRED
>


The stylesheet:

<!-- matrixXSL.xsl : convert xml document using my own DTD to VML document -->
<!-- Revision History -->
<!-- O3/15/2002 Namon Nuttayasakul -->
<!--            Original -->
<!-- 04/03/2002 Namon Nuttayasakul -->
<!--            1)add capability handle nested matrix -->
<!--               1.1)Implement its own code in column[matrix] template.   -->
<!-- 		   1.2)Add <choose> to assign the value to maxRows in the column[matrix] template. -->
<!--		       - If it has nested matrix in that matrix then set maxRows to number of rows in all the descendant then minus 1. -->
<!--		       - If it doesn't have nested matrix then set maxRows to numberOfRows attribute of that matrix -->
<!--               1.3)Add <choose> in the column[matrix] template to check if it's the first row then add bracket, otherwise just add <tr> tag -->
<!--               1.4)change the value assigning in the FindMaxRows template -->
<!--            2)add capability to handle extra columns that is more than the first row's number of columns -->
<!--            3)Change the text element in the matrix from HTML code to VML code. This is to prevent the problem when we increase the   -->
<!--              text size from the browser then the HTML tag element would increase its font size which will not match the VML tag for bracket -->
<!--              which never change its size when the brouwser try to change its size.  -->

<!-- XML Header -->
<?xml version="1.0"?>
<!-- xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform xmlns:xsl="http://www.w3.org/TR/WD-xsl" -->
<!-- xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" -->
<xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxsl="urn:schemas-microsoft-com:xslt"
      xmlns:user="http://mycompany.com/mynamespace">
<xsl:output method="html"/>


<!-- Declare variables -->
<!-- variable: heightPortion is used for multiply with the number of maximum rows in the matrix to assign the height of left & right matrix bracket -->
<xsl:variable name="heightPortion" select="170"/>

<!-- Function: JavaScript function to find the maximum number of column within each row. So, we can add <tr> tag for extra column. This is to make the bracket to cover extra column. -->
<msxsl:script language="JScript" implements-prefix="user">
  <![CDATA[
   function AddColumns(columnsAdd) {
      var output = "";
     while(columnsAdd != 0){
         output += "<td></td>";
         columnsAdd--;
      }
   
      return(output)
   }
  ]]>
</msxsl:script>    

<msxsl:script language="JScript" implements-prefix="user">
  <![CDATA[
   function FindMaxColumns(columns) {
      var output = "";
     while(columnsAdd != 0){
         output += "<td></td>";
         columnsAdd--;
      }
   
      return(output)
   }
  ]]>
</msxsl:script> 



<!-- variable: MaxRows is used for find the number of maximum row in the matrix (can be complicated in case of nested matrices) -->
<xsl:variable name="maxRows">
     	<xsl:call-template name="FindMaxRows">
             <xsl:with-param name="value" select="0"/>
        </xsl:call-template >
</xsl:variable>



<!-- If match with the root (matrices) add header of VML document -->
<xsl:template match="/">

    <html xmlns:v="urn:schemas-microsoft-com:vml">
        <head>
            <title>XML2VML-Matrix</title>
            <object id="VMLRender"
                classid="CLSID:10072CEC-8CC1-11D1-986E-00A0C955B42E">
            </object>
            <style>
                v\:* {behavior: url(#VMLRender)}
            </style>
            
            <v:shapetype id="leftbracket"
	      	coordsize="516,516"
	      	stroke="true"
	        strokecolor="black"
	        strokeweight="1.50pt"
	      	path="m 50,30 l 30,30, 30,120, 50,120 e">
	      </v:shapetype>
	    
	      <v:shapetype id="rightbracket"
	        	coordsize="516,516"
	        	path="m 30,30 l 50,30, 50,120, 30,120  e"
	        	stroke="true"
	    		strokecolor="black"
	    		strokeweight="1.50pt">
	      </v:shapetype>
        </head>
        
        <body>
            
            <xsl:apply-templates/>
            
        </body>        
    </html>
    
</xsl:template>

<!-- If match "matrix", add table header and set align to "center" -->
<xsl:template match="matrix">
    <!-- sets table width and align at center -->
    <table width="15%" align = "center">
    
    
    <!-- Add each row -->
    <xsl:apply-templates/>
    
       
    </table>
</xsl:template>


<!-- if row is the first one then add bracket into it -->
<!-- The left and right brackets are in the first row of table (in HTML). Therefore, the rowspan must be the number of rows of the entire matrix -->
<xsl:template match="row[position() = 1 ]">
   

   <!-- xsl:variable name="maxRows" select="sum(//@numberOfRows) - 1"/ -->
   
   <!-- output to test the value of maxRows -->
   <!-- xsl:text>maxRows = </xsl:text><xsl:value-of select="$maxRows"/ -->

   <tr>
	<!--Add Left Bracket ( we can also make this a template )-->
	   <!--<td rowspan="NumberOfRows" width="10%"> -->
	   <!--<v:shape type="#leftbracket" style='width:100px; height:(numberOfRows * heightPortion)px'/></v:shape> -->
	   <!--</td> -->
	
	<!-- This element uses attribute "tdBracketAttributes" to add <td> tag with its attributes to wrap this element -->
	<xsl:element name="td" use-attribute-sets="tdBracketAttributes">
	    
	    	<!-- output vml tag "v:shape type="#leftbracket" style='width:100px; height:300px'/></v:shape>" -->
		
		<!-- output and open vml tag "<" -->
	    	<xsl:text disable-output-escaping="yes">&lt;</xsl:text>
	    	
	    	<!-- output vml tag "v:shape type=" -->
	    	<xsl:text disable-output-escaping="yes">v:shape type=&quot;#leftbracket&quot; style=&quot;width:100px; height:</xsl:text>
	    	
	    	<!-- output hieght of the bracket which is "numberOfRow * heightPortion" -->
	      	<xsl:value-of select="$maxRows*$heightPortion"/>
	    	<xsl:text disable-output-escaping="yes">px &quot; /&gt;</xsl:text>
	</xsl:element>
	


	<!-- Add each column -->
	<xsl:apply-templates select="column"/>
	
		
        <!-- add <td> tag when there are extra columns in the following rows -->
        <!-- must find the maximum number of all the numberOfColumns in the following rows then compare with the numberOfColumns in the first rows -->
        <xsl:variable name="maxColumns" select="parent::matrix/attribute::numberOfColumns"/>
        <xsl:variable name="columnsInFirstRow" select="count(child::column)"/>
        <xsl:for-each select="following-sibling::row">
            
        	<xsl:if test="count(child::column) = $maxColumns">
        	   <xsl:for-each select="child::column">
        	      <xsl:if test="position() &gt; $columnsInFirstRow">
        		<td></td>
        	      </xsl:if>
        	   </xsl:for-each>
        	</xsl:if>
        </xsl:for-each>
	
	<!-- Add Right Bracket -->
	   <!-- <td rowspan="NumberOfRows" width="10%"> -->
	   <!-- <v:shape type="#rightbracket" style='width:100px; height:(numberOfRows * heightPortion)px'/></v:shape> -->
	   <!-- </td> -->
	
	<xsl:element name="td" use-attribute-sets="tdBracketAttributes">
	    
	    	<!-- output vml tag "v:shape type="#leftbracket" style='width:100px; height:300px'/></v:shape>" -->
		
		<!-- output and open vml tag "<" -->
	    	<xsl:text disable-output-escaping="yes">&lt;</xsl:text>
	    	
	    	<!-- output vml tag "v:shape type=" -->
	    	<xsl:text disable-output-escaping="yes">v:shape type=&quot;#rightbracket&quot; style=&quot;width:100px; height:</xsl:text>
	    	
	    	<!-- output hieght of the bracket which is "numberOfRow * heightPortion" -->
	      	<xsl:value-of select="$maxRows*$heightPortion"/>
	    	<xsl:text disable-output-escaping="yes">px &quot; /&gt;</xsl:text>
	</xsl:element>
    </tr>
</xsl:template>	  




<!-- if row is not the fist one then just add new row of table -->
<xsl:template match="row[position() &gt; 1]">
    <tr>
	<xsl:apply-templates select="column"/>
    </tr>
</xsl:template>


<!-- problem 1. it doesn't go in for-each. 2.it doesn't call column template -->


<xsl:template match="column[matrix]">
    <td width="25%" align="center"> 
   
    <!-- set maxRows to the numberOfRows attribute of the content node. -->
    <!-- if it contain nested matrix then set maxRows to Sum of numberOfRows of all the descendant and minus 1. -->    
    <!-- We need to copy the whole thing inside this loop, because the maxRows value doesn't update the global maxRows value outside this "when" tag -->
    <xsl:choose>
    	<xsl:when test="child::matrix/descendant::matrix">
     	    <xsl:variable name="maxRows" select="sum(descendant-or-self::*/@numberOfRows) - 1"/> 
     	     <!-- xsl:text> Have nested Matrix maxRows = </xsl:text><xsl:value-of select="$maxRows"/ -->
	    
	    
	    <table width="15%" align = "center">
	    
	     <!-- select only the child of child level (not more than that), So it doesn't go in the nested matrix. -->
	     <xsl:for-each select="child::matrix/child::row">
		
		<xsl:choose>
		   <!-- If it's the first row then add bracket to it, otherwise just add td tag -->	
		   <xsl:when test="position() = 1">
		   
    		   <tr>
    		    		    
			<!--Add Left Bracket ( we can also make this a template )-->
			   <!--<td rowspan="NumberOfRows" width="10%"> -->
			   <!--<v:shape type="#leftbracket" style='width:100px; height:(numberOfRows * heightPortion)px'/></v:shape> -->
			   <!--</td> -->
			
			<!-- This element uses attribute "tdBracketAttributes" to add <td> tag with its attributes to wrap this element -->
			<xsl:element name="td" use-attribute-sets="tdBracketAttributes">
			    
			    	<!-- output vml tag "v:shape type="#leftbracket" style='width:100px; height:300px'/></v:shape>" -->
				
				<!-- output and open vml tag "<" -->
			    	<xsl:text disable-output-escaping="yes">&lt;</xsl:text>
			    	
			    	<!-- output vml tag "v:shape type=" -->
			    	<xsl:text disable-output-escaping="yes">v:shape type=&quot;#leftbracket&quot; style=&quot;width:100px; height:</xsl:text>
			    	
			    	<!-- output hieght of the bracket which is "numberOfRow * heightPortion" -->
			      	<xsl:value-of select="$maxRows*$heightPortion"/>
			    	<xsl:text disable-output-escaping="yes">px &quot; /&gt;</xsl:text>
			</xsl:element>
			
		
		
			<!-- Add each column -->
			<xsl:apply-templates select="column"/>
			
		        <!-- add <td> tag when there are extra columns in the following rows -->
		        <!-- must find the maximum number of all the numberOfColumns in the following rows then compare with the numberOfColumns in the first rows -->
		        <xsl:variable name="maxColumns" select="parent::matrix/attribute::numberOfColumns"/>
		        <xsl:variable name="columnsInFirstRow" select="count(child::column)"/>
		        <xsl:for-each select="following-sibling::row">
		            
		        	<xsl:if test="count(child::column) = $maxColumns">
		        	   <xsl:for-each select="child::column">
		        	      <xsl:if test="position() &gt; $columnsInFirstRow">
		        		<td></td>
		        	      </xsl:if>
		        	   </xsl:for-each>
		        	</xsl:if>
       		       </xsl:for-each>
        		
        					
			
			<!-- Add Right Bracket -->
			   <!-- <td rowspan="NumberOfRows" width="10%"> -->
			   <!-- <v:shape type="#rightbracket" style='width:100px; height:(numberOfRows * heightPortion)px'/></v:shape> -->
			   <!-- </td> -->
			
			<xsl:element name="td" use-attribute-sets="tdBracketAttributes">
			    
			    	<!-- output vml tag "v:shape type="#leftbracket" style='width:100px; height:300px'/></v:shape>" -->
				
				<!-- output and open vml tag "<" -->
			    	<xsl:text disable-output-escaping="yes">&lt;</xsl:text>
			    	
			    	<!-- output vml tag "v:shape type=" -->
			    	<xsl:text disable-output-escaping="yes">v:shape type=&quot;#rightbracket&quot; style=&quot;width:100px; height:</xsl:text>
			    	
			    	<!-- output hieght of the bracket which is "numberOfRow * heightPortion" -->
			      	<xsl:value-of select="$maxRows*$heightPortion"/>
			    	<xsl:text disable-output-escaping="yes">px &quot; /&gt;</xsl:text>
			</xsl:element>
		    </tr>
		    	
		   </xsl:when>
		   
		   
		   <!-- if it's not the first row just add tr tag to it, then call column template. -->
		   <xsl:when test="position() &gt; 1">
		    	<xsl:for-each select=".">
		   	  <tr>
				<xsl:apply-templates select="column"/>
    			  </tr>		      		
		    	</xsl:for-each>
		   
		  </xsl:when>
		  
		  
		        
                </xsl:choose>
	      </xsl:for-each>
       
   	    </table>


   	</xsl:when>
   	
   	
   	<!-- Check if it doesn't have anymore nested matrix then set maxRows to numberOfRows attribute of that matrix -->
   	<!-- We need to copy the whole thing inside this loop, because the maxRows value doesn't update the global maxRows value outside this "when" tag -->
   	<xsl:otherwise>
   	    <xsl:variable name="maxRows" select="child::matrix/attribute::numberOfRows"/>
   	    <!-- xsl:text> No nested matrix maxRows = </xsl:text><xsl:value-of select="$maxRows"/ -->
   	    

	    <table width="15%" align = "center">
	    
	     <!-- select only the child of child level (not more than that), So it doesn't go in the nested matrix. -->
	     <xsl:for-each select="child::matrix/child::row">
		
		<xsl:choose>
		   <!-- If it's the first row then add bracket to it, otherwise just add td tag -->	
		   <xsl:when test="position() = 1">
		   
    		   <tr>
    		    		    
			<!--Add Left Bracket ( we can also make this a template )-->
			   <!--<td rowspan="NumberOfRows" width="10%"> -->
			   <!--<v:shape type="#leftbracket" style='width:100px; height:(numberOfRows * heightPortion)px'/></v:shape> -->
			   <!--</td> -->
			
			<!-- This element uses attribute "tdBracketAttributes" to add <td> tag with its attributes to wrap this element -->
			<xsl:element name="td" use-attribute-sets="tdBracketAttributes">
			    
			    	<!-- output vml tag "v:shape type="#leftbracket" style='width:100px; height:300px'/></v:shape>" -->
				
				<!-- output and open vml tag "<" -->
			    	<xsl:text disable-output-escaping="yes">&lt;</xsl:text>
			    	
			    	<!-- output vml tag "v:shape type=" -->
			    	<xsl:text disable-output-escaping="yes">v:shape type=&quot;#leftbracket&quot; style=&quot;width:100px; height:</xsl:text>
			    	
			    	<!-- output hieght of the bracket which is "numberOfRow * heightPortion" -->
			      	<xsl:value-of select="$maxRows*$heightPortion"/>
			    	<xsl:text disable-output-escaping="yes">px &quot; /&gt;</xsl:text>
			</xsl:element>
			
		
			
			<!-- Add each column -->
			<xsl:apply-templates select="column"/>
   		
   		        <!-- add <td> tag when there are extra columns in the following rows -->
		        <!-- must find the maximum number of all the numberOfColumns in the following rows then compare with the numberOfColumns in the first rows -->
		        <xsl:variable name="maxColumns" select="parent::matrix/attribute::numberOfColumns"/>
		        <xsl:variable name="columnsInFirstRow" select="count(child::column)"/>
		        <xsl:for-each select="following-sibling::row">
		            
		        	<xsl:if test="count(child::column) = $maxColumns">
		        	   <xsl:for-each select="child::column">
		        	      <xsl:if test="position() &gt; $columnsInFirstRow">
		        		<td></td>
		        	      </xsl:if>
		        	   </xsl:for-each>
		        	</xsl:if>
        		</xsl:for-each>
			
			
			<!-- Add Right Bracket -->
			   <!-- <td rowspan="NumberOfRows" width="10%"> -->
			   <!-- <v:shape type="#rightbracket" style='width:100px; height:(numberOfRows * heightPortion)px'/></v:shape> -->
			   <!-- </td> -->
			
			<xsl:element name="td" use-attribute-sets="tdBracketAttributes">
			    
			    	<!-- output vml tag "v:shape type="#leftbracket" style='width:100px; height:300px'/></v:shape>" -->
				
				<!-- output and open vml tag "<" -->
			    	<xsl:text disable-output-escaping="yes">&lt;</xsl:text>
			    	
			    	<!-- output vml tag "v:shape type=" -->
			    	<xsl:text disable-output-escaping="yes">v:shape type=&quot;#rightbracket&quot; style=&quot;width:100px; height:</xsl:text>
			    	
			    	<!-- output hieght of the bracket which is "numberOfRow * heightPortion" -->
			      	<xsl:value-of select="$maxRows*$heightPortion"/>
			    	<xsl:text disable-output-escaping="yes">px &quot; /&gt;</xsl:text>
			</xsl:element>
		    </tr>
		    	
		   </xsl:when>
		   
		   
		   <!-- if it's not the first row just add tr tag to it, then call column template. -->
		   <xsl:when test="position() &gt; 1">
		    	<xsl:for-each select=".">
		   	  <tr>
				<xsl:apply-templates select="column"/>
    			  </tr>		      		
		    	</xsl:for-each>
		   
		  </xsl:when>
		        
                </xsl:choose>
	      </xsl:for-each>
       
   	    </table>   	
   	
   	</xsl:otherwise>
    </xsl:choose>
    	
    
        <!-- test number of rows in this loop and out put the value of maxRows --> 
        <!-- xsl:text>maxRowsInColumn[matrix] = </xsl:text><xsl:value-of select="$maxRows"/ -->
        <!-- end test -->
    

    </td>
	
</xsl:template>


<xsl:template match="column">

 
       <xsl:text disable-output-escaping="yes">&lt;td width=&quot;25%&quot;&gt;</xsl:text>
 
    <!-- The font is VML code -->
    <!-- <div align="center"> -->
    <!-- <v:shape style='width:60;height:70' path="m 200 500 l 600 500 e" fillcolor="black" title="mi" > -->
    <!-- <v:path textpathok="t"/>  -->
    <!-- <v:textpath on="t" style='position:absolute;font-family:"Courier New";monospace; font-style:"italic";' -->
    <!--  string="a" /> -->
    <!-- </v:shape> -->
    <!--  </div> -->
    <!-- end comment -->
        
        
      <div align="center"><i>
	

	<!-- output and open vml tag "<" -->
	<xsl:text disable-output-escaping="yes">&lt;</xsl:text>
	<!-- output vml tag "v:shape type=" -->
        <xsl:text disable-output-escaping="yes">v:shape style=&quot;width:50;height:60&quot; path=&quot;m 200 500 l 600 500 e&quot; fillcolor=&quot;black&quot; title=&quot;mi&quot; &gt;</xsl:text>
        <xsl:text disable-output-escaping="yes">&lt;v:path textpathok=&quot;t&quot;/&gt;</xsl:text>
        <xsl:text disable-output-escaping="yes">&lt;v:textpath on=&quot;t&quot; style=&quot;position:absolute;font-family:&quot;Courier New&quot;;monospace; font-style:&quot;italic&quot;;&quot; string=&quot;</xsl:text>
        <!-- The value of matrix's element -->
        <xsl:value-of select="@content"/>
        <xsl:text disable-output-escaping="yes">&quot; /&gt;</xsl:text>
        <xsl:text disable-output-escaping="yes">&lt;/v:shape&gt;</xsl:text>
	
      
      </i></div>
   <xsl:text disable-output-escaping="yes">&lt;/td&gt;</xsl:text>
	
</xsl:template>

<!-- Template to assign the value to the global variable "maxRows" -->
<!-- maxRows is equal to number of rows of this root matrix and all the nested matrix minus 1 -->
<xsl:template name="FindMaxRows">

 	<xsl:param name="value"/>
	<xsl:choose>

	<xsl:when test="$value=0">
 	   <xsl:value-of select="sum(descendant-or-self::*/@numberOfRows)"/>   
	</xsl:when>
    
        </xsl:choose>
        
</xsl:template>

<!-- Attributes of td for the left & right brackets -->
<xsl:attribute-set name="tdBracketAttributes">
	<xsl:attribute name="rowspan"><xsl:value-of select="$maxRows"/></xsl:attribute>
	<xsl:attribute name="width">10%</xsl:attribute>
</xsl:attribute-set>


 
<!-- Attributes of extracolumn for adding text tag-->
<xsl:attribute-set name="textAttributes">
	<xsl:attribute name="disable-output-escaping"><xsl:value-of select="yes"/></xsl:attribute>	
</xsl:attribute-set>



<xsl:template name="AddMoreColumns">

    <xsl:param name="value"/>
    <xsl:choose>

	  <xsl:when test="$value=0">
 	   <xsl:value-of select="1"/>   
	   <td>
	   </td>
	  </xsl:when>
	
	  <xsl:otherwise>
	   <td>
	   </td>
	   <xsl:variable name="temp">
	      <xsl:call-template name="AddMoreColumns">
	        <xsl:with-param name="value" select="$value - 1"/>
              </xsl:call-template>
	   </xsl:variable>
	   <xsl:value-of select="$temp * $value"/>
	</xsl:otherwise>
  	  
    </xsl:choose>
        
</xsl:template>


</xsl:stylesheet>