changeset 12:01e125d722be

widening scope so better names
author Henry S. Thompson <ht@markup.co.uk>
date Mon, 03 Apr 2017 13:46:54 +0100
parents 480454d218f7
children f78e8c55c06b
files ascii.xpl ascii.xsl rect.xsl visualise.xpl
diffstat 4 files changed, 104 insertions(+), 100 deletions(-) [+]
line wrap: on
line diff
--- a/ascii.xpl	Mon Apr 03 13:27:32 2017 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-<?xml version='1.0'?>
-<!DOCTYPE p:pipeline SYSTEM "../../../WWW/XML/XProc/docs/schemas/xproc.dtd" >
-<p:pipeline xmlns:p="http://www.w3.org/ns/xproc" xmlns:x="http://www.w3.org/1999/xhtml" version="1.0" name="ascii">
- 
- <p:documentation xmlns="http://www.w3.org/1999/xhtml">
-  <div>Run this e.g. as follows:
-       xproc --input source=sample2/xl/worksheets/sheet1.xml ascii.xpl elabDir=file:/d/MT/sonra/OOXML</div>
- </p:documentation>
- 
- <p:option name="elabDir" required="true">
-  <p:documentation xmlns="http://www.w3.org/1999/xhtml">
-   <div>Directory where stylesheets, other info for stylesheet elaboration are found</div>
-  </p:documentation>
- </p:option>
- 
- <p:load name="ss1">
-  <p:with-option name="href" select="concat($elabDir,'/format.xsl')"/>
- </p:load>
-
- <p:xslt name="format">
-   <p:input port="source">
-    <p:pipe step="ascii" port="source"/>
-   </p:input>
-  <p:input port="stylesheet">
-   <p:pipe step="ss1" port="result"/>
-  </p:input>
-  <p:with-param name="elabDir" select="$elabDir"/>
- </p:xslt>
- 
- <p:load name="ss2">
-  <p:with-option name="href" select="concat($elabDir,'/ascii.xsl')"/>
- </p:load>
- 
- <p:xslt name="asc">
-   <p:input port="source">
-    <p:pipe step="format" port="result"/>
-   </p:input>
-  <p:input port="stylesheet">
-   <p:pipe step="ss2" port="result"/>
-  </p:input>
-  <p:with-param name="elabDir" select="$elabDir"/>
- </p:xslt>
-</p:pipeline>
--- a/ascii.xsl	Mon Apr 03 13:27:32 2017 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-<?xml version='1.0'?>
-<!DOCTYPE doc SYSTEM "../../../lib/xml/xsl.dtd" >
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xmlns:s="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:e="http://markup.co.uk/excel" exclude-result-prefixes="xs s xpf" xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:xpf="http://www.w3.org/2005/xpath-functions">
- 
- <xsl:function name="e:a2n" as="xs:integer">
-  <!-- Convert an alphabetic excel column 'index' into a number,
-       a sort of base 26 + 1, since 'A' is 1 and 'AA' is 27 -->
-  <xsl:param name="aa" as="xs:string"/>
-  <xsl:value-of select="let $l := string-length($aa),
-                        $lv := string-to-codepoints(substring($aa,$l))-$codeBase
-                        return if ($l=1) then $lv
-                               else $lv+(26*e:a2n(substring($aa,1,$l - 1)))"/>
- </xsl:function>
- 
- <xsl:function name="e:n2aa" as="xs:integer*">
-  <!-- Does the real work for e:n2a -->
-  <xsl:param name="n" as="xs:integer"/>
-  <xsl:sequence select="let $least := $codeBase+(($n - 1) mod 26)+1
-                         return if ($n &lt; 27) then $least
-                          else (e:n2aa($n idiv 26),$least)"/>
- </xsl:function>
-
- <xsl:function name="e:n2a" as="xs:string">
-  <!-- Invert the a2n computation -->
-  <xsl:param name="n" as="xs:integer"/>
-  <xsl:value-of select="codepoints-to-string(e:n2aa($n))"/>
- </xsl:function>
-
- <xsl:variable name="dim" select="//s:dimension/@ref"/>
- <xsl:variable name="codeBase" select="string-to-codepoints('A')-1"/>
-
- <xsl:template match="s:sheetData">
-  <xsl:if test="s:row">
-   <xsl:variable name="dims" select="analyze-string($dim,'([A-Z]+)([0-9]+):([A-Z]+)([0-9]+)')"/> 
-   <xsl:variable name="height" select="1+xs:integer($dims//xpf:group[@nr='4'])-xs:integer($dims//xpf:group[@nr='2'])"/>
-   <xsl:variable name="width" select="1+e:a2n($dims//xpf:group[@nr='3'])-e:a2n($dims//xpf:group[@nr='1'])"/>
-   <!-- Brute force! -->
-   <xsl:variable name="sheet" select="."/>
-   <e:a>
-    <xsl:text>&#10;</xsl:text>
-    <xsl:for-each select="(1 to $height)"><xsl:variable name="row" select="."/>
-     <e:r r="{$row}">
-      <xsl:for-each select="(1 to $width)">
-       <xsl:variable name="col" select="."/>
-       <xsl:variable name="r" select="concat(e:n2a($col),string($row))"/>
-       <xsl:variable name="c" select="$sheet/s:row/s:c[@r=$r]"/>
-       <e:c c="{$col}">
-        <xsl:if test="$c/s:f"><xsl:attribute name="f">1</xsl:attribute></xsl:if>
-        <xsl:if test="$c"><xsl:value-of select="substring($c/@e:type,1,1)"/></xsl:if>
-       </e:c>
-      </xsl:for-each>
-     </e:r>
-     <xsl:text>&#10;</xsl:text></xsl:for-each>
-   </e:a>
-  </xsl:if>
- </xsl:template>
-</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rect.xsl	Mon Apr 03 13:46:54 2017 +0100
@@ -0,0 +1,57 @@
+<?xml version='1.0'?>
+<!DOCTYPE doc SYSTEM "../../../lib/xml/xsl.dtd" >
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xmlns:s="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:e="http://markup.co.uk/excel" exclude-result-prefixes="xs s xpf" xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:xpf="http://www.w3.org/2005/xpath-functions">
+ 
+ <xsl:function name="e:a2n" as="xs:integer">
+  <!-- Convert an alphabetic excel column 'index' into a number,
+       a sort of base 26 + 1, since 'A' is 1 and 'AA' is 27 -->
+  <xsl:param name="aa" as="xs:string"/>
+  <xsl:value-of select="let $l := string-length($aa),
+                        $lv := string-to-codepoints(substring($aa,$l))-$codeBase
+                        return if ($l=1) then $lv
+                               else $lv+(26*e:a2n(substring($aa,1,$l - 1)))"/>
+ </xsl:function>
+ 
+ <xsl:function name="e:n2aa" as="xs:integer*">
+  <!-- Does the real work for e:n2a -->
+  <xsl:param name="n" as="xs:integer"/>
+  <xsl:sequence select="let $least := $codeBase+(($n - 1) mod 26)+1
+                         return if ($n &lt; 27) then $least
+                          else (e:n2aa($n idiv 26),$least)"/>
+ </xsl:function>
+
+ <xsl:function name="e:n2a" as="xs:string">
+  <!-- Invert the a2n computation -->
+  <xsl:param name="n" as="xs:integer"/>
+  <xsl:value-of select="codepoints-to-string(e:n2aa($n))"/>
+ </xsl:function>
+
+ <xsl:variable name="dim" select="//s:dimension/@ref"/>
+ <xsl:variable name="codeBase" select="string-to-codepoints('A')-1"/>
+
+ <xsl:template match="s:sheetData">
+  <xsl:if test="s:row">
+   <xsl:variable name="dims" select="analyze-string($dim,'([A-Z]+)([0-9]+):([A-Z]+)([0-9]+)')"/> 
+   <xsl:variable name="height" select="1+xs:integer($dims//xpf:group[@nr='4'])-xs:integer($dims//xpf:group[@nr='2'])"/>
+   <xsl:variable name="width" select="1+e:a2n($dims//xpf:group[@nr='3'])-e:a2n($dims//xpf:group[@nr='1'])"/>
+   <!-- Brute force! -->
+   <xsl:variable name="sheet" select="."/>
+   <e:a>
+    <xsl:text>&#10;</xsl:text>
+    <xsl:for-each select="(1 to $height)"><xsl:variable name="row" select="."/>
+     <e:r r="{$row}">
+      <xsl:for-each select="(1 to $width)">
+       <xsl:variable name="col" select="."/>
+       <xsl:variable name="r" select="concat(e:n2a($col),string($row))"/>
+       <xsl:variable name="c" select="$sheet/s:row/s:c[@r=$r]"/>
+       <e:c c="{$col}">
+        <xsl:if test="$c/s:f"><xsl:attribute name="f">1</xsl:attribute></xsl:if>
+        <xsl:if test="$c"><xsl:value-of select="substring($c/@e:type,1,1)"/></xsl:if>
+       </e:c>
+      </xsl:for-each>
+     </e:r>
+     <xsl:text>&#10;</xsl:text></xsl:for-each>
+   </e:a>
+  </xsl:if>
+ </xsl:template>
+</xsl:stylesheet>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/visualise.xpl	Mon Apr 03 13:46:54 2017 +0100
@@ -0,0 +1,47 @@
+<?xml version='1.0'?>
+<!DOCTYPE p:pipeline SYSTEM "../../../WWW/XML/XProc/docs/schemas/xproc.dtd" >
+<p:pipeline xmlns:p="http://www.w3.org/ns/xproc" xmlns:x="http://www.w3.org/1999/xhtml" version="1.0" name="ascii">
+ 
+ <p:documentation xmlns="http://www.w3.org/1999/xhtml">
+  <div>Run this e.g. as follows:
+       xproc --input source=sample2/xl/worksheets/sheet1.xml ascii.xpl elabDir=file:/d/MT/sonra/OOXML</div>
+ </p:documentation>
+ 
+ <p:option name="elabDir" required="true">
+  <p:documentation xmlns="http://www.w3.org/1999/xhtml">
+   <div>Directory where stylesheets, other info for stylesheet elaboration are found</div>
+  </p:documentation>
+ </p:option>
+ 
+ <p:load name="ss1">
+  <p:with-option name="href" select="concat($elabDir,'/format.xsl')"/>
+ </p:load>
+
+ <p:xslt name="format">
+   <p:input port="source">
+    <p:pipe step="ascii" port="source"/>
+   </p:input>
+  <p:input port="stylesheet">
+   <p:pipe step="ss1" port="result"/>
+  </p:input>
+  <p:with-param name="elabDir" select="$elabDir"/>
+ </p:xslt>
+ 
+ <p:load name="ss2">
+  <p:with-option name="href" select="concat($elabDir,'/rect.xsl')"/>
+ </p:load>
+ 
+ <p:xslt name="asc">
+   <p:input port="source">
+    <p:pipe step="format" port="result"/>
+   </p:input>
+  <p:input port="stylesheet">
+   <p:pipe step="ss2" port="result"/>
+  </p:input>
+  <p:with-param name="elabDir" select="$elabDir"/>
+ </p:xslt>
+ 
+ <p:load name="ss3">
+  <p:with-option name="href" select="concat($elabDir,'/ascii.xsl')"/>
+ </p:load>
+</p:pipeline>