1
1
<?xml version="1.0" encoding="UTF-8"?>
4
Document $Id: cmd_common.xsl,v 1.2 2006/05/02 13:19:55 dleidert Exp $
4
Document $Id: cmd_common.xsl,v 1.6 2007/01/27 11:41:57 dleidert Exp $
5
5
Summary XSLT stylesheet that contains commonly used templates.
7
Copyright (C) 2006 Daniel Leidert <daniel.leidert@wgdd.de>.
7
Copyright (C) 2006,2007 Daniel Leidert <daniel.leidert@wgdd.de>.
9
9
This file is free software. The copyright owner gives unlimited
10
10
permission to copy, distribute and modify it.
13
13
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
14
14
xmlns:saxon="http://icl.com/saxon"
15
15
xmlns:lxslt="http://xml.apache.org/xslt"
16
xmlns:xalanredirect="org.apache.xalan.xslt.extensions.Redirect"
16
xmlns:redirect="http://xml.apache.org/xalan/redirect"
17
17
xmlns:exsl="http://exslt.org/common"
19
extension-element-prefixes="saxon xalanredirect lxslt exsl">
22
This template writes out the specified file.
24
<xsl:template name="write.chunk">
19
extension-element-prefixes="saxon redirect lxslt exsl">
22
<!-- ********************************************************************* -->
23
<!-- * Named templates for common functions. -->
24
<!-- ********************************************************************* -->
26
<xsl:template name="common.header.text">
27
<!-- * A created text file shall contain a header with information about -->
28
<!-- * the license and the database version. -->
29
<xsl:text># This file is part of the chemical-mime-data package.
30
# It is distributed under the GNU Lesser General Public License version 2.1.
32
# Database: </xsl:text><xsl:value-of select="chemical-mime/@id"/><xsl:text> </xsl:text>
35
<xsl:template name="common.header.xml">
36
<!-- * A created xml file shall contain a header with information about -->
37
<!-- * the license and the database version. -->
40
This file is part of the chemical-mime-data package.
41
It is distributed under the GNU Lesser General Public License version 2.1.
44
<xsl:value-of select="chemical-mime/@id"/>
45
<xsl:text> </xsl:text>
47
<xsl:text> </xsl:text>
50
<xsl:template name="common.write.chunk">
51
<!-- * This template output the given content into a file with the given -->
52
<!-- * filename, encoding and media type. With this template we can -->
53
<!-- * write several output files from one input file. Therefor we need -->
54
<!-- * several extensions. The default is EXSLT, which is implemented in -->
55
<!-- * linxslt1.1 (xsltproc). The other are nice to have, but unused -->
25
57
<xsl:param name="filename" select="''"/>
26
<xsl:param name="method" select="''"/>
58
<xsl:param name="method" select="''"/>
27
59
<xsl:param name="indent" select="''"/>
28
60
<xsl:param name="omit-xml-declaration" select="''"/>
29
61
<xsl:param name="media-type" select="''"/>
30
62
<xsl:param name="doctype-public" select="''"/>
31
63
<xsl:param name="doctype-system" select="''"/>
32
<xsl:param name="content"/>
64
<xsl:param name="content"/>
35
Output the specified file.
38
<!-- exslt:document -->
67
<!-- * Check if EXSLT's exslt:document() is available. -->
39
68
<xsl:when test="element-available('exsl:document')">
41
70
<xsl:when test="$doctype-public != '' and $doctype-system != ''">
94
<!-- xalanredirect -->
95
<xsl:when test="element-available('xalanredirect:write')">
96
<xalanredirect:write file="{$filename}">
123
<!-- * Check if Xalan's redirect:write() is available. -->
124
<xsl:when test="element-available('redirect:write')">
125
<redirect:write file="{$filename}">
97
126
<xsl:copy-of select="$content"/>
98
</xalanredirect:write>
101
<!-- it doesn't matter since we won't be making chunks... -->
102
<xsl:message terminate="yes">
103
<xsl:text>Can't make chunks with </xsl:text>
104
<xsl:value-of select="system-property('xsl:vendor')"/>
105
<xsl:text>'s processor.</xsl:text>
130
<!-- * And if nothing of these are available, output an error. -->
131
<xsl:message terminate="yes">
132
<xsl:text>Can't make chunks with </xsl:text>
133
<xsl:value-of select="system-property('xsl:vendor')"/>
134
<xsl:text>'s processor.</xsl:text>
111
Now be a bit verbose and tell, which file we wrote.
139
<!-- * Be verbose, which file is output. -->
114
141
<xsl:text>Writing </xsl:text>
115
142
<xsl:value-of select="$filename"/>
121
The created text-files all contain the same header.
123
<xsl:template name="header.desktop">
124
<xsl:text>[Desktop Entry]
126
Type=MimeType </xsl:text>
130
Even the created text-files shall contain a short summary with license
131
and database version information.
133
<xsl:template name="header.text">
134
<xsl:text># This file is part of the chemical-mime-data package.
135
# It is distributed under the GNU Lesser General Public License version 2.1.
137
# Database: </xsl:text><xsl:value-of select="chemical-mime/@id"/><xsl:text> </xsl:text>
141
Even the created xml-files shall contain a short summary with license
142
and database version information.
144
<xsl:template name="header.xml">
147
This file is part of the chemical-mime-data package.
148
It is distributed under the GNU Lesser General Public License version 2.1.
150
Database: </xsl:text>
151
<xsl:value-of select="chemical-mime/@id"/>
152
<xsl:text> </xsl:text>
154
<xsl:text> </xsl:text>
b'\\ No newline at end of file'