1 | <!--
|
---|
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 |
|
---|
6 | (C) Copyright Shawn McKenzie, 2007. All Rights Reserved.
|
---|
7 | *-->
|
---|
8 | <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
---|
9 |
|
---|
10 | <xsl:template name="gethref">
|
---|
11 | <xsl:param name="ditahref"/>
|
---|
12 |
|
---|
13 | <xsl:if test="@scope='external' and @format='html'">
|
---|
14 | <xsl:value-of select="@href"/>
|
---|
15 | </xsl:if>
|
---|
16 |
|
---|
17 |
|
---|
18 | <xsl:if test="not(@scope='external')">
|
---|
19 | <xsl:if test="contains($ditahref, '#')">
|
---|
20 | <xsl:call-template name="swapext">
|
---|
21 | <xsl:with-param name="newhref" select="substring-before($ditahref, '#')"/>
|
---|
22 | </xsl:call-template>
|
---|
23 | </xsl:if>
|
---|
24 |
|
---|
25 | <xsl:if test="not(contains($ditahref, '#'))">
|
---|
26 | <xsl:call-template name="swapext">
|
---|
27 | <xsl:with-param name="newhref" select="$ditahref"/>
|
---|
28 | </xsl:call-template>
|
---|
29 | </xsl:if>
|
---|
30 | </xsl:if>
|
---|
31 |
|
---|
32 | </xsl:template>
|
---|
33 |
|
---|
34 |
|
---|
35 | <xsl:template name="swapext">
|
---|
36 | <xsl:param name="newhref"/>
|
---|
37 |
|
---|
38 | <xsl:if test="substring($newhref, string-length($newhref) - string-length('.xml') +1) = '.xml'">
|
---|
39 | <xsl:value-of select="concat(substring-before($newhref, '.xml'), '.html')"/>
|
---|
40 | </xsl:if>
|
---|
41 | <xsl:if
|
---|
42 | test="substring($newhref, string-length($newhref) - string-length('.dita') +1) =
|
---|
43 | '.dita'">
|
---|
44 | <xsl:value-of select="concat(substring-before($newhref, '.dita'), '.html')"/>
|
---|
45 | </xsl:if>
|
---|
46 |
|
---|
47 | </xsl:template>
|
---|
48 |
|
---|
49 |
|
---|
50 | </xsl:stylesheet>
|
---|