summaryrefslogtreecommitdiff
path: root/Build/tools/tpmfromcat.xsl
blob: 8e044a6ed188d4215de046fc580cf7928ca23dbf (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<!-- $Id$
     Written by Sebastian Rahtz.  Public domain. -->

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet 
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:TPM="http://texlive.dante.de/"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    exclude-result-prefixes="rdf TPM" 
    version="1.0">

<xsl:output 
   method="xml"
   indent="yes"
   doctype-system="../../support/tpm.dtd"
  />

<xsl:param name="sarovar"/>
<xsl:param name="authors"/>

<xsl:template match="@*|processing-instruction()|comment()|text()" >
  <xsl:copy/>
</xsl:template>

<xsl:template match="*" >
  <xsl:copy>
    <xsl:apply-templates
	select="*|@*|processing-instruction()|comment()|text()" />
  </xsl:copy>
</xsl:template>

<xsl:template match="TPM:Description">
  <xsl:variable name="S">
    <xsl:value-of select="document($sarovar)/entry/description"/>
  </xsl:variable>
  <TPM:Description>
    <xsl:choose>
      <xsl:when test="$S=''">
	<xsl:apply-templates/>
      </xsl:when>
      <xsl:otherwise>
	<xsl:value-of select="$S"/>
	[description copied from TeX Catalogue]
      </xsl:otherwise>
    </xsl:choose>
  </TPM:Description>
</xsl:template>

<xsl:template match="TPM:Title">
  <xsl:variable name="S">
    <xsl:value-of select="document($sarovar)/entry/caption"/>
  </xsl:variable>
  <TPM:Title>
    <xsl:choose>
      <xsl:when test="$S=''">
	<xsl:apply-templates/>
      </xsl:when>
      <xsl:otherwise>
	<xsl:value-of select="$S"/>
      </xsl:otherwise>
    </xsl:choose>
  </TPM:Title>
</xsl:template>

<xsl:template match="TPM:Author">
  <xsl:variable name="A">
    <xsl:value-of select="document($sarovar)/entry/authorref/@id"/>
  </xsl:variable>
  <xsl:variable name="S">
    <xsl:value-of select="document($authors)/authors/author[@id=$A]"/>
  </xsl:variable>
  <TPM:Author>
    <xsl:choose>
      <xsl:when test="$S=''">
	<xsl:apply-templates/>
      </xsl:when>
      <xsl:otherwise>
	<xsl:value-of select="$S"/>
      </xsl:otherwise>
    </xsl:choose>
  </TPM:Author>
</xsl:template>

</xsl:stylesheet>