summaryrefslogtreecommitdiff
path: root/tests/docbook/html/xtchunker.xsl
blob: 62837df919b3de6deffaeba4aa97932600988a2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xt="http://www.jclark.com/xt"
                extension-element-prefixes="xt"
		version="1.0">

<!-- This stylesheet works with XT; for others use chunker.xsl -->

<!-- ==================================================================== -->

<xsl:template name="make-relative-filename">
  <xsl:param name="base.dir" select="'./'"/>
  <xsl:param name="base.name" select="''"/>

  <!-- XT makes chunks relative -->
  <xsl:choose>
    <xsl:when test="count(parent::*) = 0">
      <xsl:value-of select="concat($base.dir,$base.name)"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$base.name"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template name="write.chunk">
  <xsl:param name="filename" select="''"/>
  <xsl:param name="method" select="'html'"/>
  <xsl:param name="encoding" select="'ISO-8859-1'"/>
  <xsl:param name="indent" select="'no'"/>
  <xsl:param name="content" select="''"/>

  <xsl:message>
    <xsl:text>Writing </xsl:text>
    <xsl:value-of select="$filename"/>
    <xsl:if test="name(.) != ''">
      <xsl:text> for </xsl:text>
      <xsl:value-of select="name(.)"/>
    </xsl:if>
  </xsl:message>

  <!-- apparently XT doesn't support AVTs for method and encoding -->
  <xsl:choose>
    <xsl:when test="$method = 'xml'">
      <xt:document href="{$filename}"
                   method="xml"
                   indent="{$indent}"
                   encoding="ISO-8859-1">
        <xsl:copy-of select="$content"/>
      </xt:document>
    </xsl:when>
    <xsl:when test="$method = 'text'">
      <xt:document href="{$filename}"
                   method="text"
                   indent="{$indent}"
                   encoding="ISO-8859-1">
        <xsl:copy-of select="$content"/>
      </xt:document>
    </xsl:when>
    <xsl:otherwise>
      <xt:document href="{$filename}"
                   method="html"
                   indent="{$indent}"
                   encoding="ISO-8859-1">
        <xsl:copy-of select="$content"/>
      </xt:document>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

</xsl:stylesheet>