Changeset 00b1e11 in clfs-embedded for BOOK/stylesheets/lfs-xsl/docbook-xsl-snapshot/xhtml/chunk-common.xsl
- Timestamp:
- Jul 21, 2007, 8:07:11 AM (17 years ago)
- Branches:
- master
- Children:
- a6966fa
- Parents:
- 3ca2208
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BOOK/stylesheets/lfs-xsl/docbook-xsl-snapshot/xhtml/chunk-common.xsl
r3ca2208 r00b1e11 738 738 <xsl:param name="context" select="."/> 739 739 <xsl:param name="object" select="."/> 740 740 <xsl:param name="toc-context" select="."/> 741 <!-- * If $toc-context contains some node other than the current node, --> 742 <!-- * it means we're processing a link in a TOC. In that case, to --> 743 <!-- * ensure the link will work correctly, we need to take a look at --> 744 <!-- * where the file containing the TOC will get written, and where --> 745 <!-- * the file that's being linked to will get written. --> 746 <xsl:variable name="toc-output-dir"> 747 <xsl:if test="not($toc-context = .)"> 748 <!-- * Get the $toc-context node and all its ancestors, look down --> 749 <!-- * through them to find the last/closest node to the --> 750 <!-- * toc-context node that has a "dbhtml dir" PI, and get the --> 751 <!-- * directory name from that. That's the name of the directory --> 752 <!-- * to which the current toc output file will get written. --> 753 <xsl:call-template name="dbhtml-dir"> 754 <xsl:with-param name="context" select="$toc-context/ancestor-or-self::*[processing-instruction('dbhtml')[contains(.,'dir')]][last()]"/> 755 </xsl:call-template> 756 </xsl:if> 757 </xsl:variable> 758 <xsl:variable name="linked-file-output-dir"> 759 <xsl:if test="not($toc-context = .)"> 760 <!-- * Get the current node and all its ancestors, look down --> 761 <!-- * through them to find the last/closest node to the current --> 762 <!-- * node that has a "dbhtml dir" PI, and get the directory name --> 763 <!-- * from that. That's the name of the directory to which the --> 764 <!-- * file that's being linked to will get written. --> 765 <xsl:call-template name="dbhtml-dir"> 766 <xsl:with-param name="context" select="ancestor-or-self::*[processing-instruction('dbhtml')[contains(.,'dir')]][last()]"/> 767 </xsl:call-template> 768 </xsl:if> 769 </xsl:variable> 741 770 <xsl:variable name="href.to.uri"> 742 771 <xsl:call-template name="href.target.uri"> … … 744 773 </xsl:call-template> 745 774 </xsl:variable> 746 747 775 <xsl:variable name="href.from.uri"> 748 776 <xsl:call-template name="href.target.uri"> … … 750 778 </xsl:call-template> 751 779 </xsl:variable> 752 753 <!-- 754 <xsl:message>href.to.uri: <xsl:value-of select="$href.to.uri"/></xsl:message> 755 <xsl:message>href.from.uri: <xsl:value-of select="$href.from.uri"/></xsl:message> 756 --> 757 780 <!-- * <xsl:message>toc-context: <xsl:value-of select="local-name($toc-context)"/></xsl:message> --> 781 <!-- * <xsl:message>node: <xsl:value-of select="local-name(.)"/></xsl:message> --> 782 <!-- * <xsl:message>context: <xsl:value-of select="local-name($context)"/></xsl:message> --> 783 <!-- * <xsl:message>object: <xsl:value-of select="local-name($object)"/></xsl:message> --> 784 <!-- * <xsl:message>toc-output-dir: <xsl:value-of select="$toc-output-dir"/></xsl:message> --> 785 <!-- * <xsl:message>linked-file-output-dir: <xsl:value-of select="$linked-file-output-dir"/></xsl:message> --> 786 <!-- * <xsl:message>href.to.uri: <xsl:value-of select="$href.to.uri"/></xsl:message> --> 787 <!-- * <xsl:message>href.from.uri: <xsl:value-of select="$href.from.uri"/></xsl:message> --> 758 788 <xsl:variable name="href.to"> 759 <xsl:call-template name="trim.common.uri.paths"> 760 <xsl:with-param name="uriA" select="$href.to.uri"/> 761 <xsl:with-param name="uriB" select="$href.from.uri"/> 762 <xsl:with-param name="return" select="'A'"/> 763 </xsl:call-template> 764 </xsl:variable> 765 789 <xsl:choose> 790 <!-- * 2007-07-19, MikeSmith: Added the following conditional to --> 791 <!-- * deal with a problem case for links in TOCs. It checks to see --> 792 <!-- * if the output dir that a TOC will get written to is --> 793 <!-- * different from the output dir of the file being linked to. --> 794 <!-- * If it is different, we do not call trim.common.uri.paths. --> 795 <!-- * --> 796 <!-- * Reason why I added that conditional is: I ran into a bug for --> 797 <!-- * this case: --> 798 <!-- * --> 799 <!-- * 1. we are chunking into separate dirs --> 800 <!-- * --> 801 <!-- * 2. output for the TOC is written to current dir, but the file --> 802 <!-- * being linked to is written to some subdir "foo". --> 803 <!-- * --> 804 <!-- * For that case, links to that file in that TOC did not show --> 805 <!-- * the correct path - they omitted the "foo". --> 806 <!-- * --> 807 <!-- * The cause of that problem was that the trim.common.uri.paths --> 808 <!-- * template[1] was being called under all conditions. But it's --> 809 <!-- * apparent that we don't want to call trim.common.uri.paths in --> 810 <!-- * the case where a linked file is being written to a different --> 811 <!-- * directory than the TOC that contains the link, because doing --> 812 <!-- * so will cause a necessary (not redundant) directory-name --> 813 <!-- * part of the link to get inadvertently trimmed, resulting in --> 814 <!-- * a broken link to that file. Thus, added the conditional. --> 815 <!-- * --> 816 <!-- * [1] The purpose of the trim.common.uri.paths template is to --> 817 <!-- * prevent cases where, if we didn't call it, we end up with --> 818 <!-- * unnecessary, redundant directory names getting output; for --> 819 <!-- * example, "foo/foo/refname.html". --> 820 <xsl:when test="not($toc-output-dir = $linked-file-output-dir)"> 821 <xsl:value-of select="$href.to.uri"/> 822 </xsl:when> 823 <xsl:otherwise> 824 <xsl:call-template name="trim.common.uri.paths"> 825 <xsl:with-param name="uriA" select="$href.to.uri"/> 826 <xsl:with-param name="uriB" select="$href.from.uri"/> 827 <xsl:with-param name="return" select="'A'"/> 828 </xsl:call-template> 829 </xsl:otherwise> 830 </xsl:choose> 831 </xsl:variable> 766 832 <xsl:variable name="href.from"> 767 833 <xsl:call-template name="trim.common.uri.paths"> … … 771 837 </xsl:call-template> 772 838 </xsl:variable> 773 774 839 <xsl:variable name="depth"> 775 840 <xsl:call-template name="count.uri.path.depth"> … … 777 842 </xsl:call-template> 778 843 </xsl:variable> 779 780 844 <xsl:variable name="href"> 781 845 <xsl:call-template name="copy-string"> … … 785 849 <xsl:value-of select="$href.to"/> 786 850 </xsl:variable> 787 788 851 <!-- 789 852 <xsl:message> … … 800 863 </xsl:message> 801 864 --> 802 803 865 <xsl:value-of select="$href"/> 804 866 </xsl:template> … … 1445 1507 </xsl:template> 1446 1508 1509 <!-- ==================================================================== --> 1510 1511 <xsl:template name="dbhtml-dir"> 1512 <xsl:param name="context" select="."/> 1513 <!-- directories are now inherited from previous levels --> 1514 <xsl:variable name="ppath"> 1515 <xsl:if test="$context/parent::*"> 1516 <xsl:call-template name="dbhtml-dir"> 1517 <xsl:with-param name="context" select="$context/parent::*"/> 1518 </xsl:call-template> 1519 </xsl:if> 1520 </xsl:variable> 1521 <xsl:variable name="path"> 1522 <xsl:call-template name="pi.dbhtml_dir"> 1523 <xsl:with-param name="node" select="$context"/> 1524 </xsl:call-template> 1525 </xsl:variable> 1526 <xsl:choose> 1527 <xsl:when test="$path = ''"> 1528 <xsl:if test="$ppath != ''"> 1529 <xsl:value-of select="$ppath"/> 1530 </xsl:if> 1531 </xsl:when> 1532 <xsl:otherwise> 1533 <xsl:if test="$ppath != ''"> 1534 <xsl:value-of select="$ppath"/> 1535 <xsl:if test="substring($ppath, string-length($ppath), 1) != '/'"> 1536 <xsl:text>/</xsl:text> 1537 </xsl:if> 1538 </xsl:if> 1539 <xsl:value-of select="$path"/> 1540 <xsl:text>/</xsl:text> 1541 </xsl:otherwise> 1542 </xsl:choose> 1543 </xsl:template> 1544 1447 1545 </xsl:stylesheet>
Note: See TracChangeset
for help on using the changeset viewer.