Mercurial > hg > ooxml
comparison 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 |
comparison
equal
deleted
inserted
replaced
4:fe3fc6b2d890 | 5:106bf970a867 |
---|---|
1 <?xml version='1.0'?> | 1 <?xml version='1.0'?> |
2 <!DOCTYPE doc SYSTEM "../../../lib/xml/xsl.dtd" > | 2 <!DOCTYPE doc SYSTEM "../../../lib/xml/xsl.dtd" > |
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"> | 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 <xsl:param name="elabDir"/> | 4 <xsl:param name="elabDir"/> |
5 <xsl:variable name="xldir" select="replace(base-uri(),'/[^/]*/[^/]*$','')"/> | 5 <xsl:variable name="xldir" select="replace(base-uri(),'/[^/]*/[^/]*$','')"/> |
6 <xsl:variable name="fmts" select="document($elabDir/fmt.xml)/fmts/fmt"/> | 6 <xsl:variable name="fmts" select="document(concat($elabDir,'/fmt.xml'))/fmts/fmt"/> |
7 <xsl:variable name="styles" select="document(concat($xldir,'/styles.xml'))/*"></xsl:variable> | 7 <xsl:variable name="styles" select="document(concat($xldir,'/styles.xml'))/*"/> |
8 <xsl:variable name="xfs" select="$styles//s:cellXfs/s:xf"/> | 8 <xsl:variable name="xfs" select="$styles//s:cellXfs/s:xf"/> |
9 <xsl:variable name="nfs" select="$styles//s:numFmts/s:numFmt"/> | |
10 <xsl:template match="s:worksheet"> | |
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> | |
12 </xsl:template> | |
9 <xsl:template match="s:c"> | 13 <xsl:template match="s:c"> |
10 <xsl:if test="@s"> | 14 <xsl:if test="@s"> |
11 <s:c e:type="{$xfs[position()=current()/@s]/@numFmtId}"> | 15 <xsl:variable name="i" select="number(@s)"/> |
16 <xsl:variable name="nfi" select="$xfs[position()-1=$i]/@numFmtId"/> | |
17 <xsl:variable name="builtin" select="$fmts[@i=$nfi]"/> | |
18 <xsl:variable name="biClass" select="$builtin/@class"/> | |
19 <c> | |
20 <xsl:choose> | |
21 <xsl:when test="$biClass"> | |
22 <xsl:attribute namespace="http://markup.co.uk/excel" name="class"> | |
23 <xsl:value-of select="$biClass"/> | |
24 </xsl:attribute> | |
25 </xsl:when> | |
26 <xsl:when test="$nfs[@numFmtId=$nfi]"> | |
27 <xsl:attribute namespace="http://markup.co.uk/excel" name="code"> | |
28 <xsl:value-of select="$nfs[@numFmtId=$nfi]/@formatCode"/> | |
29 </xsl:attribute> | |
30 </xsl:when> | |
31 </xsl:choose> | |
12 <xsl:for-each select="@*"><xsl:copy/></xsl:for-each> | 32 <xsl:for-each select="@*"><xsl:copy/></xsl:for-each> |
13 <xsl:apply-templates/> | 33 <xsl:apply-templates/> |
14 </s:c> | 34 </c> |
15 </xsl:if> | 35 </xsl:if> |
16 </xsl:template> | 36 </xsl:template> |
37 <xsl:template match="@*|node()"><xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy> | |
38 </xsl:template> | |
17 </xsl:stylesheet> | 39 </xsl:stylesheet> |