diff n2a.xsl @ 34:93fd0d532754

fix bug in refs wrt e.g. [1]!.SGX, adapt html and ascii to new-format refs, move a2n and n2a into separate files for re-use
author Henry S. Thompson <ht@markup.co.uk>
date Wed, 12 Apr 2017 21:35:04 +0100
parents
children 5469a32795da
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/n2a.xsl	Wed Apr 12 21:35:04 2017 +0100
@@ -0,0 +1,19 @@
+<?xml version='1.0'?>
+<!DOCTYPE xsl:stylesheet SYSTEM "file:///C:/C64/home/ht/lib/xml/xsl.dtd" >
+<xsl:stylesheet xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:e="http://markup.co.uk/excel" version="3.0">
+ <xsl:variable name="codeBase" select="string-to-codepoints('A')-1"/>
+ 
+ <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:stylesheet>