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