changeset 59:f90bbd38b8f6

towards display of reffed info via colour
author Henry S. Thompson <ht@markup.co.uk>
date Fri, 02 Jun 2017 12:54:54 +0100
parents adeb9575b273
children 588cb9ba7c9c
files backref.xsl html.xsl merge.xsl
diffstat 3 files changed, 65 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/backref.xsl	Fri Jun 02 12:54:54 2017 +0100
@@ -0,0 +1,24 @@
+<?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 xpf e" xmlns="http://www.w3.org/1999/xhtml" xmlns:xpf="http://www.w3.org/2005/xpath-functions">
+ 
+ <xsl:import href="n2a.xsl"/>
+  
+ <xsl:key name="fcell" match="e:c[@fi]" use="@r"/>
+
+ <xsl:template match="e:i">
+  <xsl:variable name="row" select="../../@r"/>
+  <xsl:variable name="col" select="../@c"/>
+  <xsl:variable name="r" select="concat(e:n2a($col),$row)"/>
+  <xsl:variable name="ris" select="for $r in e:r/text()
+                                    return key('fcell',$r)/@fi"/>
+  <xsl:copy>
+   <xsl:attribute name="ri"><xsl:value-of select="string-join($ris,',')"/></xsl:attribute>
+   <xsl:apply-templates select="node()|@*"/>
+  </xsl:copy>
+ </xsl:template>
+ 
+ <xsl:template match="@*|node()"><xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy>
+ </xsl:template>
+ 
+</xsl:stylesheet>
--- a/html.xsl	Thu Jun 01 17:21:45 2017 +0100
+++ b/html.xsl	Fri Jun 02 12:54:54 2017 +0100
@@ -5,6 +5,31 @@
  <xsl:output omit-xml-declaration="yes"/>
  
  <xsl:include href="n2a.xsl"/>
+ 
+ <xsl:variable name="colours" select="(
+      '#FFB300', /* Vivid Yellow */
+      '#803E75', /* Strong Purple */
+      '#FF6800', /* Vivid Orange */
+      '#A6BDD7', /* Very Light Blue */
+      '#C10020', /* Vivid Red */
+      '#CEA262', /* Grayish Yellow */
+      '#817066', /* Medium Gray */
+      /* The following don't work well for people with defective color vision */
+      '#007D34', /* Vivid Green */
+      '#F6768E', /* Strong Purplish Pink */
+      '#00538A', /* Strong Blue */
+      '#FF7A5C', /* Strong Yellowish Pink */
+      '#53377A', /* Strong Violet */
+      '#FF8E00', /* Vivid Orange Yellow */
+      '#B32851', /* Strong Purplish Red */
+      '#F4C800', /* Vivid Greenish Yellow */
+      '#7F180D', /* Strong Reddish Brown */
+      '#93AA00', /* Vivid Yellowish Green */
+      '#593315', /* Deep Yellowish Brown */
+      '#F13A13', /* Vivid Reddish Orange */
+      '#232C16'  /* Dark Olive Green */)"><xsl:comment>From http://stackoverflow.com/questions/470690/how-to-automatically-generate-n-distinct-colors</xsl:comment></xsl:variable>
+ <xsl:variable name="nColours" select="count($colours)"/>
+ <xsl:variable name="colourClassStyles" select="for $c in colours, $i in (1 to $nColours) return concat('.c',$i,' {background-color: ',$c,'}')"/>
 
  <xsl:template match="/">
   <html>
@@ -18,29 +43,8 @@
        .reffed {border: solid 1px black}
        table {table-layout: fixed}
        th {width: 1en}
-      /* http://stackoverflow.com/questions/470690/how-to-automatically-generate-n-distinct-colors */
-      .c1 {background-color: #FFB300} /* Vivid Yellow */
-      .c2 {background-color: #803E75} /* Strong Purple */
-      .c3 {background-color: #FF6800} /* Vivid Orange */
-      .c4 {background-color: #A6BDD7} /* Very Light Blue */
-      .c5 {background-color: #C10020} /* Vivid Red */
-      .c6 {background-color: #CEA262} /* Grayish Yellow */
-      .c7 {background-color: #817066} /* Medium Gray */
-      /* The following don't work well for people with defective color vision */
-      .c8 {background-color: #007D34} /* Vivid Green */
-      .c9 {background-color: #F6768E} /* Strong Purplish Pink */
-      .c10 {background-color: #00538A} /* Strong Blue */
-      .c11 {background-color: #FF7A5C} /* Strong Yellowish Pink */
-      .c12 {background-color: #53377A} /* Strong Violet */
-      .c13 {background-color: #FF8E00} /* Vivid Orange Yellow */
-      .c14 {background-color: #B32851} /* Strong Purplish Red */
-      .c15 {background-color: #F4C800} /* Vivid Greenish Yellow */
-      .c16 {background-color: #7F180D} /* Strong Reddish Brown */
-      .c17 {background-color: #93AA00} /* Vivid Yellowish Green */
-      .c18 {background-color: #593315} /* Deep Yellowish Brown */
-      .c19 {background-color: #F13A13} /* Vivid Reddish Orange */
-      .c20 {background-color: #232C16} /* Dark Olive Green */
     </style>
+    <style><xsl:value-of select="string-join($colourClassStyles,'&#10;       "/></style>
    </head>
    <body>
     <xsl:apply-templates/>
@@ -74,7 +78,7 @@
      <xsl:attribute name="class">
       <xsl:value-of select="(if (@t) then @t else text(),
                              if (e:f) then 'formula' else (),
-                             if (e:i) then 'reffed' else (),
+                             if (e:i) then e:rf(e:i/@ri) else (),
                              if (@fi) then concat('c',@fi) else ())"/>
      </xsl:attribute>
      <xsl:attribute name="title">
@@ -92,4 +96,15 @@
    </xsl:choose>
    </td>
  </xsl:template>
+ 
+ <xsl:variable name="borders" select="('left','right','top','bottom')"/>
+ 
+ <xsl:function name="e:rf" as="xs:string">
+  <xsl:param name="ris" as="attribute(ri)*"/>
+  <xsl:value-of select="let $ff := (for $ri in split($ris,',')
+                                return if ($ri le $nColours) then $ri else ())
+                          return if $ff
+                           then concat('.b',string-join($ff,'b'))
+                           else 'reffed'"/>
+ </xsl:function>
 </xsl:stylesheet>
--- a/merge.xsl	Thu Jun 01 17:21:45 2017 +0100
+++ b/merge.xsl	Fri Jun 02 12:54:54 2017 +0100
@@ -25,10 +25,12 @@
  <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)"/>
+  <xsl:variable name="r" select="concat(e:n2a($col),$row)"/>
+  <xsl:variable name="reffed" select="key('ref',$r,$refs)"/>
   <c>
    <xsl:apply-templates select="@*"/>
    <xsl:if test="e:f">
+    <xsl:attribute name="r"><xsl:value-of select="$r"/></xsl:attribute>
     <xsl:attribute name="fi"><xsl:value-of select="key('nf',e:nf/text(),$nfs)/@i"/></xsl:attribute>
    </xsl:if>
   <xsl:if test="$reffed"><xsl:copy-of select="$reffed"/></xsl:if>