Mercurial > hg > ooxml
changeset 10:01e80c7a9575
simple ascii type matrix output working
author | Henry S. Thompson <ht@markup.co.uk> |
---|---|
date | Mon, 03 Apr 2017 12:31:58 +0100 |
parents | 5f2d691014ff |
children | 480454d218f7 |
files | ascii.xpl ascii.xsl notes.txt |
diffstat | 3 files changed, 25 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/ascii.xpl Sun Apr 02 23:45:02 2017 +0800 +++ b/ascii.xpl Mon Apr 03 12:31:58 2017 +0100 @@ -31,9 +31,9 @@ <p:with-option name="href" select="concat($elabDir,'/ascii.xsl')"/> </p:load> - <p:xslt name="ascii"> + <p:xslt name="asc"> <p:input port="source"> - <p:pipe step="format" port="source"/> + <p:pipe step="format" port="result"/> </p:input> <p:input port="stylesheet"> <p:pipe step="ss2" port="result"/>
--- a/ascii.xsl Sun Apr 02 23:45:02 2017 +0800 +++ b/ascii.xsl Mon Apr 03 12:31:58 2017 +0100 @@ -1,8 +1,6 @@ <?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:variable name="dim" select="//s:dimension/@ref"/> - <xsl:variable name="codeBase" select="string-to-codepoints('A')-1"/> <xsl:function name="e:a2n" as="xs:integer"> <!-- Convert an alphabetic excel column 'index' into a number, @@ -27,13 +25,29 @@ <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="width" select="1+number($dims//xpf:group[@nr='4'])-number($dims//xpf:group[@nr='2'])"/> - <xsl:message><xsl:value-of select="$width"/>|<xsl:value-of select="1+e:a2n($dims//xpf:group[@nr='3'])-e:a2n($dims//xpf:group[@nr='1'])"/>|<xsl:value-of select="e:a2n('AA')"/></xsl:message> - <xsl:message><xsl:value-of select="e:n2a(1)"/>|<xsl:value-of select="e:n2a(26)"/>|<xsl:value-of select="e:n2a(27)"/>|<xsl:value-of select="e:n2a(52)"/>|<xsl:value-of select="e:n2a(54)"/></xsl:message> + <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="."/> + <a> + <xsl:text> </xsl:text> + <xsl:for-each select="(1 to $height)"> + <xsl:variable name="row" select="."/> + <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]"></xsl:variable> + <xsl:value-of select="if (count($c)=1) then substring($c/@e:type,1,1) else ' '"/> + </xsl:for-each> + <xsl:text> </xsl:text> + </xsl:for-each></a> </xsl:if> </xsl:template> </xsl:stylesheet>
--- a/notes.txt Sun Apr 02 23:45:02 2017 +0800 +++ b/notes.txt Mon Apr 03 12:31:58 2017 +0100 @@ -35,3 +35,6 @@ children of <cellXfs> in styles.xml, and bin is a built-in date format code, see 18.8.30 numFmt (Number Format) in ISO/IEC 29500-1:2016(E) == C071691e.pdf +--------- +Decided to distinguish between type (num, date, str, err, ...) and +class (cur, others to come?). If non-standard code, just record that.