File: create-permalink.xsl

package info (click to toggle)
appstream 1.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 18,408 kB
  • sloc: ansic: 51,906; xml: 10,459; cpp: 4,721; python: 538; sh: 260; makefile: 24
file content (47 lines) | stat: -rw-r--r-- 1,318 bytes parent folder | download | duplicates (5)
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
<?xml version="1.0" encoding="UTF-8"?>
<!-- 
  Purpose:
     Create permalink for divisions and formal object
     
  Parameters:
     * object (default ".")
       object node
     
     * generate.permalinks
       Flag which enables or disables the complete permalink generation
     
  Output:
     Creates an <a> tag with a href attribute, pointing to the
     respective ID.

   Author(s):    Thomas Schraitle <toms@opensuse.org>
   Copyright: 2012, Thomas Schraitle

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

  <xsl:template name="create.permalink">
    <xsl:param name="object" select="."/>
    <xsl:variable name="target">
      <xsl:call-template name="href.target">
        <xsl:with-param name="object" select="$object"/>
      </xsl:call-template>
    </xsl:variable>

    <xsl:if test="$generate.permalinks != 0">
      <a title="Permalink" class="permalink">
        <xsl:attribute name="href">
          <xsl:choose>
            <xsl:when test="$target != ''">
              <xsl:value-of select="$target"/>
            </xsl:when>
            <xsl:otherwise>#</xsl:otherwise>
          </xsl:choose>
        </xsl:attribute>
        <xsl:text>#</xsl:text>
      </a>
    </xsl:if>
  </xsl:template>
</xsl:stylesheet>