| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- This file is part of the DITA Open Toolkit project hosted on
- Sourceforge.net. See the accompanying license.txt file for
- applicable licenses.-->
- <!-- (c) Copyright IBM Corp. 2006 All Rights Reserved. -->
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
- version="2.0"
- xmlns:dita-ot="http://dita-ot.sourceforge.net/ns/201007/dita-ot"
- xmlns:mappull="http://dita-ot.sourceforge.net/ns/200704/mappull"
- xmlns:ditamsg="http://dita-ot.sourceforge.net/ns/200704/ditamsg"
- exclude-result-prefixes="xs dita-ot mappull ditamsg">
- <xsl:import href="../common/dita-utilities.xsl"/>
- <xsl:import href="../common/output-message.xsl"/>
- <!-- Deprecated since 2.3 -->
- <xsl:variable name="msgprefix">DOTX</xsl:variable>
- <xsl:param name="file-being-processed" as="xs:string"/>
- <xsl:param name="child-topicref-warning" as="xs:string" select="'true'"/>
- <!-- list of attributes that can be overidden. -->
- <xsl:variable name="special-atts" select="('href', 'copy-to', 'class', 'linking', 'toc', 'print', 'audience', 'product', 'platform', 'otherprops', 'props')" as="xs:string*"/>
- <!-- the xsl:key to get all maprefs in the document in order to get reltable -->
- <xsl:key name="reltable" match="//*[contains(@class, ' map/topicref ')]" use="@format"/>
- <xsl:key name="reltable" match="//*[contains(@class, ' map/topicref ')]" use="@dita-ot:orig-format"/>
- <xsl:template match="@* | node()">
- <xsl:copy>
- <xsl:apply-templates select="@* | node()"/>
- </xsl:copy>
- </xsl:template>
- <xsl:template match="*[contains(@class, ' map/topicref ')][(@format, @dita-ot:orig-format) = 'ditamap']
- [empty(@href(: | @dita-ot:orig-href:)) or
- (:@processing-role = 'resource-only' or:)
- @scope = ('peer', 'external')]" priority="15">
- <xsl:copy>
- <xsl:apply-templates select="@* | node()"/>
- </xsl:copy>
- </xsl:template>
- <xsl:template match="*[contains(@class, ' map/topicref ')][(@format, @dita-ot:orig-format) = 'ditamap']" priority="10">
- <xsl:param name="refclass" select="(@dita-ot:orig-class, @class)[1]" as="xs:string"/>
- <xsl:param name="relative-path" as="xs:string">#none#</xsl:param>
- <xsl:param name="mapref-id-path" as="xs:string*"/>
- <xsl:param name="referTypeFlag" as="xs:string">#none#</xsl:param>
-
- <xsl:variable name="href" select="(@href, @dita-ot:orig-href)[1]" as="xs:string?"/>
- <xsl:choose>
- <xsl:when test="generate-id(.) = $mapref-id-path">
- <!-- it is mapref but it didn't pass the loop dependency check -->
- <xsl:call-template name="output-message">
- <xsl:with-param name="id" select="'DOTX053E'"/>
- <xsl:with-param name="msgparams">%1=<xsl:value-of select="$href"/></xsl:with-param>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable name="updated-id-path" select="($mapref-id-path, generate-id(.))" as="xs:string*"/>
- <xsl:variable name="file" as="document-node()?">
- <xsl:variable name="fileurl" as="xs:string?">
- <xsl:variable name="WORKDIR" as="xs:string">
- <xsl:apply-templates select="/processing-instruction('workdir-uri')[1]" mode="get-work-dir"/>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="empty($href)"/>
- <xsl:when test="contains($href, '://')">
- <xsl:value-of select="$href"/>
- </xsl:when>
- <xsl:when test="starts-with($href, '#')">
- <xsl:value-of select="concat($WORKDIR, $file-being-processed)"/>
- </xsl:when>
- <xsl:when test="contains($href, '#')">
- <xsl:value-of select="concat($WORKDIR, substring-before($href, '#'))"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="concat($WORKDIR, $href)"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:if test="exists($fileurl)">
- <xsl:sequence select="document($fileurl, /)"/>
- </xsl:if>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="empty($file)">
- <xsl:variable name="filename" as="xs:string?">
- <xsl:choose>
- <xsl:when test="empty($href)"/>
- <!-- resolve the file name, if the @href contains :// then don't do anything -->
- <xsl:when test="contains($href,'://')">
- <xsl:value-of select="$href"/>
- </xsl:when>
- <xsl:when test="starts-with($href,'#')">
- <xsl:value-of select="$file-being-processed"/>
- </xsl:when>
- <!-- if @href contains # get the part before # -->
- <xsl:when test="contains($href,'#')">
- <xsl:value-of select="substring-before($href,'#')"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$href"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:call-template name="output-message">
- <xsl:with-param name="id" select="'DOTX031E'"/>
- <xsl:with-param name="msgparams">%1=<xsl:value-of select="$filename"/></xsl:with-param>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable name="element-id" as="xs:string?">
- <xsl:if test="contains($href, '#')">
- <xsl:value-of select="substring-after($href, '#')"/>
- </xsl:if>
- </xsl:variable>
- <xsl:variable name="target" as="element()?">
- <xsl:choose>
- <xsl:when test="exists($element-id)">
- <xsl:sequence select="$file//*[@id = $element-id]"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:sequence select="$file/*"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="contents" as="node()*">
- <xsl:choose>
- <xsl:when test="not(contains($href,'://') or empty($element-id) or $file/*[contains(@class,' map/map ')][@id = $element-id])">
- <xsl:sequence select="$file//*[contains(@class,' map/topicref ')][@id = $element-id]"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:sequence select="$file/*/*[contains(@class,' map/topicref ')] |
- $file/*/processing-instruction()"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <!-- retain key definition as a separate element -->
- <xsl:if test="@keys">
- <keydef class="+ map/topicref mapgroup-d/keydef ditaot-d/keydef " processing-role="resource-only">
- <xsl:apply-templates select="@* except (@class | @processing-role)"/>
- <xsl:apply-templates select="*[contains(@class, ' map/topicmeta ')]"/>
- </keydef>
- </xsl:if>
- <!-- href and format need to be retained for keyref processing but must be put to an internal namespace to prevent other modules to interact with this element -->
- <submap class="+ map/topicref mapgroup-d/topicgroup ditaot-d/submap "
- dita-ot:orig-href="{$href}"
- dita-ot:orig-format="{(@format, @dita-ot:orig-format)[1]}"
- dita-ot:orig-class="{(@class, @dita-ot:orig-class)[1]}">
- <xsl:attribute name="dita-ot:orig-href">
- <xsl:if test="not($relative-path = ('#none#', ''))">
- <xsl:value-of select="$relative-path"/>
- </xsl:if>
- <xsl:value-of select="$href"/>
- </xsl:attribute>
- <xsl:if test="@keyscope | $target[@keyscope and contains(@class, ' map/map ')]">
- <xsl:attribute name="keyscope">
- <xsl:variable name="keyscope">
- <xsl:value-of select="@keyscope"/>
- <xsl:text> </xsl:text>
- <xsl:value-of select="$target[contains(@class, ' map/map ')]/@keyscope"/>
- </xsl:variable>
- <xsl:value-of select="normalize-space($keyscope)"/>
- </xsl:attribute>
- </xsl:if>
- <xsl:apply-templates select="@* except (@class, @href, @dita-ot:orig-href, @format, @dita-ot:orig-format, @keys, @keyscope, @type)"/>
- <xsl:apply-templates select="*[contains(@class, ' ditavalref-d/ditavalref ')]"/>
- <xsl:apply-templates select="$contents">
- <xsl:with-param name="refclass" select="$refclass"/>
- <xsl:with-param name="mapref-id-path" select="$updated-id-path"/>
- <xsl:with-param name="relative-path">
- <xsl:choose>
- <xsl:when test="not($relative-path = ('#none#', ''))">
- <xsl:value-of select="$relative-path"/>
- <xsl:call-template name="find-relative-path">
- <xsl:with-param name="remainingpath" select="$href"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="find-relative-path">
- <xsl:with-param name="remainingpath" select="$href"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:with-param>
- <xsl:with-param name="referTypeFlag" select="'element'"/>
- </xsl:apply-templates>
- </submap>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:if test="$child-topicref-warning = 'true' and *[contains(@class, ' map/topicref ')]
- [not(contains(@class, ' ditavalref-d/ditavalref '))]">
- <xsl:call-template name="output-message">
- <xsl:with-param name="id" select="'DOTX068W'"/>
- </xsl:call-template>
- </xsl:if>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template match="*[contains(@class, ' map/topicref ')]" priority="5">
- <xsl:param name="refclass" select="@class"/>
- <xsl:param name="relative-path" as="xs:string">#none#</xsl:param>
- <xsl:param name="mapref-id-path" as="xs:string*"/>
- <xsl:param name="referTypeFlag" as="xs:string">#none#</xsl:param>
- <xsl:copy>
- <xsl:for-each select="@href | @copy-to">
- <xsl:choose>
- <xsl:when test=". = ''"/>
- <xsl:when test="$relative-path = '#none#' or contains(.,'://')">
- <xsl:attribute name="{name()}">
- <xsl:value-of select="."/>
- </xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="{name()}">
- <xsl:value-of select="dita-ot:normalize-uri(concat($relative-path, .))"/>
- </xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:for-each>
- <xsl:attribute name="class">
- <xsl:choose>
- <xsl:when test="contains($refclass, ' mapgroup-d/mapref ')">
- <xsl:value-of select="@class"/>
- </xsl:when>
- <!-- if the element is not at the top level of reference target, @class equals to $refclass -->
- <xsl:when test="not(contains(@class, substring($refclass, 3)))">
- <xsl:value-of select="$refclass"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="@class"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- <!-- linking and following attributes processed in the same way -->
- <xsl:call-template name="generate-attribute">
- <xsl:with-param name="referTypeFlag" select="$referTypeFlag"/>
- <xsl:with-param name="name" select="'linking'"/>
- </xsl:call-template>
- <xsl:call-template name="generate-attribute">
- <xsl:with-param name="referTypeFlag" select="$referTypeFlag"/>
- <xsl:with-param name="name" select="'toc'"/>
- </xsl:call-template>
- <xsl:call-template name="generate-attribute">
- <xsl:with-param name="referTypeFlag" select="$referTypeFlag"/>
- <xsl:with-param name="name" select="'print'"/>
- </xsl:call-template>
- <xsl:call-template name="generate-attribute">
- <xsl:with-param name="referTypeFlag" select="$referTypeFlag"/>
- <xsl:with-param name="name" select="'audience'"/>
- </xsl:call-template>
- <xsl:call-template name="generate-attribute">
- <xsl:with-param name="referTypeFlag" select="$referTypeFlag"/>
- <xsl:with-param name="name" select="'product'"/>
- </xsl:call-template>
- <xsl:call-template name="generate-attribute">
- <xsl:with-param name="referTypeFlag" select="$referTypeFlag"/>
- <xsl:with-param name="name" select="'platform'"/>
- </xsl:call-template>
- <xsl:call-template name="generate-attribute">
- <xsl:with-param name="referTypeFlag" select="$referTypeFlag"/>
- <xsl:with-param name="name" select="'otherprops'"/>
- </xsl:call-template>
- <xsl:call-template name="generate-attribute">
- <xsl:with-param name="referTypeFlag" select="$referTypeFlag"/>
- <xsl:with-param name="name" select="'props'"/>
- </xsl:call-template>
- <xsl:call-template name="generate-attribute">
- <xsl:with-param name="referTypeFlag" select="$referTypeFlag"/>
- <xsl:with-param name="name" select="'processing-role'"/>
- </xsl:call-template>
- <xsl:call-template name="generate-attribute">
- <xsl:with-param name="referTypeFlag" select="$referTypeFlag"/>
- <xsl:with-param name="name" select="'importance'"/>
- </xsl:call-template>
- <xsl:call-template name="generate-attribute">
- <xsl:with-param name="referTypeFlag" select="$referTypeFlag"/>
- <xsl:with-param name="name" select="'search'"/>
- </xsl:call-template>
- <xsl:call-template name="generate-attribute">
- <xsl:with-param name="referTypeFlag" select="$referTypeFlag"/>
- <xsl:with-param name="name" select="'rev'"/>
- </xsl:call-template>
- <xsl:apply-templates select="@*[not(local-name() = $special-atts)] | node()">
- <xsl:with-param name="relative-path" select="$relative-path"/>
- <!-- pass the relative-path to sub elements -->
- <xsl:with-param name="mapref-id-path" select="$mapref-id-path"/>
- <!-- pass the mapref-id-path to sub elements -->
- </xsl:apply-templates>
- </xsl:copy>
- </xsl:template>
-
- <xsl:template name="generate-attribute">
- <xsl:param name="referTypeFlag" as="xs:string">#none#</xsl:param>
- <xsl:param name="name"/>
-
- <xsl:choose>
- <!-- refer to an element in map file -->
- <xsl:when test="$referTypeFlag = 'element'">
- <xsl:copy-of select="ancestor-or-self::*[@*[local-name() = $name]][1]/@*[local-name() = $name]"/>
- </xsl:when>
- <!-- for sub element -->
- <xsl:otherwise>
- <xsl:copy-of select="@*[local-name() = $name]"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="*[contains(@class,' map/map ')]">
- <xsl:copy>
- <xsl:apply-templates select="@* | node()"/>
- <xsl:call-template name="gen-reltable"/>
- </xsl:copy>
- </xsl:template>
- <xsl:template name="gen-reltable">
- <xsl:param name="relative-path" as="xs:string">#none#</xsl:param>
- <xsl:param name="mapref-id-path" as="xs:string*"/>
- <xsl:apply-templates select="key('reltable','ditamap')" mode="mapref">
- <xsl:with-param name="relative-path" select="$relative-path"/>
- <xsl:with-param name="mapref-id-path" select="$mapref-id-path"/>
- </xsl:apply-templates>
- </xsl:template>
-
- <xsl:template match="*[contains(@class,' map/topicref ')]" mode="mapref">
- <xsl:param name="relative-path" as="xs:string">#none#</xsl:param>
- <xsl:param name="mapref-id-path" as="xs:string*"/>
- <xsl:variable name="linking" as="xs:string?">
- <xsl:choose>
- <xsl:when test="empty(@linking)">
- <xsl:call-template name="inherit">
- <xsl:with-param name="attrib">linking</xsl:with-param>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="@linking"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="generate-id(.) = $mapref-id-path">
- <xsl:call-template name="output-message">
- <xsl:with-param name="id" select="'DOTX053E'"/>
- <xsl:with-param name="msgparams">%1=<xsl:value-of select="@href"/></xsl:with-param>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="not($linking='none') and @href and not(contains(@href,'#'))">
- <xsl:variable name="update-id-path" select="($mapref-id-path, generate-id(.))"/>
- <xsl:variable name="href" select="@href" as="xs:string?"/>
- <xsl:apply-templates select="document($href, /)/*[contains(@class,' map/map ')]" mode="mapref">
- <xsl:with-param name="relative-path">
- <xsl:choose>
- <xsl:when test="not($relative-path = '#none#' or $relative-path='')">
- <xsl:value-of select="$relative-path"/>
- <xsl:call-template name="find-relative-path">
- <xsl:with-param name="remainingpath" select="@href"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="find-relative-path">
- <xsl:with-param name="remainingpath" select="@href"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:with-param>
- <xsl:with-param name="mapref-id-path" select="$update-id-path"/>
- </xsl:apply-templates>
- </xsl:when>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template match="*[contains(@class,' map/map ')]" mode="mapref">
- <xsl:param name="relative-path" as="xs:string">#none#</xsl:param>
- <xsl:param name="mapref-id-path" as="xs:string*"/>
- <xsl:apply-templates select="*[contains(@class,' map/reltable ')]" mode="reltable-copy">
- <xsl:with-param name="relative-path" select="$relative-path" tunnel="yes"/>
- </xsl:apply-templates>
- <!--xsl:copy-of select="*[contains(@class,' map/reltable ')]"/-->
- <xsl:call-template name="gen-reltable">
- <xsl:with-param name="relative-path" select="$relative-path"/>
- <xsl:with-param name="mapref-id-path" select="$mapref-id-path"/>
- </xsl:call-template>
- </xsl:template>
- <xsl:template match="@* | node()" mode="reltable-copy">
- <xsl:copy>
- <xsl:apply-templates select="@* | node()" mode="reltable-copy"/>
- </xsl:copy>
- </xsl:template>
- <xsl:template match="@href | @copy-to" mode="reltable-copy">
- <xsl:param name="relative-path" as="xs:string" tunnel="yes">#none#</xsl:param>
- <xsl:attribute name="{name()}">
- <xsl:choose>
- <xsl:when test="not(contains(.,'://') or ../@scope = 'external' or $relative-path = ('#none#', ''))">
- <xsl:value-of select="dita-ot:normalize-uri(concat($relative-path, .))"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="."/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:template>
- <!-- RDA: FUNCTIONS TO IMPROVE OVERRIDE CAPABILITIES FOR INHERITING ATTRIBUTES -->
- <!-- Original function: processing moved to matching templates with mode="mappull:inherit-attribute"
- Result is the same as in original code: if the attribute is present or inherited, return
- the inherited value; if it is not available in the ancestor-or-self tree, return #none# -->
- <xsl:template name="inherit">
- <xsl:param name="attrib"/>
- <xsl:apply-templates select="." mode="mappull:inherit-from-self-then-ancestor">
- <xsl:with-param name="attrib" select="$attrib"/>
- </xsl:apply-templates>
- </xsl:template>
- <!-- Similar to the template above, but saves duplicated processing by setting the
- inherited attribute when the inherited value != #none# -->
- <xsl:template match="*" mode="mappull:inherit-and-set-attribute">
- <xsl:param name="attrib"/>
- <xsl:variable name="inherited-value">
- <xsl:apply-templates select="." mode="mappull:inherit-from-self-then-ancestor">
- <xsl:with-param name="attrib" select="$attrib"/>
- </xsl:apply-templates>
- </xsl:variable>
- <xsl:if test="$inherited-value!='#none#'">
- <xsl:attribute name="{$attrib}">
- <xsl:value-of select="$inherited-value"/>
- </xsl:attribute>
- </xsl:if>
- </xsl:template>
- <!-- Same as above, but for @format only. Allows us to warn if the inherited value seems wrong. -->
- <xsl:template match="*" mode="mappull:inherit-and-set-format-attribute">
- <xsl:variable name="inherited-value">
- <xsl:apply-templates select="." mode="mappull:inherit-from-self-then-ancestor">
- <xsl:with-param name="attrib" select="'format'"/>
- </xsl:apply-templates>
- </xsl:variable>
- <xsl:if test="$inherited-value!='#none#'">
- <xsl:attribute name="format">
- <xsl:value-of select="$inherited-value"/>
- </xsl:attribute>
- </xsl:if>
- </xsl:template>
- <!-- Match the attribute which we are trying to inherit.
- If an attribute should never inherit, add this template to an override:
- <xsl:template match="@attributeName" mode="mappull:inherit-attribute"/>
- If an attribute should never inherit for a specific element, add this to an override:
- <xsl:template match="*[contains(@class,' spec/elem ')]/@attributeName" mode="mappull:inherit-attribute"/> -->
- <xsl:template match="@*" mode="mappull:inherit-attribute">
- <xsl:value-of select="."/>
- </xsl:template>
- <!-- Some elements should not pass an attribute to children, but they SHOULD set the
- attribute locally. If it is specified locally, use it. Otherwise, go to parent. This
- template should ONLY be called from the actual element that is trying to set attributes.
- For example, when <specialGroup format="group"> should keep @format locally, but should
- never pass that value to children. -->
- <xsl:template match="*" mode="mappull:inherit-from-self-then-ancestor">
- <xsl:param name="attrib"/>
- <xsl:variable name="attrib-here">
- <xsl:if test="@*[local-name()=$attrib]">
- <xsl:value-of select="@*[local-name()=$attrib]"/>
- </xsl:if>
- </xsl:variable>
- <xsl:choose>
- <!-- Any time the attribute is specified on this element, use it -->
- <xsl:when test="$attrib-here!=''">
- <xsl:value-of select="$attrib-here"/>
- </xsl:when>
- <!-- Otherwise, use normal inheritance fallback -->
- <xsl:otherwise>
- <xsl:apply-templates select="." mode="mappull:inherit-attribute">
- <xsl:with-param name="attrib" select="$attrib"/>
- </xsl:apply-templates>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <!-- Match an element when trying to inherit an attribute. Put the value of the attribute in $attrib-here.
- * If the attribute is present and should be used ($attrib=here!=''), then use it
- * If we are at the root element, attribute can't be inherited, so return #none#
- * If in relcell: try to inherit from self, row, or column, then move to table
- * Anything else, move on to parent -->
- <xsl:template match="*" mode="mappull:inherit-attribute">
- <!--@importance|@linking|@toc|@print|@search|@format|@scope-->
- <xsl:param name="attrib"/>
- <xsl:variable name="attrib-here">
- <xsl:apply-templates select="@*[local-name()=$attrib]" mode="mappull:inherit-attribute"/>
- </xsl:variable>
- <xsl:choose>
- <!-- Any time the attribute is specified on this element, use it -->
- <xsl:when test="$attrib-here!=''">
- <xsl:value-of select="$attrib-here"/>
- </xsl:when>
- <!-- If this is not the first time thru the map, all attributes are already inherited, so do not check ancestors -->
- <xsl:when test="/processing-instruction('reparse')">#none#</xsl:when>
- <!-- No ancestors left to check, so the value is not available. -->
- <xsl:when test="not(parent::*)">#none#</xsl:when>
- <!-- When in a relcell, check inheritance in this order: row, then colspec,
- then proceed normally with the table. The value is not specified here on the entry,
- or it would have been caught in the first xsl:when test. -->
- <xsl:when test="contains(@class,' map/relcell ')">
- <xsl:variable name="position" select="1+count(preceding-sibling::*)"/>
- <xsl:variable name="row">
- <xsl:apply-templates select=".." mode="mappull:inherit-one-level">
- <xsl:with-param name="attrib" select="$attrib"/>
- </xsl:apply-templates>
- </xsl:variable>
- <xsl:variable name="colspec">
- <xsl:apply-templates select="ancestor::*[contains(@class, ' map/reltable ')]/*[contains(@class, ' map/relheader ')]/*[contains(@class, ' map/relcolspec ')][position()=$position ]"
- mode="mappull:inherit-one-level">
- <xsl:with-param name="attrib" select="$attrib"/>
- </xsl:apply-templates>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="$row!=''">
- <xsl:value-of select="$row"/>
- </xsl:when>
- <xsl:when test="$colspec!=''">
- <xsl:value-of select="$colspec"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates select="ancestor::*[contains(@class, ' map/reltable ')]" mode="mappull:inherit-attribute">
- <xsl:with-param name="attrib" select="$attrib"/>
- </xsl:apply-templates>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates select="parent::*" mode="mappull:inherit-attribute">
- <xsl:with-param name="attrib" select="$attrib"/>
- </xsl:apply-templates>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <!-- Check if an attribute can be inherited from a specific element, without
- looking at ancestors. For example, check if can inherit from relrow; next
- comes relcolspec, which is not in the normal inheritance order. -->
- <xsl:template match="*" mode="mappull:inherit-one-level">
- <xsl:param name="attrib"/>
- <xsl:if test="@*[local-name()=$attrib]">
- <xsl:value-of select="@*[local-name()=$attrib]"/>
- </xsl:if>
- </xsl:template>
- <!-- RDA: END FUNCTIONS TO IMPROVE OVERRIDE CAPABILITIES FOR INHERITING ATTRIBUTES -->
- <!-- Find the relative path to another topic or map -->
- <xsl:template name="find-relative-path">
- <xsl:param name="remainingpath"/>
- <xsl:if test="contains($remainingpath,'/')">
- <xsl:value-of select="substring-before($remainingpath,'/')"/>
- <xsl:text>/</xsl:text>
- <xsl:call-template name="find-relative-path">
- <xsl:with-param name="remainingpath" select="substring-after($remainingpath,'/')"/>
- </xsl:call-template>
- </xsl:if>
- </xsl:template>
- </xsl:stylesheet>
|