Mercurial > hg > ooxml
changeset 49:d3569a8cbf7a
shared refs rebuilt correctly
author | Henry S. Thompson <ht@markup.co.uk> |
---|---|
date | Wed, 10 May 2017 20:13:06 +0100 |
parents | 5d9806f90896 |
children | 01a7c2ebd3d1 |
files | n2a.xsl notes.txt rect.xsl |
diffstat | 3 files changed, 57 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/n2a.xsl Wed May 10 16:52:04 2017 +0100 +++ b/n2a.xsl Wed May 10 20:13:06 2017 +0100 @@ -57,6 +57,54 @@ else $b/text())"/> </xsl:function> + <xsl:template name="shift"> + <xsl:param name="row" as="xs:integer"/> + <xsl:param name="col" as="xs:integer"/> + <!-- Reconstruct a shifted version of an analysed formula, relative to a new position --> + <xsl:copy> + <xsl:apply-templates select="@*"/> + <xsl:apply-templates select="*" mode="shift"> + <xsl:with-param name="row" select="$row"/> + <xsl:with-param name="col" select="$col"/> + </xsl:apply-templates> + </xsl:copy> + </xsl:template> + + <xsl:template match="e:s" mode="shift"> + <xsl:param name="row" as="xs:integer"/> + <xsl:param name="col" as="xs:integer"/> + <xsl:copy> + <xsl:attribute name="r"> + <xsl:value-of select="concat(e:n2a(e:delta(*[1],$col)), + e:delta(*[2],$row))"/> + </xsl:attribute> + <xsl:apply-templates select="node()" mode="shift"> + <xsl:with-param name="row" select="$row"/> + <xsl:with-param name="col" select="$col"/> + </xsl:apply-templates> + </xsl:copy> + </xsl:template> + + <xsl:function name="e:delta" as="xs:integer"> + <xsl:param name="c" as="element(*)"/> + <xsl:param name="h" as="xs:integer"/> + <xsl:value-of select="if (local-name($c)='a') then xs:integer($c/text()) + else if (local-name($c)='r') + then xs:integer($c/@d)+$h + else e:shouldnt()"/> + </xsl:function> + + <xsl:template match="e:*|@*" mode="shift"> + <xsl:param name="row" as="xs:integer"/> + <xsl:param name="col" as="xs:integer"/> + <xsl:copy> + <xsl:apply-templates select="node()|@*" mode="shift"> + <xsl:with-param name="row" select="$row"/> + <xsl:with-param name="col" select="$col"/> + </xsl:apply-templates> + </xsl:copy> + </xsl:template> + <xsl:function name="e:shouldnt"> <xsl:message terminate="yes">shouldn't happen</xsl:message> </xsl:function>
--- a/notes.txt Wed May 10 16:52:04 2017 +0100 +++ b/notes.txt Wed May 10 20:13:06 2017 +0100 @@ -190,9 +190,11 @@ rel ::= '\xAE' ( ( '-' xs:positiveInteger ) | xs:nonNegativeInteger ) ----------- Would <c c=COL [fi= [si=]]> be sufficient? - fi an index into _all_ functions, si original index into explicitly + @@ fi an index into _all_ functions, si original index into explicitly shared functions Brute force for now -- rect sees shared table, computes CRNF + Not good enough -- <f> in shared table can't be used as is, need to + rebuild ref names relative to each new home. FIXED ----------- Picking colours to label regions, e.g. with similar formulae: http://stackoverflow.com/questions/470690/how-to-automatically-generate-n-distinct-colors
--- a/rect.xsl Wed May 10 16:52:04 2017 +0100 +++ b/rect.xsl Wed May 10 20:13:06 2017 +0100 @@ -69,7 +69,12 @@ <xsl:sequence select="e:analyse($c/s:f/text(),$row,$col)"/> </xsl:when> <xsl:when test="$c/s:f/@si"> - <xsl:copy-of select="key('shared',$si,$shared)/*"/> + <xsl:variable name="s" select="key('shared',$si,$shared)"/> + <xsl:for-each select="$s/e:f"><xsl:call-template name="shift"> + <xsl:with-param name="row" select="$row"/> + <xsl:with-param name="col" select="$col"/> + </xsl:call-template></xsl:for-each> + <xsl:copy-of select="$s/e:nf"/> </xsl:when> </xsl:choose> <xsl:value-of select="substring($c/@e:type,1,1)"/>