Mercurial > hg > ooxml
view n2a.xsl @ 48:5d9806f90896
basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
author | Henry S. Thompson <ht@markup.co.uk> |
---|---|
date | Wed, 10 May 2017 16:52:04 +0100 |
parents | 6ed900e8cc61 |
children | d3569a8cbf7a |
line wrap: on
line source
<?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 < 27) then $least else (e:n2aa(($n - 1) 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:function name="e:crnf" as="xs:string"> <!-- compute CR-normal-form of a singleton reference --> <xsl:param name="s" as="element(e:s)"/> <xsl:value-of select="concat(e:snf(($s/*)[1]),e:snf(($s/*)[2]))"/> </xsl:function> <xsl:function name="e:snf" as="xs:string"> <xsl:param name="s" as="element(*)"/><!-- either a(bsolute) or r(elative)--> <xsl:value-of select="if (local-name($s)='a') then concat('ª',$s) else concat('º',$s/@d)"/> </xsl:function> <xsl:function name="e:rnf" as="xs:string"> <!-- CRNF for a range or singleton reference --> <xsl:param name="b" as="element(*)"/> <xsl:value-of select="if (local-name($b)='s') then e:crnf($b) else if (local-name($b)='r') then let $l := ($b/e:s)[1], $r := ($b/e:s)[2] return concat(e:crnf($l), ':', e:crnf($r)) else if (local-name($b)='v') then $b/text() else e:shouldnt()"/> </xsl:function> <xsl:function name="e:fnf" as="xs:string"> <!-- rebuild a formula from its parts, but using CRNF for all references --> <xsl:param name="bits" as="element(*)*"/> <xsl:value-of select="string-join( for $b in $bits return if (local-name($b)=('s','r')) then e:rnf($b) else if (local-name($b)='e') then concat($b/@x,'!',e:rnf($b/*)) else $b/text())"/> </xsl:function> <xsl:function name="e:shouldnt"> <xsl:message terminate="yes">shouldn't happen</xsl:message> </xsl:function> </xsl:stylesheet>