| 1 |
<?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- --> |
| 2 |
<!-- |
| 3 |
This program is free software; you can redistribute it and/or modify it under |
| 4 |
the terms of the GNU Lesser General Public License as published by the Free |
| 5 |
Software Foundation; either version 2 of the License, or (at your option) any |
| 6 |
later version. |
| 7 |
|
| 8 |
This program is distributed in the hope that it will be useful, but WITHOUT |
| 9 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 10 |
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
| 11 |
details. |
| 12 |
|
| 13 |
You should have received a copy of the GNU Lesser General Public License |
| 14 |
along with this program; see the file COPYING.LGPL. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
--> |
| 16 |
<!DOCTYPE xsl:stylesheet [ |
| 17 |
<!ENTITY % selectors SYSTEM "dita-selectors.mod"> |
| 18 |
%selectors; |
| 19 |
]> |
| 20 |
|
| 21 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 22 |
xmlns:exsl="http://exslt.org/common" |
| 23 |
xmlns:str="http://exslt.org/strings" |
| 24 |
exclude-result-prefixes="exsl str" |
| 25 |
version="1.0"> |
| 26 |
|
| 27 |
<!--!!========================================================================== |
| 28 |
DITA Maps |
| 29 |
|
| 30 |
REMARK: Describe this module |
| 31 |
--> |
| 32 |
|
| 33 |
|
| 34 |
<xsl:param name="dita.map.base" select="/"/> |
| 35 |
|
| 36 |
<xsl:variable name="_dita.map"> |
| 37 |
<xsl:apply-templates mode="dita.map.copy.mode" select="/&map_map;"/> |
| 38 |
</xsl:variable> |
| 39 |
<xsl:param name="dita.map" select="exsl:node-set($_dita.map)"/> |
| 40 |
|
| 41 |
<xsl:template mode="dita.map.copy.mode" match="*"> |
| 42 |
<xsl:param name="base"/> |
| 43 |
<xsl:copy> |
| 44 |
<xsl:copy-of select="@*"/> |
| 45 |
<xsl:apply-templates mode="dita.map.copy.mode"> |
| 46 |
<xsl:with-param name="base" select="$base"/> |
| 47 |
</xsl:apply-templates> |
| 48 |
</xsl:copy> |
| 49 |
</xsl:template> |
| 50 |
|
| 51 |
<xsl:template mode="dita.map.copy.mode" match="&map_topicref;"> |
| 52 |
<xsl:param name="base"/> |
| 53 |
<xsl:variable name="uri"> |
| 54 |
<xsl:choose> |
| 55 |
<xsl:when test="contains(@href, ':') or starts-with(@href, '/')"> |
| 56 |
<xsl:value-of select="@href"/> |
| 57 |
</xsl:when> |
| 58 |
<xsl:otherwise> |
| 59 |
<xsl:value-of select="$base"/> |
| 60 |
<xsl:value-of select="@href"/> |
| 61 |
</xsl:otherwise> |
| 62 |
</xsl:choose> |
| 63 |
</xsl:variable> |
| 64 |
<xsl:choose> |
| 65 |
<!-- FIXME: conref and keyref --> |
| 66 |
<xsl:when test="@href and @format = 'ditamap'"> |
| 67 |
<xsl:apply-templates mode="dita.map.copy.mode" |
| 68 |
select="document($uri, $dita.map.base)/*/*[not(self::&topic_title_all;)]"> |
| 69 |
<xsl:with-param name="base"> |
| 70 |
<xsl:variable name="_base"> |
| 71 |
<xsl:if test="contains($uri, '/')"> |
| 72 |
<xsl:for-each select="str:split($uri, '/')"> |
| 73 |
<xsl:if test="position() != last()"> |
| 74 |
<xsl:value-of select="."/> |
| 75 |
<xsl:text>/</xsl:text> |
| 76 |
</xsl:if> |
| 77 |
</xsl:for-each> |
| 78 |
</xsl:if> |
| 79 |
</xsl:variable> |
| 80 |
<xsl:value-of select="$_base"/> |
| 81 |
</xsl:with-param> |
| 82 |
</xsl:apply-templates> |
| 83 |
</xsl:when> |
| 84 |
<xsl:otherwise> |
| 85 |
<xsl:copy> |
| 86 |
<xsl:copy-of select="@*[name(.) != 'href']"/> |
| 87 |
<xsl:if test="@href"> |
| 88 |
<xsl:attribute name="href"> |
| 89 |
<xsl:value-of select="$uri"/> |
| 90 |
</xsl:attribute> |
| 91 |
</xsl:if> |
| 92 |
<xsl:apply-templates mode="dita.map.copy.mode"> |
| 93 |
<xsl:with-param name="base" select="$base"/> |
| 94 |
</xsl:apply-templates> |
| 95 |
</xsl:copy> |
| 96 |
</xsl:otherwise> |
| 97 |
</xsl:choose> |
| 98 |
</xsl:template> |
| 99 |
|
| 100 |
</xsl:stylesheet> |