source: stylesheets/lfs-xsl/docbook-xsl-1.78.1/common/insertfile.xsl@ 58675ce

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 7.5 7.6 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 58675ce was 15c7d39, checked in by Matthew Burgess <matthew@…>, 11 years ago

Update stylesheets to docbook-xsl-1.78.1.

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@10355 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 3.9 KB
Line 
1<?xml version='1.0'?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:xi="http://www.w3.org/2001/XInclude"
4 version='1.0'>
5
6<!-- ********************************************************************
7 $Id: insertfile.xsl 5262 2005-10-12 14:58:42Z xmldoc $
8 ********************************************************************
9
10 This file is part of the XSL DocBook Stylesheet distribution.
11 See ../README or http://docbook.sf.net/release/xsl/current/ for
12 copyright and other information.
13
14 ******************************************************************** -->
15
16<xsl:param name="textdata.default.encoding"></xsl:param>
17
18<!-- * This stylesheet makes a copy of a source tree, replacing all -->
19<!-- * instances of the following with corresponding Xinclude instances -->
20<!-- * in the result tree. -->
21<!-- * -->
22<!-- * <textobject><textdata fileref="foo.txt"> -->
23<!-- * <imagedata format="linespecific" fileref="foo.txt"> -->
24<!-- * <inlinegraphic format="linespecific" fileref="foo.txt"> -->
25<!-- * -->
26<!-- * Those become: -->
27<!-- * -->
28<!-- * <xi:include href="foo.txt" parse="text"/> -->
29<!-- * -->
30<!-- * It also works as expected with entityref in place of fileref, -->
31<!-- * and copies over the value of the <textdata>“encoding” atrribute (if -->
32<!-- * found). It is basically intended as an alternative to using the -->
33<!-- * DocBook XSLT Java insertfile() extension. -->
34
35<!-- ==================================================================== -->
36
37<xsl:template name="get.external.filename">
38 <xsl:choose>
39 <xsl:when test="@entityref">
40 <xsl:value-of select="unparsed-entity-uri(@entityref)"/>
41 </xsl:when>
42 <xsl:otherwise>
43 <xsl:value-of select="@fileref"/>
44 </xsl:otherwise>
45 </xsl:choose>
46</xsl:template>
47
48<!-- ==================================================================== -->
49
50<xsl:template match="textobject[child::textdata[@entityref|@fileref]]">
51 <xsl:apply-templates select="textdata"/>
52</xsl:template>
53
54<xsl:template match="textdata[@entityref|@fileref]">
55 <xsl:variable name="filename">
56 <xsl:call-template name="get.external.filename"/>
57 </xsl:variable>
58 <xsl:variable name="encoding">
59 <xsl:choose>
60 <xsl:when test="@encoding">
61 <xsl:value-of select="@encoding"/>
62 </xsl:when>
63 <xsl:otherwise>
64 <xsl:value-of select="$textdata.default.encoding"/>
65 </xsl:otherwise>
66 </xsl:choose>
67 </xsl:variable>
68 <xi:include href="{$filename}" parse="text" encoding="{$encoding}"/>
69</xsl:template>
70
71<!-- ==================================================================== -->
72
73<xsl:template
74 match="inlinemediaobject
75 [child::imageobject
76 [child::imagedata
77 [@format = 'linespecific' and
78 (@entityref|@fileref)]]]">
79 <xsl:apply-templates select="imageobject/imagedata"/>
80</xsl:template>
81
82<xsl:template match="imagedata
83 [@format = 'linespecific' and
84 (@entityref|@fileref)]">
85 <xsl:variable name="filename">
86 <xsl:call-template name="get.external.filename"/>
87 </xsl:variable>
88 <xi:include href="{$filename}" parse="text" encoding="{$textdata.default.encoding}"/>
89</xsl:template>
90
91<!-- ==================================================================== -->
92
93<xsl:template match="inlinegraphic
94 [@format = 'linespecific' and
95 (@entityref|@fileref)]">
96 <xsl:variable name="filename">
97 <xsl:call-template name="get.external.filename"/>
98 </xsl:variable>
99 <xi:include href="{$filename}" parse="text" encoding="{$textdata.default.encoding}"/>
100</xsl:template>
101
102<!-- ==================================================================== -->
103
104<!-- * copy everything else into result tree as-is -->
105<xsl:template match="node() | @*">
106 <xsl:copy>
107 <xsl:apply-templates select="@* | node()"/>
108 </xsl:copy>
109</xsl:template>
110
111</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.