xref: /trunk/main/xmlhelp/util/main_transform.xsl (revision d41ee026)
1<?xml version="1.0" encoding="UTF-8"?>
2
3
4<!--***********************************************************************
5  This is the main transformation style sheet for transforming.
6  Only use with OOo 2.0
7  Owner: fpe@openoffice.org
8  =========================================================================
9  Changes Log
10    May 24 2004 Created
11    Aug 24 2004 Fixed for help2 CWS
12    Aug 27 2004 Added css link, fixed missing embed-mode for variable
13                Removed width/height for images
14    Sep 03 2004 Modularized xsl, added some embedded modes
15    Oct 08 2004 Fixed bug wrong mode "embedded" for links
16                Added embedded modes for embed and embedvar (for cascaded embeds)
17                Added <p> tags around falsely embedded pars and vars
18    Dec 08 2004 #i38483#, fixed wrong handling of web links
19                #i37377#, fixed missing usage of Database parameter for switching
20    Jan 04 2005 #i38905#, fixed buggy branding replacement template
21    Mar 17 2005 #i43972#, added language info to image URL, evaluate Language parameter
22                evaluate new localize attribute in images
23    May 10 2005 #i48785#, fixed wrong setting of distrib variable
24    Aug 16 2005 workaround for #i53365#
25    Aug 19 2005 fixed missing list processing in embedded sections
26    Aug 19 2005 #i53535#, fixed wrong handling of Database parameter
27    Oct 17 2006 #i70462#, disabled sorting to avoid output of error messages to console
28    Jun 15 2009 #i101799#, fixed wrong handling of http URLs with anchors
29***********************************************************************//-->
30
31<!--***********************************************************
32 *
33 * Licensed to the Apache Software Foundation (ASF) under one
34 * or more contributor license agreements.  See the NOTICE file
35 * distributed with this work for additional information
36 * regarding copyright ownership.  The ASF licenses this file
37 * to you under the Apache License, Version 2.0 (the
38 * "License"); you may not use this file except in compliance
39 * with the License.  You may obtain a copy of the License at
40 *
41 *   http://www.apache.org/licenses/LICENSE-2.0
42 *
43 * Unless required by applicable law or agreed to in writing,
44 * software distributed under the License is distributed on an
45 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
46 * KIND, either express or implied.  See the License for the
47 * specific language governing permissions and limitations
48 * under the License.
49 *
50 ***********************************************************-->
51
52<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
53
54<xsl:output indent="yes" method="html"/>
55
56<!--
57############################
58# Variables and Parameters #
59############################
60//-->
61
62<!-- General Usage -->
63<xsl:variable name="am" select="'&amp;'"/>
64<xsl:variable name="sl" select="'/'"/>
65<xsl:variable name="qt" select="'&quot;'"/>
66
67<!-- generic Icon alt text -->
68<xsl:variable name="alttext" select="'text/shared/00/icon_alt.xhp'"/>
69
70<!-- For calculating pixel sizes -->
71<xsl:variable name="dpi" select="'96'"/>
72<xsl:variable name="dpcm" select="'38'"/>
73
74<!-- Product brand variables used in the help files -->
75<xsl:variable name="brand1" select="'$[officename]'"/>
76<xsl:variable name="brand2" select="'$[officeversion]'"/>
77<xsl:variable name="brand3" select="'%PRODUCTNAME'"/>
78<xsl:variable name="brand4" select="'%PRODUCTVERSION'"/>
79<xsl:variable name="brand5" select="'%WRITERCOMPATIBILITYVERSIONOOO11'"/>
80
81<!-- meta data variables from the help file -->
82<xsl:variable name="filename" select="/helpdocument/meta/topic/filename"/>
83<xsl:variable name="topic_id" select="/helpdocument/meta/topic/@id"/>
84<xsl:variable name="topic_status" select="/helpdocument/meta/topic/@status"/>
85<xsl:variable name="title" select="/helpdocument/meta/topic/title"/>
86<xsl:variable name="doclang" select="/helpdocument/meta/topic/title/@xml-lang"/>
87
88<!-- Module and the corresponding switching values-->
89<xsl:param name="Database" select="'swriter'"/>
90<xsl:variable name="module" select="$Database"/>
91<xsl:variable name="appl">
92	<xsl:choose>
93		<xsl:when test="$module = 'swriter'"><xsl:value-of select="'WRITER'"/></xsl:when>
94		<xsl:when test="$module = 'scalc'"><xsl:value-of select="'CALC'"/></xsl:when>
95		<xsl:when test="$module = 'sdraw'"><xsl:value-of select="'DRAW'"/></xsl:when>
96		<xsl:when test="$module = 'simpress'"><xsl:value-of select="'IMPRESS'"/></xsl:when>
97		<xsl:when test="$module = 'schart'"><xsl:value-of select="'CHART'"/></xsl:when>
98		<xsl:when test="$module = 'sbasic'"><xsl:value-of select="'BASIC'"/></xsl:when>
99		<xsl:when test="$module = 'smath'"><xsl:value-of select="'MATH'"/></xsl:when>
100	</xsl:choose>
101</xsl:variable>
102
103<!-- the other parameters given by the help caller -->
104<xsl:param name="System" select="'WIN'"/>
105<xsl:param name="productname" select="'Office'"/>
106<xsl:param name="productversion" select="''"/>
107<xsl:variable name="pversion">
108	<xsl:value-of select="translate($productversion,' ','')"/>
109</xsl:variable>
110<!-- this is were the images are -->
111<xsl:param name="imgrepos" select="''"/>
112<xsl:param name="Id" />
113<!-- (lame) distinction between OS and Commercial -->
114<xsl:param name="distrib">
115	<xsl:choose>
116		<xsl:when test="starts-with($productname,'OpenOffice')">
117			<xsl:value-of select="'OpenSource'"/>
118		</xsl:when>
119		<xsl:otherwise>
120			<xsl:value-of select="'COMMERCIAL'"/>
121		</xsl:otherwise>
122	</xsl:choose>
123</xsl:param>
124<xsl:param name="Language" select="'en-US'"/>
125<xsl:variable name="lang" select="$Language"/>
126
127<xsl:param name="ExtensionId" select="''"/>
128<xsl:param name="ExtensionPath" select="''"/>
129
130
131<!-- parts of help and image urls -->
132<xsl:variable name="help_url_prefix" select="'vnd.sun.star.help://'"/>
133<xsl:variable name="img_url_prefix" select="concat('vnd.sun.star.zip://',$imgrepos,'/')"/>
134<xsl:variable name="urlpost" select="concat('?Language=',$lang,$am,'System=',$System,$am,'UseDB=no')"/>
135<xsl:variable name="urlpre" select="$help_url_prefix" />
136<xsl:variable name="linkprefix" select="$urlpre"/>
137<xsl:variable name="linkpostfix" select="$urlpost"/>
138
139<xsl:variable name="css" select="'default.css'"/>
140
141<!-- images for notes, tips and warnings -->
142<xsl:variable name="note_img" select="concat($img_url_prefix,'res/helpimg/note.png')"/>
143<xsl:variable name="tip_img" select="concat($img_url_prefix,'res/helpimg/tip.png')"/>
144<xsl:variable name="warning_img" select="concat($img_url_prefix,'res/helpimg/warning.png')"/>
145
146<!--
147#############
148# Templates #
149#############
150//-->
151
152<!-- Create the document skeleton -->
153<xsl:template match="/">
154	<xsl:variable name="csslink" select="concat($urlpre,'/',$urlpost)"/>
155	<html>
156		<head>
157			<title><xsl:value-of select="$title"/></title>
158			<link href="{$csslink}" rel="Stylesheet" type="text/css" /> <!-- stylesheet link -->
159		<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
160		</head>
161		<body lang="{$lang}">
162			<xsl:apply-templates select="/helpdocument/body"/>
163		</body>
164	</html>
165</xsl:template>
166
167<!-- AHELP -->
168<xsl:template match="ahelp">
169	<xsl:if test="not(@visibility='hidden')"><span class="avis"><xsl:apply-templates /></span></xsl:if>
170</xsl:template>
171
172<!-- ALT -->
173<xsl:template match="alt"/>
174
175<!-- BOOKMARK -->
176<xsl:template match="bookmark">
177	<a name="{@id}"></a>
178	<xsl:choose>
179		<xsl:when test="starts-with(@branch,'hid')" />
180		<xsl:otherwise><xsl:apply-templates /></xsl:otherwise>
181	</xsl:choose>
182</xsl:template>
183<xsl:template match="bookmark" mode="embedded" />
184
185<!-- BOOKMARK_VALUE -->
186<xsl:template match="bookmark_value" />
187
188<!-- BR -->
189<xsl:template match="br"><br /></xsl:template>
190
191<!-- CAPTION -->
192<xsl:template match="caption" />
193
194<!-- CASE -->
195<xsl:template match="case"><xsl:call-template name="insertcase" /></xsl:template>
196<xsl:template match="case" mode="embedded">
197	<xsl:call-template name="insertcase">
198		<xsl:with-param name="embedded" select="'yes'"/>
199	</xsl:call-template>
200</xsl:template>
201
202<!-- CASEINLINE -->
203<xsl:template match="caseinline"><xsl:call-template name="insertcase" /></xsl:template>
204<xsl:template match="caseinline" mode="embedded">
205	<xsl:call-template name="insertcase">
206		<xsl:with-param name="embedded" select="'yes'"/>
207	</xsl:call-template>
208</xsl:template>
209
210<!-- COMMENT -->
211<xsl:template match="comment" />
212<xsl:template match="comment" mode="embedded"/>
213
214<!-- CREATED -->
215<xsl:template match="created" />
216
217<!-- DEFAULT -->
218<xsl:template match="default"><xsl:call-template name="insertdefault" /></xsl:template>
219<xsl:template match="default" mode="embedded">
220	<xsl:call-template name="insertdefault">
221		<xsl:with-param name="embedded" select="'yes'"/>
222	</xsl:call-template>
223</xsl:template>
224
225<!-- DEFAULTINLINE -->
226<xsl:template match="defaultinline"><xsl:call-template name="insertdefault" /></xsl:template>
227<xsl:template match="defaultinline" mode="embedded">
228	<xsl:call-template name="insertdefault">
229		<xsl:with-param name="embedded" select="'yes'"/>
230	</xsl:call-template>
231</xsl:template>
232
233<!-- EMBED -->
234<xsl:template match="embed"><xsl:call-template name="resolveembed"/></xsl:template>
235<xsl:template match="embed" mode="embedded"><xsl:call-template name="resolveembed"/></xsl:template>
236
237<!-- EMBEDVAR -->
238<xsl:template match="embedvar"><xsl:call-template name="resolveembedvar"/></xsl:template>
239<xsl:template match="embedvar" mode="embedded"><xsl:call-template name="resolveembedvar"/></xsl:template>
240
241<!-- EMPH -->
242<xsl:template match="emph">
243	<span class="emph"><xsl:apply-templates /></span>
244</xsl:template>
245<xsl:template match="emph" mode="embedded">
246	<span class="emph"><xsl:apply-templates /></span>
247</xsl:template>
248
249<!-- FILENAME -->
250<xsl:template match="filename" />
251
252<!-- HISTORY -->
253<xsl:template match="history" />
254
255<!-- IMAGE -->
256<xsl:template match="image"><xsl:call-template name="insertimage"/></xsl:template>
257<xsl:template match="image" mode="embedded"><xsl:call-template name="insertimage"/></xsl:template>
258
259<!-- ITEM -->
260<xsl:template match="item"><span class="{@type}"><xsl:apply-templates /></span></xsl:template>
261<xsl:template match="item" mode="embedded"><span class="{@type}"><xsl:apply-templates /></span></xsl:template>
262
263<!-- LASTEDITED -->
264<xsl:template match="lastedited" />
265
266<!-- LINK -->
267<xsl:template match="link">
268	<xsl:choose> <!-- don't insert the heading link to itself -->
269		<xsl:when test="(concat('/',@href) = /helpdocument/meta/topic/filename) or (@href = /helpdocument/meta/topic/filename)">
270			<xsl:apply-templates />
271		</xsl:when>
272		<xsl:when test="contains(child::embedvar/@href,'/00/00000004.xhp#wie')"> <!-- special treatment of howtoget links -->
273			<xsl:call-template name="insert_howtoget">
274				<xsl:with-param name="linkhref" select="@href"/>
275			</xsl:call-template>
276		</xsl:when>
277		<xsl:otherwise>
278			<xsl:call-template name="createlink" />
279		</xsl:otherwise>
280	</xsl:choose>
281</xsl:template>
282<xsl:template match="link" mode="embedded">
283	<xsl:call-template name="createlink"/>
284</xsl:template>
285
286<!-- LIST -->
287<xsl:template match="list">
288	<xsl:choose>
289		<xsl:when test="@type='ordered'">
290			<ol>
291				<xsl:if test="@startwith">
292					<xsl:attribute name="start"><xsl:value-of select="@startwith"/></xsl:attribute>
293				</xsl:if>
294				<xsl:apply-templates />
295			</ol>
296		</xsl:when>
297		<xsl:otherwise>
298			<ul><xsl:apply-templates /></ul>
299		</xsl:otherwise>
300	</xsl:choose>
301</xsl:template>
302
303<xsl:template match="list" mode="embedded">
304	<xsl:choose>
305		<xsl:when test="@type='ordered'">
306			<ol>
307				<xsl:if test="@startwith">
308					<xsl:attribute name="start"><xsl:value-of select="@startwith"/></xsl:attribute>
309				</xsl:if>
310				<xsl:apply-templates mode="embedded"/>
311			</ol>
312		</xsl:when>
313		<xsl:otherwise>
314			<ul><xsl:apply-templates mode="embedded"/></ul>
315		</xsl:otherwise>
316	</xsl:choose>
317</xsl:template>
318
319<!-- LISTITEM -->
320<xsl:template match="listitem">
321	<li><xsl:apply-templates /></li>
322</xsl:template>
323
324<xsl:template match="listitem" mode="embedded">
325	<li><xsl:apply-templates mode="embedded"/></li>
326</xsl:template>
327
328<!-- META, SEE HEADER -->
329<xsl:template match="meta" />
330
331<!-- OBJECT (UNUSED) -->
332<xsl:template match="object" />
333
334<!-- PARAGRAPH -->
335<xsl:template match="paragraph">
336	<xsl:choose>
337
338		<xsl:when test="@role='heading'">
339			<xsl:call-template name="insertheading">
340				<xsl:with-param name="level" select="@level"/>
341			</xsl:call-template>
342		</xsl:when>
343
344		<xsl:when test="contains(' note warning tip ',@role)">
345			<xsl:call-template name="insertnote">
346				<xsl:with-param name="type" select="@role" />
347			</xsl:call-template>
348		</xsl:when>
349
350		<xsl:when test="contains(descendant::embedvar/@href,'/00/00000004.xhp#wie')"> <!-- special treatment of howtoget links -->
351			<xsl:apply-templates />
352		</xsl:when>
353
354		<xsl:otherwise>
355			<xsl:call-template name="insertpara" />
356		</xsl:otherwise>
357
358	</xsl:choose>
359</xsl:template>
360
361<xsl:template match="paragraph" mode="embedded">
362		<xsl:choose>
363
364		<xsl:when test="@role='heading'">	<!-- increase the level of headings that are embedded -->
365		<!--
366			The internal sablotron processor does not seem to support the number function.
367			Therefore, we need a workaround for
368			<xsl:variable name="level"><xsl:value-of select="number(@level)+1"/></xsl:variable>
369		-->
370			<xsl:variable name="newlevel">
371				<xsl:choose>
372					<xsl:when test="@level='1'"><xsl:value-of select="'2'"/></xsl:when>
373					<xsl:when test="@level='2'"><xsl:value-of select="'2'"/></xsl:when>
374					<xsl:when test="@level='3'"><xsl:value-of select="'3'"/></xsl:when>
375					<xsl:when test="@level='4'"><xsl:value-of select="'4'"/></xsl:when>
376					<xsl:when test="@level='5'"><xsl:value-of select="'5'"/></xsl:when>
377				</xsl:choose>
378			</xsl:variable>
379
380			<xsl:call-template name="insertheading">
381				<xsl:with-param name="level" select="$newlevel"/>
382				<xsl:with-param name="embedded" select="'yes'"/>
383			</xsl:call-template>
384		</xsl:when>
385
386		<xsl:when test="contains(' note warning tip ',@role)">
387			<xsl:call-template name="insertnote">
388				<xsl:with-param name="type" select="@role" />
389			</xsl:call-template>
390		</xsl:when>
391
392		<xsl:when test="contains(descendant::embedvar/@href,'/00/00000004.xhp#wie')"> <!-- special treatment of howtoget links -->
393			<xsl:apply-templates />
394		</xsl:when>
395
396		<xsl:otherwise>
397			<xsl:call-template name="insertpara" />
398		</xsl:otherwise>
399
400	</xsl:choose>
401</xsl:template>
402
403
404<!-- SECTION -->
405<xsl:template match="section">
406	<a name="{@id}"></a>
407
408		<xsl:choose>
409
410			<xsl:when test="@id='relatedtopics'">
411				<div class="relatedtopics">
412					<xsl:variable name="href"><xsl:value-of select="concat($urlpre,'shared/text/shared/00/00000004.xhp',$urlpost)"/></xsl:variable>
413					<xsl:variable name="anchor"><xsl:value-of select="'related'"/></xsl:variable>
414					<xsl:variable name="doc" select="document($href)"/>
415					<p class="related">
416						<xsl:apply-templates select="$doc//variable[@id=$anchor]"/>
417					</p>
418					<div class="relatedbody">
419						<xsl:apply-templates />
420					</div>
421				</div>
422			</xsl:when>
423
424			<xsl:when test="@id='howtoget'">
425				<xsl:call-template name="insert_howtoget" />
426			</xsl:when>
427
428			<xsl:otherwise>
429						<xsl:apply-templates/>
430			</xsl:otherwise>
431
432		</xsl:choose>
433
434</xsl:template>
435
436
437<!-- SECTION -->
438<xsl:template match="section" mode="embedded">
439	<a name="{@id}"></a>
440	<xsl:apply-templates mode="embedded"/>
441</xsl:template>
442
443<!-- SORT -->
444<xsl:template match="sort" >
445	<xsl:apply-templates><xsl:sort select="descendant::paragraph"/></xsl:apply-templates>
446</xsl:template>
447<xsl:template match="sort" mode="embedded">
448	<xsl:apply-templates><xsl:sort select="descendant::paragraph"/></xsl:apply-templates>
449</xsl:template>
450
451<!-- SWITCH -->
452<xsl:template match="switch"><xsl:apply-templates /></xsl:template>
453<xsl:template match="switch" mode="embedded"><xsl:apply-templates /></xsl:template>
454
455<!-- SWITCHINLINE -->
456<xsl:template match="switchinline"><xsl:apply-templates /></xsl:template>
457<xsl:template match="switchinline" mode="embedded"><xsl:apply-templates mode="embedded"/></xsl:template>
458
459<!-- TABLE -->
460<xsl:template match="table"><xsl:call-template name="inserttable"/></xsl:template>
461<xsl:template match="table" mode="embedded"><xsl:call-template name="inserttable"/></xsl:template>
462
463<!-- TABLECELL -->
464<xsl:template match="tablecell"><td valign="top"><xsl:apply-templates /></td></xsl:template>
465<xsl:template match="tablecell" mode="icontable"><td valign="top"><xsl:apply-templates/></td></xsl:template>
466<xsl:template match="tablecell" mode="embedded"><td valign="top"><xsl:apply-templates mode="embedded"/></td></xsl:template>
467
468<!-- TABLEROW -->
469<xsl:template match="tablerow"><tr><xsl:apply-templates /></tr></xsl:template>
470<xsl:template match="tablerow" mode="icontable"><tr><xsl:apply-templates mode="icontable"/></tr></xsl:template>
471<xsl:template match="tablerow" mode="embedded"><tr><xsl:apply-templates mode="embedded"/></tr></xsl:template>
472
473<!-- TITLE -->
474<xsl:template match="title"/>
475
476<!-- TOPIC -->
477<xsl:template match="topic"/>
478
479<!-- VARIABLE -->
480<xsl:template match="variable"><a name="{@id}"></a><xsl:apply-templates /></xsl:template>
481<xsl:template match="variable" mode="embedded"><a name="{@id}"></a><xsl:apply-templates mode="embedded"/></xsl:template>
482
483<xsl:template match="text()">
484	<xsl:call-template name="brand">
485		<xsl:with-param name="string"><xsl:value-of select="."/></xsl:with-param>
486	</xsl:call-template>
487</xsl:template>
488
489<xsl:template match="text()" mode="embedded">
490	<xsl:call-template name="brand">
491		<xsl:with-param name="string"><xsl:value-of select="."/></xsl:with-param>
492	</xsl:call-template>
493</xsl:template>
494
495<!-- In case of missing help files -->
496<xsl:template match="help-id-missing"><xsl:value-of select="$Id"/></xsl:template>
497
498<!--
499###################
500# NAMED TEMPLATES #
501###################
502//-->
503
504<!-- Branding -->
505<xsl:template name="brand" >
506	<xsl:param name="string"/>
507
508	<xsl:choose>
509
510		<xsl:when test="contains($string,$brand1)">
511			<xsl:variable name="newstr">
512				<xsl:value-of select="substring-before($string,$brand1)"/>
513				<xsl:value-of select="$productname"/>
514				<xsl:value-of select="substring-after($string,$brand1)"/>
515			</xsl:variable>
516			<xsl:call-template name="brand">
517				<xsl:with-param name="string" select="$newstr"/>
518			</xsl:call-template>
519		</xsl:when>
520
521		<xsl:when test="contains($string,$brand2)">
522			<xsl:variable name="newstr">
523				<xsl:value-of select="substring-before($string,$brand2)"/>
524				<xsl:value-of select="$pversion"/>
525				<xsl:value-of select="substring-after($string,$brand2)"/>
526			</xsl:variable>
527			<xsl:call-template name="brand">
528				<xsl:with-param name="string" select="$newstr"/>
529			</xsl:call-template>
530		</xsl:when>
531
532		<xsl:when test="contains($string,$brand3)">
533			<xsl:variable name="newstr">
534				<xsl:value-of select="substring-before($string,$brand3)"/>
535				<xsl:value-of select="$productname"/>
536				<xsl:value-of select="substring-after($string,$brand3)"/>
537			</xsl:variable>
538			<xsl:call-template name="brand">
539				<xsl:with-param name="string" select="$newstr"/>
540			</xsl:call-template>
541		</xsl:when>
542
543		<xsl:when test="contains($string,$brand4)">
544				<xsl:variable name="newstr">
545				<xsl:value-of select="substring-before($string,$brand4)"/>
546				<xsl:value-of select="$pversion"/>
547				<xsl:value-of select="substring-after($string,$brand4)"/>
548			</xsl:variable>
549			<xsl:call-template name="brand">
550				<xsl:with-param name="string" select="$newstr"/>
551			</xsl:call-template>
552		</xsl:when>
553
554		<xsl:when test="contains($string,$brand5)">
555				<xsl:variable name="newstr">
556				<xsl:value-of select="substring-before($string,$brand5)"/>
557				<xsl:value-of select="'OpenOffice.org 1.1'"/>
558				<xsl:value-of select="substring-after($string,$brand5)"/>
559				</xsl:variable>
560			<xsl:call-template name="brand">
561				<xsl:with-param name="string" select="$newstr"/>
562			</xsl:call-template>
563		</xsl:when>
564
565		<xsl:otherwise>
566			<xsl:value-of select="$string"/>
567		</xsl:otherwise>
568	</xsl:choose>
569
570</xsl:template>
571
572
573<!-- Insert Paragraph -->
574<xsl:template name="insertpara">
575	<xsl:variable name="role">
576		<xsl:choose>
577			<xsl:when test="ancestor::table">
578				<xsl:value-of select="concat(@role,'intable')"/>
579			</xsl:when>
580			<xsl:otherwise>
581				<xsl:value-of select="@role"/>
582			</xsl:otherwise>
583		</xsl:choose>
584	</xsl:variable>
585	<p class="{$role}"><xsl:apply-templates /></p>
586</xsl:template>
587
588<!-- Insert "How to get Link" -->
589<xsl:template name="insert_howtoget">
590	<xsl:param name="linkhref" />
591	<xsl:variable name="archive" select="'shared'"/>
592	<xsl:variable name="tmp_href"><xsl:value-of select="concat($urlpre,'shared/text/shared/00/00000004.xhp',$urlpost)"/></xsl:variable>
593	<xsl:variable name="tmp_doc" select="document($tmp_href)"/>
594	<table class="howtoget" width="100%" border="1" cellpadding="3" cellspacing="0">
595		<tr>
596			<td>
597				<p class="howtogetheader"><xsl:apply-templates select="$tmp_doc//variable[@id='wie']"/></p>
598				<div class="howtogetbody">
599				<xsl:choose>
600					<xsl:when test="$linkhref = ''"> <!-- new style -->
601						<xsl:apply-templates/>
602					</xsl:when>
603					<xsl:otherwise> <!-- old style -->
604						<xsl:variable name="archive1"><xsl:value-of select="concat(substring-before(substring-after($linkhref,'text/'),'/'),'/')"/></xsl:variable>
605						<xsl:variable name="href"><xsl:value-of select="concat($urlpre,$archive1,substring-before($linkhref,'#'),$urlpost)"/></xsl:variable>
606						<xsl:variable name="anc"><xsl:value-of select="substring-after($linkhref,'#')"/></xsl:variable>
607						<xsl:variable name="docum" select="document($href)"/>
608
609						<xsl:call-template name="insertembed">
610							<xsl:with-param name="doc" select="$docum" />
611							<xsl:with-param name="anchor" select="$anc" />
612						</xsl:call-template>
613
614					</xsl:otherwise>
615				</xsl:choose>
616				</div>
617			</td>
618		</tr>
619	</table>
620	<br/>
621</xsl:template>
622
623<!-- Create a link -->
624<xsl:template name="createlink">
625<xsl:variable name="archive"><xsl:value-of select="concat(substring-before(substring-after(@href,'text/'),'/'),'/')"/></xsl:variable>
626<xsl:variable name="dbpostfix"><xsl:call-template name="createDBpostfix"><xsl:with-param name="archive" select="$archive"/></xsl:call-template></xsl:variable>
627	<xsl:choose>
628		<xsl:when test="starts-with(@href,'http://') or starts-with(@href,'https://')"> <!-- web links -->
629			<a href="{@href}"><xsl:apply-templates /></a>
630		</xsl:when>
631		<xsl:when test="contains(@href,'#')">
632			<xsl:variable name="anchor"><xsl:value-of select="concat('#',substring-after(@href,'#'))"/></xsl:variable>
633			<xsl:variable name="href"><xsl:value-of select="concat($linkprefix,$archive,substring-before(@href,'#'),$linkpostfix,$dbpostfix,$anchor)"/></xsl:variable>
634			<a href="{$href}"><xsl:apply-templates /></a>
635		</xsl:when>
636		<xsl:otherwise>
637			<xsl:variable name="href"><xsl:value-of select="concat($linkprefix,$archive,@href,$linkpostfix,$dbpostfix)"/></xsl:variable>
638			<a href="{$href}"><xsl:apply-templates /></a>
639		</xsl:otherwise>
640	</xsl:choose>
641</xsl:template>
642
643<!-- Insert Note, Warning, or Tip -->
644<xsl:template name="insertnote">
645	<xsl:param name="type" /> <!-- note, tip, or warning -->
646	<xsl:variable name="imgsrc">
647		<xsl:choose>
648			<xsl:when test="$type='note'"><xsl:value-of select="$note_img"/></xsl:when>
649			<xsl:when test="$type='tip'"><xsl:value-of select="$tip_img"/></xsl:when>
650			<xsl:when test="$type='warning'"><xsl:value-of select="$warning_img"/></xsl:when>
651		</xsl:choose>
652	</xsl:variable>
653	<xsl:variable name="dbpostfix"><xsl:call-template name="createDBpostfix"><xsl:with-param name="archive" select="'shared'"/></xsl:call-template></xsl:variable>
654	<xsl:variable name="alt">
655		<xsl:variable name="href"><xsl:value-of select="concat($urlpre,'shared/',$alttext,$urlpost,$dbpostfix)"/></xsl:variable>
656		<xsl:variable name="anchor"><xsl:value-of select="concat('alt_',$type)"/></xsl:variable>
657		<xsl:variable name="doc" select="document($href)"/>
658		<xsl:apply-templates select="$doc//variable[@id=$anchor]" mode="embedded"/>
659	</xsl:variable>
660	<div class="{$type}">
661		<table border="0" class="{$type}" cellspacing="0" cellpadding="5">
662			<tr>
663				<td><img src="{$imgsrc}" alt="{$alt}" title="{$alt}"/></td>
664				<td><xsl:apply-templates /></td>
665			</tr>
666		</table>
667	</div>
668	<br/>
669</xsl:template>
670
671<!-- Insert a heading -->
672<xsl:template name="insertheading">
673	<xsl:param name="level" />
674	<xsl:param name="embedded" />
675	<xsl:text disable-output-escaping="yes">&lt;h</xsl:text><xsl:value-of select="$level"/><xsl:text disable-output-escaping="yes">&gt;</xsl:text>
676		<xsl:choose>
677			<xsl:when test="$embedded = 'yes'">
678				<xsl:apply-templates mode="embedded"/>
679			</xsl:when>
680			<xsl:otherwise>
681				<xsl:apply-templates />
682			</xsl:otherwise>
683		</xsl:choose>
684	<xsl:text disable-output-escaping="yes">&lt;/h</xsl:text><xsl:value-of select="$level"/><xsl:text disable-output-escaping="yes">&gt;</xsl:text>
685</xsl:template>
686
687<!-- Evaluate a case or caseinline switch -->
688<xsl:template name="insertcase">
689	<xsl:param name="embedded" />
690	<xsl:choose>
691		<xsl:when test="parent::switch[@select='sys'] or parent::switchinline[@select='sys']">
692			<xsl:if test="@select = $System">
693				<xsl:choose>
694					<xsl:when test="$embedded = 'yes'">
695						<xsl:apply-templates mode="embedded"/>
696					</xsl:when>
697					<xsl:otherwise>
698						<xsl:apply-templates />
699					</xsl:otherwise>
700				</xsl:choose>
701			</xsl:if>
702		</xsl:when>
703		<xsl:when test="parent::switch[@select='appl'] or parent::switchinline[@select='appl']">
704			<xsl:if test="@select = $appl">
705				<xsl:choose>
706					<xsl:when test="$embedded = 'yes'">
707						<xsl:apply-templates mode="embedded"/>
708					</xsl:when>
709					<xsl:otherwise>
710						<xsl:apply-templates />
711					</xsl:otherwise>
712				</xsl:choose>
713			</xsl:if>
714		</xsl:when>
715		<xsl:when test="parent::switch[@select='distrib'] or parent::switchinline[@select='distrib']">
716			<xsl:if test="@select = $distrib">
717				<xsl:choose>
718					<xsl:when test="$embedded = 'yes'">
719						<xsl:apply-templates mode="embedded"/>
720					</xsl:when>
721					<xsl:otherwise>
722						<xsl:apply-templates />
723					</xsl:otherwise>
724				</xsl:choose>
725			</xsl:if>
726		</xsl:when>
727	</xsl:choose>
728</xsl:template>
729
730<!-- Evaluate a default or defaultinline switch -->
731<xsl:template name="insertdefault">
732	<xsl:param name="embedded" />
733
734	<xsl:choose>
735		<xsl:when test="parent::switch[@select='sys'] or parent::switchinline[@select='sys']">
736			<xsl:if test="not(../child::case[@select=$System]) and not(../child::caseinline[@select=$System])">
737				<xsl:choose>
738					<xsl:when test="$embedded = 'yes'">
739						<xsl:apply-templates mode="embedded"/>
740					</xsl:when>
741					<xsl:otherwise>
742						<xsl:apply-templates />
743					</xsl:otherwise>
744				</xsl:choose>
745			</xsl:if>
746		</xsl:when>
747		<xsl:when test="parent::switch[@select='appl'] or parent::switchinline[@select='appl']">
748			<xsl:if test="not(../child::case[@select=$appl]) and not(../child::caseinline[@select=$appl])">
749				<xsl:choose>
750					<xsl:when test="$embedded = 'yes'">
751						<xsl:apply-templates mode="embedded"/>
752					</xsl:when>
753					<xsl:otherwise>
754						<xsl:apply-templates />
755					</xsl:otherwise>
756				</xsl:choose>
757			</xsl:if>
758		</xsl:when>
759		<xsl:when test="parent::switch[@select='distrib'] or parent::switchinline[@select='distrib']">
760			<xsl:if test="not(../child::case[@select=$distrib]) and not(../child::caseinline[@select=$distrib])">
761				<xsl:choose>
762					<xsl:when test="$embedded = 'yes'">
763						<xsl:apply-templates mode="embedded"/>
764					</xsl:when>
765					<xsl:otherwise>
766						<xsl:apply-templates />
767					</xsl:otherwise>
768				</xsl:choose>
769			</xsl:if>
770		</xsl:when>
771	</xsl:choose>
772</xsl:template>
773
774<!-- evaluate embeds -->
775<xsl:template name="insertembed">
776	<xsl:param name="doc" />
777	<xsl:param name="anchor" />
778	<!-- different embed targets (also falsely used embed instead embedvar) -->
779	<xsl:choose>
780		<xsl:when test="$doc//section[@id=$anchor]"> <!-- first test for a section of that name -->
781			<xsl:apply-templates select="$doc//section[@id=$anchor]" mode="embedded"/>
782		</xsl:when>
783		<xsl:when test="$doc//paragraph[@id=$anchor]"> <!-- then test for a para of that name -->
784			<p class="embedded">
785				<xsl:apply-templates select="$doc//paragraph[@id=$anchor]" mode="embedded"/>
786			</p>
787		</xsl:when>
788		<xsl:when test="$doc//variable[@id=$anchor]"> <!-- then test for a variable of that name -->
789			<p class="embedded">
790				<xsl:apply-templates select="$doc//variable[@id=$anchor]" mode="embedded"/>
791			</p>
792		</xsl:when>
793		<xsl:otherwise> <!-- then give up -->
794			<p class="bug">D'oh! You found a bug (<xsl:value-of select="@href"/> not found).</p>
795		</xsl:otherwise>
796	</xsl:choose>
797</xsl:template>
798
799<!-- Insert an image -->
800<xsl:template name="insertimage">
801
802	<xsl:variable name="fpath">
803		<xsl:call-template name="getfpath">
804			<xsl:with-param name="s"><xsl:value-of select="@src"/></xsl:with-param>
805		</xsl:call-template>
806	</xsl:variable>
807
808	<xsl:variable name="fname">
809		<xsl:call-template name="getfname">
810			<xsl:with-param name="s"><xsl:value-of select="@src"/></xsl:with-param>
811		</xsl:call-template>
812	</xsl:variable>
813
814	<xsl:variable name="src">
815		<xsl:choose>
816			<xsl:when test="not($ExtensionId='') and starts-with(@src,$ExtensionId)">
817				<xsl:value-of select="concat($ExtensionPath,'/',@src)"/>
818			</xsl:when>
819			<xsl:otherwise>
820				<xsl:choose>
821					<xsl:when test="(@localize='true') and not($lang='en-US')">
822						<xsl:value-of select="concat($img_url_prefix,$fpath,$lang,'/',$fname)"/>
823					</xsl:when>
824					<xsl:otherwise>
825						<xsl:value-of select="concat($img_url_prefix,$fpath,$fname)"/>
826					</xsl:otherwise>
827				</xsl:choose>
828			</xsl:otherwise>
829		</xsl:choose>
830	</xsl:variable>
831
832	<!--<xsl:variable name="src"><xsl:value-of select="concat($img_url_prefix,@src)"/></xsl:variable>-->
833	<xsl:variable name="alt"><xsl:value-of select="./alt"/></xsl:variable>
834	<xsl:variable name="width" select="''"/> <!-- Images don't all have the correct size -->
835	<xsl:variable name="height" select="''"/><!-- Image don't all have the correct size -->
836	<img src="{$src}" alt="{$alt}" title="{$alt}">
837		<xsl:if test="not($width='')"><xsl:attribute name="width"><xsl:value-of select="$width"/></xsl:attribute></xsl:if>
838		<xsl:if test="not($height='')"><xsl:attribute name="height"><xsl:value-of select="$height"/></xsl:attribute></xsl:if>
839	</img>
840</xsl:template>
841
842<!-- Insert a Table -->
843<xsl:template name="inserttable">
844	<xsl:variable name="imgsrc">	<!-- see if we are in an image table -->
845		<xsl:value-of select="tablerow/tablecell[1]/paragraph[1]/image/@src"/>
846	</xsl:variable>
847
848	<xsl:choose>
849
850		<xsl:when test="count(descendant::tablecell)=1">
851			<table border="0" class="onecell" cellpadding="0" cellspacing="0">
852				<xsl:apply-templates />
853		 </table>
854		</xsl:when>
855
856		<xsl:when test="descendant::tablecell[1]/descendant::image">
857			<table border="0" class="icontable" cellpadding="5" cellspacing="0">
858				<xsl:apply-templates mode="icontable"/>
859		 </table>
860		</xsl:when>
861
862		<xsl:when test="@class='wide'">
863			<table border="1" class="{@class}" cellpadding="0" cellspacing="0" width="100%" >
864				<xsl:apply-templates />
865		 </table>
866		</xsl:when>
867
868		<xsl:when test="not(@class='')">
869			<table border="1" class="{@class}" cellpadding="0" cellspacing="0" >
870				<xsl:apply-templates />
871		 </table>
872		</xsl:when>
873
874		<xsl:otherwise>
875			<table border="1" class="border" cellpadding="0" cellspacing="0" >
876				<xsl:apply-templates />
877		 </table>
878		</xsl:otherwise>
879	</xsl:choose>
880
881	<br/>
882</xsl:template>
883
884<xsl:template name="resolveembed">
885	<div class="embedded">
886		<xsl:variable name="archive"><xsl:value-of select="concat(substring-before(substring-after(@href,'text/'),'/'),'/')"/></xsl:variable>
887		<xsl:variable name="dbpostfix"><xsl:call-template name="createDBpostfix"><xsl:with-param name="archive" select="$archive"/></xsl:call-template></xsl:variable>
888		<xsl:variable name="href"><xsl:value-of select="concat($urlpre,$archive,substring-before(@href,'#'),$urlpost,$dbpostfix)"/></xsl:variable>
889		<xsl:variable name="anc"><xsl:value-of select="substring-after(@href,'#')"/></xsl:variable>
890		<xsl:variable name="docum" select="document($href)"/>
891
892		<xsl:call-template name="insertembed">
893			<xsl:with-param name="doc" select="$docum" />
894			<xsl:with-param name="anchor" select="$anc" />
895		</xsl:call-template>
896
897	</div>
898</xsl:template>
899
900<xsl:template name="resolveembedvar">
901	<xsl:if test="not(@href='text/shared/00/00000004.xhp#wie')"> <!-- special treatment if howtoget links -->
902		<xsl:variable name="archive"><xsl:value-of select="concat(substring-before(substring-after(@href,'text/'),'/'),'/')"/></xsl:variable>
903		<xsl:variable name="dbpostfix"><xsl:call-template name="createDBpostfix"><xsl:with-param name="archive" select="$archive"/></xsl:call-template></xsl:variable>
904		<xsl:variable name="href"><xsl:value-of select="concat($urlpre,$archive,substring-before(@href,'#'),$urlpost,$dbpostfix)"/></xsl:variable>
905		<xsl:variable name="anchor"><xsl:value-of select="substring-after(@href,'#')"/></xsl:variable>
906		<xsl:variable name="doc" select="document($href)"/>
907		<xsl:choose>
908			<xsl:when test="$doc//variable[@id=$anchor]"> <!-- test for a variable of that name -->
909				<xsl:apply-templates select="$doc//variable[@id=$anchor]" mode="embedded"/>
910			</xsl:when>
911			<xsl:otherwise> <!-- or give up -->
912				<span class="bug">[<xsl:value-of select="@href"/> not found].</span>
913			</xsl:otherwise>
914		</xsl:choose>
915	</xsl:if>
916</xsl:template>
917
918<!-- Apply -->
919<xsl:template name="apply">
920	<xsl:param name="embedded" />
921	<xsl:choose>
922		<xsl:when test="$embedded = 'yes'">
923			<xsl:apply-templates mode="embedded"/>
924		</xsl:when>
925		<xsl:otherwise>
926			<xsl:apply-templates />
927		</xsl:otherwise>
928	</xsl:choose>
929</xsl:template>
930
931<xsl:template name="getfpath">
932	<xsl:param name="s"/>
933	<xsl:param name="p"/>
934	<xsl:choose>
935		<xsl:when test="contains($s,'/')">
936			<xsl:call-template name="getfpath">
937				<xsl:with-param name="p"><xsl:value-of select="concat($p,substring-before($s,'/'),'/')"/></xsl:with-param>
938				<xsl:with-param name="s"><xsl:value-of select="substring-after($s,'/')"/></xsl:with-param>
939			</xsl:call-template>
940		</xsl:when>
941		<xsl:otherwise>
942			<xsl:value-of select="$p"/>
943		</xsl:otherwise>
944	</xsl:choose>
945</xsl:template>
946
947<xsl:template name="getfname">
948	<xsl:param name="s"/>
949	<xsl:choose>
950		<xsl:when test="contains($s,'/')">
951			<xsl:call-template name="getfname">
952				<xsl:with-param name="s"><xsl:value-of select="substring-after($s,'/')"/></xsl:with-param>
953			</xsl:call-template>
954		</xsl:when>
955		<xsl:otherwise>
956			<xsl:value-of select="$s"/>
957		</xsl:otherwise>
958	</xsl:choose>
959</xsl:template>
960
961<xsl:template name="createDBpostfix">
962	<xsl:param name="archive"/>
963	<xsl:variable name="newDB">
964		<xsl:choose>
965			<xsl:when test="(substring($archive,1,6) = 'shared')"><xsl:value-of select="$Database"/></xsl:when>
966			<xsl:otherwise><xsl:value-of select="substring-before($archive,'/')"/></xsl:otherwise>
967		</xsl:choose>
968	</xsl:variable>
969	<xsl:value-of select="concat($am,'DbPAR=',$newDB)"/>
970</xsl:template>
971
972</xsl:stylesheet>
973