summaryrefslogtreecommitdiff
path: root/Build/tools/collection2list.xsl
blob: af7f86ba404a2eb60bef3eda6cc4de2fbb9a5488 (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
85
86
87
88
89
90
91
92
<!-- $Id$
     Written by Sebastian Rahtz.  Public domain. -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
  xmlns:exsl="http://exslt.org/common"
  exclude-result-prefixes="exsl" 
  extension-element-prefixes="exsl"  
  xmlns:TPM="http://texlive.dante.de/"  
  version="1.0">

<xsl:output method="xml" omit-xml-declaration="yes"/>

<xsl:strip-space elements="*"/>

<!-- assume the current directory is Master, as Tools/update arranges. -->
<xsl:param name="ROOT">.</xsl:param>

<xsl:variable name="Master">
  <xsl:value-of select="$ROOT"/>/texmf/lists/</xsl:variable>
<xsl:variable name="COL">texmf/tpm/</xsl:variable>
<xsl:variable name="LISTS">texmf/lists/</xsl:variable>

<xsl:template match="/">
  <!--
 <xsl:message>Write <xsl:value-of select="concat($Master,.//TPM:Name)"/></xsl:message>
-->
 <exsl:document href="{concat($Master,//TPM:Name)}" method="text">
<xsl:text>*Title: </xsl:text>
 <xsl:value-of select="normalize-space(.//TPM:Title)"/>
<xsl:text>&#10;</xsl:text>
<xsl:text>*Size: </xsl:text>
 <xsl:call-template name="findSize"/>
 <xsl:text>&#10;</xsl:text>
  <xsl:apply-templates select=".//TPM:Requires"/>
  <xsl:apply-templates select=".//TPM:DocFiles"/><xsl:text>&#10;</xsl:text>
  <xsl:apply-templates select=".//TPM:SourceFiles"/><xsl:text>&#10;</xsl:text>
  <xsl:apply-templates select=".//TPM:RunFiles"/><xsl:text>&#10;</xsl:text>
 <xsl:text>&#10;</xsl:text>
 <xsl:value-of select="$LISTS"/>
 <xsl:value-of select=".//TPM:Name"/>
 <xsl:text>&#10;</xsl:text>
 </exsl:document>
</xsl:template>

<xsl:template match="TPM:DocFiles|TPM:SourceFiles|TPM:RunFiles">
 <xsl:value-of select="translate(normalize-space(.),' ','&#10;')"/>
</xsl:template>

<xsl:template match="TPM:Requires">
<xsl:for-each select="TPM:Documentation|TPM:Package|TPM:TLCore">
<xsl:sort select="normalize-space(@name)"/>
<xsl:text>+</xsl:text>
<xsl:value-of select="translate(normalize-space(@name),' ','&#10;')"/>
<xsl:text>&#10;</xsl:text>
</xsl:for-each>
<xsl:for-each select="TPM:Collection">
<xsl:text>-</xsl:text>
<xsl:value-of select="translate(normalize-space(@name),' ','&#10;')"/>
<xsl:text>&#10;</xsl:text>
</xsl:for-each>
</xsl:template>

<xsl:template name="findSize">
  <xsl:variable name="Sizes">
    <Sizes>
      <Size><xsl:value-of select=".//TPM:Size"/></Size>
      <xsl:for-each select=".//TPM:Requires">
	<xsl:for-each select="TPM:Documentation">
	  <xsl:for-each
	   select="document(concat($ROOT,'/texmf-doc/tpm/',@name,'.tpm'))">
	    <Size><xsl:value-of select=".//TPM:Size"/></Size>
	  </xsl:for-each>
	</xsl:for-each>
	<xsl:for-each select="TPM:Package">
	  <xsl:for-each
	   select="document(concat($ROOT,'/texmf-dist/tpm/',@name,'.tpm'))">
	    <Size><xsl:value-of select=".//TPM:Size"/></Size>
	  </xsl:for-each>
	</xsl:for-each>
	<xsl:for-each select="TPM:Core">
	  <xsl:for-each
	   select="document(concat($ROOT,'/texmf/tpm/',@name,'.tpm'))">
	    <Size><xsl:value-of select=".//TPM:Size"/></Size>
	  </xsl:for-each>
	</xsl:for-each>
      </xsl:for-each>
    </Sizes>
  </xsl:variable>
<xsl:value-of select="sum(exsl:node-set($Sizes)//Size)"/>
</xsl:template>

</xsl:stylesheet>