VirtualBox

source: vbox/trunk/src/libs/dita-ot-1.8.5/plugins/org.dita.eclipsehelp/xsl/map2eclipse/map2eclipseImpl.xsl@ 99507

最後變更 在這個檔案從99507是 98584,由 vboxsync 提交於 2 年 前

Docs: bugref:10302. Setting svn properties of DITA-OT library.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 14.1 KB
 
1<?xml version="1.0" encoding="UTF-8" ?>
2<!-- This file is part of the DITA Open Toolkit project hosted on
3 Sourceforge.net. See the accompanying license.txt file for
4 applicable licenses.-->
5<!-- (c) Copyright IBM Corp. 2004, 2005 All Rights Reserved. -->
6
7<xsl:stylesheet version="1.0"
8 xmlns:dita-ot="http://dita-ot.sourceforge.net/ns/201007/dita-ot"
9 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
10 exclude-result-prefixes="dita-ot">
11
12<xsl:import href="plugin:org.dita.base:xsl/common/output-message.xsl"/>
13<xsl:import href="plugin:org.dita.base:xsl/common/dita-utilities.xsl"/>
14<xsl:import href="plugin:org.dita.base:xsl/common/dita-textonly.xsl"/>
15
16
17<xsl:output indent="yes"/>
18
19<!-- Define the error message prefix identifier -->
20<xsl:variable name="msgprefix">DOTX</xsl:variable>
21
22<xsl:param name="WORKDIR" select="''"/>
23<xsl:param name="OUTEXT" select="'.html'"/>
24<xsl:param name="DBG" select="no"/>
25<xsl:param name="DITAEXT" select="'.xml'"/>
26<xsl:variable name="work.dir">
27 <xsl:choose>
28 <xsl:when test="$WORKDIR and not($WORKDIR='')">
29 <xsl:choose>
30 <xsl:when test="not(substring($WORKDIR,string-length($WORKDIR))='/')and not(substring($WORKDIR,string-length($WORKDIR))='\')">
31 <xsl:value-of select="translate($WORKDIR,
32 '\/=+|?[]{}()!#$%^&amp;*__~`;:.,-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
33 '//=+|?[]{}()!#$%^&amp;*__~`;:.,-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')"/><xsl:text>/</xsl:text>
34 </xsl:when>
35 <xsl:otherwise>
36 <xsl:value-of select="translate($WORKDIR,
37 '\/=+|?[]{}()!#$%^&amp;*__~`;:.,-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
38 '//=+|?[]{}()!#$%^&amp;*__~`;:.,-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
39 </xsl:otherwise>
40 </xsl:choose>
41 </xsl:when>
42 <xsl:otherwise/>
43 </xsl:choose>
44</xsl:variable>
45
46<xsl:template match="*[contains(@class, ' map/map ')]">
47 <!-- add NLS processing instruction -->
48 <xsl:text>
49</xsl:text><xsl:processing-instruction name="NLS"> TYPE="org.eclipse.help.toc"</xsl:processing-instruction><xsl:text>
50</xsl:text>
51 <toc>
52 <xsl:choose>
53 <xsl:when test="*[contains(@class,' topic/title ')]">
54 <xsl:attribute name="label">
55 <xsl:value-of select="normalize-space(*[contains(@class,' topic/title ')])"/>
56 </xsl:attribute>
57 </xsl:when>
58 <xsl:when test="@title">
59 <xsl:attribute name="label"><xsl:value-of select="@title"/></xsl:attribute>
60 </xsl:when>
61 <xsl:otherwise>
62 <xsl:call-template name="output-message">
63 <xsl:with-param name="msgnum">002</xsl:with-param>
64 <xsl:with-param name="msgsev">W</xsl:with-param>
65 </xsl:call-template>
66 </xsl:otherwise>
67 </xsl:choose>
68 <xsl:apply-templates select="@anchorref"/>
69 <!-- Add @topic to map, using the first @href in the map -->
70 <xsl:if test="*[contains(@class, ' map/topicref ')][1]/descendant-or-self::*[@href]">
71 <xsl:attribute name="topic">
72 <xsl:apply-templates select="*[contains(@class, ' map/topicref ')][1]/descendant-or-self::*[@href][1]" mode="format-href"/>
73 </xsl:attribute>
74 </xsl:if>
75 <xsl:apply-templates/>
76 </toc>
77</xsl:template>
78
79<!-- anchorref must use forward slash, not back slash. Allow
80 anchorref to a non-ditamap, but warn if the format is still dita. -->
81<xsl:template match="@anchorref">
82 <xsl:variable name="fix-anchorref">
83 <xsl:value-of select="translate(.,
84 '\/=+|?[]{}()!#$%^&amp;*__~`;:.,-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
85 '//=+|?[]{}()!#$%^&amp;*__~`;:.,-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
86 </xsl:variable>
87 <xsl:attribute name="link_to">
88 <xsl:choose>
89 <xsl:when test="contains($fix-anchorref,'.ditamap')">
90 <!-- xsl:value-of select="$work.dir"/><xsl:text>/</xsl:text><xsl:value-of select="substring-before($fix-anchorref,'.ditamap')"/>.xml<xsl:value-of select="substring-after($fix-anchorref,'.ditamap')"/ -->
91 <xsl:value-of select="$work.dir"/><xsl:value-of select="substring-before($fix-anchorref,'.ditamap')"/>.xml<xsl:value-of select="substring-after($fix-anchorref,'.ditamap')"/>
92 </xsl:when>
93 <xsl:when test="contains($fix-anchorref,'.xml')"><xsl:value-of select="$work.dir"/><xsl:value-of select="$fix-anchorref"/></xsl:when>
94 <xsl:otherwise> <!-- should be dita, but name does not include .ditamap -->
95 <!-- use the for-each so that the message scope is the map element, not the attribute -->
96 <xsl:for-each select="parent::*">
97 <xsl:call-template name="output-message">
98 <xsl:with-param name="msgnum">003</xsl:with-param>
99 <xsl:with-param name="msgsev">I</xsl:with-param>
100 <xsl:with-param name="msgparams">%1=<xsl:value-of select="@anchorref"/></xsl:with-param>
101 </xsl:call-template>
102 </xsl:for-each>
103 <xsl:value-of select="$work.dir"/><xsl:value-of select="$fix-anchorref"/>
104 </xsl:otherwise>
105 </xsl:choose>
106 </xsl:attribute>
107</xsl:template>
108
109<!-- Format @href for the title attribute on the map element -->
110<xsl:template match="*" mode="format-href">
111 <xsl:choose>
112 <xsl:when test="@type='external' or (@scope='external' and not(@format)) or not(not(@format) or @format='dita' or @format='DITA')"><xsl:value-of select="@href"/></xsl:when> <!-- adding local -->
113 <xsl:when test="starts-with(@href,'#')"><xsl:value-of select="@href"/></xsl:when>
114 <xsl:when test="@copy-to and (not(@format) or @format = 'dita')">
115 <xsl:value-of select="$work.dir"/>
116 <xsl:call-template name="replace-extension">
117 <xsl:with-param name="filename" select="@copy-to"/>
118 <xsl:with-param name="extension" select="$OUTEXT"/>
119 <xsl:with-param name="ignore-fragment" select="true()"/>
120 </xsl:call-template>
121 </xsl:when>
122 <xsl:when test="@href and (not(@format) or @format = 'dita')">
123 <xsl:value-of select="$work.dir"/>
124 <xsl:call-template name="replace-extension">
125 <xsl:with-param name="filename" select="@href"/>
126 <xsl:with-param name="extension" select="$OUTEXT"/>
127 <xsl:with-param name="ignore-fragment" select="true()"/>
128 </xsl:call-template>
129 </xsl:when>
130 <!-- If it is a bad value, there will be a message when doing the real topic link -->
131 <xsl:otherwise><xsl:value-of select="$work.dir"/><xsl:value-of select="@href"/></xsl:otherwise>
132 </xsl:choose>
133</xsl:template>
134
135<!-- Make the same changes for navref/@mapref that were made for @anchorref. -->
136<xsl:template match="*[contains(@class, ' map/navref ')]/@mapref">
137 <xsl:variable name="fix-mapref">
138 <xsl:value-of select="translate(.,
139 '\/=+|?[]{}()!#$%^&amp;*__~`;:.,-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
140 '//=+|?[]{}()!#$%^&amp;*__~`;:.,-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
141 </xsl:variable>
142 <xsl:attribute name="toc">
143 <xsl:choose>
144 <xsl:when test="contains($fix-mapref,'.ditamap')"><xsl:value-of select="$work.dir"/><xsl:value-of select="substring-before($fix-mapref,'.ditamap')"/>.xml</xsl:when>
145 <xsl:when test="contains($fix-mapref,'.xml')"><xsl:value-of select="$work.dir"/><xsl:value-of select="$fix-mapref"/></xsl:when>
146 <xsl:otherwise>
147 <xsl:for-each select="parent::*">
148 <xsl:call-template name="output-message">
149 <xsl:with-param name="msgnum">003</xsl:with-param>
150 <xsl:with-param name="msgsev">I</xsl:with-param>
151 <xsl:with-param name="msgparams">%1=<xsl:value-of select="@mapref"/></xsl:with-param>
152 </xsl:call-template>
153 </xsl:for-each>
154 <xsl:value-of select="$work.dir"/><xsl:value-of select="$fix-mapref"/>
155 </xsl:otherwise>
156 </xsl:choose>
157 </xsl:attribute>
158</xsl:template>
159
160<xsl:template match="*[contains(@class, ' map/navref ')]">
161 <xsl:choose>
162 <xsl:when test="@mapref">
163 <link><xsl:apply-templates select="@mapref"/></link>
164 </xsl:when>
165 <xsl:otherwise>
166 <xsl:call-template name="output-message">
167 <xsl:with-param name="msgnum">004</xsl:with-param>
168 <xsl:with-param name="msgsev">I</xsl:with-param>
169 </xsl:call-template>
170 </xsl:otherwise>
171 </xsl:choose>
172</xsl:template>
173
174<xsl:template match="*[contains(@class, ' map/anchor ')]">
175 <anchor id="{@id}"/>
176</xsl:template>
177
178<!-- If the topicref is a "topicgroup", or some other topicref that does not point
179 to a file or have link text, then just move on to children. -->
180<xsl:template match="*[contains(@class, ' map/topicref ')][not(@toc='no')][not(@processing-role='resource-only')]">
181 <xsl:choose>
182 <xsl:when test="contains(@class, ' mapgroup/topicgroup ')">
183 <xsl:apply-templates/>
184 </xsl:when>
185 <xsl:when test="not(@href) and not(@navtitle) and not(*[contains(@class, ' map/topicmeta ')]/*[contains(@class, ' topic/navtitle ')]) and
186 not(*[contains(@class, ' map/topicmeta ')]/*[contains(@class, ' map/linktext ')])">
187 <xsl:apply-templates/>
188 </xsl:when>
189 <xsl:otherwise>
190 <topic>
191 <xsl:attribute name="label">
192 <xsl:choose>
193 <xsl:when test="*[contains(@class,'- map/topicmeta ')]/*[contains(@class, '- topic/navtitle ')]">
194 <xsl:apply-templates select="*[contains(@class,'- map/topicmeta ')]/*[contains(@class, '- topic/navtitle ')]" mode="dita-ot:text-only"/>
195 </xsl:when>
196 <xsl:when test="not(*[contains(@class,'- map/topicmeta ')]/*[contains(@class, '- topic/navtitle ')]) and @navtitle">
197 <xsl:value-of select="@navtitle"/>
198 </xsl:when>
199 <xsl:when test="*[contains(@class, ' map/topicmeta ')]/*[contains(@class, ' map/linktext ')]">
200 <xsl:apply-templates select="*[contains(@class, ' map/topicmeta ')]/*[contains(@class, ' map/linktext ')]" mode="dita-ot:text-only"/>
201 </xsl:when>
202 <xsl:otherwise>
203 <xsl:choose>
204 <xsl:when test="@type='external' or not(not(@format) or @format='dita' or @format='DITA')"><xsl:value-of select="@href"/></xsl:when> <!-- adding local -->
205 <xsl:when test="starts-with(@href,'#')"><xsl:value-of select="@href"/></xsl:when>
206 <xsl:when test="@copy-to and (not(@format) or @format = 'dita')">
207 <xsl:call-template name="replace-extension">
208 <xsl:with-param name="filename" select="@copy-to"/>
209 <xsl:with-param name="extension" select="$OUTEXT"/>
210 <xsl:with-param name="ignore-fragment" select="true()"/>
211 </xsl:call-template>
212 </xsl:when>
213 <xsl:when test="@href and (not(@format) or @format = 'dita')">
214 <xsl:call-template name="replace-extension">
215 <xsl:with-param name="filename" select="@href"/>
216 <xsl:with-param name="extension" select="$OUTEXT"/>
217 </xsl:call-template>
218 </xsl:when>
219 <xsl:when test="not(@href) or @href=''"/> <!-- P017000: error generated in prior step -->
220 <xsl:otherwise>
221 <xsl:value-of select="@href"/>
222 <xsl:call-template name="output-message">
223 <xsl:with-param name="msgnum">005</xsl:with-param>
224 <xsl:with-param name="msgsev">E</xsl:with-param>
225 <xsl:with-param name="msgparams">%1=<xsl:value-of select="@href"/></xsl:with-param>
226 </xsl:call-template>
227 </xsl:otherwise>
228 </xsl:choose>
229 </xsl:otherwise>
230 </xsl:choose>
231 </xsl:attribute>
232 <xsl:if test="@href and not(@href='')">
233 <xsl:attribute name="href">
234 <xsl:choose>
235 <xsl:when test="@type='external' or (@scope='external' and not(@format)) or not(not(@format) or @format='dita' or @format='DITA')"><xsl:value-of select="@href"/></xsl:when> <!-- adding local -->
236 <xsl:when test="starts-with(@href,'#')"><xsl:value-of select="@href"/></xsl:when>
237 <xsl:when test="@copy-to and (not(@format) or @format = 'dita')">
238 <xsl:value-of select="$work.dir"/>
239 <xsl:call-template name="replace-extension">
240 <xsl:with-param name="filename" select="@copy-to"/>
241 <xsl:with-param name="extension" select="$OUTEXT"/>
242 <xsl:with-param name="ignore-fragment" select="true()"/>
243 </xsl:call-template>
244 </xsl:when>
245 <xsl:when test="@href and (not(@format) or @format = 'dita')">
246 <xsl:value-of select="$work.dir"/>
247 <xsl:call-template name="replace-extension">
248 <xsl:with-param name="filename" select="@href"/>
249 <xsl:with-param name="extension" select="$OUTEXT"/>
250 </xsl:call-template>
251 </xsl:when>
252 <xsl:otherwise>
253 <xsl:value-of select="$work.dir"/><xsl:value-of select="@href"/>
254 <xsl:call-template name="output-message">
255 <xsl:with-param name="msgnum">006</xsl:with-param>
256 <xsl:with-param name="msgsev">E</xsl:with-param>
257 <xsl:with-param name="msgparams">%1=<xsl:value-of select="@href"/></xsl:with-param>
258 </xsl:call-template>
259 </xsl:otherwise>
260 </xsl:choose>
261 </xsl:attribute>
262 </xsl:if>
263 <xsl:apply-templates/>
264 </topic>
265 </xsl:otherwise>
266 </xsl:choose>
267</xsl:template>
268
269<!--makes sure that any literal text in topicmeta does not get output as literal text in the output TOC file, which should only have text in attributes, as pulled in by the topicref template-->
270<!--xsl:template match="text()">
271 <xsl:apply-templates/>
272</xsl:template-->
273
274<xsl:template match="text()"/>
275
276<!-- do nothing when meeting with reltable -->
277<xsl:template match="*[contains(@class,' map/reltable ')]"/>
278
279</xsl:stylesheet>
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette