diff shared.xsl @ 48:5d9806f90896

basic integration of shared, but copying <f> is wrong, should reconstruct by denormalising <nf> for new home
author Henry S. Thompson <ht@markup.co.uk>
date Wed, 10 May 2017 16:52:04 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/shared.xsl	Wed May 10 16:52:04 2017 +0100
@@ -0,0 +1,21 @@
+<?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 e xf" xmlns="http://markup.co.uk/excel" xmlns:xf="http://www.w3.org/2005/xpath-functions">
+ 
+ <xsl:template match="/">
+  <masters><xsl:apply-templates select="/s:worksheet/s:sheetData"/></masters>
+ </xsl:template>
+ 
+ <xsl:template match="s:sheetData">
+  <xsl:variable select="s:row/s:c/s:f[@si]" name="sfs"/>
+  <xsl:variable name="indices" select="distinct-values(for $sf in $sfs/@si return string($sf))">
+   <!-- s:f/@si values -->
+  </xsl:variable>
+  
+  <xsl:for-each select="$indices">
+   <xsl:variable name="i" select="."/>
+   <xsl:variable name="sf" select="($sfs[@si=$i])[1]"/>
+   <master si="{$i}" r="{$sf/../@r}"><xsl:value-of select="$sf"/></master>
+  </xsl:for-each>
+ </xsl:template>
+</xsl:stylesheet>