summaryrefslogtreecommitdiff
path: root/docs/xslt/generate-dependencies.xsl
blob: 37e03f08d104388f97be279cd1f19531971b19bb (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
<?xml version='1.0'?>
<!--
	Find the image dependencies of a certain XML file
	Generates (part of) a Makefile

	- $(FNAME)-images-latex-{png,dvi} for role=latex
	- $(FNAME)-images-role for all other roles
	- $(TXTDIR)/$(FNAME)-text 

	(C) Jelmer Vernooij	2004-2005
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.1">
	<xsl:output method="text"/>

	<xsl:template match="/">
		<xsl:for-each select="//mediaobject/imageobject[@role and not(@role=following::imageobject/@role)]">
			<xsl:call-template name="generate-images">
				<xsl:with-param name="role"><xsl:value-of select="@role"/></xsl:with-param>
			</xsl:call-template>
		</xsl:for-each>
		<xsl:call-template name="generate-images">
			<xsl:with-param name="role"/>
		</xsl:call-template>
		<xsl:call-template name="generate-txt-chunks"/>
	</xsl:template>

	<xsl:template name="generate-images">
		<xsl:value-of select="$target"/><xsl:text>-images-</xsl:text><xsl:value-of select="$role"/><xsl:text> = </xsl:text>
		<xsl:for-each select="//mediaobject/imageobject[@role=$role]">
			<xsl:value-of select="imagedata/@fileref"/>
			<xsl:text> </xsl:text>
		</xsl:for-each>
		<xsl:text>&#10;</xsl:text>
	</xsl:template>

	<xsl:template name="generate-txt-chunks">
		<xsl:value-of select="$target"/><xsl:text>-txt-chunks: </xsl:text>
		<xsl:for-each select="(//chapter|//preface|//appendix)[@id]|book">
			<xsl:value-of select="$txtbasedir"/>
			<xsl:choose>
				<xsl:when test="name() = 'book'">
					<xsl:text>index</xsl:text>
				</xsl:when>
				<xsl:when test="@id != ''">
					<xsl:value-of select="@id"/>
				</xsl:when>
			</xsl:choose>
			<xsl:text>.txt </xsl:text>
		</xsl:for-each>
		<xsl:text>&#10;</xsl:text>
	</xsl:template>
</xsl:stylesheet>