changeset 47:3e9a3e51627e

explicit form match working, but shared still needs work
author Henry S. Thompson <ht@markup.co.uk>
date Tue, 09 May 2017 23:08:18 +0100
parents 8dd54346bfd8
children 5d9806f90896
files merge.xsl notes.txt rect.xsl refs.xsl refs2.xsl
diffstat 5 files changed, 56 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/merge.xsl	Sun May 07 22:03:31 2017 +0100
+++ b/merge.xsl	Tue May 09 23:08:18 2017 +0100
@@ -7,8 +7,20 @@
  <xsl:include href="n2a.xsl"/> 
  
  <xsl:variable name="refs" select="collection()[2]/*"/>
+ <xsl:variable name="nfs">
+  <xsl:for-each select="$refs/e:nf">
+   <xsl:sort select="@n" order="descending" data-type="number"/>
+   <xsl:message><xsl:value-of select="@n"/>|<xsl:value-of select="position()"/>|<xsl:value-of select="text()"/></xsl:message>
+   <e:nf i="{position()}" n="{@n}"><xsl:value-of select="text()"/></e:nf>
+  </xsl:for-each>
+ </xsl:variable>
  
  <xsl:key name="ref" match="e:i" use="@r"/>
+ <xsl:key name="nf" match="e:nf" use="text()"/>
+ 
+ <xsl:template match="/"><a><xsl:copy-of select="$nfs"/>|<xsl:value-of select="count($refs/e:i)"/>|<xsl:value-of select="count($nfs/e:nf)"/>|<xsl:value-of select="count(key('nf','SUM(&#170;2&#170;7:&#170;3&#170;7)',$nfs))"/>|<xsl:value-of select="count($nfs/e:nf[.='SUM(&#170;2&#170;7:&#170;3&#170;7)'])"/>
+  <xsl:apply-templates/></a>
+ </xsl:template>
 
  <xsl:template match="e:r/e:c">
   <xsl:variable name="row" select="../@r"/>
@@ -17,9 +29,11 @@
   <c>
    <xsl:apply-templates select="@*"/>
    <xsl:if test="e:f">
-    <xsl:attribute name="f"></xsl:attribute>
+    <xsl:message><xsl:value-of select="e:f"/></xsl:message>
+    <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>
+   <xsl:apply-templates select="node()"/>
   </c>
  </xsl:template>
  
--- a/notes.txt	Sun May 07 22:03:31 2017 +0100
+++ b/notes.txt	Tue May 09 23:08:18 2017 +0100
@@ -102,7 +102,7 @@
  ??? Variables on l or r of ranges are just looked up: if they are complex
   no recursion is done: the _semantics_ of this case are not clear to
   me, need a real-life example... 
- @@ Variables whose value is itself a range are not being handled
+ Variables whose value is itself a range are not being handled FIXED
 -----------
 Switch to default namespace in order to reduce size and improve
 readability, and to elements instead of attributes DONE
@@ -188,5 +188,31 @@
     row ::= abs | rel
     abs ::= '\xAA' xs:positiveInteger
     rel ::= '\xAE' ( ( '-' xs:positiveInteger ) | xs:nonNegativeInteger )
-
-    
+-----------
+Picking colours to label regions, e.g. with similar formulae:
+  http://stackoverflow.com/questions/470690/how-to-automatically-generate-n-distinct-colors
+Start with just top-n, limited to 22 from Kelly
+    #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
+------------
+@@ string identify, to say nothing of actual value, is lost -- fix?
+@@ row/column/both spans
--- a/rect.xsl	Sun May 07 22:03:31 2017 +0100
+++ b/rect.xsl	Tue May 09 23:08:18 2017 +0100
@@ -35,9 +35,14 @@
           <xsl:if test="$c/@e:class"><xsl:attribute name="t"><xsl:value-of select="substring($c/@e:class,1,1)"/></xsl:attribute></xsl:if>
           <xsl:if test="$c/@e:code"><xsl:attribute name="l"><xsl:value-of select="$c/@e:code"/></xsl:attribute></xsl:if>
           <xsl:if test="$c/s:f">
+           <xsl:variable name="toks" select="e:tokenise($c/s:f,$row,$col)"/>
            <f>
-            <xsl:copy-of select="e:tokenise($c/s:f,$row,$col)"/>
-           </f></xsl:if>
+            <xsl:copy-of select="$toks"/>
+           </f>
+           <nf>
+            <xsl:copy-of select="e:fnf($toks)"/>
+           </nf>
+          </xsl:if>
           <xsl:value-of select="substring($c/@e:type,1,1)"/>         
         </xsl:if>
        </c>
--- a/refs.xsl	Sun May 07 22:03:31 2017 +0100
+++ b/refs.xsl	Tue May 09 23:08:18 2017 +0100
@@ -14,7 +14,7 @@
   <xsl:variable name="i" select="concat(e:n2a($c),$r)"/>
   <xsl:if test="@r='xxx' and @c='1'"><xsl:message><xsl:value-of select="count(e:f/*)"/>|</xsl:message>
   </xsl:if>
-  <nf r="{$i}"><xsl:value-of select="e:fnf(e:f/*)"/></nf>
+  <nf r="{$i}"><xsl:value-of select="e:nf/text()"/></nf>
   <xsl:if test="e:f[e:s|e:r]"><ref r="{$i}"><xsl:apply-templates select="e:f/(e:s|e:r)"/></ref></xsl:if>
  </xsl:template>
  
--- a/refs2.xsl	Sun May 07 22:03:31 2017 +0100
+++ b/refs2.xsl	Tue May 09 23:08:18 2017 +0100
@@ -32,10 +32,11 @@
      <r><xsl:value-of select="@r"/>&gt;</r>
     </xsl:for-each>
    </i>
-  </xsl:for-each>   
-  <xsl:for-each select="distinct-values(e:nf/text())">
-   <nf i="{position()}"><xsl:value-of select="."/></nf>
   </xsl:for-each>
+   <!-- We want to be able to sort by frequency, so just d-v isn't enough -->
+  <xsl:for-each-group select="e:nf" group-by="text()">
+   <nf i="{position()}" n="{count(current-group())}"><xsl:value-of select="current-group()[1]/text()"/></nf>
+  </xsl:for-each-group>
  </xsl:variable>
   <xsl:copy>
    <xsl:copy-of select="$invert"/>