| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!--
- Copyright © 2004-2005 by Idiom Technologies, Inc. All rights reserved.
- IDIOM is a registered trademark of Idiom Technologies, Inc. and WORLDSERVER
- and WORLDSTART are trademarks of Idiom Technologies, Inc. All other
- trademarks are the property of their respective owners.
- IDIOM TECHNOLOGIES, INC. IS DELIVERING THE SOFTWARE "AS IS," WITH
- ABSOLUTELY NO WARRANTIES WHATSOEVER, WHETHER EXPRESS OR IMPLIED, AND IDIOM
- TECHNOLOGIES, INC. DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- PURPOSE AND WARRANTY OF NON-INFRINGEMENT. IDIOM TECHNOLOGIES, INC. SHALL NOT
- BE LIABLE FOR INDIRECT, INCIDENTAL, SPECIAL, COVER, PUNITIVE, EXEMPLARY,
- RELIANCE, OR CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT LIMITED TO LOSS OF
- ANTICIPATED PROFIT), ARISING FROM ANY CAUSE UNDER OR RELATED TO OR ARISING
- OUT OF THE USE OF OR INABILITY TO USE THE SOFTWARE, EVEN IF IDIOM
- TECHNOLOGIES, INC. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- Idiom Technologies, Inc. and its licensors shall not be liable for any
- damages suffered by any person as a result of using and/or modifying the
- Software or its derivatives. In no event shall Idiom Technologies, Inc.'s
- liability for any damages hereunder exceed the amounts received by Idiom
- Technologies, Inc. as a result of this transaction.
- These terms and conditions supersede the terms and conditions in any
- licensing agreement to the extent that such terms and conditions conflict
- with those set forth herein.
- This file is part of the DITA Open Toolkit project.
- See the accompanying license.txt file for applicable licenses.
- -->
- <!-- An adaptation of the Toolkit topicmerge.xsl for FO plugin use. -->
- <xsl:stylesheet version="2.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:ot-placeholder="http://suite-sol.com/namespaces/ot-placeholder"
- xmlns:dita-ot="http://dita-ot.sourceforge.net/ns/201007/dita-ot"
- exclude-result-prefixes="xs dita-ot">
- <xsl:import href="plugin:org.dita.base:xsl/common/dita-utilities.xsl"/>
- <xsl:import href="plugin:org.dita.base:xsl/common/output-message.xsl"/>
- <!-- Deprecated since 2.3 -->
- <xsl:variable name="msgprefix" select="'PDFX'"/>
- <xsl:output indent="no"/>
- <xsl:key name="topic" match="dita-merge/*[contains(@class,' topic/topic ')]" use="concat('#',@id)"/>
- <xsl:key name="topic" match="dita-merge/dita" use="concat('#',*[contains(@class, ' topic/topic ')][1]/@id)"/>
- <xsl:key name="topicref" match="//*[contains(@class,' map/topicref ')]" use="generate-id()"/>
- <!--
- <xsl:template match="/">
- <xsl:copy-of select="."/>
- </xsl:template>
- -->
- <xsl:template match="dita-merge">
- <xsl:variable name="map" select="(*[contains(@class,' map/map ')])[1]"/>
- <xsl:element name="{name($map)}">
- <xsl:copy-of select="$map/@*"/>
- <xsl:apply-templates select="$map" mode="build-tree"/>
- </xsl:element>
- </xsl:template>
- <xsl:template match="dita-merge/*[contains(@class,' map/map ')]" mode="build-tree">
- <opentopic:map xmlns:opentopic="http://www.idiominc.com/opentopic">
- <xsl:apply-templates/>
- </opentopic:map>
- <xsl:apply-templates mode="build-tree"/>
- </xsl:template>
- <xsl:template match="*[contains(@class,' map/topicref ')]" mode="build-tree">
- <xsl:choose>
- <xsl:when test="not(normalize-space(@first_topic_id) = '')">
- <xsl:apply-templates select="key('topic',@first_topic_id)">
- <xsl:with-param name="parentId" select="generate-id()"/>
- </xsl:apply-templates>
- <xsl:if test="@first_topic_id != @href">
- <xsl:apply-templates select="key('topic',@href)">
- <xsl:with-param name="parentId" select="generate-id()"/>
- </xsl:apply-templates>
- </xsl:if>
- </xsl:when>
- <xsl:when test="not(normalize-space(@href) = '')">
- <xsl:apply-templates select="key('topic',@href)">
- <xsl:with-param name="parentId" select="generate-id()"/>
- </xsl:apply-templates>
- </xsl:when>
- <xsl:when test="contains(@class, ' bookmap/part ') or
- (normalize-space(@navtitle) != '' or *[contains(@class,' map/topicmeta ')]/*[contains(@class,' topic/navtitle ')])">
- <xsl:variable name="isNotTopicRef" as="xs:boolean">
- <xsl:call-template name="isNotTopicRef"/>
- </xsl:variable>
- <xsl:if test="not($isNotTopicRef)">
- <topic id="{generate-id()}" class="+ topic/topic pdf2-d/placeholder ">
- <title class="- topic/title ">
- <xsl:choose>
- <xsl:when test="*[contains(@class,' map/topicmeta ')]/*[contains(@class,' topic/navtitle ')]">
- <xsl:copy-of select="*[contains(@class,' map/topicmeta ')]/*[contains(@class,' topic/navtitle ')]/node()"/>
- </xsl:when>
- <xsl:when test="@navtitle">
- <xsl:value-of select="@navtitle"/>
- </xsl:when>
- </xsl:choose>
- </title>
- <!--body class=" topic/body "/-->
- <xsl:apply-templates mode="build-tree"/>
- </topic>
- </xsl:if>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates mode="build-tree"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- <xsl:template match="*[@print = 'no']" priority="5" mode="build-tree"/>
- <xsl:template match="*[contains(@class,' bookmap/backmatter ')] |
- *[contains(@class,' bookmap/booklists ')] |
- *[contains(@class,' bookmap/frontmatter ')]" priority="2" mode="build-tree">
- <xsl:apply-templates mode="build-tree"/>
- </xsl:template>
- <xsl:template match="*[contains(@class,' bookmap/toc ')][not(@href)]" priority="2" mode="build-tree">
- <ot-placeholder:toc id="{generate-id()}">
- <xsl:apply-templates mode="build-tree"/>
- </ot-placeholder:toc>
- </xsl:template>
-
- <xsl:template match="*[contains(@class,' bookmap/indexlist ')][not(@href)]" priority="2" mode="build-tree">
- <ot-placeholder:indexlist id="{generate-id()}">
- <xsl:apply-templates mode="build-tree"/>
- </ot-placeholder:indexlist>
- </xsl:template>
-
- <xsl:template match="*[contains(@class,' bookmap/glossarylist ')][not(@href)]" priority="2" mode="build-tree">
- <ot-placeholder:glossarylist id="{generate-id()}">
- <xsl:apply-templates mode="build-tree"/>
- </ot-placeholder:glossarylist>
- </xsl:template>
-
- <xsl:template match="*[contains(@class,' bookmap/tablelist ')][not(@href)]" priority="2" mode="build-tree">
- <ot-placeholder:tablelist id="{generate-id()}">
- <xsl:apply-templates mode="build-tree"/>
- </ot-placeholder:tablelist>
- </xsl:template>
-
- <xsl:template match="*[contains(@class,' bookmap/figurelist ')][not(@href)]" priority="2" mode="build-tree">
- <ot-placeholder:figurelist id="{generate-id()}">
- <xsl:apply-templates mode="build-tree"/>
- </ot-placeholder:figurelist>
- </xsl:template>
- <xsl:template match="*[contains(@class, ' map/topicref ') and @print='no']" priority="6"/>
- <xsl:template match="*[contains(@class,' topic/topic ')] | dita-merge/dita">
- <xsl:param name="parentId"/>
- <xsl:variable name="idcount">
- <!--for-each is used to change context. There's only one entry with a key of $parentId-->
- <xsl:for-each select="key('topicref',$parentId)">
- <xsl:value-of select="count(preceding::*[@href = current()/@href][not(ancestor::*[contains(@class, ' map/reltable ')])]) + count(ancestor::*[@href = current()/@href])"/>
- </xsl:for-each>
- </xsl:variable>
- <xsl:copy>
- <xsl:apply-templates select="@*[name() != 'id']"/>
- <xsl:variable name="new_id">
- <xsl:choose>
- <xsl:when test="number($idcount) > 0">
- <xsl:value-of select="concat(@id,'_ssol',$idcount)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="@id"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:attribute name="id">
- <xsl:value-of select="$new_id"/>
- </xsl:attribute>
- <xsl:apply-templates>
- <xsl:with-param name="newid" select="$new_id"/>
- </xsl:apply-templates>
- <xsl:apply-templates select="key('topicref',$parentId)/*" mode="build-tree"/>
- </xsl:copy>
- </xsl:template>
-
- <!-- Linkless topicref or topichead -->
- <xsl:template match="*[contains(@class,' map/topicref ')][not(@href)]" priority="5">
- <xsl:param name="newid"/>
- <xsl:copy>
- <xsl:attribute name="id">
- <xsl:value-of select="generate-id()"/>
- </xsl:attribute>
- <xsl:apply-templates select="@*">
- <xsl:with-param name="newid" select="$newid"/>
- </xsl:apply-templates>
- <xsl:apply-templates select="*|text()|processing-instruction()">
- <xsl:with-param name="newid" select="$newid"/>
- </xsl:apply-templates>
- </xsl:copy>
- </xsl:template>
-
- <xsl:template match="*[contains(@class,' map/topicref ')]/@id" priority="5"/>
- <xsl:template match="@href">
- <xsl:param name="newid"/>
- <xsl:variable name="topic-id" select="dita-ot:get-topic-id(.)" as="xs:string?"/>
- <xsl:variable name="element-id" select="dita-ot:get-element-id(.)" as="xs:string?"/>
-
- <xsl:attribute name="href">
- <xsl:choose>
- <xsl:when test="empty($element-id) or not(starts-with(., '#unique'))">
- <xsl:value-of select="."/>
- </xsl:when>
- <xsl:when test="ancestor::*[contains(@class, ' topic/topic ')][1]/@id = $topic-id">
- <xsl:text>#</xsl:text>
- <xsl:value-of select="$newid"/>
- <xsl:text>/</xsl:text>
- <xsl:value-of select="$newid"/>
- <xsl:text>_Connect_42_</xsl:text>
- <xsl:value-of select="$element-id"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="concat('#',$topic-id,'/',$topic-id,'_Connect_42_',$element-id)"/>
- </xsl:otherwise>
- </xsl:choose>
-
-
- </xsl:attribute>
- </xsl:template>
- <xsl:template match="*[contains(@class,' map/topicref ')]/@href">
- <xsl:copy-of select="."/>
- <xsl:attribute name="id">
- <xsl:variable name="fragmentId" select="substring-after(.,'#')"/>
- <xsl:variable name="idcount" select="count(../preceding::*[@href = current()][not(ancestor::*[contains(@class, ' map/reltable ')])]) + count(../ancestor::*[@href = current()])"/>
- <xsl:choose>
- <xsl:when test="$idcount > 0">
- <xsl:value-of select="concat($fragmentId,'_ssol',$idcount)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$fragmentId"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:attribute>
- </xsl:template>
- <xsl:template match="*" mode="build-tree" priority="-1">
- <xsl:apply-templates mode="build-tree"/>
- </xsl:template>
- <xsl:template match="text()" mode="build-tree" priority="-1"/>
- <xsl:template match="*" priority="-1">
- <xsl:param name="newid"/>
- <xsl:copy>
- <xsl:apply-templates select="@*">
- <xsl:with-param name="newid" select="$newid"/>
- </xsl:apply-templates>
- <xsl:apply-templates select="*|text()|processing-instruction()">
- <xsl:with-param name="newid" select="$newid"/>
- </xsl:apply-templates>
- </xsl:copy>
- </xsl:template>
- <xsl:template match="@*" priority="-1">
- <xsl:copy-of select="."/>
- </xsl:template>
- <xsl:template match="processing-instruction()" priority="-1">
- <xsl:copy-of select="."/>
- </xsl:template>
- <xsl:key name="duplicate-id"
- match="*[not(contains(@class, ' topic/topic '))]/@id"
- use="concat(ancestor::*[contains(@class, ' topic/topic ')][1]/@id, '|', .)"/>
- <xsl:template match="@id[not(parent::*[contains(@class, ' topic/topic ')])]">
- <xsl:param name="newid"/>
- <xsl:attribute name="id">
- <xsl:value-of select="$newid"/>
- <xsl:text>_Connect_42_</xsl:text>
- <xsl:value-of select="."/>
- <xsl:variable name="current-id" select="concat(ancestor::*[contains(@class, ' topic/topic ')][1]/@id, '|', .)"/>
- <xsl:if test="not(generate-id(.) = generate-id(key('duplicate-id', $current-id)[1]))">
- <xsl:text>_</xsl:text>
- <xsl:value-of select="generate-id()"/>
- </xsl:if>
- </xsl:attribute>
- </xsl:template>
- <xsl:template name="isNotTopicRef" as="xs:boolean">
- <xsl:param name="class" select="@class"/>
- <xsl:sequence select="contains($class,' bookmap/abbrevlist ')
- or contains($class,' bookmap/amendments ')
- or contains($class,' bookmap/bookabstract ')
- or contains($class,' bookmap/booklist ')
- or contains($class,' bookmap/colophon ')
- or contains($class,' bookmap/dedication ')
- or contains($class,' bookmap/tablelist ')
- or contains($class,' bookmap/trademarklist ')
- or contains($class,' bookmap/figurelist ')"/>
- </xsl:template>
- <xsl:template match="*[contains(@class, ' map/reltable ')]" mode="build-tree"/>
- </xsl:stylesheet>
|