annotate format.xsl @ 5:106bf970a867

builtin fmt and locally-defined fmtCode
author Henry S. Thompson <ht@markup.co.uk>
date Sat, 01 Apr 2017 23:50:20 +0800
parents fe3fc6b2d890
children d6dae580f6a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
2c115aefde6b beginning work on elaboration of worksheets
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
1 <?xml version='1.0'?>
2c115aefde6b beginning work on elaboration of worksheets
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
2 <!DOCTYPE doc SYSTEM "../../../lib/xml/xsl.dtd" >
5
106bf970a867 builtin fmt and locally-defined fmtCode
Henry S. Thompson <ht@markup.co.uk>
parents: 4
diff changeset
3 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.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" xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
4
fe3fc6b2d890 1st level of format type lookup
Henry S. Thompson <ht@markup.co.uk>
parents: 3
diff changeset
4 <xsl:param name="elabDir"/>
3
2c115aefde6b beginning work on elaboration of worksheets
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
5 <xsl:variable name="xldir" select="replace(base-uri(),'/[^/]*/[^/]*$','')"/>
5
106bf970a867 builtin fmt and locally-defined fmtCode
Henry S. Thompson <ht@markup.co.uk>
parents: 4
diff changeset
6 <xsl:variable name="fmts" select="document(concat($elabDir,'/fmt.xml'))/fmts/fmt"/>
106bf970a867 builtin fmt and locally-defined fmtCode
Henry S. Thompson <ht@markup.co.uk>
parents: 4
diff changeset
7 <xsl:variable name="styles" select="document(concat($xldir,'/styles.xml'))/*"/>
4
fe3fc6b2d890 1st level of format type lookup
Henry S. Thompson <ht@markup.co.uk>
parents: 3
diff changeset
8 <xsl:variable name="xfs" select="$styles//s:cellXfs/s:xf"/>
5
106bf970a867 builtin fmt and locally-defined fmtCode
Henry S. Thompson <ht@markup.co.uk>
parents: 4
diff changeset
9 <xsl:variable name="nfs" select="$styles//s:numFmts/s:numFmt"/>
106bf970a867 builtin fmt and locally-defined fmtCode
Henry S. Thompson <ht@markup.co.uk>
parents: 4
diff changeset
10 <xsl:template match="s:worksheet">
106bf970a867 builtin fmt and locally-defined fmtCode
Henry S. Thompson <ht@markup.co.uk>
parents: 4
diff changeset
11 <worksheet xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"><xsl:apply-templates select="@*|node()"/></worksheet>
106bf970a867 builtin fmt and locally-defined fmtCode
Henry S. Thompson <ht@markup.co.uk>
parents: 4
diff changeset
12 </xsl:template>
4
fe3fc6b2d890 1st level of format type lookup
Henry S. Thompson <ht@markup.co.uk>
parents: 3
diff changeset
13 <xsl:template match="s:c">
fe3fc6b2d890 1st level of format type lookup
Henry S. Thompson <ht@markup.co.uk>
parents: 3
diff changeset
14 <xsl:if test="@s">
5
106bf970a867 builtin fmt and locally-defined fmtCode
Henry S. Thompson <ht@markup.co.uk>
parents: 4
diff changeset
15 <xsl:variable name="i" select="number(@s)"/>
106bf970a867 builtin fmt and locally-defined fmtCode
Henry S. Thompson <ht@markup.co.uk>
parents: 4
diff changeset
16 <xsl:variable name="nfi" select="$xfs[position()-1=$i]/@numFmtId"/>
106bf970a867 builtin fmt and locally-defined fmtCode
Henry S. Thompson <ht@markup.co.uk>
parents: 4
diff changeset
17 <xsl:variable name="builtin" select="$fmts[@i=$nfi]"/>
106bf970a867 builtin fmt and locally-defined fmtCode
Henry S. Thompson <ht@markup.co.uk>
parents: 4
diff changeset
18 <xsl:variable name="biClass" select="$builtin/@class"/>
106bf970a867 builtin fmt and locally-defined fmtCode
Henry S. Thompson <ht@markup.co.uk>
parents: 4
diff changeset
19 <c>
106bf970a867 builtin fmt and locally-defined fmtCode
Henry S. Thompson <ht@markup.co.uk>
parents: 4
diff changeset
20 <xsl:choose>
106bf970a867 builtin fmt and locally-defined fmtCode
Henry S. Thompson <ht@markup.co.uk>
parents: 4
diff changeset
21 <xsl:when test="$biClass">
106bf970a867 builtin fmt and locally-defined fmtCode
Henry S. Thompson <ht@markup.co.uk>
parents: 4
diff changeset
22 <xsl:attribute namespace="http://markup.co.uk/excel" name="class">
106bf970a867 builtin fmt and locally-defined fmtCode
Henry S. Thompson <ht@markup.co.uk>
parents: 4
diff changeset
23 <xsl:value-of select="$biClass"/>
106bf970a867 builtin fmt and locally-defined fmtCode
Henry S. Thompson <ht@markup.co.uk>
parents: 4
diff changeset
24 </xsl:attribute>
106bf970a867 builtin fmt and locally-defined fmtCode
Henry S. Thompson <ht@markup.co.uk>
parents: 4
diff changeset
25 </xsl:when>
106bf970a867 builtin fmt and locally-defined fmtCode
Henry S. Thompson <ht@markup.co.uk>
parents: 4
diff changeset
26 <xsl:when test="$nfs[@numFmtId=$nfi]">
106bf970a867 builtin fmt and locally-defined fmtCode
Henry S. Thompson <ht@markup.co.uk>
parents: 4
diff changeset
27 <xsl:attribute namespace="http://markup.co.uk/excel" name="code">
106bf970a867 builtin fmt and locally-defined fmtCode
Henry S. Thompson <ht@markup.co.uk>
parents: 4
diff changeset
28 <xsl:value-of select="$nfs[@numFmtId=$nfi]/@formatCode"/>
106bf970a867 builtin fmt and locally-defined fmtCode
Henry S. Thompson <ht@markup.co.uk>
parents: 4
diff changeset
29 </xsl:attribute>
106bf970a867 builtin fmt and locally-defined fmtCode
Henry S. Thompson <ht@markup.co.uk>
parents: 4
diff changeset
30 </xsl:when>
106bf970a867 builtin fmt and locally-defined fmtCode
Henry S. Thompson <ht@markup.co.uk>
parents: 4
diff changeset
31 </xsl:choose>
4
fe3fc6b2d890 1st level of format type lookup
Henry S. Thompson <ht@markup.co.uk>
parents: 3
diff changeset
32 <xsl:for-each select="@*"><xsl:copy/></xsl:for-each>
fe3fc6b2d890 1st level of format type lookup
Henry S. Thompson <ht@markup.co.uk>
parents: 3
diff changeset
33 <xsl:apply-templates/>
5
106bf970a867 builtin fmt and locally-defined fmtCode
Henry S. Thompson <ht@markup.co.uk>
parents: 4
diff changeset
34 </c>
4
fe3fc6b2d890 1st level of format type lookup
Henry S. Thompson <ht@markup.co.uk>
parents: 3
diff changeset
35 </xsl:if>
3
2c115aefde6b beginning work on elaboration of worksheets
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
36 </xsl:template>
5
106bf970a867 builtin fmt and locally-defined fmtCode
Henry S. Thompson <ht@markup.co.uk>
parents: 4
diff changeset
37 <xsl:template match="@*|node()"><xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy>
106bf970a867 builtin fmt and locally-defined fmtCode
Henry S. Thompson <ht@markup.co.uk>
parents: 4
diff changeset
38 </xsl:template>
3
2c115aefde6b beginning work on elaboration of worksheets
Henry S. Thompson <ht@markup.co.uk>
parents:
diff changeset
39 </xsl:stylesheet>