source: stylesheets/lfs-xsl/docbook-xsl-snapshot/common/insertfile.xsl@ 65b2904

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 6.3 6.3-rc1 6.3-rc2 6.3-rc3 7.10 7.4 7.5 7.6 7.6-blfs 7.6-systemd 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 9.0 9.1 basic bdubbs/svn elogind gnome kde5-13430 kde5-14269 kde5-14686 kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts krejzi/svn lazarus lxqt nosym perl-modules plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition systemd-11177 systemd-13485 trunk upgradedb xry111/intltool xry111/llvm18 xry111/soup3 xry111/test-20220226 xry111/xf86-video-removal
Last change on this file since 65b2904 was 65b2904, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Added LFS-XSL Stylesheets files.

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@6840 af4574ff-66df-0310-9fd7-8a98e5e911e0

  • Property mode set to 100644
File size: 3.8 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$
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.