Changeset b1a51ac1 for stylesheets/lfs-xsl/docbook-xsl-1.78.1/fo/xref.xsl
- Timestamp:
- 12/10/2013 11:37:38 PM (11 years ago)
- Branches:
- 7.5-systemd, 7.6-systemd, 7.7-systemd, 7.8-systemd, 7.9-systemd
- Children:
- 112db9d
- Parents:
- f2a5108
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
stylesheets/lfs-xsl/docbook-xsl-1.78.1/fo/xref.xsl
rf2a5108 rb1a51ac1 4 4 xmlns:exsl="http://exslt.org/common" 5 5 xmlns:xlink='http://www.w3.org/1999/xlink' 6 exclude-result-prefixes="exsl "6 exclude-result-prefixes="exsl xlink" 7 7 version='1.0'> 8 8 9 9 <!-- ******************************************************************** 10 $Id $10 $Id: xref.xsl 9723 2013-02-06 13:08:06Z kosek $ 11 11 ******************************************************************** 12 12 … … 27 27 <xsl:call-template name="object.id"/> 28 28 </xsl:variable> 29 <fo:inline id="{$id}"/> 29 30 <xsl:variable name="wrapper.name"> 31 <xsl:call-template name="inline.or.block"/> 32 </xsl:variable> 33 34 <xsl:element name="{$wrapper.name}"> 35 <xsl:attribute name="id"> 36 <xsl:value-of select="$id"/> 37 </xsl:attribute> 38 </xsl:element> 30 39 </xsl:template> 31 40 … … 134 143 and ( $insert.xref.page.number = 'yes' 135 144 or $insert.xref.page.number = '1') 136 or local-name($target) = 'para'"> 145 or (local-name($target) = 'para' and 146 $xrefstyle = '')"> 137 147 <xsl:apply-templates select="$target" mode="page.citation"> 138 148 <xsl:with-param name="id" select="$target/@id|$target/@xml:id"/> … … 233 243 234 244 <xsl:choose> 235 <xsl:when test=" function-available('exsl:node-set')">245 <xsl:when test="$exsl.node.set.available != 0"> 236 246 <xsl:apply-templates select="exsl:node-set($endterm)" mode="remove-ids"/> 237 247 </xsl:when> … … 309 319 |itemizedlist|legalnotice|lot|msg|msgexplan|msgmain 310 320 |msgrel|msgset|msgsub|note|orderedlist|partintro 311 |productionset|qandadiv|refsynopsisdiv|s egmentedlist321 |productionset|qandadiv|refsynopsisdiv|screenshot|segmentedlist 312 322 |set|setindex|sidebar|tip|toc|variablelist|warning" 313 323 mode="xref-to"> … … 396 406 </xsl:template> 397 407 398 <xsl:template match="dedication| preface|chapter|appendix" mode="xref-to">408 <xsl:template match="dedication|acknowledgements|preface|chapter|appendix" mode="xref-to"> 399 409 <xsl:param name="referrer"/> 400 410 <xsl:param name="xrefstyle"/> … … 516 526 </xsl:template> 517 527 518 <xsl:template match="glossterm " mode="xref-to">528 <xsl:template match="glossterm|firstterm" mode="xref-to"> 519 529 <xsl:apply-templates/> 520 530 </xsl:template> … … 562 572 </xsl:template> 563 573 564 <xsl:template match=" bridgehead" mode="xref-to">574 <xsl:template match="topic" mode="xref-to"> 565 575 <xsl:param name="referrer"/> 566 576 <xsl:param name="xrefstyle"/> … … 573 583 <xsl:with-param name="verbose" select="$verbose"/> 574 584 </xsl:apply-templates> 575 <!-- What about "in Chapter X"? --> 576 </xsl:template> 577 578 <xsl:template match="qandaset" mode="xref-to"> 585 </xsl:template> 586 587 <xsl:template match="bridgehead" mode="xref-to"> 579 588 <xsl:param name="referrer"/> 580 589 <xsl:param name="xrefstyle"/> … … 587 596 <xsl:with-param name="verbose" select="$verbose"/> 588 597 </xsl:apply-templates> 589 </xsl:template> 590 591 <xsl:template match="qandadiv" mode="xref-to"> 598 <!-- What about "in Chapter X"? --> 599 </xsl:template> 600 601 <xsl:template match="qandaset" mode="xref-to"> 592 602 <xsl:param name="referrer"/> 593 603 <xsl:param name="xrefstyle"/> … … 602 612 </xsl:template> 603 613 604 <xsl:template match="qandaentry" mode="xref-to"> 605 <xsl:param name="referrer"/> 606 <xsl:param name="xrefstyle"/> 607 <xsl:param name="verbose" select="1"/> 608 609 <xsl:apply-templates select="question[1]" mode="object.xref.markup"> 610 <xsl:with-param name="purpose" select="'xref'"/> 611 <xsl:with-param name="xrefstyle" select="$xrefstyle"/> 612 <xsl:with-param name="referrer" select="$referrer"/> 613 <xsl:with-param name="verbose" select="$verbose"/> 614 </xsl:apply-templates> 615 </xsl:template> 616 617 <xsl:template match="question|answer" mode="xref-to"> 614 <xsl:template match="qandadiv" mode="xref-to"> 618 615 <xsl:param name="referrer"/> 619 616 <xsl:param name="xrefstyle"/> … … 626 623 <xsl:with-param name="verbose" select="$verbose"/> 627 624 </xsl:apply-templates> 625 </xsl:template> 626 627 <xsl:template match="qandaentry" mode="xref-to"> 628 <xsl:param name="referrer"/> 629 <xsl:param name="xrefstyle"/> 630 <xsl:param name="verbose" select="1"/> 631 632 <xsl:apply-templates select="question[1]" mode="xref-to"> 633 <xsl:with-param name="xrefstyle" select="$xrefstyle"/> 634 <xsl:with-param name="referrer" select="$referrer"/> 635 <xsl:with-param name="verbose" select="$verbose"/> 636 </xsl:apply-templates> 637 </xsl:template> 638 639 <xsl:template match="question|answer" mode="xref-to"> 640 <xsl:param name="referrer"/> 641 <xsl:param name="xrefstyle"/> 642 <xsl:param name="verbose" select="1"/> 643 644 <xsl:choose> 645 <xsl:when test="string-length(label) != 0"> 646 <xsl:apply-templates select="." mode="label.markup"/> 647 </xsl:when> 648 <xsl:otherwise> 649 <xsl:apply-templates select="." mode="object.xref.markup"> 650 <xsl:with-param name="purpose" select="'xref'"/> 651 <xsl:with-param name="xrefstyle" select="$xrefstyle"/> 652 <xsl:with-param name="referrer" select="$referrer"/> 653 <xsl:with-param name="verbose" select="$verbose"/> 654 </xsl:apply-templates> 655 </xsl:otherwise> 656 </xsl:choose> 628 657 </xsl:template> 629 658 … … 743 772 </xsl:template> 744 773 745 <xsl:template match="para" mode="xref-to"> 774 <!-- These are elements for which no link text exists, so an xref to one 775 uses the xrefstyle attribute if specified, or if not it falls back 776 to the container element's link text --> 777 <xsl:template match="para|phrase|simpara|anchor|quote" mode="xref-to"> 746 778 <xsl:param name="referrer"/> 747 779 <xsl:param name="xrefstyle"/> … … 755 787 |ancestor::sect4 756 788 |ancestor::sect5 789 |ancestor::topic 757 790 |ancestor::refsection 758 791 |ancestor::refsect1 … … 764 797 |ancestor::partintro 765 798 |ancestor::dedication 799 |ancestor::acknowledgements 766 800 |ancestor::colophon 767 801 |ancestor::bibliography … … 772 806 |ancestor::varlistentry)[last()]"/> 773 807 774 <xsl:apply-templates select="$context" mode="xref-to"> 775 <xsl:with-param name="xrefstyle" select="$xrefstyle"/> 776 <xsl:with-param name="referrer" select="$referrer"/> 777 <xsl:with-param name="verbose" select="$verbose"/> 778 </xsl:apply-templates> 808 <xsl:choose> 809 <xsl:when test="$xrefstyle != ''"> 810 <xsl:apply-templates select="." mode="object.xref.markup"> 811 <xsl:with-param name="xrefstyle" select="$xrefstyle"/> 812 <xsl:with-param name="referrer" select="$referrer"/> 813 <xsl:with-param name="verbose" select="$verbose"/> 814 </xsl:apply-templates> 815 </xsl:when> 816 <xsl:otherwise> 817 <xsl:if test="$verbose != 0"> 818 <xsl:message> 819 <xsl:text>WARNING: xref to <</xsl:text> 820 <xsl:value-of select="local-name()"/> 821 <xsl:text> id="</xsl:text> 822 <xsl:value-of select="@id|@xml:id"/> 823 <xsl:text>"> has no generated text. Trying its ancestor elements.</xsl:text> 824 </xsl:message> 825 </xsl:if> 826 <xsl:apply-templates select="$context" mode="xref-to"> 827 <xsl:with-param name="xrefstyle" select="$xrefstyle"/> 828 <xsl:with-param name="referrer" select="$referrer"/> 829 <xsl:with-param name="verbose" select="$verbose"/> 830 </xsl:apply-templates> 831 </xsl:otherwise> 832 </xsl:choose> 833 </xsl:template> 834 835 <xsl:template match="indexterm" mode="xref-to"> 836 <xsl:value-of select="primary"/> 837 </xsl:template> 838 839 <xsl:template match="primary|secondary|tertiary" mode="xref-to"> 840 <xsl:value-of select="."/> 779 841 </xsl:template> 780 842 … … 825 887 <!-- Use the xlink:href if no other text --> 826 888 <xsl:when test="@xlink:href"> 827 <xsl:value-of select="@xlink:href"/> 889 <fo:inline hyphenate="false"> 890 <xsl:call-template name="hyphenate-url"> 891 <xsl:with-param name="url" select="@xlink:href"/> 892 </xsl:call-template> 893 </fo:inline> 828 894 </xsl:when> 829 895 <xsl:otherwise> … … 881 947 external-destination="{$ulink.url}"> 882 948 <xsl:choose> 883 <xsl:when test="count(child::node())=0"> 884 <xsl:call-template name="hyphenate-url"> 885 <xsl:with-param name="url" select="$url"/> 886 </xsl:call-template> 949 <xsl:when test="count(child::node())=0 or (string(.) = $url)"> 950 <fo:inline hyphenate="false"> 951 <xsl:call-template name="hyphenate-url"> 952 <xsl:with-param name="url" select="$url"/> 953 </xsl:call-template> 954 </fo:inline> 887 955 </xsl:when> 888 956 <xsl:otherwise> … … 891 959 </xsl:choose> 892 960 </fo:basic-link> 961 <!-- * Call the template for determining whether the URL for this --> 962 <!-- * hyperlink is displayed, and how to display it (either inline or --> 963 <!-- * as a numbered footnote). --> 964 <xsl:call-template name="hyperlink.url.display"> 965 <xsl:with-param name="url" select="$url"/> 966 <xsl:with-param name="ulink.url" select="$ulink.url"/> 967 </xsl:call-template> 968 </xsl:template> 969 970 <xsl:template name="hyperlink.url.display"> 971 <!-- * This template is called for all external hyperlinks (ulinks and --> 972 <!-- * for all simple xlinks); it determines whether the URL for the --> 973 <!-- * hyperlink is displayed, and how to display it (either inline or --> 974 <!-- * as a numbered footnote). --> 975 <xsl:param name="url"/> 976 <xsl:param name="ulink.url"> 977 <!-- * ulink.url is just the value of the URL wrapped in 'url(...)' --> 978 <xsl:call-template name="fo-external-image"> 979 <xsl:with-param name="filename" select="$url"/> 980 </xsl:call-template> 981 </xsl:param> 893 982 894 983 <xsl:if test="count(child::node()) != 0 895 984 and string(.) != $url 896 985 and $ulink.show != 0"> 897 <!-- yes, show the URI --> 986 <!-- * Display the URL for this hyperlink only if it is non-empty, --> 987 <!-- * and the value of its content is not a URL that is the same as --> 988 <!-- * URL it links to, and if ulink.show is non-zero. --> 898 989 <xsl:choose> 899 <xsl:when test="$ulink.footnotes != 0 and not(ancestor::footnote)"> 990 <xsl:when test="$ulink.footnotes != 0 and not(ancestor::footnote) and not(ancestor::*[@floatstyle='before'])"> 991 <!-- * ulink.show and ulink.footnote are both non-zero; that --> 992 <!-- * means we display the URL as a footnote (instead of inline) --> 900 993 <fo:footnote> 901 994 <xsl:call-template name="ulink.footnote.number"/> … … 912 1005 </xsl:when> 913 1006 <xsl:otherwise> 1007 <!-- * ulink.show is non-zero, but ulink.footnote is not; that --> 1008 <!-- * means we display the URL inline --> 914 1009 <fo:inline hyphenate="false"> 1010 <!-- * put square brackets around the URL --> 915 1011 <xsl:text> [</xsl:text> 916 1012 <fo:basic-link external-destination="{$ulink.url}"> … … 938 1034 </xsl:choose> 939 1035 <xsl:variable name="fnum"> 1036 <!-- * Determine the footnote number to display for this hyperlink, --> 1037 <!-- * by counting all foonotes, ulinks, and any elements that have --> 1038 <!-- * an xlink:href attribute that meets the following criteria: --> 1039 <!-- * --> 1040 <!-- * - the content of the element is not a URI that is the same --> 1041 <!-- * URI as the value of the href attribute --> 1042 <!-- * - the href attribute is not an internal ID reference (does --> 1043 <!-- * not start with a hash sign) --> 1044 <!-- * - the href is not part of an olink reference (the element --> 1045 <!-- * - does not have an xlink:role attribute that indicates it is --> 1046 <!-- * an olink, and the href does not contain a hash sign) --> 1047 <!-- * - the element either has no xlink:type attribute or has --> 1048 <!-- * an xlink:type attribute whose value is 'simple' --> 940 1049 <!-- FIXME: list in @from is probably not complete --> 941 1050 <xsl:number level="any" 942 from="chapter|appendix|preface|article|refentry|bibliography[not(parent::article)]" 943 count="footnote[not(@label)][not(ancestor::tgroup)]|ulink[node()][@url != .][not(ancestor::footnote)]" 1051 from="chapter|appendix|preface|article|refentry|bibliography[not(parent::article)]" 1052 count="footnote[not(@label)][not(ancestor::tgroup)] 1053 |ulink[node()][@url != .][not(ancestor::footnote)] 1054 |*[node()][@xlink:href][not(@xlink:href = .)][not(starts-with(@xlink:href,'#'))] 1055 [not(contains(@xlink:href,'#') and @xlink:role = $xolink.role)] 1056 [not(@xlink:type) or @xlink:type='simple'] 1057 [not(ancestor::footnote)]" 944 1058 format="1"/> 945 1059 </xsl:variable> … … 984 1098 <!-- olink content may be passed in from xlink olink --> 985 1099 <xsl:param name="content" select="NOTANELEMENT"/> 986 987 <xsl:call-template name="anchor"/>988 989 <xsl:variable name="localinfo" select="@localinfo"/>990 1100 991 1101 <xsl:choose> … … 1082 1192 <xsl:variable name="hottext"> 1083 1193 <xsl:choose> 1084 <xsl:when test=" $content">1194 <xsl:when test="string-length($content) != 0"> 1085 1195 <xsl:copy-of select="$content"/> 1086 1196 </xsl:when> … … 1116 1226 <fo:basic-link internal-destination="{$linkend}" 1117 1227 xsl:use-attribute-sets="xref.properties"> 1228 <xsl:call-template name="anchor"/> 1118 1229 <xsl:copy-of select="$hottext"/> 1119 1230 <xsl:copy-of select="$olink.page.citation"/> … … 1122 1233 <xsl:when test="$href != ''"> 1123 1234 <xsl:choose> 1235 <xsl:when test="$fop1.extensions != 0"> 1236 <xsl:variable name="mybeg" select="substring-before($href,'#')"/> 1237 <xsl:variable name="myend" select="substring-after($href,'#')"/> 1238 <fo:basic-link external-destination="url({concat($mybeg,'#dest=',$myend)})" 1239 xsl:use-attribute-sets="olink.properties"> 1240 <xsl:copy-of select="$hottext"/> 1241 </fo:basic-link> 1242 <xsl:copy-of select="$olink.page.citation"/> 1243 <xsl:copy-of select="$olink.docname.citation"/> 1244 </xsl:when> 1124 1245 <xsl:when test="$xep.extensions != 0"> 1125 1246 <fo:basic-link external-destination="url({$href})" 1126 1247 xsl:use-attribute-sets="olink.properties"> 1248 <xsl:call-template name="anchor"/> 1127 1249 <xsl:copy-of select="$hottext"/> 1128 1250 </fo:basic-link> … … 1194 1316 <xsl:for-each select="$target.database" > 1195 1317 <xsl:value-of 1196 select="key('targetptr-key', $olink.key) /@lang" />1318 select="key('targetptr-key', $olink.key)[1]/@lang" /> 1197 1319 </xsl:for-each> 1198 1320 </xsl:variable> … … 1219 1341 1220 1342 1221 <xsl:template name="olink.outline">1222 <xsl:param name="outline.base.uri"/>1223 <xsl:param name="localinfo"/>1224 <xsl:param name="return" select="href"/>1225 1226 <xsl:message terminate="yes">Fatal error: olink.outline template: what is this supposed to do?</xsl:message>1227 </xsl:template>1228 1229 1343 <!-- ==================================================================== --> 1230 1344 … … 1237 1351 or local-name($target) = 'table' 1238 1352 or local-name($target) = 'dedication' 1353 or local-name($target) = 'acknowledgements' 1239 1354 or local-name($target) = 'preface' 1240 1355 or local-name($target) = 'bibliography' … … 1317 1432 1318 1433 <xsl:choose> 1319 <!-- FIXME: what about the case where titleabbrev is inside the info? --> 1320 <xsl:when test="$purpose = 'xref' and titleabbrev"> 1321 <xsl:apply-templates select="." mode="titleabbrev.markup"/> 1434 <xsl:when test="$purpose = 'xref'"> 1435 <xsl:copy-of select="$title"/> 1322 1436 </xsl:when> 1323 1437 <xsl:otherwise>
Note:
See TracChangeset
for help on using the changeset viewer.