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