adjust frame width
[librarian.git] / librarian / fb2 / description.xslt
1 <?xml version="1.0" encoding="utf-8"?>
2 <!--
3
4         This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
5         Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
6
7 -->
8 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
9         xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
10         xmlns:dc="http://purl.org/dc/elements/1.1/"
11         xmlns="http://www.gribuser.ru/xml/fictionbook/2.0">
12
13         <!-- description parsing -->
14         <xsl:template match="rdf:Description" mode="outer">
15                 <description>
16                         <!-- need to keep ordering here... -->
17
18                         <title-info>
19                                 <!-- obligatory: genre, author, book-title, lang -->
20
21                                 <!-- XXX -->
22                                 <genre>literature</genre> 
23                                 <xsl:apply-templates mode="description"
24                                         select="dc:creator"/>
25                                 <xsl:apply-templates mode="description"
26                                         select="dc:title"/>
27                                 <xsl:apply-templates mode="description"
28                                         select="dc:date.pd"/>
29                                 <xsl:apply-templates mode="description"
30                                         select="dc:language"/>
31                         </title-info>
32                         <document-info>
33                                 <!-- obligatory: author, date, id, version -->
34
35                                 <xsl:apply-templates mode="description"
36                                         select="dc:contributor.editor"/>
37                                 <xsl:apply-templates mode="description"
38                                         select="dc:contributor.technical_editor"/>
39                                 <program-used>book2fb2</program-used>
40                                 <!-- maybe today's date instead? -->
41                                 <xsl:apply-templates mode="description"
42                                         select="dc:date"/>
43                                 <xsl:apply-templates mode="description"
44                                         select="dc:identifier.url"/>
45                                 <!-- XXX -->
46                                 <version>0</version>
47                         </document-info>
48                         <publish-info>
49                                 <publisher>
50                                         <xsl:for-each select="//dc:publisher/text()">
51                                                 <xsl:value-of select="."/>
52                                                 <xsl:if test="not(position() = last())">; </xsl:if>
53                                         </xsl:for-each>
54                                 </publisher>
55                         </publish-info>
56                 </description>
57         </xsl:template>
58
59         <xsl:template mode="description"
60                         match="dc:creator|dc:contributor.editor|dc:contributor.technical_editor">
61                 <!-- last name, first name -->
62                 <xsl:variable name="last"
63                         select="normalize-space(substring-before(., ','))"/>
64                 <xsl:variable name="first"
65                         select="normalize-space(substring-after(., ','))"/>
66
67                 <author>
68                         <first-name><xsl:value-of select="$first"/></first-name>
69                         <last-name><xsl:value-of select="$last"/></last-name>
70                 </author>
71         </xsl:template>
72         <xsl:template mode="description" match="dc:title">
73                 <book-title><xsl:value-of select="."/></book-title>
74         </xsl:template>
75         <xsl:template mode="description" match="dc:language">
76                 <lang><xsl:value-of select="."/></lang>
77         </xsl:template>
78         <xsl:template mode="description" match="dc:date.pd|dc:date">
79                 <date><xsl:value-of select="."/></date>
80         </xsl:template>
81         <xsl:template mode="description" match="dc:publisher">
82                 <publisher><xsl:value-of select="."/></publisher>
83         </xsl:template>
84         <xsl:template mode="description" match="dc:identifier.url">
85                 <id><xsl:value-of select="."/></id>
86         </xsl:template>
87 </xsl:stylesheet>