This repository has been archived by the owner on Nov 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.xsl
74 lines (67 loc) · 2.49 KB
/
test.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sfa="http://developer.apple.com/namespaces/sfa" xmlns:sf="http://developer.apple.com/namespaces/sf"
>
<xsl:template match="/">
<html>
<head>
<style>
<xsl:for-each select="//sf:paragraphstyle">
<xsl:if test="@sf:ident!=''">
.<xsl:value-of select="@sf:ident"/> {
<xsl:if test='./sf:property-map/sf:fontName/sf:string'>font-family: "<xsl:value-of select="./sf:property-map/sf:fontName/sf:string/@sfa:string"/>";
</xsl:if>
<xsl:if test='./sf:property-map/sf:fontSize/sf:number'>font-size: <xsl:value-of select="./sf:property-map/sf:fontSize/sf:number/@sfa:number"/>px;
</xsl:if>
<xsl:if test='./sf:property-map/sf:fontColor/sf:color'>color: rgb(<xsl:value-of select="./sf:property-map/sf:fontColor/sf:color/@sfa:r"/>,<xsl:value-of select="./sf:property-map/sf:fontColor/sf:color/@sfa:g"/>,<xsl:value-of select="./sf:property-map/sf:fontColor/sf:color/@sfa:b"/>);
</xsl:if>
<xsl:if test='./sf:property-map/sf:italic/sf:number'>font-style:italic;
</xsl:if>
<xsl:if test='./sf:property-map/sf:bold/sf:number'>font-weight:bold;
</xsl:if>}
</xsl:if>
</xsl:for-each>
</style>
</head>
<body>
<xsl:for-each select="//sf:p">
<p><xsl:attribute name="class"><xsl:value-of select="@sf:style"/></xsl:attribute>
<xsl:for-each select="child::node()">
<xsl:choose>
<xsl:when test="name()='sf:toc-bookmark'">
<a><xsl:attribute name="id"><xsl:value-of select="@sf:name"/></xsl:attribute></a>
</xsl:when>
<xsl:when test="name()='sf:br'">
<br/>
</xsl:when>
<xsl:when test="name()='sf:lnbr'">
<br/>
</xsl:when>
<xsl:when test="name()='sf:span'">
<span><xsl:attribute name="class"><xsl:value-of select="@sf:style"/></xsl:attribute><xsl:value-of select="."/></span>
</xsl:when>
<xsl:when test="name()='sf:link'">
<a><xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute><xsl:value-of select="."/></a>
</xsl:when>
<xsl:when test="name()='sf:page-start'">
<!-- ignore -->
</xsl:when>
<xsl:when test="name()='sf:container-hint'">
<!-- ignore -->
</xsl:when>
<xsl:when test="name()='sf:toc-pagenum'">
<a><xsl:attribute name="href">#<xsl:value-of select="@sf:bookmark"/></xsl:attribute><xsl:value-of select="@sf:value"/></a>
</xsl:when>
<xsl:otherwise>
<strong>!!!<xsl:value-of select="name()"/>!!!</strong>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</p>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>