1 | <?xml version="1.0"?> |
---|
2 | <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
---|
3 | xmlns:xslo="http://www.w3.org/1999/XSL/TransformAlias" |
---|
4 | xmlns:fo="http://www.w3.org/1999/XSL/Format" |
---|
5 | exclude-result-prefixes="fo" |
---|
6 | version="1.0"> |
---|
7 | |
---|
8 | <xsl:include href="../lib/lib.xsl"/> |
---|
9 | |
---|
10 | <xsl:output method="xml" encoding="US-ASCII"/> |
---|
11 | |
---|
12 | <xsl:namespace-alias stylesheet-prefix="xslo" result-prefix="xsl"/> |
---|
13 | |
---|
14 | <xsl:preserve-space elements="*"/> |
---|
15 | |
---|
16 | <xsl:template match="/"> |
---|
17 | <xsl:comment>This file was created automatically by xsl2profile</xsl:comment> |
---|
18 | <xsl:comment>from the DocBook XSL stylesheets.</xsl:comment> |
---|
19 | <xsl:apply-templates/> |
---|
20 | </xsl:template> |
---|
21 | |
---|
22 | <!-- Make sure we override some templates and parameters appropriately for XHTML --> |
---|
23 | <xsl:template match="xsl:stylesheet"> |
---|
24 | <xsl:copy> |
---|
25 | <xsl:attribute name="exslt:dummy" xmlns:exslt="http://exslt.org/common">dummy</xsl:attribute> |
---|
26 | <xsl:attribute name="ng:dummy" xmlns:ng="http://docbook.org/docbook-ng">dummy</xsl:attribute> |
---|
27 | <xsl:attribute name="db:dummy" xmlns:db="http://docbook.org/ns/docbook">dummy</xsl:attribute> |
---|
28 | <xsl:if test="not(@extension-element-prefixes)"> |
---|
29 | <xsl:attribute name="extension-element-prefixes">exslt</xsl:attribute> |
---|
30 | </xsl:if> |
---|
31 | <xsl:if test="not(@exclude-result-prefixes)"> |
---|
32 | <xsl:attribute name="exclude-result-prefixes">exslt</xsl:attribute> |
---|
33 | </xsl:if> |
---|
34 | <xsl:for-each select="@*"> |
---|
35 | <xsl:choose> |
---|
36 | <xsl:when test="local-name(.) = 'extension-element-prefixes' or |
---|
37 | local-name(.) = 'exclude-result-prefixes'"> |
---|
38 | <xsl:attribute name="{local-name(.)}"><xsl:value-of select="concat(., ' exslt')"/></xsl:attribute> |
---|
39 | </xsl:when> |
---|
40 | <xsl:otherwise> |
---|
41 | <xsl:attribute name="{local-name(.)}"><xsl:value-of select="."/></xsl:attribute> |
---|
42 | </xsl:otherwise> |
---|
43 | </xsl:choose> |
---|
44 | </xsl:for-each> |
---|
45 | <xsl:apply-templates/> |
---|
46 | </xsl:copy> |
---|
47 | </xsl:template> |
---|
48 | |
---|
49 | <xsl:template match="*"> |
---|
50 | <xsl:copy> |
---|
51 | <xsl:copy-of select="@*"/> |
---|
52 | <xsl:apply-templates/> |
---|
53 | </xsl:copy> |
---|
54 | </xsl:template> |
---|
55 | |
---|
56 | <xsl:template match="comment()|processing-instruction()|text()"> |
---|
57 | <xsl:copy/> |
---|
58 | </xsl:template> |
---|
59 | |
---|
60 | <xsl:template match="xsl:template[@match='/']"> |
---|
61 | <xslo:include href="../profiling/profile-mode.xsl"/> |
---|
62 | <xslo:variable name="profiled-content"> |
---|
63 | <xslo:choose> |
---|
64 | <xslo:when test="*/self::ng:* or */self::db:*"> |
---|
65 | <xslo:message>Note: namesp. cut : stripped namespace before processing</xslo:message> |
---|
66 | <xslo:variable name="stripped-content"> |
---|
67 | <xslo:apply-templates select="/" mode="stripNS"/> |
---|
68 | </xslo:variable> |
---|
69 | <xslo:message>Note: namesp. cut : processing stripped document</xslo:message> |
---|
70 | <xslo:apply-templates select="exslt:node-set($stripped-content)" mode="profile"/> |
---|
71 | </xslo:when> |
---|
72 | <xslo:otherwise> |
---|
73 | <xslo:apply-templates select="/" mode="profile"/> |
---|
74 | </xslo:otherwise> |
---|
75 | </xslo:choose> |
---|
76 | </xslo:variable> |
---|
77 | <xslo:variable name="profiled-nodes" select="exslt:node-set($profiled-content)"/> |
---|
78 | <xsl:copy> |
---|
79 | <xsl:copy-of select="@*"/> |
---|
80 | <xsl:apply-templates mode="correct"/> |
---|
81 | </xsl:copy> |
---|
82 | </xsl:template> |
---|
83 | |
---|
84 | <xsl:template match="xsl:template[@name='hhc-main' or @name='hhp-main' or @name='etoc'] | xsl:variable[@name='raw.help.title']"> |
---|
85 | <xsl:copy> |
---|
86 | <xsl:copy-of select="@*"/> |
---|
87 | <xsl:apply-templates mode="correct"/> |
---|
88 | </xsl:copy> |
---|
89 | </xsl:template> |
---|
90 | |
---|
91 | <xsl:template match="*[starts-with(@select, '/')]" mode="correct"> |
---|
92 | <xsl:copy> |
---|
93 | <xsl:for-each select="@*"> |
---|
94 | <xsl:choose> |
---|
95 | <xsl:when test="local-name(.) = 'select' and string(.) = '/'"> |
---|
96 | <xsl:attribute name="{local-name(.)}">$profiled-nodes</xsl:attribute> |
---|
97 | </xsl:when> |
---|
98 | <xsl:when test="local-name(.) = 'select' and starts-with(., '/')"> |
---|
99 | <xsl:attribute name="{local-name(.)}">$profiled-nodes<xsl:value-of select="."/></xsl:attribute> |
---|
100 | </xsl:when> |
---|
101 | <xsl:otherwise> |
---|
102 | <xsl:attribute name="{local-name(.)}"><xsl:value-of select="."/></xsl:attribute> |
---|
103 | </xsl:otherwise> |
---|
104 | </xsl:choose> |
---|
105 | </xsl:for-each> |
---|
106 | <xsl:apply-templates mode="correct"/> |
---|
107 | </xsl:copy> |
---|
108 | </xsl:template> |
---|
109 | |
---|
110 | <xsl:template match='*[contains(@*, "key('id',$rootid)")]' mode="correct" priority="2"> |
---|
111 | <xsl:copy> |
---|
112 | <xsl:for-each select="@*"> |
---|
113 | <xsl:choose> |
---|
114 | <xsl:when test='contains(., "key('id',$rootid)")'> |
---|
115 | <xsl:attribute name="{local-name(.)}"> |
---|
116 | <xsl:call-template name="string.subst"> |
---|
117 | <xsl:with-param name="string" select="."/> |
---|
118 | <xsl:with-param name="target">key('id',$rootid)</xsl:with-param> |
---|
119 | <xsl:with-param name="replacement">$profiled-nodes//*[@id=$rootid]</xsl:with-param> |
---|
120 | </xsl:call-template> |
---|
121 | </xsl:attribute> |
---|
122 | </xsl:when> |
---|
123 | <xsl:otherwise> |
---|
124 | <xsl:attribute name="{local-name(.)}"><xsl:value-of select="."/></xsl:attribute> |
---|
125 | </xsl:otherwise> |
---|
126 | </xsl:choose> |
---|
127 | </xsl:for-each> |
---|
128 | <xsl:apply-templates mode="correct"/> |
---|
129 | </xsl:copy> |
---|
130 | </xsl:template> |
---|
131 | |
---|
132 | <!-- FO stylesheet has apply-templates without select, we must detect it by context --> |
---|
133 | <xsl:template match="fo:root//xsl:apply-templates" mode="correct"> |
---|
134 | <xsl:copy> |
---|
135 | <xsl:copy-of select="@*"/> |
---|
136 | <xsl:attribute name="select">$profiled-nodes/node()</xsl:attribute> |
---|
137 | <xsl:apply-templates mode="correct"/> |
---|
138 | </xsl:copy> |
---|
139 | </xsl:template> |
---|
140 | |
---|
141 | <!-- DB5 namespace stripping is already done --> |
---|
142 | <xsl:template match="xsl:when[contains(@test, 'self::db')]" mode="correct"> |
---|
143 | <xsl:copy> |
---|
144 | <xsl:attribute name="test">false()</xsl:attribute> |
---|
145 | </xsl:copy> |
---|
146 | </xsl:template> |
---|
147 | |
---|
148 | <xsl:template match="*" mode="correct"> |
---|
149 | <xsl:copy> |
---|
150 | <xsl:copy-of select="@*"/> |
---|
151 | <xsl:apply-templates mode="correct"/> |
---|
152 | </xsl:copy> |
---|
153 | </xsl:template> |
---|
154 | |
---|
155 | <xsl:template match="comment()|processing-instruction()|text()" mode="correct"> |
---|
156 | <xsl:copy/> |
---|
157 | </xsl:template> |
---|
158 | |
---|
159 | </xsl:stylesheet> |
---|