# HG changeset patch
# User Henning Brinkmann <hbrinkm@openoffice.org>
# Date 1282725743 -7200
# Node ID d87fcd24d47c7fa2f9895dae2e35b0688c9811d0
# Parent  63097700fafde0b9c5d6f30736882f02dbe2a375
rtftok01: spectobnf.xsl: extract bnf from RTF specification

diff --git a/writerfilter/source/rtftok/spectobnf.xsl b/writerfilter/source/rtftok/spectobnf.xsl
new file mode 100644
--- /dev/null
+++ b/writerfilter/source/rtftok/spectobnf.xsl
@@ -0,0 +1,627 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0" 
+                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:ve="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+                xmlns:o="urn:schemas-microsoft-com:office:office" 
+                xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" 
+                xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math" 
+                xmlns:v="urn:schemas-microsoft-com:vml" 
+                xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" 
+                xmlns:w10="urn:schemas-microsoft-com:office:word" 
+                xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" 
+                xmlns:wne="http://schemas.microsoft.com/office/word/2006/wordml"
+                xmlns:fn="http://www.w3.org/2005/xpath-functions">
+
+<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="no"/>
+
+<xsl:template name="definename">
+  <xsl:param name="token"/>
+  <xsl:value-of select="substring-before(substring-after ($token, '&lt;'), '&gt;')"/>
+</xsl:template>
+
+<xsl:template name="braceinner">
+  <xsl:param name="string"/>
+  <xsl:param name="depth"/>
+
+  <xsl:if test="number($depth) &gt; 0">
+    <xsl:variable name="beforeclose">
+      <xsl:choose>
+        <xsl:when test="contains($string, ')')">
+          <xsl:value-of select="substring-before($string, ')')"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:value-of select="$string"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+    <xsl:variable name="beforeopen">
+      <xsl:choose>
+        <xsl:when test="contains($string, '(')">
+          <xsl:value-of select="substring-before($string, '(')"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:value-of select="$string"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+    
+    <xsl:choose>
+      <xsl:when test="string-length($beforeclose) &lt; string-length($beforeopen)">
+        <xsl:value-of select="$beforeclose"/>
+        <xsl:variable name="newdepth" select="number($depth) - 1"/>
+
+        <xsl:if test="number($newdepth) &gt; 0">
+          <xsl:text>)</xsl:text>
+          <xsl:call-template name="braceinner">
+            <xsl:with-param name="string" select="substring-after($string, ')')"/>
+            <xsl:with-param name="depth" select="$newdepth"/>
+          </xsl:call-template>
+        </xsl:if>
+      </xsl:when>
+      <xsl:when test="string-length($beforeclose) &gt; string-length($beforeopen)">
+        <xsl:value-of select="$beforeopen"/>
+        <xsl:text>(</xsl:text>
+        <xsl:call-template name="braceinner">
+          <xsl:with-param name="string" select="substring-after($string, '(')"/>
+          <xsl:with-param name="depth" select="number($depth) + 1"/>
+        </xsl:call-template>
+      </xsl:when>
+    </xsl:choose>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template name="control">
+  <xsl:param name="string"/>
+  
+  <xsl:variable name="first" select="substring($string, 1, 1)"/>
+  <xsl:variable name="translated" select="translate($first, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')"/>
+  <xsl:choose>
+    <xsl:when test="$translated = 'a'">
+      <xsl:value-of select="substring($string, 1, 1)"/>
+      <xsl:call-template name="control">
+        <xsl:with-param name="string" select="substring($string, 2)"/>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:otherwise>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template name="literal">
+  <xsl:param name="string"/>              
+  <xsl:value-of select='substring-before($string, "&apos;")'/>
+</xsl:template>
+
+<xsl:template name="ref">
+  <xsl:param name="string"/>
+  <xsl:value-of select="substring-before($string, '&gt;')"/>
+</xsl:template>
+
+<xsl:template name="precedence">
+  <xsl:param name="token"/>
+  <xsl:choose>
+    <xsl:when test="translate(substring($token, 1, 1), '|&amp;', 'aa') = 'a'">
+      <xsl:text>2</xsl:text>
+    </xsl:when>
+    <xsl:when test="translate(substring($token, 1, 1), '+?*', 'aaa') = 'a'">
+      <xsl:text>1</xsl:text>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:text>0</xsl:text>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template name="nexttokens">
+  <xsl:param name="string"/>
+  <xsl:param name="precedence"/>
+  <xsl:param name="guard"/>
+
+  <xsl:if test="not(number($guard) &gt; 0)">
+    <xsl:text>guard</xsl:text>
+  </xsl:if>
+  <xsl:if test="string-length($string) &gt; 0 and number($guard) &gt; 0">
+    <xsl:variable name="token">
+      <xsl:call-template name="nexttoken">
+        <xsl:with-param name="string" select="$string"/>
+      </xsl:call-template>
+    </xsl:variable>
+    <xsl:variable name="prec">
+      <xsl:call-template name="precedence">
+        <xsl:with-param name="token" select="$token"/>
+      </xsl:call-template>
+    </xsl:variable>
+    
+    <xsl:if test="number($prec) &lt; number($precedence)">
+      <xsl:variable name="rest" select="substring-after($string, $token)"/>
+      <xsl:value-of select="$token"/>
+      
+      <xsl:call-template name="nexttokens">
+        <xsl:with-param name="string" select="$rest"/>
+        <xsl:with-param name="precedence" select="$precedence"/>
+        <xsl:with-param name="guard" select="number($guard) - 1"/>
+      </xsl:call-template>
+      
+    </xsl:if>
+  </xsl:if>
+</xsl:template>
+
+<xsl:template name="nexttoken">
+  <xsl:param name="string"/>
+  <xsl:choose>
+    <xsl:when test="starts-with($string, ' ') or starts-with($string, ' ')">
+      <xsl:call-template name="nexttoken">
+        <xsl:with-param name="string" select="substring($string, 2)"/>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:when test="starts-with($string, '(')">
+      <xsl:text>(</xsl:text>
+      <xsl:call-template name="braceinner">
+        <xsl:with-param name="string" select="substring($string, 2)"/>
+        <xsl:with-param name="depth">1</xsl:with-param>
+      </xsl:call-template>
+      <xsl:text>)</xsl:text>
+    </xsl:when>
+    <xsl:when test="starts-with($string, '#SDATA')">
+      <xsl:text>#SDATA</xsl:text>
+    </xsl:when>
+    <xsl:when test="starts-with($string, '#BDATA')">
+      <xsl:text>#BDATA</xsl:text>
+    </xsl:when>
+    <xsl:when test="starts-with($string, '#PCDATA')">
+      <xsl:text>#PCDATA</xsl:text>
+    </xsl:when>
+    <xsl:when test="starts-with($string, '\')">
+      <xsl:text>\</xsl:text>
+      <xsl:call-template name="control">
+        <xsl:with-param name="string" select="substring($string,2)"/>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:when test='starts-with($string, "&apos;")'>
+      <xsl:text>&apos;</xsl:text>
+      <xsl:call-template name="literal">
+        <xsl:with-param name="string" select="substring($string, 2)"/>
+      </xsl:call-template>
+      <xsl:text>&apos;</xsl:text>
+    </xsl:when>
+    <xsl:when test="starts-with($string, '&lt;')">
+      <xsl:text>&lt;</xsl:text>
+      <xsl:call-template name="ref">
+        <xsl:with-param name="string" select="substring($string, 2)"/>
+      </xsl:call-template>
+      <xsl:text>&gt;</xsl:text>
+    </xsl:when>
+    <xsl:when test="translate(substring($string, 1, 1), '?+*|&amp;N', 'xxxxxx') = 'x'">
+      <xsl:value-of select="substring($string, 1, 1)"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:value-of select="$string"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<xsl:template name="parseright">
+  <xsl:param name="right"/>
+  <xsl:param name="prev"/>
+
+  <xsl:variable name="token">
+    <xsl:call-template name="nexttoken">
+      <xsl:with-param name="string" select="$right"/>
+    </xsl:call-template>
+  </xsl:variable>
+  
+  <xsl:choose>
+    <xsl:when test="string-length($token) > 0">
+      <xsl:variable name="rest" select="substring-after($right, $token)"/>
+      
+      <xsl:choose>
+        <xsl:when test="starts-with($token, '#SDATA')">
+          <xsl:copy-of select="$prev"/>
+          <xsl:call-template name="parseright">
+            <xsl:with-param name="right" select="$rest"/>
+            <xsl:with-param name="prev">
+              <sdata/>
+            </xsl:with-param>
+          </xsl:call-template>
+        </xsl:when>
+        <xsl:when test="starts-with($token, '#BDATA')">
+          <xsl:copy-of select="$prev"/>
+          <xsl:call-template name="parseright">
+            <xsl:with-param name="right" select="$rest"/>
+            <xsl:with-param name="prev">
+              <bdata/>
+            </xsl:with-param>
+          </xsl:call-template>
+        </xsl:when>
+        <xsl:when test="starts-with($token, '#PCDATA')">
+          <xsl:copy-of select="$prev"/>
+          <xsl:call-template name="parseright">
+            <xsl:with-param name="right" select="$rest"/>
+            <xsl:with-param name="prev">
+              <pcdata/>
+            </xsl:with-param>
+          </xsl:call-template>
+        </xsl:when>
+        <xsl:when test="starts-with($token, '\')">
+          <xsl:copy-of select="$prev"/>
+          <xsl:call-template name="parseright">
+            <xsl:with-param name="right" select="$rest"/>
+            <xsl:with-param name="prev">
+              <control>
+                <xsl:attribute name="name">
+                  <xsl:value-of select="substring($token, 2)"/>
+                </xsl:attribute>
+              </control>
+            </xsl:with-param>
+          </xsl:call-template>
+        </xsl:when>
+        <xsl:when test="starts-with($token, '&lt;')">
+          <xsl:copy-of select="$prev"/>
+          <xsl:call-template name="parseright">
+            <xsl:with-param name="right" select="$rest"/>
+            <xsl:with-param name="prev">
+              <ref>
+                <xsl:attribute name="name">
+                  <xsl:value-of select="substring-before(substring($token, 2), '&gt;')"/>
+                </xsl:attribute>
+              </ref>
+            </xsl:with-param>
+          </xsl:call-template>
+        </xsl:when>
+        <xsl:when test='starts-with($token, "&apos;")'>
+          <xsl:copy-of select="$prev"/>
+          <xsl:call-template name="parseright">
+            <xsl:with-param name="right" select="$rest"/>
+            <xsl:with-param name="prev">
+              <literal>
+                <xsl:value-of select='substring-before(substring($token, 2), "&apos;")'/>
+              </literal>
+            </xsl:with-param>
+          </xsl:call-template>
+        </xsl:when>
+        <xsl:when test="starts-with($token, '?')">
+          <xsl:call-template name="parseright">
+            <xsl:with-param name="right" select="$rest"/>
+            <xsl:with-param name="prev">
+              <optional>
+                <xsl:copy-of select="$prev"/>
+              </optional>
+            </xsl:with-param>
+          </xsl:call-template>
+        </xsl:when>
+        <xsl:when test="starts-with($token, '+')">
+          <xsl:call-template name="parseright">
+            <xsl:with-param name="right" select="$rest"/>
+            <xsl:with-param name="prev">
+              <one-or-more>
+                <xsl:copy-of select="$prev"/>
+              </one-or-more>
+            </xsl:with-param>
+          </xsl:call-template>
+        </xsl:when>
+        <xsl:when test="starts-with($token, '*')">
+          <xsl:call-template name="parseright">
+            <xsl:with-param name="right" select="$rest"/>
+            <xsl:with-param name="prev">
+              <zero-or-more>
+                <xsl:copy-of select="$prev"/>
+              </zero-or-more>
+            </xsl:with-param>
+          </xsl:call-template>
+        </xsl:when>
+        <xsl:when test="starts-with($token, '|')">
+          <xsl:variable name="myright">
+            <xsl:call-template name="nexttokens">
+              <xsl:with-param name="string" select="$rest"/>
+              <xsl:with-param name="precedence" select="1"/>
+              <xsl:with-param name="guard" select="10"/>
+            </xsl:call-template>
+          </xsl:variable>
+          <xsl:variable name="myrest" select="substring-after($rest, $myright)"/>
+          <xsl:call-template name="parseright">
+            <xsl:with-param name="right" select="$myrest"/>
+            <xsl:with-param name="prev">
+              <choice>
+                <xsl:copy-of select="$prev"/>
+                <xsl:call-template name="parseright">
+                  <xsl:with-param name="right" select="$myright"/>
+                </xsl:call-template>
+              </choice>
+            </xsl:with-param>
+          </xsl:call-template>
+        </xsl:when>
+        <xsl:when test="starts-with($token, '&amp;')">
+          <xsl:variable name="myright">
+            <xsl:call-template name="nexttokens">
+              <xsl:with-param name="string" select="$rest"/>
+              <xsl:with-param name="precedence" select="1"/>
+              <xsl:with-param name="guard" select="10"/>
+            </xsl:call-template>
+          </xsl:variable>
+          <xsl:variable name="myrest" select="substring-after($rest, $myright)"/>
+          <xsl:call-template name="parseright">
+            <xsl:with-param name="right" select="$myrest"/>
+            <xsl:with-param name="prev">
+              <any>
+                <xsl:copy-of select="$prev"/>
+                <xsl:call-template name="parseright">
+                  <xsl:with-param name="right" select="$myright"/>
+                </xsl:call-template>
+              </any>
+            </xsl:with-param>
+          </xsl:call-template>
+        </xsl:when>
+        <xsl:when test="starts-with($token, '(')">
+          <xsl:copy-of select="$prev"/>
+          <xsl:call-template name="parseright">
+            <xsl:with-param name="right" select="$rest"/>
+            <xsl:with-param name="prev">
+              <paren>
+                <xsl:call-template name="parseright">
+                  <xsl:with-param name="right" select="substring($token, 2, string-length($token) - 2)"/>
+                </xsl:call-template>
+              </paren>
+            </xsl:with-param>
+          </xsl:call-template>
+        </xsl:when>
+        <xsl:when test="starts-with($token, 'N')">
+          <xsl:call-template name="parseright">
+            <xsl:with-param name="right" select="$rest"/>
+            <xsl:with-param name="prev">
+              <group>
+                <xsl:copy-of select="$prev"/>
+                <ref name="number"/>
+              </group>
+            </xsl:with-param>
+          </xsl:call-template>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:copy-of select="$prev"/>
+          <token>
+            <xsl:value-of select="$token"/>
+          </token>
+          <xsl:call-template name="parseright">
+            <xsl:with-param name="right" select="$rest"/>
+          </xsl:call-template>
+        </xsl:otherwise>
+      </xsl:choose>
+
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:copy-of select="$prev"/>
+      <notoken>
+        <xsl:value-of select="$right"/>
+      </notoken>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
+<!--
+<xsl:template name="parseright">
+  <xsl:param name="right"/>
+  <xsl:param name="prev"/>
+  <xsl:param name="any"/>
+  <xsl:choose>
+    <xsl:when test="starts-with($right, 'N')">
+      <xsl:call-template name="parseright">
+        <xsl:with-param name="right" select="substring-after($right, 'N')"/>
+        <xsl:with-param name="prev">
+          <group>
+            <xsl:copy-of select="$prev"/>
+            <ref name="number"/>
+          </group>
+        </xsl:with-param>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:when test="starts-with($right, '#PCDATA')">
+      <xsl:copy-of select="$prev"/>
+      <xsl:call-template name="parseright">
+        <xsl:with-param name="right" select="substring-after($right, '#PCDATA')"/>
+        <xsl:with-param name="prev">
+          <pcdata/>
+        </xsl:with-param>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:when test="starts-with($right, '#SDATA')">
+      <xsl:copy-of select="$prev"/>
+      <xsl:call-template name="parseright">
+        <xsl:with-param name="right" select="substring-after($right, '#SDATA')"/>
+        <xsl:with-param name="prev">
+          <sdata/>
+        </xsl:with-param>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:when test="starts-with($right, '#BDATA')">
+      <xsl:copy-of select="$prev"/>
+      <xsl:call-template name="parseright">
+        <xsl:with-param name="right" select="substring-after($right, '#BDATA')"/>
+        <xsl:with-param name="prev">
+          <bdata/>
+        </xsl:with-param>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:when test="starts-with($right, ' ')">
+      <xsl:call-template name="parseright">
+        <xsl:with-param name="right" select="substring-after($right, ' ')"/>
+        <xsl:with-param name="prev" select="$prev"/>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:when test="starts-with($right, '?')">
+      <xsl:call-template name="parseright">
+        <xsl:with-param name="right" select="substring-after($right, '?')"/>
+        <xsl:with-param name="prev">
+          <optional>
+            <xsl:copy-of select="$prev"/>
+          </optional>
+        </xsl:with-param>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:when test="starts-with($right, '*')">
+      <xsl:call-template name="parseright">
+        <xsl:with-param name="right" select="substring-after($right, '*')"/>
+        <xsl:with-param name="prev">
+          <zero-or-more>
+            <xsl:copy-of select="$prev"/>
+          </zero-or-more>
+        </xsl:with-param>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:when test="starts-with($right, '+')">
+      <xsl:call-template name="parseright">
+        <xsl:with-param name="right" select="substring-after($right, '+')"/>
+        <xsl:with-param name="prev">
+          <one-or-more>
+            <xsl:copy-of select="$prev"/>
+          </one-or-more>
+        </xsl:with-param>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:when test="starts-with($right, '(')">
+      <xsl:copy-of select="$prev"/>
+
+      <xsl:variable name="innerandrest" select="substring-after($right, '(')"/>
+      <xsl:variable name="inner">
+        <xsl:call-template name="braceinner">
+          <xsl:with-param name="string" select="substring-after($right, '(')"/>
+          <xsl:with-param name="depth" select="1"/>
+        </xsl:call-template>
+      </xsl:variable> 
+      <xsl:variable name="innerandparen">
+        <xsl:value-of select="$inner"/>
+        <xsl:text>)</xsl:text>
+      </xsl:variable>
+      <xsl:variable name="rest" select="substring-after($innerandrest, $innerandparen)"/>
+      <xsl:call-template name="parseright">
+        <xsl:with-param name="right" select="$rest"/>
+        <xsl:with-param name="prev">
+          <paren>
+          <xsl:call-template name="parseright">
+            <xsl:with-param name="right">
+              <xsl:value-of select="$inner"/>
+            </xsl:with-param>
+          </xsl:call-template>
+          </paren>
+        </xsl:with-param>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:when test="starts-with($right, '|')">
+      <choice>
+        <xsl:copy-of select="$prev"/>
+        <xsl:call-template name="parseright">
+          <xsl:with-param name="right" select="substring-after($right, '|')"/>
+        </xsl:call-template>
+      </choice>
+    </xsl:when>
+    <xsl:when test='starts-with($right, "&amp;")'>
+      <any>
+        <xsl:copy-of select="$prev"/>
+        <xsl:call-template name="parseright">
+          <xsl:with-param name="right" select='substring-after($right, "&amp;")'/>
+        </xsl:call-template>
+      </any>
+    </xsl:when>
+    <xsl:when test="starts-with($right, '\')">
+      <xsl:copy-of select="$prev"/>
+
+      <xsl:variable name="controlandrest" select="substring-after($right, '\')"/>
+      <xsl:variable name="control">
+        <xsl:call-template name="control">
+          <xsl:with-param name="string" select="$controlandrest"/>
+        </xsl:call-template>
+      </xsl:variable>
+      <xsl:variable name="rest" select="substring-after($controlandrest, $control)"/>
+      <xsl:call-template name="parseright">
+        <xsl:with-param name="right" select="$rest"/>
+        <xsl:with-param name="prev">
+          <control>
+            <xsl:attribute name="name">
+              <xsl:value-of select="$control"/>
+            </xsl:attribute>
+          </control>
+        </xsl:with-param>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:when test='starts-with($right, "&apos;")'>
+      <xsl:copy-of select="$prev"/>
+
+      <xsl:variable name="literalandrest" select='substring-after($right, "&apos;")'/>
+      <xsl:variable name="literal" select='substring-before($literalandrest, "&apos;")'/>
+      <xsl:variable name="rest" select='substring-after($literalandrest, "&apos;")'/>
+      <xsl:call-template name="parseright">
+        <xsl:with-param name="right" select="$rest"/>
+        <xsl:with-param name="prev">
+          <literal>
+            <xsl:value-of select="$literal"/>
+          </literal>
+        </xsl:with-param>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:when test='starts-with($right, "&lt;")'>
+      <xsl:copy-of select="$prev"/>
+
+      <xsl:variable name="refandrest" select='substring-after($right, "&lt;")'/>
+      <xsl:variable name="ref" select='substring-before($refandrest, "&gt;")'/>
+      <xsl:variable name="rest" select='substring-after($refandrest, "&gt;")'/>
+      <xsl:call-template name="parseright">
+        <xsl:with-param name="right" select="$rest"/>
+        <xsl:with-param name="prev">
+          <ref>
+            <xsl:attribute name="name">
+              <xsl:value-of select="$ref"/>
+            </xsl:attribute>
+          </ref>
+        </xsl:with-param>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:copy-of select="$prev"/>
+      <xsl:value-of select="$right"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+-->
+
+<xsl:template match="/">
+  <out>
+    <xsl:for-each select=".//w:tbl">
+      <xsl:for-each select=".//w:tr[count(.//w:tc) = 2]">
+        <xsl:variable name="definename">
+          <xsl:for-each select=".//w:tc[1]">
+            <xsl:call-template name="definename">
+              <xsl:with-param name="token">
+                <xsl:for-each select=".//w:t">
+                  <xsl:value-of select="."/>
+                </xsl:for-each>
+              </xsl:with-param>
+            </xsl:call-template>
+          </xsl:for-each>
+        </xsl:variable>
+        <xsl:if test="string-length($definename) > 0">
+          <define>
+            <xsl:attribute name="name">
+              <xsl:value-of select="$definename"/>
+            </xsl:attribute>
+            <xsl:variable name="right">
+              <xsl:for-each select=".//w:tc[2]">
+                <xsl:for-each select=".//w:t">
+                  <xsl:value-of select="."/>
+                </xsl:for-each>
+              </xsl:for-each>
+            </xsl:variable>
+            <xsl:comment>
+              <xsl:value-of select="$right"/>
+            </xsl:comment>
+            <xsl:call-template name="parseright">
+              <xsl:with-param name="right" select="$right"/>
+            </xsl:call-template>
+          </define>
+        </xsl:if>
+      </xsl:for-each>
+    </xsl:for-each>
+  </out>
+</xsl:template>
+
+<xsl:template match="*">
+</xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file
