diff refs2.xsl @ 36:ae605b77d1e4

compute (but not use) master formula cells info, extend refs collection to include abs/reloc info
author Henry S. Thompson <ht@markup.co.uk>
date Tue, 25 Apr 2017 12:24:31 +0100
parents
children ac6d1ca099f7
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/refs2.xsl	Tue Apr 25 12:24:31 2017 +0100
@@ -0,0 +1,33 @@
+<?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:xs="http://www.w3.org/2001/XMLSchema" xmlns:e="http://markup.co.uk/excel" exclude-result-prefixes="xs e" xmlns="http://markup.co.uk/excel">
+ <!-- Invert the singleton references extracted from formulae by refs.xsl 
+      Input e:refs/e:ref/e:s  e:ref[@c] contains one or more e:s
+                                        for each singleton reference
+                                        to e:s/@r in c's formula
+      Output e:refs/e:i/e:r e:i[@r] contains one e:r for each cell which
+                                     references r -->
+ 
+ <xsl:include href="n2a.xsl"/>
+ <xsl:include href="a2n.xsl"/>
+ 
+ <xsl:key name="ref" match="e:ref" use="for $s in e:s return translate($s/@r,'$','')"/>
+ 
+ <xsl:template match="e:refs">
+  <xsl:variable name="refs" select="."/>
+  <xsl:variable name="invert">
+  <xsl:for-each select="distinct-values(
+                        for $s in e:ref/e:s return translate($s/@r,'$',''))">
+   <xsl:variable name="r" select="."/>
+   <i r="{$r}">
+    <xsl:for-each select="key('ref',$r,$refs)">
+     <r><xsl:value-of select="@c"/></r>
+    </xsl:for-each>
+   </i>
+  </xsl:for-each>
+ </xsl:variable>
+  <xsl:copy>
+   <xsl:copy-of select="$invert"/>
+  </xsl:copy>
+ </xsl:template>
+</xsl:stylesheet>