home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 June / maximum-cd-2011-06.iso / DiscContents / LibO_3.3.1_Win_x86_install_multi.exe / libreoffice1.cab / wordml2ooo_path.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2010-12-01  |  113.2 KB  |  1,819 lines

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3.  
  4.   DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  5.   
  6.   Copyright 2000, 2010 Oracle and/or its affiliates.
  7.  
  8.   OpenOffice.org - a multi-platform office productivity suite
  9.  
  10.   This file is part of OpenOffice.org.
  11.  
  12.   OpenOffice.org is free software: you can redistribute it and/or modify
  13.   it under the terms of the GNU Lesser General Public License version 3
  14.   only, as published by the Free Software Foundation.
  15.  
  16.   OpenOffice.org is distributed in the hope that it will be useful,
  17.   but WITHOUT ANY WARRANTY; without even the implied warranty of
  18.   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19.   GNU Lesser General Public License version 3 for more details
  20.   (a copy is included in the LICENSE file that accompanied this code).
  21.  
  22.   You should have received a copy of the GNU Lesser General Public License
  23.   version 3 along with OpenOffice.org.  If not, see
  24.   <http://www.openoffice.org/license.html>
  25.   for a copy of the LGPLv3 License.
  26.  
  27. -->
  28. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word/2003/auxHint" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:aml="http://schemas.microsoft.com/aml/2001/core" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" exclude-result-prefixes="w wx aml o dt  v">
  29.     <xsl:include href="../../common/math.xsl"/>
  30.     <xsl:template name="dummy">
  31.         <xsl:call-template name="test"/>
  32.     </xsl:template>
  33.     <xsl:template name="test-arc">
  34.         <xsl:call-template name="svg-arc2vml-arc">
  35.             <!--  M 125,75 a100,50 0 ?,? 100,50 -->
  36.             <xsl:with-param name="x0" select="125"/>
  37.             <xsl:with-param name="y0" select="75"/>
  38.             <xsl:with-param name="rx" select="100"/>
  39.             <xsl:with-param name="ry" select="50"/>
  40.             <xsl:with-param name="x-axis-rotation" select="0"/>
  41.             <xsl:with-param name="large-arc-flag" select="0"/>
  42.             <xsl:with-param name="sweep-flag" select="0"/>
  43.             <xsl:with-param name="x" select="225"/>
  44.             <xsl:with-param name="y" select="125"/>
  45.         </xsl:call-template>
  46.     </xsl:template>
  47.     <xsl:template name="test">
  48.         <xsl:call-template name="vmlpath2svgpath">
  49.             <xsl:with-param name="vml-path" select="'m,l,4500,3420,2520,6120,4500r2160,l6660,3240,8460,2520,8460,,3960,540r360,720l2700,1260,3240,540,,xe'"/>
  50.         </xsl:call-template>
  51.     </xsl:template>
  52.     <xsl:template name="vmlpath2svgpath">
  53.         <xsl:param name="vml-path"/>
  54.         <xsl:param name="svg-path" select="''"/>
  55.         <xsl:param name="position" select="1"/>
  56.         <xsl:param name="last-command" select="'m'"/>
  57.         <xsl:param name="current-x" select="'0'"/>
  58.         <xsl:param name="current-y" select="'0'"/>
  59.         <xsl:variable name="command-and-newpos">
  60.             <xsl:call-template name="get-path-command">
  61.                 <xsl:with-param name="vml-path" select="$vml-path"/>
  62.                 <xsl:with-param name="position" select="$position"/>
  63.                 <xsl:with-param name="last-command" select="$last-command"/>
  64.             </xsl:call-template>
  65.         </xsl:variable>
  66.         <xsl:variable name="command" select="substring-before($command-and-newpos , ':')"/>
  67.         <xsl:variable name="newpos" select="substring-after($command-and-newpos , ':')"/>
  68.         <xsl:choose>
  69.             <xsl:when test="$command = 'm' ">
  70.                 <!-- absolute moveto -->
  71.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' M ' ) "/>
  72.                 <xsl:variable name="num-and-pos">
  73.                     <xsl:call-template name="get-number-after">
  74.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  75.                         <xsl:with-param name="position" select="$newpos"/>
  76.                         <xsl:with-param name="count" select="2"/>
  77.                     </xsl:call-template>
  78.                 </xsl:variable>
  79.                 <xsl:call-template name="vmlpath2svgpath">
  80.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  81.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  82.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  83.                     <xsl:with-param name="last-command" select="$command"/>
  84.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  85.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  86.                 </xsl:call-template>
  87.             </xsl:when>
  88.             <xsl:when test="$command = 't' ">
  89.                 <!-- relative moveto -->
  90.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' m ' ) "/>
  91.                 <xsl:variable name="num-and-pos">
  92.                     <xsl:call-template name="get-number-after">
  93.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  94.                         <xsl:with-param name="position" select="$newpos"/>
  95.                         <xsl:with-param name="count" select="2"/>
  96.                     </xsl:call-template>
  97.                 </xsl:variable>
  98.                 <xsl:call-template name="vmlpath2svgpath">
  99.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  100.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  101.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  102.                     <xsl:with-param name="last-command" select="$command"/>
  103.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')    , ' ')  + $current-x"/>
  104.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')    , ' ') + $current-y "/>
  105.                 </xsl:call-template>
  106.             </xsl:when>
  107.             <xsl:when test="$command = 'l' ">
  108.                 <!-- absolute lineto -->
  109.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' L ' ) "/>
  110.                 <xsl:variable name="num-and-pos">
  111.                     <xsl:call-template name="get-number-after">
  112.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  113.                         <xsl:with-param name="position" select="$newpos"/>
  114.                         <xsl:with-param name="count" select="2"/>
  115.                     </xsl:call-template>
  116.                 </xsl:variable>
  117.                 <xsl:call-template name="vmlpath2svgpath">
  118.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  119.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  120.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  121.                     <xsl:with-param name="last-command" select="$command"/>
  122.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  123.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  124.                 </xsl:call-template>
  125.             </xsl:when>
  126.             <xsl:when test="$command = 'r' ">
  127.                 <!-- relative lineto -->
  128.                 <!-- 'l' command is not supported currently, so we use 'L' -->
  129.                 <xsl:message>'l' command is not supported currently, so we use 'L'. This may case problem.</xsl:message>
  130.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' L ' ) "/>
  131.                 <xsl:variable name="num-and-pos">
  132.                     <xsl:call-template name="get-number-after">
  133.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  134.                         <xsl:with-param name="position" select="$newpos"/>
  135.                         <xsl:with-param name="count" select="2"/>
  136.                     </xsl:call-template>
  137.                 </xsl:variable>
  138.                 <xsl:variable name="new-x" select=" substring-before( substring-before( $num-and-pos , ':')  , ' ')  + $current-x  "/>
  139.                 <xsl:variable name="new-y" select=" substring-after( substring-before( $num-and-pos , ':')    , ' ')  + $current-y "/>
  140.                 <xsl:call-template name="vmlpath2svgpath">
  141.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  142.                     <!-- 'l' command is not supported currently-->
  143.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , $new-x ,' ' , $new-y  , ' ') "/>
  144.                     <!-- xsl:with-param name="svg-path" select=" concat($new-svg-path , substring-before( $num-and-pos , ':')  , ' ') "/ -->
  145.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  146.                     <xsl:with-param name="last-command" select="$command"/>
  147.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')  , ' ')  + $current-x  "/>
  148.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')    , ' ')  + $current-y "/>
  149.                 </xsl:call-template>
  150.             </xsl:when>
  151.             <xsl:when test="$command = 'dummyH' ">
  152.                 <!-- absolute horizontal  lineto -->
  153.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' l ' ) "/>
  154.                 <xsl:variable name="num-and-pos">
  155.                     <xsl:call-template name="get-number-after">
  156.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  157.                         <xsl:with-param name="position" select="$newpos"/>
  158.                         <xsl:with-param name="count" select="1"/>
  159.                     </xsl:call-template>
  160.                 </xsl:variable>
  161.                 <xsl:call-template name="vmlpath2svgpath">
  162.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  163.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , substring-before( $num-and-pos , ':')  , ' ' , $current-y , ' ') "/>
  164.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  165.                     <xsl:with-param name="last-command" select="$command"/>
  166.                     <xsl:with-param name="current-x" select=" substring-before( $num-and-pos , ':')  "/>
  167.                     <xsl:with-param name="current-y" select=" $current-y"/>
  168.                 </xsl:call-template>
  169.             </xsl:when>
  170.             <xsl:when test="$command = 'dummyh' ">
  171.                 <!-- relative horizontal  lineto -->
  172.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' l ' ) "/>
  173.                 <xsl:variable name="num-and-pos">
  174.                     <xsl:call-template name="get-number-after">
  175.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  176.                         <xsl:with-param name="position" select="$newpos"/>
  177.                         <xsl:with-param name="count" select="1"/>
  178.                     </xsl:call-template>
  179.                 </xsl:variable>
  180.                 <xsl:call-template name="vmlpath2svgpath">
  181.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  182.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , substring-before( $num-and-pos , ':') + $current-x  , ' ' , $current-y , ' ') "/>
  183.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  184.                     <xsl:with-param name="last-command" select="$command"/>
  185.                     <xsl:with-param name="current-x" select=" substring-before( $num-and-pos , ':')  + $current-x"/>
  186.                     <xsl:with-param name="current-y" select=" $current-y"/>
  187.                 </xsl:call-template>
  188.             </xsl:when>
  189.             <xsl:when test="$command = 'dummyV' ">
  190.                 <!-- absolute vertical  lineto -->
  191.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' l ' ) "/>
  192.                 <xsl:variable name="num-and-pos">
  193.                     <xsl:call-template name="get-number-after">
  194.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  195.                         <xsl:with-param name="position" select="$newpos"/>
  196.                         <xsl:with-param name="count" select="1"/>
  197.                     </xsl:call-template>
  198.                 </xsl:variable>
  199.                 <xsl:call-template name="vmlpath2svgpath">
  200.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  201.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , $current-x , ' ' , substring-before( $num-and-pos , ':')  , ' ' ) "/>
  202.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  203.                     <xsl:with-param name="last-command" select="$command"/>
  204.                     <xsl:with-param name="current-x" select=" $current-x"/>
  205.                     <xsl:with-param name="current-y" select=" substring-before( $num-and-pos , ':')  "/>
  206.                 </xsl:call-template>
  207.             </xsl:when>
  208.             <xsl:when test="$command = 'dummyv' ">
  209.                 <!-- relative horizontal  lineto -->
  210.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' l ' ) "/>
  211.                 <xsl:variable name="num-and-pos">
  212.                     <xsl:call-template name="get-number-after">
  213.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  214.                         <xsl:with-param name="position" select="$newpos"/>
  215.                         <xsl:with-param name="count" select="1"/>
  216.                     </xsl:call-template>
  217.                 </xsl:variable>
  218.                 <xsl:call-template name="vmlpath2svgpath">
  219.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  220.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , $current-x , ' ' , substring-before( $num-and-pos , ':')  + $current-y , ' ' ) "/>
  221.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  222.                     <xsl:with-param name="last-command" select="$command"/>
  223.                     <xsl:with-param name="current-x" select=" $current-x"/>
  224.                     <xsl:with-param name="current-y" select=" substring-before( $num-and-pos , ':')  "/>
  225.                 </xsl:call-template>
  226.             </xsl:when>
  227.             <xsl:when test="$command = 'c' ">
  228.                 <!-- absolute curveto -->
  229.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' C ' ) "/>
  230.                 <xsl:variable name="control-and-pos">
  231.                     <xsl:call-template name="get-number-after">
  232.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  233.                         <xsl:with-param name="position" select="$newpos"/>
  234.                         <xsl:with-param name="count" select="4"/>
  235.                     </xsl:call-template>
  236.                 </xsl:variable>
  237.                 <xsl:variable name="num-and-pos">
  238.                     <xsl:call-template name="get-number-after">
  239.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  240.                         <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
  241.                         <xsl:with-param name="count" select="2"/>
  242.                     </xsl:call-template>
  243.                 </xsl:variable>
  244.                 <xsl:call-template name="vmlpath2svgpath">
  245.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  246.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , substring-before( $control-and-pos , ':')  , ' ' ,  substring-before( $num-and-pos , ':')  , ' ') "/>
  247.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  248.                     <xsl:with-param name="last-command" select="$command"/>
  249.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  250.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  251.                 </xsl:call-template>
  252.             </xsl:when>
  253.             <xsl:when test="$command = 'v' ">
  254.                 <!-- relative curveto -->
  255.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' c ' ) "/>
  256.                 <xsl:variable name="control-and-pos">
  257.                     <xsl:call-template name="get-number-after">
  258.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  259.                         <xsl:with-param name="position" select="$newpos"/>
  260.                         <xsl:with-param name="count" select="4"/>
  261.                     </xsl:call-template>
  262.                 </xsl:variable>
  263.                 <xsl:variable name="num-and-pos">
  264.                     <xsl:call-template name="get-number-after">
  265.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  266.                         <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
  267.                         <xsl:with-param name="count" select="2"/>
  268.                     </xsl:call-template>
  269.                 </xsl:variable>
  270.                 <xsl:call-template name="vmlpath2svgpath">
  271.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  272.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , substring-before( $control-and-pos , ':')  , ' ' ,  substring-before( $num-and-pos , ':')  , ' ') "/>
  273.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  274.                     <xsl:with-param name="last-command" select="$command"/>
  275.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')  , ' ')  + $current-x  "/>
  276.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')    , ' ')  + $current-y "/>
  277.                 </xsl:call-template>
  278.             </xsl:when>
  279.             <xsl:when test="$command = 'dummyS' ">
  280.                 <!-- absolute shorthand/smooth curveto -->
  281.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' c ' ) "/>
  282.                 <xsl:variable name="control-and-pos">
  283.                     <xsl:call-template name="get-number-after">
  284.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  285.                         <xsl:with-param name="position" select="$newpos"/>
  286.                         <xsl:with-param name="count" select="2"/>
  287.                     </xsl:call-template>
  288.                 </xsl:variable>
  289.                 <xsl:variable name="num-and-pos">
  290.                     <xsl:call-template name="get-number-after">
  291.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  292.                         <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
  293.                         <xsl:with-param name="count" select="2"/>
  294.                     </xsl:call-template>
  295.                 </xsl:variable>
  296.                 <xsl:variable name="control-1">
  297.                     <xsl:choose>
  298.                         <xsl:when test="string-length(translate($last-command, 'CcSs','')  )= 0 ">
  299.                             <xsl:variable name="previous-control-2">
  300.                                 <xsl:call-template name="get-number-before">
  301.                                     <xsl:with-param name="vml-path" select="$vml-path"/>
  302.                                     <xsl:with-param name="position" select="$position"/>
  303.                                     <xsl:with-param name="count" select="2"/>
  304.                                     <xsl:with-param name="skipcount" select="2"/>
  305.                                 </xsl:call-template>
  306.                             </xsl:variable>
  307.                             <xsl:value-of select="substring-before($previous-control-2 , ':') "/>
  308.                         </xsl:when>
  309.                         <xsl:otherwise>
  310.                             <xsl:value-of select="substring-before($control-and-pos, ':') "/>
  311.                         </xsl:otherwise>
  312.                     </xsl:choose>
  313.                 </xsl:variable>
  314.                 <xsl:call-template name="vmlpath2svgpath">
  315.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  316.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path ,  $control-1 , ' ' ,  substring-before( $control-and-pos , ':')  , ' ' ,  substring-before( $num-and-pos , ':')  , ' ') "/>
  317.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  318.                     <xsl:with-param name="last-command" select="$command"/>
  319.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  320.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  321.                 </xsl:call-template>
  322.             </xsl:when>
  323.             <xsl:when test="$command = 'dummys' ">
  324.                 <!-- absolute shorthand/smooth curveto -->
  325.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' v ' ) "/>
  326.                 <xsl:variable name="control-and-pos">
  327.                     <xsl:call-template name="get-number-after">
  328.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  329.                         <xsl:with-param name="position" select="$newpos"/>
  330.                         <xsl:with-param name="count" select="2"/>
  331.                     </xsl:call-template>
  332.                 </xsl:variable>
  333.                 <xsl:variable name="num-and-pos">
  334.                     <xsl:call-template name="get-number-after">
  335.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  336.                         <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
  337.                         <xsl:with-param name="count" select="2"/>
  338.                     </xsl:call-template>
  339.                 </xsl:variable>
  340.                 <xsl:variable name="control-1">
  341.                     <xsl:choose>
  342.                         <xsl:when test="string-length(translate($last-command, 'CcSs' , '')) = 0 ">
  343.                             <xsl:variable name="previous-control-2">
  344.                                 <xsl:call-template name="get-number-before">
  345.                                     <xsl:with-param name="vml-path" select="$vml-path"/>
  346.                                     <xsl:with-param name="position" select="$position"/>
  347.                                     <xsl:with-param name="count" select="2"/>
  348.                                     <xsl:with-param name="skipcount" select="2"/>
  349.                                 </xsl:call-template>
  350.                             </xsl:variable>
  351.                             <xsl:value-of select="substring-before($previous-control-2 , ':') "/>
  352.                         </xsl:when>
  353.                         <xsl:otherwise>
  354.                             <xsl:value-of select="substring-before($control-and-pos, ':') "/>
  355.                         </xsl:otherwise>
  356.                     </xsl:choose>
  357.                 </xsl:variable>
  358.                 <xsl:call-template name="vmlpath2svgpath">
  359.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  360.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path ,  $control-1 , ' ' ,  substring-before( $control-and-pos , ':')  , ' ' ,  substring-before( $num-and-pos , ':')  , ' ') "/>
  361.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  362.                     <xsl:with-param name="last-command" select="$command"/>
  363.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')  , ' ')  + $current-x  "/>
  364.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')    , ' ')  + $current-y "/>
  365.                 </xsl:call-template>
  366.             </xsl:when>
  367.             <xsl:when test="$command = 'dummyQ' ">
  368.                 <!-- absolute quadratic  b├⌐zier curves  -->
  369.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' qb ' ) "/>
  370.                 <xsl:variable name="control-and-pos">
  371.                     <xsl:call-template name="get-number-after">
  372.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  373.                         <xsl:with-param name="position" select="$newpos"/>
  374.                         <xsl:with-param name="count" select="2"/>
  375.                     </xsl:call-template>
  376.                 </xsl:variable>
  377.                 <xsl:variable name="num-and-pos">
  378.                     <xsl:call-template name="get-number-after">
  379.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  380.                         <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
  381.                         <xsl:with-param name="count" select="2"/>
  382.                     </xsl:call-template>
  383.                 </xsl:variable>
  384.                 <xsl:call-template name="vmlpath2svgpath">
  385.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  386.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , substring-before( $control-and-pos , ':')  , ' ' ,  substring-before( $num-and-pos , ':')  , ' ') "/>
  387.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  388.                     <xsl:with-param name="last-command" select="$command"/>
  389.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  390.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  391.                 </xsl:call-template>
  392.             </xsl:when>
  393.             <xsl:when test="$command = 'dummyq' ">
  394.                 <!-- relative  quadratic  b├⌐zier curves -->
  395.                 <xsl:variable name="control-and-pos">
  396.                     <xsl:call-template name="get-number-after">
  397.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  398.                         <xsl:with-param name="position" select="$newpos"/>
  399.                         <xsl:with-param name="count" select="2"/>
  400.                     </xsl:call-template>
  401.                 </xsl:variable>
  402.                 <xsl:variable name="control" select="substring-before( $control-and-pos , ':') "/>
  403.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' qb ' ,  substring-before($control,' ') + $current-x , ' '  , substring-after($control , ' ') + $current-y ) "/>
  404.                 <xsl:variable name="num-and-pos">
  405.                     <xsl:call-template name="get-number-after">
  406.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  407.                         <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
  408.                         <xsl:with-param name="count" select="2"/>
  409.                     </xsl:call-template>
  410.                 </xsl:variable>
  411.                 <xsl:variable name="number" select="substring-before($num-and-pos, ':')"/>
  412.                 <xsl:variable name="absolute-number" select="concat(substring-before($number, ' ') + $current-x  , ' ' , substring-after($number, ' ') + $current-y)"/>
  413.                 <xsl:call-template name="vmlpath2svgpath">
  414.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  415.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path   , ' ' ,  $absolute-number  , ' ') "/>
  416.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  417.                     <xsl:with-param name="last-command" select="$command"/>
  418.                     <xsl:with-param name="current-x" select=" substring-before( $absolute-number  , ' ') "/>
  419.                     <xsl:with-param name="current-y" select=" substring-after( $absolute-number   , ' ') "/>
  420.                 </xsl:call-template>
  421.             </xsl:when>
  422.             <xsl:when test="$command = 'x' ">
  423.                 <!--dummy or $command = 'z' "-->
  424.                 <!-- closepath -->
  425.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' Z ' ) "/>
  426.                 <xsl:call-template name="vmlpath2svgpath">
  427.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  428.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , ' ') "/>
  429.                     <xsl:with-param name="position" select=" $newpos  "/>
  430.                     <xsl:with-param name="last-command" select="$command"/>
  431.                     <xsl:with-param name="current-x" select=" $current-x "/>
  432.                     <xsl:with-param name="current-y" select=" $current-y"/>
  433.                 </xsl:call-template>
  434.             </xsl:when>
  435.             <xsl:when test="$command = 'e' ">
  436.                 <!-- end path -->
  437.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' N ' )"/>
  438.                 <xsl:call-template name="vmlpath2svgpath">
  439.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  440.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , ' ') "/>
  441.                     <xsl:with-param name="position" select=" $newpos  "/>
  442.                     <xsl:with-param name="last-command" select="$command"/>
  443.                     <xsl:with-param name="current-x" select=" $current-x "/>
  444.                     <xsl:with-param name="current-y" select=" $current-y"/>
  445.                 </xsl:call-template>
  446.             </xsl:when>
  447.             <!--Code below is for the support of h-command like ha,hb....hi, maybe still need to revise-->
  448.             <xsl:when test="$command = 'ha' ">
  449.                 <xsl:variable name="new-svg-path" select="$svg-path"/>
  450.                 <!--simply did nothing which might be wrong-->
  451.                 <xsl:call-template name="vmlpath2svgpath">
  452.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  453.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , ' ') "/>
  454.                     <xsl:with-param name="position" select=" $newpos  "/>
  455.                     <xsl:with-param name="last-command" select="$command"/>
  456.                     <xsl:with-param name="current-x" select=" $current-x "/>
  457.                     <xsl:with-param name="current-y" select=" $current-y"/>
  458.                 </xsl:call-template>
  459.             </xsl:when>
  460.             <xsl:when test="$command = 'hb' ">
  461.                 <xsl:variable name="new-svg-path" select="$svg-path"/>
  462.                 <!--simply did nothing which might be wrong-->
  463.                 <xsl:call-template name="vmlpath2svgpath">
  464.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  465.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , ' ') "/>
  466.                     <xsl:with-param name="position" select=" $newpos  "/>
  467.                     <xsl:with-param name="last-command" select="$command"/>
  468.                     <xsl:with-param name="current-x" select=" $current-x "/>
  469.                     <xsl:with-param name="current-y" select=" $current-y"/>
  470.                 </xsl:call-template>
  471.             </xsl:when>
  472.             <xsl:when test="$command = 'hc' ">
  473.                 <xsl:variable name="new-svg-path" select="$svg-path"/>
  474.                 <!--simply did nothing which might be wrong-->
  475.                 <xsl:call-template name="vmlpath2svgpath">
  476.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  477.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , ' ') "/>
  478.                     <xsl:with-param name="position" select=" $newpos  "/>
  479.                     <xsl:with-param name="last-command" select="$command"/>
  480.                     <xsl:with-param name="current-x" select=" $current-x "/>
  481.                     <xsl:with-param name="current-y" select=" $current-y"/>
  482.                 </xsl:call-template>
  483.             </xsl:when>
  484.             <xsl:when test="$command = 'hd' ">
  485.                 <xsl:variable name="new-svg-path" select="$svg-path"/>
  486.                 <!--simply did nothing which might be wrong-->
  487.                 <xsl:call-template name="vmlpath2svgpath">
  488.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  489.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , ' ') "/>
  490.                     <xsl:with-param name="position" select=" $newpos  "/>
  491.                     <xsl:with-param name="last-command" select="$command"/>
  492.                     <xsl:with-param name="current-x" select=" $current-x "/>
  493.                     <xsl:with-param name="current-y" select=" $current-y"/>
  494.                 </xsl:call-template>
  495.             </xsl:when>
  496.             <xsl:when test="$command = 'he' ">
  497.                 <xsl:variable name="new-svg-path" select="$svg-path"/>
  498.                 <!--simply did nothing which might be wrong-->
  499.                 <xsl:call-template name="vmlpath2svgpath">
  500.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  501.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , ' ') "/>
  502.                     <xsl:with-param name="position" select=" $newpos  "/>
  503.                     <xsl:with-param name="last-command" select="$command"/>
  504.                     <xsl:with-param name="current-x" select=" $current-x "/>
  505.                     <xsl:with-param name="current-y" select=" $current-y"/>
  506.                 </xsl:call-template>
  507.             </xsl:when>
  508.             <xsl:when test="$command = 'hf' ">
  509.                 <xsl:variable name="new-svg-path" select="$svg-path"/>
  510.                 <!--simply did nothing which might be wrong-->
  511.                 <xsl:call-template name="vmlpath2svgpath">
  512.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  513.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , ' ') "/>
  514.                     <xsl:with-param name="position" select=" $newpos  "/>
  515.                     <xsl:with-param name="last-command" select="$command"/>
  516.                     <xsl:with-param name="current-x" select=" $current-x "/>
  517.                     <xsl:with-param name="current-y" select=" $current-y"/>
  518.                 </xsl:call-template>
  519.             </xsl:when>
  520.             <xsl:when test="$command = 'hg' ">
  521.                 <xsl:variable name="new-svg-path" select="$svg-path"/>
  522.                 <!--simply did nothing which might be wrong-->
  523.                 <xsl:call-template name="vmlpath2svgpath">
  524.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  525.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , ' ') "/>
  526.                     <xsl:with-param name="position" select=" $newpos  "/>
  527.                     <xsl:with-param name="last-command" select="$command"/>
  528.                     <xsl:with-param name="current-x" select=" $current-x "/>
  529.                     <xsl:with-param name="current-y" select=" $current-y"/>
  530.                 </xsl:call-template>
  531.             </xsl:when>
  532.             <xsl:when test="$command = 'hh' ">
  533.                 <xsl:variable name="new-svg-path" select="$svg-path"/>
  534.                 <!--simply did nothing which might be wrong-->
  535.                 <xsl:call-template name="vmlpath2svgpath">
  536.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  537.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , ' ') "/>
  538.                     <xsl:with-param name="position" select=" $newpos  "/>
  539.                     <xsl:with-param name="last-command" select="$command"/>
  540.                     <xsl:with-param name="current-x" select=" $current-x "/>
  541.                     <xsl:with-param name="current-y" select=" $current-y"/>
  542.                 </xsl:call-template>
  543.             </xsl:when>
  544.             <xsl:when test="$command = 'hi' ">
  545.                 <xsl:variable name="new-svg-path" select="$svg-path"/>
  546.                 <!--simply did nothing which might be wrong-->
  547.                 <xsl:call-template name="vmlpath2svgpath">
  548.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  549.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , ' ') "/>
  550.                     <xsl:with-param name="position" select=" $newpos  "/>
  551.                     <xsl:with-param name="last-command" select="$command"/>
  552.                     <xsl:with-param name="current-x" select=" $current-x "/>
  553.                     <xsl:with-param name="current-y" select=" $current-y"/>
  554.                 </xsl:call-template>
  555.             </xsl:when>
  556.             <xsl:when test="$command = 'nf' or $command = 'ns' ">
  557.                 <xsl:variable name="new-svg-path" select="$svg-path"/>
  558.                 <!--simply did nothing which might be wrong-->
  559.                 <xsl:call-template name="vmlpath2svgpath">
  560.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  561.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , ' ') "/>
  562.                     <xsl:with-param name="position" select=" $newpos  "/>
  563.                     <xsl:with-param name="last-command" select="$command"/>
  564.                     <xsl:with-param name="current-x" select=" $current-x "/>
  565.                     <xsl:with-param name="current-y" select=" $current-y"/>
  566.                 </xsl:call-template>
  567.             </xsl:when>
  568.             <xsl:when test="$command = 'al' ">
  569.                 <!-- absolute moveto -->
  570.                 <xsl:variable name="new-svg-path" select="concat($svg-path ,' W ' ) "/>
  571.                 <xsl:variable name="num-and-pos">
  572.                     <xsl:call-template name="get-number-after">
  573.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  574.                         <xsl:with-param name="position" select="$newpos"/>
  575.                         <xsl:with-param name="count" select="6"/>
  576.                     </xsl:call-template>
  577.                 </xsl:variable>
  578.                 <xsl:call-template name="vmlpath2svgpath">
  579.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  580.                     <xsl:with-param name="svg-path" select=" concat($new-svg-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  581.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  582.                     <xsl:with-param name="last-command" select="$command"/>
  583.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  584.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  585.                 </xsl:call-template>
  586.             </xsl:when>
  587.             <xsl:otherwise>
  588.                 <xsl:value-of select="$svg-path"/>
  589.             </xsl:otherwise>
  590.         </xsl:choose>
  591.     </xsl:template>
  592.     <!-- 
  593.     **Template vmlpath2enhancedpath**
  594.     The template is resposible for converting the vml-path to enhanced-path, because the svg:path 
  595.     cann't support command a now.(But heard that will be supported in OOo3.0)
  596.     And  the 2nd reason of using an enhanced-path is that enhanced-path have a perfect maping to 
  597.     vmlpath.(You will find out that often,we  even don't need to change the parameters).
  598.     -->
  599.     <xsl:template name="vmlpath2enhancedpath">
  600.         <xsl:param name="vml-path"/>
  601.         <xsl:param name="enhanced-path" select="''"/>
  602.         <xsl:param name="position" select="1"/>
  603.         <xsl:param name="last-command" select="'m'"/>
  604.         <xsl:param name="current-x" select="'0'"/>
  605.         <xsl:param name="current-y" select="'0'"/>
  606.         <xsl:variable name="command-and-newpos">
  607.             <xsl:call-template name="get-path-command">
  608.                 <xsl:with-param name="vml-path" select="$vml-path"/>
  609.                 <xsl:with-param name="position" select="$position"/>
  610.                 <xsl:with-param name="last-command" select="$last-command"/>
  611.             </xsl:call-template>
  612.         </xsl:variable>
  613.         <xsl:variable name="command" select="substring-before($command-and-newpos , ':')"/>
  614.         <xsl:variable name="newpos" select="substring-after($command-and-newpos , ':')"/>
  615.         <xsl:choose>
  616.             <xsl:when test="$command = 'm' ">
  617.                 <!--####Notice that the "m 0,0,1,1,1,1" means two lines-->
  618.                 <!-- absolute moveto -->
  619.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' M ' ) "/>
  620.                 <xsl:variable name="num-and-pos">
  621.                     <xsl:call-template name="get-number-after">
  622.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  623.                         <xsl:with-param name="position" select="$newpos"/>
  624.                         <xsl:with-param name="count" select="2"/>
  625.                     </xsl:call-template>
  626.                 </xsl:variable>
  627.                 <xsl:call-template name="vmlpath2enhancedpath">
  628.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  629.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  630.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  631.                     <xsl:with-param name="last-command" select="$command"/>
  632.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  633.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  634.                 </xsl:call-template>
  635.             </xsl:when>
  636.             <xsl:when test="$command = 'l' ">
  637.                 <!-- absolute lineto -->
  638.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' L ' ) "/>
  639.                 <xsl:variable name="num-and-pos">
  640.                     <xsl:call-template name="get-number-after">
  641.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  642.                         <xsl:with-param name="position" select="$newpos"/>
  643.                         <xsl:with-param name="count" select="2"/>
  644.                     </xsl:call-template>
  645.                 </xsl:variable>
  646.                 <xsl:call-template name="vmlpath2enhancedpath">
  647.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  648.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  649.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  650.                     <xsl:with-param name="last-command" select="$command"/>
  651.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  652.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  653.                 </xsl:call-template>
  654.             </xsl:when>
  655.             <xsl:when test="$command = 'x' ">
  656.                 <!--dummy or $command = 'z' "-->
  657.                 <!-- closepath -->
  658.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' Z ' ) "/>
  659.                 <xsl:call-template name="vmlpath2enhancedpath">
  660.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  661.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ') "/>
  662.                     <xsl:with-param name="position" select=" $newpos  "/>
  663.                     <xsl:with-param name="last-command" select="$command"/>
  664.                     <xsl:with-param name="current-x" select=" $current-x "/>
  665.                     <xsl:with-param name="current-y" select=" $current-y"/>
  666.                 </xsl:call-template>
  667.             </xsl:when>
  668.             <xsl:when test="$command = 'e' ">
  669.                 <!-- end path -->
  670.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' N ' )"/>
  671.                 <xsl:call-template name="vmlpath2enhancedpath">
  672.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  673.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ') "/>
  674.                     <xsl:with-param name="position" select=" $newpos  "/>
  675.                     <xsl:with-param name="last-command" select="$command"/>
  676.                     <xsl:with-param name="current-x" select=" $current-x "/>
  677.                     <xsl:with-param name="current-y" select=" $current-y"/>
  678.                 </xsl:call-template>
  679.             </xsl:when>
  680.             <xsl:when test="$command = 'c' ">
  681.                 <!-- absolute curveto -->
  682.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' C ' ) "/>
  683.                 <xsl:variable name="control-and-pos">
  684.                     <xsl:call-template name="get-number-after">
  685.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  686.                         <xsl:with-param name="position" select="$newpos"/>
  687.                         <xsl:with-param name="count" select="4"/>
  688.                     </xsl:call-template>
  689.                 </xsl:variable>
  690.                 <xsl:variable name="num-and-pos">
  691.                     <xsl:call-template name="get-number-after">
  692.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  693.                         <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
  694.                         <xsl:with-param name="count" select="2"/>
  695.                     </xsl:call-template>
  696.                 </xsl:variable>
  697.                 <xsl:call-template name="vmlpath2enhancedpath">
  698.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  699.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $control-and-pos , ':')  , ' ' ,  substring-before( $num-and-pos , ':')  , ' ') "/>
  700.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  701.                     <xsl:with-param name="last-command" select="$command"/>
  702.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  703.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  704.                 </xsl:call-template>
  705.             </xsl:when>
  706.             <xsl:when test="$command = 't' ">
  707.                 <!-- relative moveto -->
  708.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' M ' ) "/>
  709.                 <!--####maybe this is not crect because t r and v hasn't direct image in enhaced-path-->
  710.                 <xsl:variable name="num-and-pos">
  711.                     <xsl:call-template name="get-number-after">
  712.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  713.                         <xsl:with-param name="position" select="$newpos"/>
  714.                         <xsl:with-param name="count" select="2"/>
  715.                     </xsl:call-template>
  716.                 </xsl:variable>
  717.                 <xsl:call-template name="vmlpath2enhancedpath">
  718.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  719.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  720.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  721.                     <xsl:with-param name="last-command" select="$command"/>
  722.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')    , ' ')  + $current-x"/>
  723.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')    , ' ') + $current-y "/>
  724.                 </xsl:call-template>
  725.             </xsl:when>
  726.             <xsl:when test="$command = 'r' ">
  727.                 <!-- relative lineto -->
  728.                 <!--####maybe this is not crect because 't' 'r' and 'v' hasn't direct image in enhaced-path-->
  729.                 <!-- 'l' command is not supported currently, so we use 'L' -->
  730.                 <xsl:message>'l' command is not supported currently, so we use 'L'. This may case problem.</xsl:message>
  731.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' L ' ) "/>
  732.                 <xsl:variable name="num-and-pos">
  733.                     <xsl:call-template name="get-number-after">
  734.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  735.                         <xsl:with-param name="position" select="$newpos"/>
  736.                         <xsl:with-param name="count" select="2"/>
  737.                     </xsl:call-template>
  738.                 </xsl:variable>
  739.                 <xsl:variable name="new-x" select=" substring-before( substring-before( $num-and-pos , ':')  , ' ')  + $current-x  "/>
  740.                 <xsl:variable name="new-y" select=" substring-after( substring-before( $num-and-pos , ':')    , ' ')  + $current-y "/>
  741.                 <xsl:call-template name="vmlpath2enhancedpath">
  742.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  743.                     <!-- 'l' command is not supported currently-->
  744.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , $new-x ,' ' , $new-y  , ' ') "/>
  745.                     <!-- xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $num-and-pos , ':')  , ' ') "/ -->
  746.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  747.                     <xsl:with-param name="last-command" select="$command"/>
  748.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')  , ' ')  + $current-x  "/>
  749.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')    , ' ')  + $current-y "/>
  750.                 </xsl:call-template>
  751.             </xsl:when>
  752.             <xsl:when test="$command = 'v' ">
  753.                 <!-- relative curveto -->
  754.                 <!--####maybe this is not crect because 't' 'r' and 'v' hasn't direct image in enhaced-path-->
  755.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' C ' ) "/>
  756.                 <!--<xsl:variable name="control-and-pos">
  757.                     <xsl:call-template name="get-number-after">
  758.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  759.                         <xsl:with-param name="position" select="$newpos"/>
  760.                         <xsl:with-param name="count" select="4"/>
  761.                     </xsl:call-template>
  762.                 </xsl:variable>
  763.                 <xsl:variable name="num-and-pos">
  764.                     <xsl:call-template name="get-number-after">
  765.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  766.                         <xsl:with-param name="position" select="substring-after( $control-and-pos , ':') "/>
  767.                         <xsl:with-param name="count" select="2"/>
  768.                     </xsl:call-template>
  769.                 </xsl:variable>
  770.                 <xsl:call-template name="vmlpath2enhancedpath">
  771.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  772.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $control-and-pos , ':')  , ' ' ,  substring-before( $num-and-pos , ':')  , ' ') "/>
  773.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  774.                     <xsl:with-param name="last-command" select="$command"/>
  775.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')  , ' ')  + $current-x  "/>
  776.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')    , ' ')  + $current-y "/>
  777.                 </xsl:call-template>-
  778.                 -->
  779.                 <xsl:variable name="x1">
  780.                     <xsl:call-template name="get-number-after">
  781.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  782.                         <xsl:with-param name="position" select="$newpos"/>
  783.                         <xsl:with-param name="count" select="1"/>
  784.                     </xsl:call-template>
  785.                 </xsl:variable>
  786.                 <xsl:variable name="y1">
  787.                     <xsl:call-template name="get-number-after">
  788.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  789.                         <xsl:with-param name="position" select="substring-after( $x1 , ':')"/>
  790.                         <xsl:with-param name="count" select="1"/>
  791.                     </xsl:call-template>
  792.                 </xsl:variable>
  793.                 <xsl:variable name="x2">
  794.                     <xsl:call-template name="get-number-after">
  795.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  796.                         <xsl:with-param name="position" select="substring-after( $y1 , ':')"/>
  797.                         <xsl:with-param name="count" select="1"/>
  798.                     </xsl:call-template>
  799.                 </xsl:variable>
  800.                 <xsl:variable name="y2">
  801.                     <xsl:call-template name="get-number-after">
  802.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  803.                         <xsl:with-param name="position" select="substring-after( $x2 , ':')"/>
  804.                         <xsl:with-param name="count" select="1"/>
  805.                     </xsl:call-template>
  806.                 </xsl:variable>
  807.                 <xsl:variable name="x">
  808.                     <xsl:call-template name="get-number-after">
  809.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  810.                         <xsl:with-param name="position" select="substring-after( $y2 , ':')"/>
  811.                         <xsl:with-param name="count" select="1"/>
  812.                     </xsl:call-template>
  813.                 </xsl:variable>
  814.                 <xsl:variable name="y">
  815.                     <xsl:call-template name="get-number-after">
  816.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  817.                         <xsl:with-param name="position" select="substring-after( $x , ':')"/>
  818.                         <xsl:with-param name="count" select="1"/>
  819.                     </xsl:call-template>
  820.                 </xsl:variable>
  821.                 <xsl:variable name="val_x1">
  822.                     <xsl:value-of select="substring-before( $x1 , ':')+$current-x"/>
  823.                 </xsl:variable>
  824.                 <xsl:variable name="val_y1">
  825.                     <xsl:value-of select="substring-before( $y1 , ':')+$current-y"/>
  826.                 </xsl:variable>
  827.                 <xsl:variable name="val_x2">
  828.                     <xsl:value-of select="substring-before( $x2 , ':')+$current-x"/>
  829.                 </xsl:variable>
  830.                 <xsl:variable name="val_y2">
  831.                     <xsl:value-of select="substring-before( $y2 , ':')+$current-y"/>
  832.                 </xsl:variable>
  833.                 <xsl:variable name="val_x">
  834.                     <xsl:value-of select="substring-before( $x , ':')+$current-x"/>
  835.                 </xsl:variable>
  836.                 <xsl:variable name="val_y">
  837.                     <xsl:value-of select="substring-before( $y , ':')+$current-y"/>
  838.                 </xsl:variable>
  839.                 <xsl:variable name="control-and-pos">
  840.                     <xsl:value-of select="concat($val_x1, ' ',$val_y1, ' ',$val_x2, ' ',$val_y2, ' ' )"/>
  841.                 </xsl:variable>
  842.                 <xsl:variable name="num-and-pos">
  843.                     <xsl:value-of select="concat($val_x, ' ',$val_y, ' ' )"/>
  844.                 </xsl:variable>
  845.                 <xsl:call-template name="vmlpath2enhancedpath">
  846.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  847.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ',$control-and-pos , ' ' , $num-and-pos , ' ') "/>
  848.                     <xsl:with-param name="position" select=" substring-after( $y , ':')  "/>
  849.                     <xsl:with-param name="last-command" select="$command"/>
  850.                     <xsl:with-param name="current-x" select=" $val_x  "/>
  851.                     <xsl:with-param name="current-y" select=" $val_y "/>
  852.                 </xsl:call-template>
  853.             </xsl:when>
  854.             <!--Code below is for the support of h-command like ha,hb....hi, maybe still need to revise-->
  855.             <xsl:when test="$command = 'ha' ">
  856.                 <xsl:variable name="new-enhanced-path" select="$enhanced-path"/>
  857.                 <!--simply did nothing which might be wrong-->
  858.                 <xsl:call-template name="vmlpath2enhancedpath">
  859.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  860.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ') "/>
  861.                     <xsl:with-param name="position" select=" $newpos  "/>
  862.                     <xsl:with-param name="last-command" select="$command"/>
  863.                     <xsl:with-param name="current-x" select=" $current-x "/>
  864.                     <xsl:with-param name="current-y" select=" $current-y"/>
  865.                 </xsl:call-template>
  866.             </xsl:when>
  867.             <xsl:when test="$command = 'hb' ">
  868.                 <xsl:variable name="new-enhanced-path" select="$enhanced-path"/>
  869.                 <!--simply did nothing which might be wrong-->
  870.                 <xsl:call-template name="vmlpath2enhancedpath">
  871.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  872.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ') "/>
  873.                     <xsl:with-param name="position" select=" $newpos  "/>
  874.                     <xsl:with-param name="last-command" select="$command"/>
  875.                     <xsl:with-param name="current-x" select=" $current-x "/>
  876.                     <xsl:with-param name="current-y" select=" $current-y"/>
  877.                 </xsl:call-template>
  878.             </xsl:when>
  879.             <xsl:when test="$command = 'hc' ">
  880.                 <xsl:variable name="new-enhanced-path" select="$enhanced-path"/>
  881.                 <!--simply did nothing which might be wrong-->
  882.                 <xsl:call-template name="vmlpath2enhancedpath">
  883.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  884.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ') "/>
  885.                     <xsl:with-param name="position" select=" $newpos  "/>
  886.                     <xsl:with-param name="last-command" select="$command"/>
  887.                     <xsl:with-param name="current-x" select=" $current-x "/>
  888.                     <xsl:with-param name="current-y" select=" $current-y"/>
  889.                 </xsl:call-template>
  890.             </xsl:when>
  891.             <xsl:when test="$command = 'hd' ">
  892.                 <xsl:variable name="new-enhanced-path" select="$enhanced-path"/>
  893.                 <!--simply did nothing which might be wrong-->
  894.                 <xsl:call-template name="vmlpath2enhancedpath">
  895.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  896.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ') "/>
  897.                     <xsl:with-param name="position" select=" $newpos  "/>
  898.                     <xsl:with-param name="last-command" select="$command"/>
  899.                     <xsl:with-param name="current-x" select=" $current-x "/>
  900.                     <xsl:with-param name="current-y" select=" $current-y"/>
  901.                 </xsl:call-template>
  902.             </xsl:when>
  903.             <xsl:when test="$command = 'he' ">
  904.                 <xsl:variable name="new-enhanced-path" select="$enhanced-path"/>
  905.                 <!--simply did nothing which might be wrong-->
  906.                 <xsl:call-template name="vmlpath2enhancedpath">
  907.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  908.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ') "/>
  909.                     <xsl:with-param name="position" select=" $newpos  "/>
  910.                     <xsl:with-param name="last-command" select="$command"/>
  911.                     <xsl:with-param name="current-x" select=" $current-x "/>
  912.                     <xsl:with-param name="current-y" select=" $current-y"/>
  913.                 </xsl:call-template>
  914.             </xsl:when>
  915.             <xsl:when test="$command = 'hf' ">
  916.                 <xsl:variable name="new-enhanced-path" select="$enhanced-path"/>
  917.                 <!--simply did nothing which might be wrong-->
  918.                 <xsl:call-template name="vmlpath2enhancedpath">
  919.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  920.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ') "/>
  921.                     <xsl:with-param name="position" select=" $newpos  "/>
  922.                     <xsl:with-param name="last-command" select="$command"/>
  923.                     <xsl:with-param name="current-x" select=" $current-x "/>
  924.                     <xsl:with-param name="current-y" select=" $current-y"/>
  925.                 </xsl:call-template>
  926.             </xsl:when>
  927.             <xsl:when test="$command = 'hg' ">
  928.                 <xsl:variable name="new-enhanced-path" select="$enhanced-path"/>
  929.                 <!--simply did nothing which might be wrong-->
  930.                 <xsl:call-template name="vmlpath2enhancedpath">
  931.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  932.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ') "/>
  933.                     <xsl:with-param name="position" select=" $newpos  "/>
  934.                     <xsl:with-param name="last-command" select="$command"/>
  935.                     <xsl:with-param name="current-x" select=" $current-x "/>
  936.                     <xsl:with-param name="current-y" select=" $current-y"/>
  937.                 </xsl:call-template>
  938.             </xsl:when>
  939.             <xsl:when test="$command = 'hh' ">
  940.                 <xsl:variable name="new-enhanced-path" select="$enhanced-path"/>
  941.                 <!--simply did nothing which might be wrong-->
  942.                 <xsl:call-template name="vmlpath2enhancedpath">
  943.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  944.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ') "/>
  945.                     <xsl:with-param name="position" select=" $newpos  "/>
  946.                     <xsl:with-param name="last-command" select="$command"/>
  947.                     <xsl:with-param name="current-x" select=" $current-x "/>
  948.                     <xsl:with-param name="current-y" select=" $current-y"/>
  949.                 </xsl:call-template>
  950.             </xsl:when>
  951.             <xsl:when test="$command = 'hi' ">
  952.                 <xsl:variable name="new-enhanced-path" select="$enhanced-path"/>
  953.                 <!--simply did nothing which might be wrong-->
  954.                 <xsl:call-template name="vmlpath2enhancedpath">
  955.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  956.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ') "/>
  957.                     <xsl:with-param name="position" select=" $newpos  "/>
  958.                     <xsl:with-param name="last-command" select="$command"/>
  959.                     <xsl:with-param name="current-x" select=" $current-x "/>
  960.                     <xsl:with-param name="current-y" select=" $current-y"/>
  961.                 </xsl:call-template>
  962.             </xsl:when>
  963.             <xsl:when test="$command = 'nf' ">
  964.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' F ' )"/>
  965.                 <!--simply did nothing which might be wrong-->
  966.                 <xsl:call-template name="vmlpath2enhancedpath">
  967.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  968.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ') "/>
  969.                     <xsl:with-param name="position" select=" $newpos  "/>
  970.                     <xsl:with-param name="last-command" select="$command"/>
  971.                     <xsl:with-param name="current-x" select=" $current-x "/>
  972.                     <xsl:with-param name="current-y" select=" $current-y"/>
  973.                 </xsl:call-template>
  974.             </xsl:when>
  975.             <xsl:when test="$command = 'ns' ">
  976.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' S ' )"/>
  977.                 <!--simply did nothing which might be wrong-->
  978.                 <xsl:call-template name="vmlpath2enhancedpath">
  979.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  980.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , ' ') "/>
  981.                     <xsl:with-param name="position" select=" $newpos  "/>
  982.                     <xsl:with-param name="last-command" select="$command"/>
  983.                     <xsl:with-param name="current-x" select=" $current-x "/>
  984.                     <xsl:with-param name="current-y" select=" $current-y"/>
  985.                 </xsl:call-template>
  986.             </xsl:when>
  987.             <!--The following is 6 command which deal with arcs:
  988.                 ae   ->T        al -> U
  989.                 at   -> A        ar  -> B
  990.                 wa -> W     wr  ->V 
  991.               These pairs of commands have shown the perfect mapping from vml-path to enhanced-path-->
  992.             <xsl:when test="$command = 'ae' ">
  993.                 <!-- arc on the screen with the start and end angles -->
  994.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' T ' ) "/>
  995.                 <xsl:variable name="num-and-pos">
  996.                     <xsl:call-template name="get-number-after">
  997.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  998.                         <xsl:with-param name="position" select="$newpos"/>
  999.                         <xsl:with-param name="count" select="6"/>
  1000.                     </xsl:call-template>
  1001.                 </xsl:variable>
  1002.                 <xsl:call-template name="vmlpath2enhancedpath">
  1003.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  1004.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  1005.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  1006.                     <xsl:with-param name="last-command" select="$command"/>
  1007.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  1008.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  1009.                 </xsl:call-template>
  1010.             </xsl:when>
  1011.             <xsl:when test="$command = 'al' ">
  1012.                 <!-- ae command plus a implicitly moveto startpoint-->
  1013.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' U ' ) "/>
  1014.                 <xsl:variable name="num-and-pos">
  1015.                     <xsl:call-template name="get-number-after">
  1016.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1017.                         <xsl:with-param name="position" select="$newpos"/>
  1018.                         <xsl:with-param name="count" select="6"/>
  1019.                     </xsl:call-template>
  1020.                 </xsl:variable>
  1021.                 <xsl:call-template name="vmlpath2enhancedpath">
  1022.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  1023.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  1024.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  1025.                     <xsl:with-param name="last-command" select="$command"/>
  1026.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  1027.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  1028.                 </xsl:call-template>
  1029.             </xsl:when>
  1030.             <xsl:when test="$command = 'at' ">
  1031.                 <!-- arc on the screen with the edge box ,start points and end points(Notice it's counter-clockwise)-->
  1032.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' A ' ) "/>
  1033.                 <xsl:variable name="num-and-pos">
  1034.                     <xsl:call-template name="get-number-after">
  1035.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1036.                         <xsl:with-param name="position" select="$newpos"/>
  1037.                         <xsl:with-param name="count" select="8"/>
  1038.                     </xsl:call-template>
  1039.                 </xsl:variable>
  1040.                 <xsl:call-template name="vmlpath2enhancedpath">
  1041.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  1042.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  1043.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  1044.                     <xsl:with-param name="last-command" select="$command"/>
  1045.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  1046.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  1047.                 </xsl:call-template>
  1048.             </xsl:when>
  1049.             <xsl:when test="$command = 'ar' ">
  1050.                 <!-- at command plus a implicitly moveto startpoint-->
  1051.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' B ' ) "/>
  1052.                 <xsl:variable name="num-and-pos">
  1053.                     <xsl:call-template name="get-number-after">
  1054.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1055.                         <xsl:with-param name="position" select="$newpos"/>
  1056.                         <xsl:with-param name="count" select="8"/>
  1057.                     </xsl:call-template>
  1058.                 </xsl:variable>
  1059.                 <xsl:call-template name="vmlpath2enhancedpath">
  1060.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  1061.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  1062.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  1063.                     <xsl:with-param name="last-command" select="$command"/>
  1064.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  1065.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  1066.                 </xsl:call-template>
  1067.             </xsl:when>
  1068.             <xsl:when test="$command = 'wa' ">
  1069.                 <!-- arc on the screen with the edge box ,start points and end points(Notice it's clockwise)-->
  1070.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' W ' ) "/>
  1071.                 <xsl:variable name="num-and-pos">
  1072.                     <xsl:call-template name="get-number-after">
  1073.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1074.                         <xsl:with-param name="position" select="$newpos"/>
  1075.                         <xsl:with-param name="count" select="8"/>
  1076.                     </xsl:call-template>
  1077.                 </xsl:variable>
  1078.                 <xsl:call-template name="vmlpath2enhancedpath">
  1079.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  1080.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  1081.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  1082.                     <xsl:with-param name="last-command" select="$command"/>
  1083.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  1084.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  1085.                 </xsl:call-template>
  1086.             </xsl:when>
  1087.             <xsl:when test="$command = 'wr' ">
  1088.                 <!-- wa command plus a implicitly moveto startpoint-->
  1089.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' V ' ) "/>
  1090.                 <xsl:variable name="num-and-pos">
  1091.                     <xsl:call-template name="get-number-after">
  1092.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1093.                         <xsl:with-param name="position" select="$newpos"/>
  1094.                         <xsl:with-param name="count" select="8"/>
  1095.                     </xsl:call-template>
  1096.                 </xsl:variable>
  1097.                 <xsl:call-template name="vmlpath2enhancedpath">
  1098.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  1099.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  1100.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  1101.                     <xsl:with-param name="last-command" select="$command"/>
  1102.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  1103.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  1104.                 </xsl:call-template>
  1105.             </xsl:when>
  1106.             <xsl:when test="$command = 'qx' ">
  1107.                 <!-- Draw a quarter ellipse retated to the x-axis-->
  1108.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' X ' ) "/>
  1109.                 <xsl:variable name="num-and-pos">
  1110.                     <xsl:call-template name="get-number-after">
  1111.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1112.                         <xsl:with-param name="position" select="$newpos"/>
  1113.                         <xsl:with-param name="count" select="2"/>
  1114.                     </xsl:call-template>
  1115.                 </xsl:variable>
  1116.                 <xsl:call-template name="vmlpath2enhancedpath">
  1117.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  1118.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  1119.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  1120.                     <xsl:with-param name="last-command" select="$command"/>
  1121.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  1122.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  1123.                 </xsl:call-template>
  1124.             </xsl:when>
  1125.             <xsl:when test="$command = 'qy' ">
  1126.                 <!-- Draw a quarter ellipse retated to the y-axis-->
  1127.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' Y ' ) "/>
  1128.                 <xsl:variable name="num-and-pos">
  1129.                     <xsl:call-template name="get-number-after">
  1130.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1131.                         <xsl:with-param name="position" select="$newpos"/>
  1132.                         <xsl:with-param name="count" select="2"/>
  1133.                     </xsl:call-template>
  1134.                 </xsl:variable>
  1135.                 <xsl:call-template name="vmlpath2enhancedpath">
  1136.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  1137.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  1138.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  1139.                     <xsl:with-param name="last-command" select="$command"/>
  1140.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  1141.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  1142.                 </xsl:call-template>
  1143.             </xsl:when>
  1144.             <xsl:when test="$command = 'qb' ">
  1145.                 <!-- quadratic Bezier-->
  1146.                 <xsl:variable name="new-enhanced-path" select="concat($enhanced-path ,' Q ' ) "/>
  1147.                 <xsl:variable name="num-and-pos">
  1148.                     <xsl:call-template name="get-number-after">
  1149.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1150.                         <xsl:with-param name="position" select="$newpos"/>
  1151.                         <xsl:with-param name="count" select="4"/>
  1152.                     </xsl:call-template>
  1153.                 </xsl:variable>
  1154.                 <xsl:call-template name="vmlpath2enhancedpath">
  1155.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  1156.                     <xsl:with-param name="enhanced-path" select=" concat($new-enhanced-path , substring-before( $num-and-pos , ':')  , ' ') "/>
  1157.                     <xsl:with-param name="position" select=" substring-after( $num-and-pos , ':')  "/>
  1158.                     <xsl:with-param name="last-command" select="$command"/>
  1159.                     <xsl:with-param name="current-x" select=" substring-before( substring-before( $num-and-pos , ':')   , ' ') "/>
  1160.                     <xsl:with-param name="current-y" select=" substring-after( substring-before( $num-and-pos , ':')   , ' ') "/>
  1161.                 </xsl:call-template>
  1162.             </xsl:when>
  1163.             <xsl:otherwise>
  1164.                 <xsl:value-of select="$enhanced-path"/>
  1165.             </xsl:otherwise>
  1166.         </xsl:choose>
  1167.     </xsl:template>
  1168.     <xsl:template name="get-number-before">
  1169.         <!--  get $count number of number before current position , output format:number1 number2 ... numberN:newpostion 
  1170.             skip $skipcount of numbers
  1171.         -->
  1172.         <xsl:param name="vml-path"/>
  1173.         <xsl:param name="position" select="1"/>
  1174.         <xsl:param name="count" select="1"/>
  1175.         <xsl:param name="skipcount" select="0"/>
  1176.         <xsl:param name="number" select="''"/>
  1177.         <xsl:choose>
  1178.             <xsl:when test="$count = 0">
  1179.                 <xsl:value-of select=" concat($number ,   ':' , $position) "/>
  1180.             </xsl:when>
  1181.             <xsl:otherwise>
  1182.                 <xsl:variable name="num-pos">
  1183.                     <xsl:call-template name="get-number-position">
  1184.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1185.                         <xsl:with-param name="position" select="$position"/>
  1186.                         <xsl:with-param name="direction" select="-1"/>
  1187.                     </xsl:call-template>
  1188.                 </xsl:variable>
  1189.                 <xsl:variable name="previous-num-and-pos">
  1190.                     <xsl:call-template name="get-previous-number">
  1191.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1192.                         <xsl:with-param name="position" select="$num-pos"/>
  1193.                     </xsl:call-template>
  1194.                 </xsl:variable>
  1195.                 <xsl:if test="$skipcount > 0">
  1196.                     <xsl:call-template name="get-number-before">
  1197.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1198.                         <xsl:with-param name="position" select="substring-after($previous-num-and-pos , ':')"/>
  1199.                         <xsl:with-param name="count" select="$count"/>
  1200.                         <xsl:with-param name="skipcount" select="$skipcount - 1"/>
  1201.                         <xsl:with-param name="number" select="$number"/>
  1202.                     </xsl:call-template>
  1203.                 </xsl:if>
  1204.                 <xsl:if test="$skipcount = 0">
  1205.                     <xsl:variable name="new-number">
  1206.                         <xsl:if test="not($count  = 1)">
  1207.                             <xsl:value-of select="' '"/>
  1208.                         </xsl:if>
  1209.                         <xsl:value-of select=" concat( substring-before($previous-num-and-pos , ':')  , $number ) "/>
  1210.                     </xsl:variable>
  1211.                     <xsl:call-template name="get-number-before">
  1212.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1213.                         <xsl:with-param name="position" select="substring-after($previous-num-and-pos , ':')"/>
  1214.                         <xsl:with-param name="count" select="$count - 1"/>
  1215.                         <xsl:with-param name="skipcount" select="0"/>
  1216.                         <xsl:with-param name="number" select="$new-number"/>
  1217.                     </xsl:call-template>
  1218.                 </xsl:if>
  1219.             </xsl:otherwise>
  1220.         </xsl:choose>
  1221.     </xsl:template>
  1222.     <xsl:template name="get-number-after">
  1223.         <!--  get $count number of number after current position, output format:number1 number2 ... numberN:newpostion
  1224.             skip $skipcount of numbers
  1225.         -->
  1226.         <xsl:param name="vml-path"/>
  1227.         <xsl:param name="position" select="1"/>
  1228.         <xsl:param name="count" select="1"/>
  1229.         <xsl:param name="skipcount" select="0"/>
  1230.         <xsl:param name="number" select="''"/>
  1231.         <xsl:choose>
  1232.             <xsl:when test="$count = 0">
  1233.                 <xsl:value-of select=" concat($number ,   ':' , $position) "/>
  1234.             </xsl:when>
  1235.             <xsl:otherwise>
  1236.                 <xsl:variable name="num-pos">
  1237.                     <xsl:call-template name="get-number-position">
  1238.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1239.                         <xsl:with-param name="position" select="$position"/>
  1240.                         <xsl:with-param name="direction" select="1"/>
  1241.                     </xsl:call-template>
  1242.                 </xsl:variable>
  1243.                 <xsl:variable name="next-num-and-pos">
  1244.                     <xsl:call-template name="get-next-number">
  1245.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1246.                         <xsl:with-param name="position" select="$num-pos"/>
  1247.                     </xsl:call-template>
  1248.                 </xsl:variable>
  1249.                 <xsl:if test="$skipcount > 0">
  1250.                     <xsl:call-template name="get-number-after">
  1251.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1252.                         <xsl:with-param name="position" select="substring-after($next-num-and-pos , ':')"/>
  1253.                         <xsl:with-param name="count" select="$count"/>
  1254.                         <xsl:with-param name="skipcount" select="$skipcount - 1"/>
  1255.                         <xsl:with-param name="number" select="$number"/>
  1256.                     </xsl:call-template>
  1257.                 </xsl:if>
  1258.                 <xsl:if test="$skipcount = 0">
  1259.                     <xsl:variable name="new-number">
  1260.                         <xsl:value-of select=" concat( $number , substring-before($next-num-and-pos , ':') ) "/>
  1261.                         <xsl:if test="not($count  = 1)">
  1262.                             <xsl:value-of select="' '"/>
  1263.                         </xsl:if>
  1264.                     </xsl:variable>
  1265.                     <xsl:call-template name="get-number-after">
  1266.                         <xsl:with-param name="vml-path" select="$vml-path"/>
  1267.                         <xsl:with-param name="position" select="substring-after($next-num-and-pos , ':')"/>
  1268.                         <xsl:with-param name="count" select="$count - 1"/>
  1269.                         <xsl:with-param name="skipcount" select="0"/>
  1270.                         <xsl:with-param name="number" select="$new-number"/>
  1271.                     </xsl:call-template>
  1272.                 </xsl:if>
  1273.             </xsl:otherwise>
  1274.         </xsl:choose>
  1275.     </xsl:template>
  1276.     <xsl:template name="get-number-position">
  1277.         <!-- get the next number start position, direction should be 1  or -1-->
  1278.         <xsl:param name="vml-path"/>
  1279.         <xsl:param name="position"/>
  1280.         <xsl:param name="direction" select="1"/>
  1281.         <xsl:choose>
  1282.             <xsl:when test="$direction  = 1 and $position > string-length($vml-path) ">0</xsl:when>
  1283.             <xsl:when test="$direction  = -1 and not($position > 0)">0</xsl:when>
  1284.             <xsl:otherwise>
  1285.                 <xsl:variable name="curr-char">
  1286.                     <xsl:if test="$direction = 1">
  1287.                         <xsl:value-of select="substring($vml-path, $position , 1)"/>
  1288.                     </xsl:if>
  1289.                     <xsl:if test="$direction = -1">
  1290.                         <xsl:value-of select="substring($vml-path, $position -1 , 1)"/>
  1291.                     </xsl:if>
  1292.                 </xsl:variable>
  1293.                 <xsl:choose>
  1294.                     <xsl:when test="string-length(translate($curr-char ,  '+-.0123456789@' ,'')) = 0 ">
  1295.                         <!-- number start-->
  1296.                         <xsl:value-of select="$position"/>
  1297.                     </xsl:when>
  1298.                     <xsl:when test="not($curr-char = ' ')">
  1299.                         <xsl:value-of select="$position"/>
  1300.                     </xsl:when>
  1301.                     <xsl:otherwise>
  1302.                         <xsl:call-template name="get-number-position">
  1303.                             <xsl:with-param name="vml-path" select="$vml-path"/>
  1304.                             <xsl:with-param name="position" select="$position + $direction"/>
  1305.                             <xsl:with-param name="direction" select="$direction"/>
  1306.                         </xsl:call-template>
  1307.                     </xsl:otherwise>
  1308.                 </xsl:choose>
  1309.             </xsl:otherwise>
  1310.         </xsl:choose>
  1311.     </xsl:template>
  1312.     <xsl:template name="skip-space">
  1313.         <xsl:param name="vml-path"/>
  1314.         <xsl:param name="position"/>
  1315.         <xsl:param name="skip-comma" select="'yes'"/>
  1316.         <xsl:variable name="curr-char" select="substring($vml-path, $position , 1)"/>
  1317.         <xsl:choose>
  1318.             <xsl:when test="$curr-char = ',' and $skip-comma = 'yes'">
  1319.                 <xsl:call-template name="skip-space">
  1320.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  1321.                     <xsl:with-param name="position" select="$position+1"/>
  1322.                     <xsl:with-param name="skip-comma" select="'no'"/>
  1323.                 </xsl:call-template>
  1324.             </xsl:when>
  1325.             <xsl:when test="$curr-char = ' '">
  1326.                 <xsl:call-template name="skip-space">
  1327.                     <xsl:with-param name="vml-path" select="$vml-path"/>
  1328.                     <xsl:with-param name="position" select="$position+1"/>
  1329.                     <xsl:with-param name="skip-comma" select="$skip-comma"/>
  1330.                 </xsl:call-template>
  1331.             </xsl:when>
  1332.             <xsl:otherwise>
  1333.                 <xsl:value-of select="$position"/>
  1334.             </xsl:otherwise>
  1335.         </xsl:choose>
  1336.     </xsl:template>
  1337.     <xsl:template name="format-number-pos">
  1338.         <xsl:param name="number"/>
  1339.         <xsl:param name="position"/>
  1340.         <xsl:choose>
  1341.             <xsl:when test="contains($number,'@')">
  1342.                 <xsl:value-of select="concat('?f',translate($number,'@',''),':' , $position ) "/>
  1343.             </xsl:when>
  1344.             <xsl:otherwise>
  1345.                 <xsl:value-of select=" concat(round($number) ,  ':' , $position) "/>
  1346.             </xsl:otherwise>
  1347.         </xsl:choose>
  1348.     </xsl:template>
  1349.     <xsl:template name="get-next-number">
  1350.         <!-- get the next number from current position-->
  1351.         <xsl:param name="vml-path"/>
  1352.         <xsl:param name="position"/>
  1353.         <xsl:param name="number" select=" '' "/>
  1354.         <xsl:choose>
  1355.             <xsl:when test="$position > string-length($vml-path) ">
  1356.                 <xsl:call-template name="format-number-pos">
  1357.                     <xsl:with-param name="number" select="$number"/>
  1358.                     <xsl:with-param name="position" select="$position"/>
  1359.                 </xsl:call-template>
  1360.             </xsl:when>
  1361.             <xsl:otherwise>
  1362.                 <xsl:variable name="curr-char" select="substring($vml-path, $position , 1)"/>
  1363.                 <xsl:choose>
  1364.                     <xsl:when test="string-length(translate($curr-char ,  '.0123456789' ,'')) = 0 ">
  1365.                         <!-- is number -->
  1366.                         <xsl:call-template name="get-next-number">
  1367.                             <xsl:with-param name="vml-path" select="$vml-path"/>
  1368.                             <xsl:with-param name="position" select="$position +1"/>
  1369.                             <xsl:with-param name="number" select="concat( $number, $curr-char) "/>
  1370.                         </xsl:call-template>
  1371.                     </xsl:when>
  1372.                     <xsl:when test="string-length(translate($curr-char ,  '@+-' ,'') ) = 0  and string-length($number) = 0">
  1373.                         <!-- is number -->
  1374.                         <xsl:call-template name="get-next-number">
  1375.                             <xsl:with-param name="vml-path" select="$vml-path"/>
  1376.                             <xsl:with-param name="position" select="$position +1"/>
  1377.                             <xsl:with-param name="number" select="concat( $number, $curr-char) "/>
  1378.                         </xsl:call-template>
  1379.                     </xsl:when>
  1380.                     <xsl:when test=" $number = '' and $curr-char = ',' ">
  1381.                         <xsl:variable name="new-pos">
  1382.                             <xsl:call-template name="skip-space">
  1383.                                 <xsl:with-param name="vml-path" select="$vml-path"/>
  1384.                                 <xsl:with-param name="position" select="$position"/>
  1385.                             </xsl:call-template>
  1386.                         </xsl:variable>
  1387.                         <xsl:value-of select="concat( '0:' , $new-pos )"/>
  1388.                     </xsl:when>
  1389.                     <xsl:when test=" $number = '' and not($curr-char = ',') ">
  1390.                         <xsl:variable name="new-pos">
  1391.                             <xsl:call-template name="skip-space">
  1392.                                 <xsl:with-param name="vml-path" select="$vml-path"/>
  1393.                                 <xsl:with-param name="position" select="$position"/>
  1394.                             </xsl:call-template>
  1395.                         </xsl:variable>
  1396.                         <xsl:value-of select="concat( '0:' , $new-pos)"/>
  1397.                     </xsl:when>
  1398.                     <xsl:otherwise>
  1399.                         <xsl:variable name="new-pos">
  1400.                             <xsl:call-template name="skip-space">
  1401.                                 <xsl:with-param name="vml-path" select="$vml-path"/>
  1402.                                 <xsl:with-param name="position" select="$position"/>
  1403.                             </xsl:call-template>
  1404.                         </xsl:variable>
  1405.                         <xsl:call-template name="format-number-pos">
  1406.                             <xsl:with-param name="number" select="$number"/>
  1407.                             <xsl:with-param name="position" select="$new-pos"/>
  1408.                         </xsl:call-template>
  1409.                     </xsl:otherwise>
  1410.                 </xsl:choose>
  1411.             </xsl:otherwise>
  1412.         </xsl:choose>
  1413.     </xsl:template>
  1414.     <xsl:template name="get-previous-number">
  1415.         <!-- get the previous number from current position-->
  1416.         <xsl:param name="vml-path"/>
  1417.         <xsl:param name="position"/>
  1418.         <xsl:param name="number" select="''"/>
  1419.         <xsl:choose>
  1420.             <xsl:when test="not($position > 0)">
  1421.                 <xsl:call-template name="format-number-pos">
  1422.                     <xsl:with-param name="number" select="$number"/>
  1423.                     <xsl:with-param name="position" select="'0'"/>
  1424.                 </xsl:call-template>
  1425.             </xsl:when>
  1426.             <xsl:otherwise>
  1427.                 <xsl:variable name="curr-char" select="substring($vml-path, $position -1 , 1)"/>
  1428.                 <xsl:choose>
  1429.                     <xsl:when test="string-length(translate($curr-char ,  '.0123456789' ,'')) = 0 ">
  1430.                         <!-- is number -->
  1431.                         <xsl:call-template name="get-previous-number">
  1432.                             <xsl:with-param name="vml-path" select="$vml-path"/>
  1433.                             <xsl:with-param name="position" select="$position -1"/>
  1434.                             <xsl:with-param name="number" select="concat($curr-char ,  $number) "/>
  1435.                         </xsl:call-template>
  1436.                     </xsl:when>
  1437.                     <xsl:when test="string-length(translate($curr-char ,  '@+-' ,'') ) = 0  and string-length($number) = 0">
  1438.                         <!-- skip it -->
  1439.                         <xsl:call-template name="get-previous-number">
  1440.                             <xsl:with-param name="vml-path" select="$vml-path"/>
  1441.                             <xsl:with-param name="position" select="$position -1"/>
  1442.                             <xsl:with-param name="number" select="$number "/>
  1443.                         </xsl:call-template>
  1444.                     </xsl:when>
  1445.                     <xsl:when test="string-length(translate($curr-char ,  '+-' ,'') ) = 0  and string-length($number) > 0">
  1446.                         <!-- finsh it with +/- -->
  1447.                         <xsl:call-template name="format-number-pos">
  1448.                             <xsl:with-param name="number" select="$number"/>
  1449.                             <xsl:with-param name="position" select="$position"/>
  1450.                         </xsl:call-template>
  1451.                     </xsl:when>
  1452.                     <xsl:otherwise>
  1453.                         <xsl:call-template name="format-number-pos">
  1454.                             <xsl:with-param name="number" select="$number"/>
  1455.                             <xsl:with-param name="position" select="$position"/>
  1456.                         </xsl:call-template>
  1457.                     </xsl:otherwise>
  1458.                 </xsl:choose>
  1459.             </xsl:otherwise>
  1460.         </xsl:choose>
  1461.     </xsl:template>
  1462.     <xsl:template name="get-path-command_dummy">
  1463.         <xsl:param name="vml-path"/>
  1464.         <xsl:param name="position" select="1"/>
  1465.         <xsl:param name="last-command"/>
  1466.         <xsl:choose>
  1467.             <xsl:when test="$position > string-length($vml-path) "/>
  1468.             <xsl:otherwise>
  1469.                 <xsl:variable name="curr-char" select="substring($vml-path, $position , 1)"/>
  1470.                 <xsl:choose>
  1471.                     <xsl:when test="string-length(translate($curr-char ,  'mlcxetrvnfsawqyb' ,'')) = 0 ">
  1472.                         <!-- "MmZzLlHhVvCcSsQqTtAa" are all possiable  command chars -->
  1473.                         <xsl:value-of select="concat( $curr-char , ':'  , $position +1)"/>
  1474.                     </xsl:when>
  1475.                     <xsl:when test="string-length(translate($curr-char ,  '+-.0123456789@' ,'')) = 0 ">
  1476.                         <!-- number start, use last command -->
  1477.                         <xsl:if test="string-length($last-command) = 0">
  1478.                             <xsl:message>ooo2wordml_path.xsl: Find undefined command</xsl:message>
  1479.                         </xsl:if>
  1480.                         <xsl:value-of select="concat( $last-command  , ':'  , $position )"/>
  1481.                     </xsl:when>
  1482.                     <xsl:when test="string-length(translate($curr-char ,  ', ' ,'')) = 0 ">
  1483.                         <!-- space or ',' should be skip -->
  1484.                         <xsl:call-template name="get-path-command">
  1485.                             <xsl:with-param name="vml-path" select="$vml-path"/>
  1486.                             <xsl:with-param name="position" select="$position +1"/>
  1487.                             <xsl:with-param name="last-command" select="$last-command"/>
  1488.                         </xsl:call-template>
  1489.                     </xsl:when>
  1490.                     <xsl:otherwise>
  1491.                         <xsl:message>ooo2wordml_path.xsl: Find undefined command:<xsl:value-of select="$curr-char"/>
  1492.                         </xsl:message>
  1493.                     </xsl:otherwise>
  1494.                 </xsl:choose>
  1495.             </xsl:otherwise>
  1496.         </xsl:choose>
  1497.     </xsl:template>
  1498.     <!--
  1499.         **get-path- command**
  1500.         This function will collect the next command from a string. If the input string should has a start of number character,
  1501.         we here implictly think the command is the last-command
  1502.         All of the command of vml is listed as following:
  1503.         __Basic commands:__
  1504.         m        l        c        x        e        t        r        v        nf        ns        ae        al        at        ar        wa        wr        qx        qy        qb    
  1505.         __Edit behavior extensions commands__
  1506.         ha     hb    hc    hd    he    hf    hg    hh    hi
  1507.  
  1508.         So we know the longest command should be four character.The function is implemented on this basis:
  1509.      -->
  1510.     <xsl:template name="get-path-command">
  1511.         <xsl:param name="vml-path"/>
  1512.         <xsl:param name="position" select="1"/>
  1513.         <xsl:param name="last-command"/>
  1514.         <xsl:choose>
  1515.             <xsl:when test="$position > string-length($vml-path) "/>
  1516.             <xsl:otherwise>
  1517.                 <xsl:variable name="curr-char" select="substring($vml-path, $position , 1)"/>
  1518.                 <xsl:variable name="curr-2char" select="substring($vml-path, $position - 1 , 2)"/>
  1519.                 <xsl:choose>
  1520.                     <xsl:when test="$curr-char = 'a' ">
  1521.                         <!--process the commands ae al at ar-->
  1522.                         <xsl:variable name="second-char" select="substring($vml-path, $position+1 , 1)"/>
  1523.                         <xsl:variable name="isvalid">
  1524.                             <xsl:choose>
  1525.                                 <xsl:when test="$second-char='e' ">1</xsl:when>
  1526.                                 <xsl:when test="$second-char='l' ">1</xsl:when>
  1527.                                 <xsl:when test="$second-char='t' ">1</xsl:when>
  1528.                                 <xsl:when test="$second-char='r' ">1</xsl:when>
  1529.                                 <xsl:otherwise>0</xsl:otherwise>
  1530.                             </xsl:choose>
  1531.                         </xsl:variable>
  1532.                         <xsl:if test="$isvalid = '1' ">
  1533.                             <xsl:value-of select="concat( $curr-char,$second-char , ':'  , $position +2)"/>
  1534.                         </xsl:if>
  1535.                         <xsl:if test="$isvalid = '0' ">
  1536.                             <xsl:message>ooo2wordml_path.xsl: Error command occured </xsl:message>
  1537.                         </xsl:if>
  1538.                     </xsl:when>
  1539.                     <xsl:when test="$curr-char = 'n' ">
  1540.                         <!--process the commands nf ns -->
  1541.                         <xsl:variable name="second-char" select="substring($vml-path, $position+1 , 1)"/>
  1542.                         <xsl:variable name="isvalid">
  1543.                             <xsl:choose>
  1544.                                 <xsl:when test="$second-char='f' ">1</xsl:when>
  1545.                                 <xsl:when test="$second-char='s' ">1</xsl:when>
  1546.                                 <xsl:otherwise>0</xsl:otherwise>
  1547.                             </xsl:choose>
  1548.                         </xsl:variable>
  1549.                         <xsl:if test="$isvalid = '1' ">
  1550.                             <xsl:value-of select="concat( $curr-char,$second-char , ':'  , $position +2)"/>
  1551.                         </xsl:if>
  1552.                         <xsl:if test="$isvalid = '0' ">
  1553.                             <xsl:message>ooo2wordml_path.xsl: Error command occured </xsl:message>
  1554.                         </xsl:if>
  1555.                     </xsl:when>
  1556.                     <xsl:when test="$curr-char = 'w' ">
  1557.                         <!--process the commands wa wr-->
  1558.                         <xsl:variable name="second-char" select="substring($vml-path, $position+1 , 1)"/>
  1559.                         <xsl:variable name="isvalid">
  1560.                             <xsl:choose>
  1561.                                 <xsl:when test="$second-char='a' ">1</xsl:when>
  1562.                                 <xsl:when test="$second-char='r' ">1</xsl:when>
  1563.                                 <xsl:otherwise>0</xsl:otherwise>
  1564.                             </xsl:choose>
  1565.                         </xsl:variable>
  1566.                         <xsl:if test="$isvalid = '1' ">
  1567.                             <xsl:value-of select="concat( $curr-char,$second-char , ':'  , $position +2)"/>
  1568.                         </xsl:if>
  1569.                         <xsl:if test="$isvalid = '0' ">
  1570.                             <xsl:message>ooo2wordml_path.xsl: Error command occured </xsl:message>
  1571.                         </xsl:if>
  1572.                     </xsl:when>
  1573.                     <xsl:when test="$curr-char = 'q' ">
  1574.                         <!--process the commands qx qy qb-->
  1575.                         <xsl:variable name="second-char" select="substring($vml-path, $position+1 , 1)"/>
  1576.                         <xsl:variable name="isvalid">
  1577.                             <xsl:choose>
  1578.                                 <xsl:when test="$second-char='x' ">1</xsl:when>
  1579.                                 <xsl:when test="$second-char='y' ">1</xsl:when>
  1580.                                 <xsl:when test="$second-char='b' ">1</xsl:when>
  1581.                                 <xsl:otherwise>0</xsl:otherwise>
  1582.                             </xsl:choose>
  1583.                         </xsl:variable>
  1584.                         <xsl:if test="$isvalid = '1' ">
  1585.                             <xsl:value-of select="concat( $curr-char,$second-char , ':'  , $position +2)"/>
  1586.                         </xsl:if>
  1587.                         <xsl:if test="$isvalid = '0' ">
  1588.                             <xsl:message>ooo2wordml_path.xsl: Error command occured </xsl:message>
  1589.                         </xsl:if>
  1590.                     </xsl:when>
  1591.                     <xsl:when test="$curr-char = 'h' ">
  1592.                         <!--process the edit behavior extensions commands-->
  1593.                         <xsl:variable name="second-char" select="substring($vml-path, $position+1 , 1)"/>
  1594.                         <xsl:variable name="isvalid">
  1595.                             <xsl:choose>
  1596.                                 <xsl:when test="string-length(translate($second-char ,  'abcdefghi' ,'')) = 0">1</xsl:when>
  1597.                                 <xsl:otherwise>0</xsl:otherwise>
  1598.                             </xsl:choose>
  1599.                         </xsl:variable>
  1600.                         <xsl:if test="$isvalid = '1' ">
  1601.                             <xsl:value-of select="concat( $curr-char,$second-char , ':'  , $position +2)"/>
  1602.                         </xsl:if>
  1603.                         <xsl:if test="$isvalid = '0' ">
  1604.                             <xsl:message>ooo2wordml_path.xsl: Error command occured </xsl:message>
  1605.                         </xsl:if>
  1606.                     </xsl:when>
  1607.                     <xsl:when test="string-length(translate($curr-char ,  'mlcxetrv' ,'')) = 0 ">
  1608.                         <!--process the single character commands m l c x e t r v -->
  1609.                         <xsl:value-of select="concat( $curr-char , ':'  , $position +1)"/>
  1610.                     </xsl:when>
  1611.                     <xsl:when test="string-length(translate($curr-char ,  '+-.0123456789@' ,'')) = 0 ">
  1612.                         <!-- number start, use last command -->
  1613.                         <xsl:if test="string-length($last-command) = 0">
  1614.                             <xsl:message>ooo2wordml_path.xsl: Find undefined command</xsl:message>
  1615.                         </xsl:if>
  1616.                         <xsl:value-of select="concat( $last-command  , ':'  , $position )"/>
  1617.                     </xsl:when>
  1618.                     <xsl:when test="$curr-2char=',,' ">
  1619.                         <!-- here are two ',' -->
  1620.                         <xsl:if test="string-length($last-command) = 0">
  1621.                             <xsl:message>ooo2wordml_path.xsl: Find undefined command</xsl:message>
  1622.                         </xsl:if>
  1623.                         <xsl:value-of select="concat( $last-command  , ':'  , $position  )"/>
  1624.                     </xsl:when>
  1625.                     <xsl:when test="string-length(translate($curr-char ,  ', ' ,'')) = 0 ">
  1626.                         <!-- space or ',' should be skip -->
  1627.                         <xsl:call-template name="get-path-command">
  1628.                             <xsl:with-param name="vml-path" select="$vml-path"/>
  1629.                             <xsl:with-param name="position" select="$position +1"/>
  1630.                             <xsl:with-param name="last-command" select="$last-command"/>
  1631.                         </xsl:call-template>
  1632.                     </xsl:when>
  1633.                     <xsl:otherwise>
  1634.                         <xsl:message>ooo2wordml_path.xsl: Find undefined command:<xsl:value-of select="$curr-char"/>
  1635.                         </xsl:message>
  1636.                     </xsl:otherwise>
  1637.                 </xsl:choose>
  1638.             </xsl:otherwise>
  1639.         </xsl:choose>
  1640.     </xsl:template>
  1641.     <xsl:template name="svg-arc2vml-arc">
  1642.         <xsl:param name="x0"/>
  1643.         <xsl:param name="y0"/>
  1644.         <xsl:param name="rx"/>
  1645.         <xsl:param name="ry"/>
  1646.         <xsl:param name="x-axis-rotation" select="0"/>
  1647.         <xsl:param name="large-arc-flag" select="0"/>
  1648.         <xsl:param name="sweep-flag" select="0"/>
  1649.         <xsl:param name="x"/>
  1650.         <xsl:param name="y"/>
  1651.         <!-- Compute 1/2 distance between current and final point -->
  1652.         <xsl:variable name="dx2" select="($x0 - $x) div 2"/>
  1653.         <xsl:variable name="dy2" select="($y0 - $y) div 2"/>
  1654.         <!--    Convert from degrees to radians -->
  1655.         <xsl:variable name="rotation-radian" select="$x-axis-rotation * $pi div 180"/>
  1656.         <!-- Compute (x1, y1). What are x1,y1?-->
  1657.         <xsl:variable name="cos-rotation">
  1658.             <xsl:call-template name="cos">
  1659.                 <xsl:with-param name="x" select="$rotation-radian"/>
  1660.             </xsl:call-template>
  1661.         </xsl:variable>
  1662.         <xsl:variable name="sin-rotation">
  1663.             <xsl:call-template name="sin">
  1664.                 <xsl:with-param name="x" select="$rotation-radian"/>
  1665.             </xsl:call-template>
  1666.         </xsl:variable>
  1667.         <xsl:variable name="x1" select="$cos-rotation * $dx2 + $sin-rotation * $dy2"/>
  1668.         <xsl:variable name="y1" select="-1 * $sin-rotation  * $dx2 + $cos-rotation * $dy2"/>
  1669.         <!-- Make sure radii are large enough -->
  1670.         <xsl:variable name="rx-abs">
  1671.             <xsl:call-template name="abs">
  1672.                 <xsl:with-param name="x" select="$rx"/>
  1673.             </xsl:call-template>
  1674.         </xsl:variable>
  1675.         <xsl:variable name="ry-abs">
  1676.             <xsl:call-template name="abs">
  1677.                 <xsl:with-param name="x" select="$ry"/>
  1678.             </xsl:call-template>
  1679.         </xsl:variable>
  1680.         <xsl:variable name="rx-sq" select="$rx-abs * $rx-abs"/>
  1681.         <xsl:variable name="ry-sq" select="$ry-abs * $ry-abs"/>
  1682.         <xsl:variable name="x1-sq" select="$x1 * $x1"/>
  1683.         <xsl:variable name="y1-sq" select="$y1 * $y1"/>
  1684.         <xsl:variable name="radius-check" select=" $x1-sq div $rx-sq + $y1-sq div $ry-sq "/>
  1685.         <xsl:variable name="radius-check-sqrt">
  1686.             <xsl:call-template name="sqrt">
  1687.                 <xsl:with-param name="x" select="$radius-check"/>
  1688.             </xsl:call-template>
  1689.         </xsl:variable>
  1690.         <xsl:variable name="new-rx">
  1691.             <xsl:choose>
  1692.                 <xsl:when test="$radius-check > 1">
  1693.                     <xsl:value-of select="$rx-abs * $radius-check-sqrt"/>
  1694.                 </xsl:when>
  1695.                 <xsl:otherwise>
  1696.                     <xsl:value-of select="$rx-abs"/>
  1697.                 </xsl:otherwise>
  1698.             </xsl:choose>
  1699.         </xsl:variable>
  1700.         <xsl:variable name="new-ry">
  1701.             <xsl:choose>
  1702.                 <xsl:when test="$radius-check > 1">
  1703.                     <xsl:value-of select="$ry-abs * $radius-check-sqrt"/>
  1704.                 </xsl:when>
  1705.                 <xsl:otherwise>
  1706.                     <xsl:value-of select="$ry-abs"/>
  1707.                 </xsl:otherwise>
  1708.             </xsl:choose>
  1709.         </xsl:variable>
  1710.         <xsl:variable name="new-ry-sq">
  1711.             <xsl:choose>
  1712.                 <xsl:when test="$radius-check > 1">
  1713.                     <xsl:value-of select="$new-ry * $new-ry"/>
  1714.                 </xsl:when>
  1715.                 <xsl:otherwise>
  1716.                     <xsl:value-of select="$ry-sq"/>
  1717.                 </xsl:otherwise>
  1718.             </xsl:choose>
  1719.         </xsl:variable>
  1720.         <xsl:variable name="new-rx-sq">
  1721.             <xsl:choose>
  1722.                 <xsl:when test="$radius-check > 1">
  1723.                     <xsl:value-of select="$new-rx * $new-rx"/>
  1724.                 </xsl:when>
  1725.                 <xsl:otherwise>
  1726.                     <xsl:value-of select="$rx-sq"/>
  1727.                 </xsl:otherwise>
  1728.             </xsl:choose>
  1729.         </xsl:variable>
  1730.         <!-- Step 2: Compute (cx1, cy1) -->
  1731.         <xsl:variable name="sign">
  1732.             <xsl:choose>
  1733.                 <xsl:when test="$large-arc-flag = $sweep-flag">-1</xsl:when>
  1734.                 <xsl:otherwise>1</xsl:otherwise>
  1735.             </xsl:choose>
  1736.         </xsl:variable>
  1737.         <xsl:variable name="unchecked-sq" select=" (($new-rx-sq * $new-ry-sq) - ($new-rx-sq * $y1-sq) - ($new-ry-sq * $x1-sq)) div   (($new-rx-sq * $y1-sq) + ($new-ry-sq * $x1-sq)) "/>
  1738.         <xsl:variable name="sq">
  1739.             <xsl:choose>
  1740.                 <xsl:when test=" $unchecked-sq < 0">0</xsl:when>
  1741.                 <xsl:otherwise>
  1742.                     <xsl:value-of select="$unchecked-sq"/>
  1743.                 </xsl:otherwise>
  1744.             </xsl:choose>
  1745.         </xsl:variable>
  1746.         <xsl:variable name="sq-sqrt">
  1747.             <xsl:call-template name="sqrt">
  1748.                 <xsl:with-param name="x" select="$sq"/>
  1749.             </xsl:call-template>
  1750.         </xsl:variable>
  1751.         <xsl:variable name="coef" select="$sign * $sq-sqrt "/>
  1752.         <xsl:variable name="cx1" select="$coef * $new-rx * $y1 div $new-ry"/>
  1753.         <xsl:variable name="cy1" select=" -1 * $coef * $new-ry * $x1 div $new-rx"/>
  1754.         <!--  Step 3: Compute (cx, cy) from (cx1, cy1) -->
  1755.         <xsl:variable name="sx2" select="($x0 +$x) div 2 "/>
  1756.         <xsl:variable name="sy2" select="($y0 +$y) div 2 "/>
  1757.         <xsl:variable name="tmp1" select="$cos-rotation * $cx1 "/>
  1758.         <xsl:variable name="tmp2" select="$cos-rotation * $cx1 "/>
  1759.         <xsl:variable name="cx" select=" $sx2 + ( $cos-rotation * $cx1 - $sin-rotation * $cy1 ) "/>
  1760.         <xsl:variable name="cy" select=" $sy2 + ( $sin-rotation * $cx1 + $cos-rotation * $cy1 ) "/>
  1761.         <!-- Step 4: Compute angle start and angle extent -->
  1762.         <xsl:variable name="ux" select="( $x1 - $cx1)  div $new-rx"/>
  1763.         <xsl:variable name="uy" select="( $y1 - $cy1)  div $new-ry"/>
  1764.         <xsl:variable name="vx" select="( - 1 *  $x1 - $cx1)  div $new-rx"/>
  1765.         <xsl:variable name="vy" select="(- 1 *  $y1 - $cy1)  div $new-ry"/>
  1766.         <xsl:variable name="n">
  1767.             <xsl:call-template name="sqrt">
  1768.                 <xsl:with-param name="x" select="  ($ux * $ux) + ($uy * $uy)  "/>
  1769.             </xsl:call-template>
  1770.         </xsl:variable>
  1771.         <!--  1 * ux + 0 * uy -->
  1772.         <xsl:variable name="p" select="$ux"/>
  1773.         <xsl:variable name="uy-sign">
  1774.             <xsl:choose>
  1775.                 <xsl:when test=" $uy < 0 ">-1</xsl:when>
  1776.                 <xsl:otherwise>1</xsl:otherwise>
  1777.             </xsl:choose>
  1778.         </xsl:variable>
  1779.         <xsl:variable name="acos-pn">
  1780.             <xsl:call-template name="acos">
  1781.                 <xsl:with-param name="x" select="$p div $n"/>
  1782.             </xsl:call-template>
  1783.         </xsl:variable>
  1784.         <xsl:variable name="theta" select="( $uy-sign * $acos-pn * 180 div $pi ) mod 360 "/>
  1785.         <xsl:variable name="n-delta">
  1786.             <xsl:call-template name="sqrt">
  1787.                 <xsl:with-param name="x" select="($ux * $ux + $uy * $uy) * ($vx * $vx + $vy * $vy)"/>
  1788.             </xsl:call-template>
  1789.         </xsl:variable>
  1790.         <xsl:variable name="p-delta" select="$ux * $vx + $uy * $vy"/>
  1791.         <xsl:variable name="vy-sign">
  1792.             <xsl:choose>
  1793.                 <xsl:when test="($ux * $vy - $uy * $vx)   < 0 ">-1</xsl:when>
  1794.                 <xsl:otherwise>1</xsl:otherwise>
  1795.             </xsl:choose>
  1796.         </xsl:variable>
  1797.         <xsl:variable name="acos-pn-delta">
  1798.             <xsl:call-template name="acos">
  1799.                 <xsl:with-param name="x" select="$p-delta div $n-delta"/>
  1800.             </xsl:call-template>
  1801.         </xsl:variable>
  1802.         <xsl:variable name="unchecked-delta" select="$vy-sign * $acos-pn-delta * 180 div $pi "/>
  1803.         <xsl:variable name="delta">
  1804.             <xsl:choose>
  1805.                 <xsl:when test=" $sweep-flag = 0 and $unchecked-delta > 0 ">
  1806.                     <xsl:value-of select=" ($unchecked-delta - 360) mod 360 "/>
  1807.                 </xsl:when>
  1808.                 <xsl:when test=" $sweep-flag = 1 and $unchecked-delta < 0 ">
  1809.                     <xsl:value-of select=" ($unchecked-delta + 360) mod 360 "/>
  1810.                 </xsl:when>
  1811.                 <xsl:otherwise>
  1812.                     <xsl:value-of select=" $unchecked-delta  mod 360 "/>
  1813.                 </xsl:otherwise>
  1814.             </xsl:choose>
  1815.         </xsl:variable>
  1816.         <xsl:value-of select="concat ($cx,  ' ' , $cy, ' ' ,  $rx, ' ' ,  $ry, ' ' ,  $theta, ' ' , $delta,  ' ' , $x-axis-rotation) "/>
  1817.     </xsl:template>
  1818. </xsl:stylesheet>
  1819.