Mercurial > hg > ooxml
diff 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 |
line wrap: on
line diff
--- a/rect.xsl Tue Apr 04 16:20:46 2017 +0100 +++ b/rect.xsl Tue Apr 04 17:45:50 2017 +0100 @@ -3,6 +3,10 @@ <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:strip-space elements="s:sheetData"/> + <xsl:variable name="refs" select="collection()[2]/*"/> + + <xsl:key name="ref" match="e:ref" use="@r"/> + <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 --> @@ -51,8 +55,10 @@ <xsl:variable name="col" select="."/> <xsl:variable name="r" select="concat(e:n2a($col),string($row))"/> <xsl:variable name="c" select="$cells[@r=$r]"/> + <xsl:variable name="reffed" select="key('ref',$r,$refs)"/> <e:c c="{$col}"> <xsl:if test="$c/s:f"><xsl:attribute name="f">1</xsl:attribute></xsl:if> + <xsl:if test="$reffed"><xsl:attribute name="r"><xsl:value-of select="$reffed/@c"/></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></xsl:if>