Debian Codegraph @

daps-xslt/common/extract-files-and-images.xsl

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3 Purpose:
4 Prints all used referenced images or XML files
5 With rootid parameter, the nearest <div> with a href attribute is processed.
6
7 Parameters:
8 * filetype (default: 'xml')
9 xml, text or image? img=images files, xml=XML files, text=text files
10 * separator (default: ' ')
11 Separator between each filename
12 * show.first (default: 0)
13 If set to 1, only the first filename will be printed
14
15 Input:
16 Output from get-all-used-files.xsl
17
18 Output:
19 List of filenames separated by $separator
20
21 DocBook 5 compatible:
22 yes
23
24 Author: Thomas Schraitle <[email protected]>
25 Copyright (C) 2012-2020 SUSE Software Solutions Germany GmbH
26
27 -->
28
29 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
30 version="1.0">
31 <xsl:import href="rootid.xsl"/>
32 <xsl:output method="text" indent="no"/>
33
34 <xsl:param name="show.first" select="0"/>
35 <xsl:param name="filetype" select="'xml'"/>
36 <xsl:param name="separator">
37 <xsl:text> </xsl:text>
38 </xsl:param>
39
40 <xsl:template match="text()"/>
41
42
43 <xsl:template match="/">
44 <xsl:call-template name="process.rootid.node"/>
45 <xsl:text>&#10;</xsl:text>
46 </xsl:template>
47
48 <xsl:template name="rootid.process">
49 <xsl:variable name="node" select="key('id',$rootid)"/>
50 <xsl:variable name="anc.href" select="$node/ancestor-or-self::*[@href]"/>
51 <!--<xsl:message>#### <xsl:value-of select="$anc.href[last()]/@href"/></xsl:message>-->
52 <!-- Use only the first div element in reversed order which is our nearest div -->
53 <xsl:apply-templates select="$anc.href[last()]"/>
54 </xsl:template>
55
56 <xsl:template match="div[@text='false']">
57 <xsl:if test="$filetype = 'xml'">
58 <xsl:if test="@href">
59 <xsl:value-of select="@href"/>
60 <!-- We only need the separator, when we are interested in all files -->
61 <xsl:if test="$show.first = 0">
62 <xsl:value-of select="$separator"/>
63 </xsl:if>
64 </xsl:if>
65 </xsl:if>
66 <xsl:if test="$show.first = 0">
67 <xsl:apply-templates />
68 </xsl:if>
69 </xsl:template>
70
71
72 <xsl:template match="div[@text='true']">
73 <xsl:if test="$filetype = 'text'">
74 <xsl:value-of select="@href"/>
75 <!-- We only need the separator, when we are interested in all files -->
76 <xsl:if test="$show.first = 0">
77 <xsl:value-of select="$separator"/>
78 </xsl:if>
79 </xsl:if>
80 </xsl:template>
81
82
83 <xsl:template match="image">
84 <xsl:if test="$filetype = 'img'">
85 <xsl:value-of select="@fileref"/>
86 <xsl:value-of select="$separator"/>
87 </xsl:if>
88 </xsl:template>
89
90 </xsl:stylesheet>