view merge.xsl @ 45:6ed900e8cc61

towards comparable formulae
author Henry S. Thompson <ht@markup.co.uk>
date Sun, 07 May 2017 19:21:53 +0100
parents 6f448ac67778
children 3e9a3e51627e
line wrap: on
line source

<?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 e s xpf" xmlns="http://markup.co.uk/excel" xmlns:xpf="http://www.w3.org/2005/xpath-functions">
 <xsl:strip-space elements="s:sheetData"/>
 
 <xsl:include href="a2n.xsl"/>
 <xsl:include href="n2a.xsl"/> 
 
 <xsl:variable name="refs" select="collection()[2]/*"/>
 
 <xsl:key name="ref" match="e:i" use="@r"/>

 <xsl:template match="e:r/e:c">
  <xsl:variable name="row" select="../@r"/>
  <xsl:variable name="col" select="@c"/>
  <xsl:variable name="reffed" select="key('ref',concat(e:n2a($col),$row),$refs)"/>
  <c>
   <xsl:apply-templates select="@*"/>
   <xsl:if test="e:f">
    <xsl:attribute name="f"></xsl:attribute>
   </xsl:if>
  <xsl:if test="$reffed"><xsl:copy-of select="$reffed"/></xsl:if>
  </c>
 </xsl:template>
 
 <xsl:template match="@*|node()"><xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy>
 </xsl:template>
</xsl:stylesheet>