File: html-chunk.xsl

package info (click to toggle)
php-doc 20061001-1
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 45,764 kB
  • ctags: 1,611
  • sloc: xml: 502,485; php: 7,645; cpp: 500; makefile: 297; perl: 161; sh: 141; awk: 28
file content (133 lines) | stat: -rw-r--r-- 4,748 bytes parent folder | download
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- 

  html-common.xsl: Common HTML customizations

  $Id: html-chunk.xsl,v 1.4 2006/01/16 10:37:59 hholzgra Exp $

-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

<!-- Use the IDs to create filenames -->
<xsl:param name="use.id.as.filename" select="1"/>

<!-- Speed up generation (no file name printouts) -->
<xsl:param name="chunk.quietly">1</xsl:param>

<!-- Make LEGALNOTICE an extra-file, omit extra-link on start-page (link
     directly from the original <COPYRIGHT>), and make nav-header/footer -->
<xsl:template match="copyright" mode="titlepage.mode">
  <p>
    <a href="{concat('copyright',$html.ext)}">
      <xsl:call-template name="gentext">
        <xsl:with-param name="key" select="'Copyright'"/>
      </xsl:call-template>
    </a>
    <xsl:text> </xsl:text>
    <xsl:call-template name="dingbat">
      <xsl:with-param name="dingbat">copyright</xsl:with-param>
    </xsl:call-template>
    <xsl:text> </xsl:text>
    <xsl:call-template name="copyright.years">
      <xsl:with-param name="years" select="year"/>
      <xsl:with-param name="print.ranges" select="$make.year.ranges"/>
      <xsl:with-param name="single.year.ranges"
                      select="$make.single.year.ranges"/>
    </xsl:call-template>
    <xsl:text> </xsl:text>
    <xsl:apply-templates select="holder" mode="titlepage.mode"/>
  </p>
</xsl:template>

<xsl:template match="legalnotice" mode="titlepage.mode">
  <xsl:variable name="filename">
    <xsl:value-of select="concat($base.dir,'copyright',$html.ext)"/>
  </xsl:variable>

  <xsl:call-template name="write.chunk">
    <xsl:with-param name="filename" select="$filename"/>
    <xsl:with-param name="quiet" select="$chunk.quietly"/>
    <xsl:with-param name="content">
      <xsl:call-template name="chunk-element-content">
        <xsl:with-param name="prev" select="/foo"/>
        <xsl:with-param name="next" select="/foo"/>
        <xsl:with-param name="content">
          <xsl:apply-templates mode="titlepage.mode"/>
        </xsl:with-param>
      </xsl:call-template>
    </xsl:with-param>
  </xsl:call-template>
</xsl:template>

<!-- Add parenthesis FUNCTIONS, and if target exists link
     them to their refentry, otherweise make them bold  -->
<xsl:template match="function">
  <xsl:variable name="content">
    <xsl:apply-templates/><xsl:text>()</xsl:text>
  </xsl:variable>
  <xsl:variable name="idbase">
    <xsl:value-of select="translate(translate(string(current()),'_','-'),
                      'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
  </xsl:variable>
  <xsl:variable name="rolename">
   <xsl:choose>
    <xsl:when test="./@role">
     <xsl:copy-of select="string(./@role)"/>
    </xsl:when>
    <xsl:when test="ancestor::chapter[@id='zend'] or ancestor::chapter[@id='tsrm']">
     <xsl:choose>
      <xsl:when test="string(current()) = translate(string(current()),
                                                    'abcdefghijklmnopqrstuvwxyz',
                                                    'ABCDEFGHIJKLMNOPQRSTUVWXYZ')">
       <xsl:copy-of select="'zend-macro'"/>
      </xsl:when>
      <xsl:otherwise>
       <xsl:copy-of select="'zend-api'"/>
      </xsl:otherwise>
     </xsl:choose>
    </xsl:when>
    <xsl:otherwise>
     <xsl:copy-of select="'php'"/>
    </xsl:otherwise>
   </xsl:choose>
  </xsl:variable>
  <xsl:variable name="targetid">
   <xsl:choose>
    <xsl:when test="$rolename='php'">
     <xsl:if test="count(//refentry[@id=concat('function.',$idbase)])>0">
      <xsl:copy-of select="concat('function.',$idbase)"/>
     </xsl:if>
    </xsl:when>
    <xsl:when test="$rolename='zend-api'">
     <xsl:if test="count(//refentry[@id=concat('zend-api.',$idbase)])>0">
      <xsl:copy-of select="concat('zend-api.',$idbase)"/>
     </xsl:if>
    </xsl:when>
    <xsl:when test="$rolename='zend-macro'">
     <xsl:if test="count(//refentry[@id=concat('zend-macro.',$idbase)])>0">
      <xsl:copy-of select="concat('zend-macro.',$idbase)"/>
     </xsl:if>
    </xsl:when>
    <xsl:when test="$rolename='libc'">
     <xsl:copy-of select="concat('http://www.opengroup.org/onlinepubs/007908799/xsh/',string(current()))"/>
    </xsl:when>
   </xsl:choose>
  </xsl:variable>
  <xsl:choose>
    <xsl:when test="ancestor::refentry/@id=$targetid
                    or string-length($targetid) = 0">
      <b><xsl:copy-of select="$content"/></b>
    </xsl:when>
    <xsl:otherwise>
      <a>
        <xsl:attribute name="href">
          <xsl:value-of select="concat($targetid,$html.ext)"/> 
        </xsl:attribute>
        <xsl:copy-of select="$content"/>
      </a>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

</xsl:stylesheet>