comparison rect.xsl @ 19:9b1b169dc8db

use refs, but broken: doesn't deal with ranges (false negs) or external refs (false pos), and not finding things it should (e.g. kenneth_lay X88)
author Henry S. Thompson <ht@markup.co.uk>
date Tue, 04 Apr 2017 17:45:50 +0100
parents 2bbd067529b6
children 104ef815b0b0
comparison
equal deleted inserted replaced
18:16bba7a0d0bd 19:9b1b169dc8db
1 <?xml version='1.0'?> 1 <?xml version='1.0'?>
2 <!DOCTYPE doc SYSTEM "../../../lib/xml/xsl.dtd" > 2 <!DOCTYPE doc SYSTEM "../../../lib/xml/xsl.dtd" >
3 <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"> 3 <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">
4 <xsl:strip-space elements="s:sheetData"/> 4 <xsl:strip-space elements="s:sheetData"/>
5
6 <xsl:variable name="refs" select="collection()[2]/*"/>
7
8 <xsl:key name="ref" match="e:ref" use="@r"/>
5 9
6 <xsl:function name="e:a2n" as="xs:integer"> 10 <xsl:function name="e:a2n" as="xs:integer">
7 <!-- Convert an alphabetic excel column 'index' into a number, 11 <!-- Convert an alphabetic excel column 'index' into a number,
8 a sort of base 26 + 1, since 'A' is 1 and 'AA' is 27 --> 12 a sort of base 26 + 1, since 'A' is 1 and 'AA' is 27 -->
9 <xsl:param name="aa" as="xs:string"/> 13 <xsl:param name="aa" as="xs:string"/>
49 <xsl:if test="$cells/*"> 53 <xsl:if test="$cells/*">
50 <xsl:for-each select="(1 to $width)"> 54 <xsl:for-each select="(1 to $width)">
51 <xsl:variable name="col" select="."/> 55 <xsl:variable name="col" select="."/>
52 <xsl:variable name="r" select="concat(e:n2a($col),string($row))"/> 56 <xsl:variable name="r" select="concat(e:n2a($col),string($row))"/>
53 <xsl:variable name="c" select="$cells[@r=$r]"/> 57 <xsl:variable name="c" select="$cells[@r=$r]"/>
58 <xsl:variable name="reffed" select="key('ref',$r,$refs)"/>
54 <e:c c="{$col}"> 59 <e:c c="{$col}">
55 <xsl:if test="$c/s:f"><xsl:attribute name="f">1</xsl:attribute></xsl:if> 60 <xsl:if test="$c/s:f"><xsl:attribute name="f">1</xsl:attribute></xsl:if>
61 <xsl:if test="$reffed"><xsl:attribute name="r"><xsl:value-of select="$reffed/@c"/></xsl:attribute></xsl:if>
56 <xsl:if test="$c/*"><xsl:value-of select="substring($c/@e:type,1,1)"/></xsl:if> 62 <xsl:if test="$c/*"><xsl:value-of select="substring($c/@e:type,1,1)"/></xsl:if>
57 </e:c> 63 </e:c>
58 </xsl:for-each></xsl:if> 64 </xsl:for-each></xsl:if>
59 </e:r> 65 </e:r>
60 <xsl:text>&#10;</xsl:text></xsl:for-each> 66 <xsl:text>&#10;</xsl:text></xsl:for-each>