-include librarian/*.xslt
-include librarian/config.xml
+include ez_setup.py
+include librarian/xslt/*.xslt
+include librarian/xslt/config.xml
method='xml', encoding=unicode, pretty_print=True)
return u'<utwor>\n' + dcstring + u'\n<plain-text>\n' + ocrtext +\
- u'\n</plain-text>\n</utwor>';
\ No newline at end of file
+ u'\n</plain-text>\n</utwor>';
+
+
+def serialize_raw(element):
+ b = u'' + (element.text or '')
+
+ for child in element.iterchildren():
+ e = etree.tostring(child, method='xml', encoding=unicode, pretty_print=True)
+ b += e
+
+ return b
+
+from wl_light import serialize_nl
+
+
+SERIALIZERS = {
+ 'raw': serialize_raw,
+ 'nl': serialize_nl,
+}
+
+def serialize_children(element, format='raw'):
+ return SERIALIZERS[format](element)
+++ /dev/null
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:wl="http://wolnelektury.pl/functions" >
-
-<xsl:output encoding="utf-8" indent="yes" omit-xml-declaration = "yes" version="2.0" />
-
-
-<xsl:template match="utwor">
- <!-- <html>
- <head>
- <title>Książka z serwisu WolneLektury.pl</title>
- <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
- </head>
- <style>
- body {
- font-size: 16px;
- font: Georgia, "Times New Roman", serif;
- line-height: 1.5em;
- margin: 0;
- }
-
- a {
- color: blue;
- text-decoration: none;
- }
-
- #book-text {
- margin: 3em;
- max-width: 36em;
- }
-
- /* ================================== */
- /* = Header with logo and menu = */
- /* ================================== */
- #header {
- margin: 3.4em 0 0 1.4em;
- }
-
- img {
- border: none;
- }
-
-
- #menu {
- position: fixed;
- left: 0em;
- top: 0em;
- width: 100%;
- height: 1.5em;
- background: #333;
- color: #FFF;
- opacity: 0.9;
- }
-
- #menu ul {
- list-style: none;
- padding: 0;
- margin: 0;
- }
-
- #menu li a {
- display: block;
- float: left;
- width: 7.5em;
- height: 1.5em;
- margin-left: 0.5em;
- text-align: center;
- color: #FFF;
- }
-
- #menu li a:hover, #menu li a:active {
- color: #000;
- background: #FFF url(/media/img/arrow-down.png) no-repeat center right;
- }
-
- #menu li a.selected {
- color: #000;
- background: #FFF url(/media/img/arrow-up.png) no-repeat center right;
- }
-
- #toc, #themes {
- position: fixed;
- left: 0em;
- top: 1.5em;
- width: 37em;
- padding: 1.5em;
- background: #FFF;
- border-bottom: 0.25em solid #DDD;
- border-right: 0.25em solid #DDD;
- display: none;
- height: 16em;
- overflow-x: hidden;
- overflow-y: auto;
- opacity: 0.9;
- }
-
- #toc ol, #themes ol {
- list-style: none;
- padding: 0;
- margin: 0;
- }
-
- #toc ol li {
- font-weight: bold;
- }
-
- #toc ol ol {
- padding: 0 0 1.5em 1.5em;
- margin: 0;
- }
-
- #toc ol ol li {
- font-weight: normal;
- }
-
- #toc h2 {
- display: none;
- }
-
- #toc .anchor {
- float: none;
- margin: 0;
- color: blue;
- font-size: 16px;
- position: inherit;
- }
-
- /* =================================================== */
- /* = Common elements: headings, paragraphs and lines = */
- /* =================================================== */
- h1 {
- font-size: 3em;
- margin: 1.5em 0;
- text-align: center;
- line-height: 1.5em;
- font-weight: bold;
- }
-
- h2 {
- font-size: 2em;
- margin: 1.5em 0 0;
- font-weight: bold;
- line-height: 1.5em;
- }
-
- h3 {
- font-size: 1.5em;
- margin: 1.5em 0 0;
- font-weight: normal;
- line-height: 1.5em;
- }
-
- h4 {
- font-size: 1em;
- margin: 1.5em 0 0;
- line-height: 1.5em;
- }
-
- p {
- margin: 0;
- }
-
- /* ======================== */
- /* = Footnotes and themes = */
- /* ======================== */
- .theme-begin {
- border-left: 0.1em solid #DDDDDD;
- color: #777;
- padding: 0 0.5em;
- width: 7.5em;
- font-style: normal;
- font-weight: normal;
- font-size: 16px;
- float: right;
- margin-right: -9.5em;
- clear: both;
- left: 40em;
- line-height: 1.5em;
- text-align: left;
- }
-
- .annotation {
- font-style: normal;
- font-weight: normal;
- font-size: 12px;
- }
-
- #footnotes .annotation {
- display: block;
- float: left;
- width: 2.5em;
- clear: both;
- }
-
- #footnotes div {
- margin: 1.5em 0 0 0;
- }
-
- #footnotes p {
- margin-left: 2.5em;
- font-size: 0.875em;
- }
-
- blockquote {
- font-size: 0.875em;
- }
-
- /* ============= */
- /* = Numbering = */
- /* ============= */
- .anchor {
- position: absolute;
- margin: -0.25em -0.5em;
- left: 1em;
- color: #777;
- font-size: 12px;
- width: 2em;
- text-align: center;
- padding: 0.25em 0.5em;
- line-height: 1.5em;
- }
-
- .anchor:hover, #book-text .anchor:active {
- color: #FFF;
- background-color: #CCC;
- }
-
- /* =================== */
- /* = Custom elements = */
- /* =================== */
- span.author {
- font-size: 0.5em;
- display: block;
- line-height: 1.5em;
- margin-bottom: 0.25em;
- }
-
- span.collection {
- font-size: 0.375em;
- display: block;
- line-height: 1.5em;
- margin-bottom: -0.25em;
- }
-
- span.subtitle {
- font-size: 0.5em;
- display: block;
- line-height: 1.5em;
- margin-top: -0.25em;
- }
-
- div.didaskalia {
- font-style: italic;
- margin: 0.5em 0 0 1.5em;
- }
-
- div.kwestia {
- margin: 0.5em 0 0;
- }
-
- div.stanza {
- margin: 1.5em 0 0;
- }
-
- div.kwestia div.stanza {
- margin: 0;
- }
-
- p.paragraph {
- text-align: justify;
- margin: 1.5em 0 0;
- }
-
- p.motto {
- text-align: justify;
- font-style: italic;
- margin: 1.5em 0 0;
- }
-
- p.motto_podpis {
- font-size: 0.875em;
- text-align: right;
- }
-
- div.fragment {
- border-bottom: 0.1em solid #999;
- padding-bottom: 1.5em;
- }
-
- div.note p, div.dedication p, div.note p.paragraph, div.dedication p.paragraph {
- text-align: right;
- font-style: italic;
- }
-
- hr.spacer {
- height: 3em;
- visibility: hidden;
- }
-
- hr.spacer-line {
- margin: 1.5em 0;
- border: none;
- border-bottom: 0.1em solid #000;
- }
-
- p.spacer-asterisk {
- padding: 0;
- margin: 1.5em 0;
- text-align: center;
- }
-
- div.person-list ol {
- list-style: none;
- padding: 0 0 0 1.5em;
- }
-
- p.place-and-time {
- font-style: italic;
- }
-
- em.math, em.foreign-word, em.book-title, em.didaskalia {
- font-style: italic;
- }
-
- em.author-emphasis {
- letter-spacing: 0.1em;
- }
-
- em.person {
- font-style: normal;
- font-variant: small-caps;
- }
- </style>
- <body> -->
- <div id="book-text">
- <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
- <xsl:if test="count(descendant::*[self::pe or self::pa or self::pr or self::pt][not(parent::extra)])">
- <div id="footnotes">
- <h3>Przypisy</h3>
- <xsl:for-each select="descendant::*[self::pe or self::pa or self::pr or self::pt][not(parent::extra)]">
- <div>
- <a name="{concat('footnote-', generate-id(.))}" />
- <a href="{concat('#anchor-', generate-id(.))}" class="annotation">[<xsl:number value="count(preceding::*[self::pa or self::pe or self::pr or self::pt]) + 1" />]</a>
- <xsl:choose>
- <xsl:when test="count(akap|akap_cd|strofa) = 0">
- <p><xsl:apply-templates select="text()|*" mode="inline" /></p>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates select="text()|*" mode="inline" />
- </xsl:otherwise>
- </xsl:choose>
- </div>
- </xsl:for-each>
- </div>
- </xsl:if>
- </div>
- <!-- </body>
- </html> -->
-</xsl:template>
-
-
-<!-- ============================================================================== -->
-<!-- = MASTER TAG = -->
-<!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
-<!-- ============================================================================== -->
-<xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny">
- <xsl:if test="nazwa_utworu">
- <h1>
- <xsl:apply-templates select="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul" mode="header" />
- </h1>
- </xsl:if>
- <xsl:apply-templates />
-</xsl:template>
-
-
-<!-- ==================================================================================== -->
-<!-- = BLOCK TAGS = -->
-<!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
-<!-- ==================================================================================== -->
-<xsl:template match="nota">
- <div class="note"><xsl:apply-templates /></div>
-</xsl:template>
-
-<xsl:template match="lista_osob">
- <div class="person-list">
- <h3><xsl:value-of select="naglowek_listy" /></h3>
- <ol>
- <xsl:apply-templates select="lista_osoba" />
- </ol>
- </div>
-</xsl:template>
-
-<xsl:template match="dedykacja">
- <div class="dedication"><xsl:apply-templates /></div>
-</xsl:template>
-
-<xsl:template match="kwestia">
- <div class="kwestia">
- <xsl:apply-templates select="strofa|akap|didaskalia" />
- </div>
-</xsl:template>
-
-<xsl:template match="dlugi_cytat|poezja_cyt">
- <blockquote><xsl:apply-templates /></blockquote>
-</xsl:template>
-
-<xsl:template match="motto">
- <div class="motto"><xsl:apply-templates mode="inline" /></div>
-</xsl:template>
-
-
-<!-- ========================================== -->
-<!-- = PARAGRAPH TAGS = -->
-<!-- = (can contain inline and special tags) = -->
-<!-- ========================================== -->
-<!-- Title page -->
-<xsl:template match="autor_utworu" mode="header">
- <span class="author editable"><xsl:apply-templates mode="inline" /></span>
-</xsl:template>
-
-<xsl:template match="nazwa_utworu" mode="header">
- <span class="title editable"><xsl:apply-templates mode="inline" /></span>
-</xsl:template>
-
-<xsl:template match="dzielo_nadrzedne" mode="header">
- <span class="collection"><xsl:apply-templates mode="inline" /></span>
-</xsl:template>
-
-<xsl:template match="podtytul" mode="header">
- <span class="subtitle"><xsl:apply-templates mode="inline" /></span>
-</xsl:template>
-
-<!-- Section headers (included in index)-->
-<xsl:template match="naglowek_akt|naglowek_czesc|srodtytul">
- <h2><xsl:apply-templates mode="inline" /></h2>
-</xsl:template>
-
-<xsl:template match="naglowek_scena|naglowek_rozdzial">
- <h3><xsl:apply-templates mode="inline" /></h3>
-</xsl:template>
-
-<xsl:template match="naglowek_osoba|naglowek_podrozdzial">
- <h4><xsl:apply-templates mode="inline" /></h4>
-</xsl:template>
-
-<!-- Other paragraph tags -->
-<xsl:template match="miejsce_czas">
- <p class="place-and-time"><xsl:apply-templates mode="inline" /></p>
-</xsl:template>
-
-<xsl:template match="didaskalia">
- <div class="didaskalia"><xsl:apply-templates mode="inline" /></div>
-</xsl:template>
-
-<xsl:template match="lista_osoba">
- <li><xsl:apply-templates mode="inline" /></li>
-</xsl:template>
-
-<xsl:template match="akap|akap_dialog|akap_cd">
- <p class="paragraph editable"><xsl:apply-templates mode="inline" /></p>
-</xsl:template>
-
-<xsl:template match="strofa">
- <div class="stanza editable">
- <xsl:choose>
- <xsl:when test="count(br) > 0">
- <xsl:call-template name="verse">
- <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
- <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
- </xsl:call-template>
- <xsl:for-each select="br">
- <!-- Each BR tag "consumes" text after it -->
- <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
- <xsl:call-template name="verse">
- <xsl:with-param name="verse-content"
- select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
- <xsl:with-param name="verse-type" select="following-sibling::*[count(preceding-sibling::br) = $lnum+1 and (name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd')][1]" />
- </xsl:call-template>
- </xsl:for-each>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="verse">
- <xsl:with-param name="verse-content" select="text() | node()" />
- <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </div>
-</xsl:template>
-
-<xsl:template name="verse">
- <xsl:param name="verse-content" />
- <xsl:param name="verse-type" />
- <p class="verse">
- <xsl:choose>
- <xsl:when test="name($verse-type) = 'wers_akap'">
- <xsl:attribute name="style">padding-left: 1em</xsl:attribute>
- </xsl:when>
- <xsl:when test="name($verse-type) = 'wers_wciety'">
- <xsl:choose>
- <xsl:when test="$verse-content/@typ">
- <xsl:attribute name="style">padding-left: <xsl:value-of select="$verse-content/@typ" />em</xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="style">padding-left: 1em</xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="name($verse-type) = 'wers_cd'">
- <xsl:attribute name="style">padding-left: 12em</xsl:attribute>
- </xsl:when>
- </xsl:choose>
- <xsl:apply-templates select="$verse-content" mode="inline" />
- </p>
-</xsl:template>
-
-<xsl:template match="motto_podpis">
- <p class="motto_podpis"><xsl:apply-templates mode="inline" /></p>
-</xsl:template>
-
-
-<!-- ================================================ -->
-<!-- = INLINE TAGS = -->
-<!-- = (contain other inline tags and special tags) = -->
-<!-- ================================================ -->
-<!-- Annotations -->
-<xsl:template match="pa|pe|pr|pt" mode="inline">
- <a name="{concat('anchor-', generate-id(.))}" />
- <a href="{concat('#footnote-', generate-id(.))}" class="annotation">[<xsl:number value="count(preceding::*[self::pa or self::pe or self::pr or self::pt]) + 1" />]</a>
-</xsl:template>
-
-<!-- Other inline tags -->
-<xsl:template match="mat" mode="inline">
- <em class="math"><xsl:apply-templates mode="inline" /></em>
-</xsl:template>
-
-<xsl:template match="didask_tekst" mode="inline">
- <em class="didaskalia"><xsl:apply-templates mode="inline" /></em>
-</xsl:template>
-
-<xsl:template match="slowo_obce" mode="inline">
- <em class="foreign-word"><xsl:apply-templates mode="inline" /></em>
-</xsl:template>
-
-<xsl:template match="tytul_dziela" mode="inline">
- <em class="book-title">
- <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
- </em>
-</xsl:template>
-
-<xsl:template match="wyroznienie" mode="inline">
- <em class="author-emphasis"><xsl:apply-templates mode="inline" /></em>
-</xsl:template>
-
-<xsl:template match="osoba" mode="inline">
- <em class="person"><xsl:apply-templates mode="inline" /></em>
-</xsl:template>
-
-
-<!-- ============================================== -->
-<!-- = STANDALONE TAGS = -->
-<!-- = (cannot contain any other tags) = -->
-<!-- ============================================== -->
-<xsl:template match="sekcja_swiatlo">
- <hr class="spacer" />
-</xsl:template>
-
-<xsl:template match="sekcja_asterysk">
- <p class="spacer-asterisk">*</p>
-</xsl:template>
-
-<xsl:template match="separator_linia">
- <hr class="spacer-line" />
-</xsl:template>
-
-
-<!-- ================ -->
-<!-- = SPECIAL TAGS = -->
-<!-- ================ -->
-<!-- Themes -->
-<xsl:template match="begin" mode="inline">
- <xsl:variable name="mnum" select="concat('m', substring(@id, 2))" />
- <a name="m{substring(@id, 2)}" class="theme-begin" fid="{substring(@id, 2)}">
- <xsl:value-of select="string(following::motyw[@id=$mnum]/text())" />
- </a>
-</xsl:template>
-
-<xsl:template match="end" mode="inline">
- <span class="theme-end" fid="{substring(@id, 2)}"> </span>
-</xsl:template>
-
-<xsl:template match="begin|end">
- <xsl:apply-templates select='.' mode="inline" />
-</xsl:template>
-
-<xsl:template match="motyw" mode="inline" />
-
-
-<!-- ================ -->
-<!-- = IGNORED TAGS = -->
-<!-- ================ -->
-<xsl:template match="extra|uwaga" />
-<xsl:template match="extra|uwaga" mode="inline" />
-
-
-<!-- ======== -->
-<!-- = TEXT = -->
-<!-- ======== -->
-<xsl:template match="text()" />
-<xsl:template match="text()" mode="inline">
- <xsl:value-of select="wl:substitute_entities(.)" />
-</xsl:template>
-
-
-</xsl:stylesheet>
\ No newline at end of file
+++ /dev/null
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:wl="http://wolnelektury.pl/functions" >
-
-<xsl:output encoding="utf-8" method="text" />
-
-<xsl:param name="wrapping" select="0" />
-
-<!-- ============================================================================== -->
-<!-- = MASTER TAG = -->
-<!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
-<!-- ============================================================================== -->
-<xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny">
-<xsl:if test="nazwa_utworu"><xsl:apply-templates select="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul" mode="header" /></xsl:if>
-<xsl:text>
-
-</xsl:text>
-<xsl:apply-templates />
-</xsl:template>
-
-
-<!-- ==================================================================================== -->
-<!-- = BLOCK TAGS = -->
-<!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
-<!-- ==================================================================================== -->
-<xsl:template match="nota">
-<xsl:apply-templates />
-</xsl:template>
-
-<xsl:template match="lista_osob">
-<xsl:text>
-
-
-</xsl:text>
-<xsl:value-of select="naglowek_listy" />
-<xsl:apply-templates select="lista_osoba" />
-<xsl:text>
-</xsl:text>
-</xsl:template>
-
-<xsl:template match="dedykacja">
-<xsl:text>
-
-</xsl:text>
-<xsl:apply-templates />
-</xsl:template>
-
-<xsl:template match="kwestia">
-<xsl:apply-templates select="strofa|akap|didaskalia" />
-</xsl:template>
-
-<xsl:template match="dlugi_cytat|poezja_cyt">
-<xsl:text>
-</xsl:text>
-<xsl:apply-templates />
-</xsl:template>
-
-<xsl:template match="motto">
-<xsl:text>
-
-
-
-</xsl:text>
-<xsl:apply-templates /><xsl:text>
-
-</xsl:text>
-</xsl:template>
-
-
-<!-- ========================================== -->
-<!-- = PARAGRAPH TAGS = -->
-<!-- = (can contain inline and special tags) = -->
-<!-- ========================================== -->
-<!-- Title page -->
-<xsl:template match="autor_utworu" mode="header">
-<xsl:text>
-
-</xsl:text>
-<xsl:apply-templates mode="inline" />
-</xsl:template>
-
-<xsl:template match="nazwa_utworu" mode="header">
-<xsl:text>
-
-</xsl:text>
-<xsl:apply-templates mode="inline" />
-</xsl:template>
-
-<xsl:template match="dzielo_nadrzedne" mode="header">
-<xsl:text>
-
-</xsl:text>
-<xsl:apply-templates mode="inline" />
-</xsl:template>
-
-<xsl:template match="podtytul" mode="header">
-<xsl:text>
-</xsl:text>
-<xsl:apply-templates mode="inline" />
-</xsl:template>
-
-<!-- Section headers (included in index)-->
-<xsl:template match="naglowek_akt|naglowek_czesc|srodtytul">
-<xsl:text>
-
-
-
-
-</xsl:text>
-<xsl:apply-templates mode="inline" />
-</xsl:template>
-
-<xsl:template match="naglowek_scena|naglowek_rozdzial">
-<xsl:text>
-
-
-
-</xsl:text>
-<xsl:apply-templates mode="inline" />
-</xsl:template>
-
-<xsl:template match="naglowek_osoba|naglowek_podrozdzial">
-<xsl:text>
-
-
-</xsl:text>
-<xsl:apply-templates mode="inline" />
-</xsl:template>
-
-<!-- Other paragraph tags -->
-<xsl:template match="miejsce_czas">
-<xsl:text>
-
-
-
-</xsl:text>
-<xsl:apply-templates mode="inline" />
-</xsl:template>
-
-<xsl:template match="didaskalia">
-<xsl:variable name="content">
- <xsl:apply-templates select="*|text()" mode="inline" />
-</xsl:variable>
-<xsl:text>
-
-/ </xsl:text><xsl:value-of select="wl:wrap_words(wl:strip($content), $wrapping)" /><xsl:text> /</xsl:text>
-</xsl:template>
-
-<xsl:template match="lista_osoba">
-<xsl:text>
- * </xsl:text>
-<xsl:apply-templates mode="inline" />
-</xsl:template>
-
-<xsl:template match="akap|akap_dialog|akap_cd">
-<xsl:variable name="content">
- <xsl:apply-templates select="*|text()" mode="inline" />
-</xsl:variable>
-<xsl:text>
-
-</xsl:text>
-<xsl:value-of select="wl:wrap_words(wl:strip($content), $wrapping)" />
-</xsl:template>
-
-<xsl:template match="strofa">
-<xsl:text>
-</xsl:text>
- <xsl:choose>
- <xsl:when test="count(br) > 0">
- <xsl:call-template name="verse">
- <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
- <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
- </xsl:call-template>
- <xsl:for-each select="br">
- <!-- Each BR tag "consumes" text after it -->
- <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
- <xsl:call-template name="verse">
- <xsl:with-param name="verse-content"
- select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
- <xsl:with-param name="verse-type" select="following-sibling::*[count(preceding-sibling::br) = $lnum+1 and (name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd')][1]" />
- </xsl:call-template>
- </xsl:for-each>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="verse">
- <xsl:with-param name="verse-content" select="text() | node()" />
- <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
-<xsl:template name="verse">
- <xsl:param name="verse-content" />
- <xsl:param name="verse-type" />
-<xsl:text>
-</xsl:text>
- <xsl:variable name="content">
- <xsl:apply-templates select="$verse-content" mode="inline" />
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="name($verse-type) = 'wers_akap'">
- <xsl:text> </xsl:text>
- </xsl:when>
- <xsl:when test="name($verse-type) = 'wers_wciety'">
- <xsl:choose>
- <xsl:when test="$verse-content/@typ">
- <xsl:text> </xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text> </xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="name($verse-type) = 'wers_cd'">
- <xsl:text> </xsl:text>
- </xsl:when>
- </xsl:choose>
-<xsl:value-of select="wl:strip($content)" />
-</xsl:template>
-
-<xsl:template match="motto_podpis">
-<xsl:apply-templates mode="inline" />
-</xsl:template>
-
-
-<!-- ================================================ -->
-<!-- = INLINE TAGS = -->
-<!-- = (contain other inline tags and special tags) = -->
-<!-- ================================================ -->
-<!-- Annotations -->
-<xsl:template match="pa|pe|pr|pt" mode="inline" />
-
-<!-- Other inline tags -->
-<xsl:template match="mat" mode="inline"><xsl:apply-templates mode="inline" /></xsl:template>
-
-<xsl:template match="didask_tekst" mode="inline"><xsl:apply-templates mode="inline" /></xsl:template>
-
-<xsl:template match="slowo_obce" mode="inline"><xsl:apply-templates mode="inline" /></xsl:template>
-
-<xsl:template match="tytul_dziela" mode="inline">
-<xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
-</xsl:template>
-
-<xsl:template match="wyroznienie" mode="inline">
-<xsl:text>*</xsl:text><xsl:apply-templates mode="inline" /><xsl:text>*</xsl:text>
-</xsl:template>
-
-<xsl:template match="osoba" mode="inline">
-<xsl:apply-templates mode="inline" />
-</xsl:template>
-
-
-<!-- ============================================== -->
-<!-- = STANDALONE TAGS = -->
-<!-- = (cannot contain any other tags) = -->
-<!-- ============================================== -->
-<xsl:template match="sekcja_swiatlo">
-<xsl:text>
-
-
-
-</xsl:text>
-</xsl:template>
-
-<xsl:template match="sekcja_asterysk">
-<xsl:text>
-
-*
-
-</xsl:text>
-</xsl:template>
-
-<xsl:template match="separator_linia">
-<xsl:text>
-
-------------------------------------------------
-
-</xsl:text>
-</xsl:template>
-
-
-<!-- ================ -->
-<!-- = SPECIAL TAGS = -->
-<!-- ================ -->
-<!-- Themes -->
-<xsl:template match="begin" mode="inline" />
-
-<xsl:template match="end" mode="inline" />
-
-<xsl:template match="begin|end" />
-
-<xsl:template match="motyw" mode="inline" />
-
-
-<!-- ================ -->
-<!-- = IGNORED TAGS = -->
-<!-- ================ -->
-<xsl:template match="extra|uwaga" />
-<xsl:template match="extra|uwaga" mode="inline" />
-
-
-<!-- ======== -->
-<!-- = TEXT = -->
-<!-- ======== -->
-<xsl:template match="text()" />
-<xsl:template match="text()" mode="inline">
- <xsl:value-of select="wl:substitute_entities(.)" />
-</xsl:template>
-
-
-</xsl:stylesheet>
-
+++ /dev/null
-<config>
- <block-elements>
- <!-- tagi głowne -->
- <utwor />
- <opowiadanie />
- <liryka_l />
- <liryka_lp />
- <powiesc />
- <dramat_wierszowany_l />
- <dramat_wierszowany_lp />
- <dramat_wspolczesny />
-
- <!-- inne tagi -->
- <nota />
- <dedykacja />
- <kwestia />
- <motto />
- <didaskalia />
- </block-elements>
-
- <inline-elements>
- <!-- with emphasis -->
- <mat />
- <didask_tekst />
- <slowo_obce />
- <wyroznienie />
- <osoba />
- <tytul_dziela />
- </inline-elements>
-
- <paragraph-elements>
- <!-- akapity -->
- <akap />
- <akap_cd />
- <akap_dialog />
- <miejsce_czas />
- <motto_podpis />
- <wers_cd />
- <wers_akap />
- <wers_wciety />
- </paragraph-elements>
-
- <header-1-elements>
- <!-- placeholder -->
- <dzielo_nadrzedne />
- </header-1-elements>
-
- <header-2-elements>
- <naglowek_akt />
- <naglowek_czesc />
- <autor_utworu />
- <nazwa_utworu />
- <srodtytul />
- </header-2-elements>
-
- <header-3-elements>
- <naglowek_scena />
- <naglowek_rozdzial />
- <podtytul />
- </header-3-elements>
-
- <header-4-elements>
- <naglowek_osoba />
- <naglowek_podrozdzial />
- </header-4-elements>
-
- <special-tags>
- <strofa />
- <lista_osob />
- <lista_osoba />
- <sekcja_swiatlo />
- <sekcja_asterysk />
- <separator_linia />
- <zastepnik_wersu />
- <dlugi_cytat />
- </special-tags>
-
- <annotations>
- <pa />
- <pe />
- <pr />
- <pt />
- </annotations>
-
- <no-show-elements>
- <begin />
- <end />
- <extra />
- <uwaga />
- <motyw />
- <br />
- <pa />
- <pe />
- <pr />
- <pt />
- </no-show-elements>
-
- <editable>
- <strofa />
- <akap />
- <akap_cd />
- <akap_dialog />
- <dzielo_nadrzedne />
-
- <naglowek_akt />
- <naglowek_czesc />
- <autor_utworu />
- <nazwa_utworu />
- <srodtytul />
-
- <naglowek_scena />
- <naglowek_rozdzial />
- <podtytul />
-
- <naglowek_osoba />
- <naglowek_podrozdzial />
-
- <lista_osoba />
-
- <dlugi_cytat />
- <poezja_cyt />
-
- <didaskalia />
- </editable>
-</config>
\ No newline at end of file
]
STYLESHEETS = {
- 'legacy': 'book2html.xslt',
- 'full': 'wl2html_full.xslt',
- 'partial': 'wl2html_partial.xslt'
+ 'legacy': 'xslt/book2html.xslt',
+ 'full': 'xslt/wl2html_full.xslt',
+ 'partial': 'xslt/wl2html_partial.xslt'
}
def get_stylesheet(name):
return result
return True
else:
- print "[Librarian] didn't find any paragraphs"
return "<empty />"
except KeyError:
raise ValueError("'%s' is not a valid stylesheet.")
# -*- coding: utf-8 -*-
from librarian import ValidationError, NoDublinCore, ParseError
-from librarian import RDFNS, DCNS
+from librarian import RDFNS
from librarian import dcparser
from xml.parsers.expat import ExpatError
data = cls.LINE_SWAP_EXPR.sub(u'<br />\n', data)
try:
- parser = etree.XMLParser(remove_blank_text=True)
+ parser = etree.XMLParser(remove_blank_text=False)
return cls(etree.parse(StringIO(data), parser), parse_dublincore=parse_dublincore)
except (ExpatError, XMLSyntaxError, XSLTApplyError), e:
raise ParseError(e)
- def part_as_text(self, path):
+ def chunk(self, path):
# convert the path to XPath
- print "[L] Retrieving part:", path
+ expr = self.path_to_xpath(path)
+ elems = self.edoc.xpath(expr)
- elems = self.edoc.xpath(self.path_to_xpath(path))
- print "[L] xpath", elems
-
if len(elems) == 0:
- return None
-
- return etree.tostring(elems[0], encoding=unicode, pretty_print=True)
-
+ return None
+ else:
+ return elems[0]
def path_to_xpath(self, path):
parts = []
parts.append(part)
else:
tag, n = match.groups()
- parts.append("node()[position() = %d and name() = '%s']" % (int(n), tag) )
+ parts.append("*[%d][name() = '%s']" % (int(n)+1, tag) )
if parts[0] == '.':
parts[0] = ''
return self.edoc.xslt(stylesheet, **options)
def update_dc(self):
- parent = self.rdf_elem.getparent()
- parent.replace( self.rdf_elem, self.book_info.to_etree(parent) )
+ if self.book_info:
+ parent = self.rdf_elem.getparent()
+ parent.replace( self.rdf_elem, self.book_info.to_etree(parent) )
def serialize(self):
self.update_dc()
for key, data in chunk_dict.iteritems():
try:
xpath = self.path_to_xpath(key)
- node = self.edoc.xpath(xpath)[0]
- repl = etree.fromstring(data)
+ node = self.edoc.xpath(xpath)[0]
+ repl = etree.fromstring(u"<%s>%s</%s>" %(node.tag, data, node.tag) )
node.getparent().replace(node, repl);
except Exception, e:
unmerged.append( repr( (key, xpath, e) ) )
def transform(input_filename, output_filename, is_file=True, parse_dublincore=True, **options):
"""Transforms file input_filename in XML to output_filename in TXT."""
# Parse XSLT
- style_filename = os.path.join(os.path.dirname(__file__), 'book2txt.xslt')
+ style_filename = os.path.join(os.path.dirname(__file__), 'xslt/book2txt.xslt')
style = etree.parse(style_filename)
if is_file:
+++ /dev/null
-
-<xsl:stylesheet
- version="1.0"
-
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:wl2o="http://nowoczesnapolska.org.pl/WL/2.0/Overlay"
- xmlns:wl="http://wolnelektury.pl/functions"
-
- exclude-result-prefixes="wl" >
-
- <xsl:variable name="config" select="document('config.xml')" />
-
- <xsl:output method="xml"
- encoding="utf-8"
- indent="yes"
- omit-xml-declaration = "yes" />
-
- <xsl:strip-space elements = "strofa utwor kwestia liryka_l liryka_lp powiesc opowiadanie dramat_wierszowany_lp" />
- <!--
- Dokument ten opisuje podstawowe przekształcenia potrzebne
- do zamiany dokumentu WLML 1.0 na poprawnie sformatowany
- dokument XHMTL.
-
- -->
-
- <xsl:template name="generic-attributes">
- <xsl:param name="element" />
- <xsl:param name="mypath" />
- <xsl:variable name="tag" select="name($element)" />
-
- <xsl:if test="$with-paths">
- <xsl:attribute name="wl2o:path">
- <xsl:value-of select="$mypath" />
- </xsl:attribute>
- </xsl:if>
-
- <xsl:if test="$config//editable/*[name() = $tag]">
- <xsl:attribute name="wl2o:editable">editable</xsl:attribute>
- </xsl:if>
-
- <xsl:attribute name="class">
- <xsl:value-of select="$tag"/>
- </xsl:attribute>
- </xsl:template>
-
- <xsl:template name="generic-descent">
- <xsl:param name="element" />
- <xsl:param name="mypath" />
-
- <xsl:for-each select="child::node()">
- <xsl:apply-templates select="." mode="element-tag">
- <xsl:with-param name="offset" select="position()" />
- <xsl:with-param name="parent-path" select="$mypath" />
- </xsl:apply-templates>
- </xsl:for-each>
- </xsl:template>
-
- <xsl:template name="generic-content">
- <xsl:param name="element" />
- <xsl:param name="mypath" />
-
- <xsl:call-template name="generic-attributes">
- <xsl:with-param name="element" select="$element" />
- <xsl:with-param name="mypath" select="$mypath" />
- </xsl:call-template>
-
- <xsl:call-template name="generic-descent">
- <xsl:with-param name="element" select="$element" />
- <xsl:with-param name="mypath" select="$mypath" />
- </xsl:call-template>
- </xsl:template>
-
- <!-- Generyczne szablony -->
- <xsl:template name="generic" >
- <xsl:param name="element" />
- <xsl:param name="mypath" />
- <xsl:param name="offset" />
-
- <!-- <xsl:param name="parent-type" select="'block'" /> -->
-
- <xsl:variable name="tag" select="name($element)" />
-
- <xsl:choose>
- <!-- ignore namespaced elements -->
- <xsl:when test="namespace-uri()" />
-
- <xsl:when test="$config//block-elements/*[local-name() = $tag]">
- <xsl:element name="div" namespace="http://www.w3.org/1999/xhtml">
- <xsl:apply-templates select="$element" mode="element-content" >
- <xsl:with-param name="mypath" select="$mypath"/>
- </xsl:apply-templates>
- </xsl:element>
- </xsl:when>
-
- <xsl:when test="$config//paragraph-elements/*[local-name() = $tag]">
- <xsl:element name="p" namespace="http://www.w3.org/1999/xhtml">
- <xsl:apply-templates select="$element" mode="element-content" >
- <xsl:with-param name="mypath" select="$mypath"/>
- </xsl:apply-templates>
- </xsl:element>
- </xsl:when>
-
- <xsl:when test="$config//inline-elements/*[local-name() = $tag]">
- <xsl:element name="span" namespace="http://www.w3.org/1999/xhtml">
- <xsl:apply-templates select="$element" mode="element-content" >
- <xsl:with-param name="mypath" select="$mypath"/>
- </xsl:apply-templates>
- </xsl:element>
- </xsl:when>
-
- <xsl:when test="$config//header-1-elements/*[local-name() = $tag]">
- <xsl:element name="h1" namespace="http://www.w3.org/1999/xhtml">
- <xsl:apply-templates select="$element" mode="element-content" >
- <xsl:with-param name="mypath" select="$mypath"/>
- </xsl:apply-templates>
- </xsl:element>
- </xsl:when>
-
- <xsl:when test="$config//header-2-elements/*[local-name() = $tag]">
- <xsl:element name="h2" namespace="http://www.w3.org/1999/xhtml">
- <xsl:apply-templates select="$element" mode="element-content" >
- <xsl:with-param name="mypath" select="$mypath"/>
- </xsl:apply-templates>
- </xsl:element>
- </xsl:when>
-
- <xsl:when test="$config//header-3-elements/*[local-name() = $tag]">
- <xsl:element name="h3" namespace="http://www.w3.org/1999/xhtml">
- <xsl:apply-templates select="$element" mode="element-content" >
- <xsl:with-param name="mypath" select="$mypath"/>
- </xsl:apply-templates>
- </xsl:element>
- </xsl:when>
-
- <xsl:when test="$config//header-4-elements/*[local-name() = $tag]">
- <xsl:element name="h4" namespace="http://www.w3.org/1999/xhtml">
- <xsl:apply-templates select="$element" mode="element-content" >
- <xsl:with-param name="mypath" select="$mypath"/>
- </xsl:apply-templates>
- </xsl:element>
- </xsl:when>
-
- <xsl:when test="$config//no-show-elements/*[local-name() = $tag]" />
-
- <xsl:otherwise>
- <xsl:message terminate="yes">
- Nieznany tag '<xsl:value-of select="$tag" />' :(.
- </xsl:message>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-
- <!--
- <special-tags>
- <strofa />
- <lista_osob />
- <sekcja_swiatlo />
- <sekcja_asterysk />
- <separator_linia />
- </special-tags>
- -->
-
- <xsl:template match="dlugi_cytat|poezja_cyt" mode="element-tag">
- <xsl:param name="offset" />
- <xsl:param name="parent-path" />
- <xsl:variable name="mypath"
- select="concat($parent-path, '/', name(), '[', string($offset),']')" />
-
- <xsl:element name="blockquote" >
- <xsl:call-template name="generic-attributes">
- <xsl:with-param name="element" select="current()" />
- <xsl:with-param name="mypath" select="$mypath" />
- </xsl:call-template>
- <xsl:call-template name="generic-descent">
- <xsl:with-param name="element" select="current()" />
- <xsl:with-param name="mypath" select="$mypath" />
- </xsl:call-template>
- </xsl:element>
- </xsl:template>
-
-
- <xsl:template match="lista_osob" mode="element-tag">
- <xsl:param name="offset" />
- <xsl:param name="parent-path" />
- <xsl:variable name="mypath"
- select="concat($parent-path, '/', name(), '[', string($offset),']')" />
-
- <xsl:element name="div" >
- <xsl:call-template name="generic-attributes">
- <xsl:with-param name="element" select="current()" />
- <xsl:with-param name="mypath" select="$mypath" />
- </xsl:call-template>
-
- <xsl:apply-templates select="./naglowek-listy" mode="element-tag" />
- <ul>
- <xsl:for-each select="./lista_osoba">
- <xsl:apply-templates select="." mode="element-tag">
- <xsl:with-param name="offset" select="position()" />
- <xsl:with-param name="parent-path" select="$mypath" />
- </xsl:apply-templates>
- </xsl:for-each>
- </ul>
- </xsl:element>
- </xsl:template>
-
- <xsl:template match="lista_osoba" mode="element-tag">
- <xsl:param name="offset" />
- <xsl:param name="parent-path" />
- <xsl:variable name="mypath"
- select="concat($parent-path, '/', name(), '[', string($offset),']')" />
-
- <xsl:element name="li" >
- <xsl:call-template name="generic-attributes">
- <xsl:with-param name="element" select="current()" />
- <xsl:with-param name="mypath" select="$mypath" />
- </xsl:call-template>
- <xsl:call-template name="generic-descent">
- <xsl:with-param name="element" select="current()" />
- <xsl:with-param name="mypath" select="$mypath" />
- </xsl:call-template>
- </xsl:element>
- </xsl:template>
-
- <xsl:template match="separator_linia" mode="element-tag">
- <xsl:param name="offset" />
- <xsl:param name="parent-path" />
- <xsl:variable name="mypath"
- select="concat($parent-path, '/', name(), '[', string($offset),']')" />
-
- <xsl:element name="hr" >
- <xsl:call-template name="generic-attributes">
- <xsl:with-param name="element" select="current()" />
- <xsl:with-param name="mypath" select="$mypath" />
- </xsl:call-template>
- </xsl:element>
- </xsl:template>
-
- <xsl:template match="sekcja_swiatlo" mode="element-tag">
- <xsl:param name="offset" />
- <xsl:param name="parent-path" />
- <xsl:variable name="mypath"
- select="concat($parent-path, '/', name(), '[', string($offset),']')" />
-
- <xsl:element name="br" >
- <xsl:call-template name="generic-attributes">
- <xsl:with-param name="element" select="current()" />
- <xsl:with-param name="mypath" select="$mypath" />
- </xsl:call-template>
- </xsl:element>
- </xsl:template>
-
- <xsl:template match="sekcja_asterysk" mode="element-tag">
- <xsl:param name="offset" />
- <xsl:param name="parent-path" />
- <xsl:variable name="mypath"
- select="concat($parent-path, '/', name(), '[', string($offset),']')" />
-
- <xsl:element name="p" >
- <xsl:call-template name="generic-attributes">
- <xsl:with-param name="element" select="current()" />
- <xsl:with-param name="mypath" select="$mypath" />
- </xsl:call-template>
- *
- </xsl:element>
- </xsl:template>
-
- <xsl:template match="zastepnik_wersu|wers_akap|wers_cd|wers_wciety" mode="element-tag">
- <xsl:param name="offset" />
- <xsl:param name="parent-path" />
-
- <xsl:variable name="mypath"
- select="concat($parent-path, '/', name(), '[',string($offset),']')" />
-
- <xsl:call-template name="generic-descent">
- <xsl:with-param name="element" select="current()" />
- <xsl:with-param name="mypath" select="$mypath" />
- </xsl:call-template>
- </xsl:template>
-
- <!-- strofy -->
- <xsl:template match="strofa" mode="element-tag">
- <xsl:param name="offset" />
- <xsl:param name="parent-path" />
-
- <xsl:variable name="mypath"
- select="concat($parent-path, '/', name(), '[', string($offset),']')" />
-
- <xsl:element name="div" >
- <xsl:call-template name="generic-attributes">
- <xsl:with-param name="element" select="current()" />
- <xsl:with-param name="mypath" select="$mypath" />
- </xsl:call-template>
-
- <xsl:choose>
- <xsl:when test="count(br) > 0">
- <xsl:call-template name="verse">
- <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
- <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
- <xsl:with-param name="mypath" select="$mypath" />
- </xsl:call-template>
- <xsl:for-each select="br">
- <!-- Each BR tag "consumes" text after it -->
- <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
- <xsl:call-template name="verse">
- <xsl:with-param name="verse-content"
- select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
- <xsl:with-param name="verse-type" select="following-sibling::*[count(preceding-sibling::br) = $lnum+1 and (name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd')][1]" />
- <xsl:with-param name="mypath" select="$mypath" />
- </xsl:call-template>
- </xsl:for-each>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="verse">
- <xsl:with-param name="verse-content" select="child::node()" />
- <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
- <xsl:with-param name="mypath" select="$mypath" />
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:element>
- </xsl:template>
-
- <xsl:template name="verse">
- <xsl:param name="verse-content" />
- <xsl:param name="verse-type" />
- <xsl:param name="mypath" />
-
- <xsl:element name="p">
- <xsl:attribute name="class">
- <xsl:value-of select="name($verse-type)" />
- </xsl:attribute>
- <xsl:for-each select="$verse-content">
- <xsl:apply-templates select="." mode="element-tag">
- <xsl:with-param name="offset" select="position()" />
- <xsl:with-param name="parent-path" select="$mypath" />
- </xsl:apply-templates>
- </xsl:for-each>
- </xsl:element>
- </xsl:template>
-
-
-<!-- default content processing -->
- <xsl:template match="*" mode="element-content">
- <xsl:param name="mypath" />
- <xsl:call-template name="generic-content">
- <xsl:with-param name="element" select="current()"/>
- <xsl:with-param name="mypath" select="$mypath"/>
- </xsl:call-template>
- </xsl:template>
-
- <xsl:template match="*" mode="element-tag" >
- <xsl:param name="offset" />
- <xsl:param name="parent-path" />
-
- <xsl:variable name="mypath"
- select="concat($parent-path, '/', name(), '[', string($offset),']')" />
-
- <xsl:call-template name="generic">
- <xsl:with-param name="element" select="current()" />
- <xsl:with-param name="offset" select="$offset" />
- <xsl:with-param name="mypath" select="$mypath" />
- </xsl:call-template>
- </xsl:template>
-
- <xsl:template match="text()" mode="element-tag">
-
- <xsl:value-of select="wl:substitute_entities(.)" />
-
- <!--<xsl:value-of select="." /> -->
- </xsl:template>
-
- <xsl:template match="node()" />
-
-</xsl:stylesheet>
+++ /dev/null
-
-<xsl:stylesheet version="1.0"
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-
- <xsl:param name="with-paths" select="boolean(0)" />
- <xsl:param name="with-annotations" select="boolean(1)" />
-
- <xsl:include href="wl2html_base.xslt" />
- <xsl:output encoding="utf-8" indent="yes" omit-xml-declaration = "yes" />
-
- <xsl:template match="/">
- <div class="document">
-
- <xsl:if test="with-toc" />
-
- <xsl:call-template name="generic">
- <xsl:with-param name="element" select="/utwor" />
- <xsl:with-param name="mypath" select="'.'" />
- <xsl:with-param name="offset" select="position()" />
- </xsl:call-template>
-
- <xsl:if test="with-annotations" />
- </div>
- </xsl:template>
-
-</xsl:stylesheet>
\ No newline at end of file
+++ /dev/null
-<xsl:stylesheet version="1.0"
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-
- <xsl:param name="with-paths" select="boolean(0)" />
- <xsl:param name="base-path" select="'.'"/>
- <xsl:param name="base-offset" select="1" />
-
- <xsl:include href="wl2html_base.xslt" />
- <xsl:output encoding="utf-8" indent="yes" omit-xml-declaration = "yes" />
-
- <xsl:template match="/">
- <xsl:message>Processing...</xsl:message>
- <xsl:apply-templates select="/*" mode="element-tag">
- <xsl:with-param name="offset" select="$base-offset" />
- <xsl:with-param name="parent-path" select="$base-path" />
- </xsl:apply-templates>
- </xsl:template>
-
-</xsl:stylesheet>
\ No newline at end of file
--- /dev/null
+# -*- encoding: utf-8 -*-
+
+__author__= "Łukasz Rekucki"
+__date__ = "$2009-10-19 16:31:14$"
+__doc__ = "Functions to operate on a tag-light version of WLML."
+
+class LightSerializer(object):
+
+ def __init__(self):
+ pass
+
+ def serialize(self, element):
+ handler = getattr(self, 'serialize_' + element.tag, self.identity)
+ return handler(element) + (element.tail or u'')
+
+ def serialize_slowo_obce(self, e):
+ return u' %%'+self.descent(e)+u'%% '
+
+ def descent(self, e):
+ b = (e.text or u'')
+ for child in e.iterchildren():
+ b += self.serialize(child)
+ return b
+
+ def identity(self, e):
+ b = u'<'+e.tag
+
+ # attributes
+ b += u' '.join((u'%s="%s"' % (attr, value) for attr,value in e.items()))
+ b += u'>'
+ b += self.descent(e)
+ b += u'</' + e.tag + u'>'
+
+ return b
+
+_serializer = LightSerializer()
+
+def serialize_nl(element):
+ prolog = u'' + element.text # ordinary stuff
+ data = u''
+
+ for child in element.iterchildren():
+ data += _serializer.serialize(child)
+
+ return prolog + data
+
+
--- /dev/null
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:wl="http://wolnelektury.pl/functions" >
+
+<xsl:output encoding="utf-8" indent="yes" omit-xml-declaration = "yes" version="2.0" />
+
+
+<xsl:template match="utwor">
+ <!-- <html>
+ <head>
+ <title>Książka z serwisu WolneLektury.pl</title>
+ <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
+ </head>
+ <style>
+ body {
+ font-size: 16px;
+ font: Georgia, "Times New Roman", serif;
+ line-height: 1.5em;
+ margin: 0;
+ }
+
+ a {
+ color: blue;
+ text-decoration: none;
+ }
+
+ #book-text {
+ margin: 3em;
+ max-width: 36em;
+ }
+
+ /* ================================== */
+ /* = Header with logo and menu = */
+ /* ================================== */
+ #header {
+ margin: 3.4em 0 0 1.4em;
+ }
+
+ img {
+ border: none;
+ }
+
+
+ #menu {
+ position: fixed;
+ left: 0em;
+ top: 0em;
+ width: 100%;
+ height: 1.5em;
+ background: #333;
+ color: #FFF;
+ opacity: 0.9;
+ }
+
+ #menu ul {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ }
+
+ #menu li a {
+ display: block;
+ float: left;
+ width: 7.5em;
+ height: 1.5em;
+ margin-left: 0.5em;
+ text-align: center;
+ color: #FFF;
+ }
+
+ #menu li a:hover, #menu li a:active {
+ color: #000;
+ background: #FFF url(/media/img/arrow-down.png) no-repeat center right;
+ }
+
+ #menu li a.selected {
+ color: #000;
+ background: #FFF url(/media/img/arrow-up.png) no-repeat center right;
+ }
+
+ #toc, #themes {
+ position: fixed;
+ left: 0em;
+ top: 1.5em;
+ width: 37em;
+ padding: 1.5em;
+ background: #FFF;
+ border-bottom: 0.25em solid #DDD;
+ border-right: 0.25em solid #DDD;
+ display: none;
+ height: 16em;
+ overflow-x: hidden;
+ overflow-y: auto;
+ opacity: 0.9;
+ }
+
+ #toc ol, #themes ol {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ }
+
+ #toc ol li {
+ font-weight: bold;
+ }
+
+ #toc ol ol {
+ padding: 0 0 1.5em 1.5em;
+ margin: 0;
+ }
+
+ #toc ol ol li {
+ font-weight: normal;
+ }
+
+ #toc h2 {
+ display: none;
+ }
+
+ #toc .anchor {
+ float: none;
+ margin: 0;
+ color: blue;
+ font-size: 16px;
+ position: inherit;
+ }
+
+ /* =================================================== */
+ /* = Common elements: headings, paragraphs and lines = */
+ /* =================================================== */
+ h1 {
+ font-size: 3em;
+ margin: 1.5em 0;
+ text-align: center;
+ line-height: 1.5em;
+ font-weight: bold;
+ }
+
+ h2 {
+ font-size: 2em;
+ margin: 1.5em 0 0;
+ font-weight: bold;
+ line-height: 1.5em;
+ }
+
+ h3 {
+ font-size: 1.5em;
+ margin: 1.5em 0 0;
+ font-weight: normal;
+ line-height: 1.5em;
+ }
+
+ h4 {
+ font-size: 1em;
+ margin: 1.5em 0 0;
+ line-height: 1.5em;
+ }
+
+ p {
+ margin: 0;
+ }
+
+ /* ======================== */
+ /* = Footnotes and themes = */
+ /* ======================== */
+ .theme-begin {
+ border-left: 0.1em solid #DDDDDD;
+ color: #777;
+ padding: 0 0.5em;
+ width: 7.5em;
+ font-style: normal;
+ font-weight: normal;
+ font-size: 16px;
+ float: right;
+ margin-right: -9.5em;
+ clear: both;
+ left: 40em;
+ line-height: 1.5em;
+ text-align: left;
+ }
+
+ .annotation {
+ font-style: normal;
+ font-weight: normal;
+ font-size: 12px;
+ }
+
+ #footnotes .annotation {
+ display: block;
+ float: left;
+ width: 2.5em;
+ clear: both;
+ }
+
+ #footnotes div {
+ margin: 1.5em 0 0 0;
+ }
+
+ #footnotes p {
+ margin-left: 2.5em;
+ font-size: 0.875em;
+ }
+
+ blockquote {
+ font-size: 0.875em;
+ }
+
+ /* ============= */
+ /* = Numbering = */
+ /* ============= */
+ .anchor {
+ position: absolute;
+ margin: -0.25em -0.5em;
+ left: 1em;
+ color: #777;
+ font-size: 12px;
+ width: 2em;
+ text-align: center;
+ padding: 0.25em 0.5em;
+ line-height: 1.5em;
+ }
+
+ .anchor:hover, #book-text .anchor:active {
+ color: #FFF;
+ background-color: #CCC;
+ }
+
+ /* =================== */
+ /* = Custom elements = */
+ /* =================== */
+ span.author {
+ font-size: 0.5em;
+ display: block;
+ line-height: 1.5em;
+ margin-bottom: 0.25em;
+ }
+
+ span.collection {
+ font-size: 0.375em;
+ display: block;
+ line-height: 1.5em;
+ margin-bottom: -0.25em;
+ }
+
+ span.subtitle {
+ font-size: 0.5em;
+ display: block;
+ line-height: 1.5em;
+ margin-top: -0.25em;
+ }
+
+ div.didaskalia {
+ font-style: italic;
+ margin: 0.5em 0 0 1.5em;
+ }
+
+ div.kwestia {
+ margin: 0.5em 0 0;
+ }
+
+ div.stanza {
+ margin: 1.5em 0 0;
+ }
+
+ div.kwestia div.stanza {
+ margin: 0;
+ }
+
+ p.paragraph {
+ text-align: justify;
+ margin: 1.5em 0 0;
+ }
+
+ p.motto {
+ text-align: justify;
+ font-style: italic;
+ margin: 1.5em 0 0;
+ }
+
+ p.motto_podpis {
+ font-size: 0.875em;
+ text-align: right;
+ }
+
+ div.fragment {
+ border-bottom: 0.1em solid #999;
+ padding-bottom: 1.5em;
+ }
+
+ div.note p, div.dedication p, div.note p.paragraph, div.dedication p.paragraph {
+ text-align: right;
+ font-style: italic;
+ }
+
+ hr.spacer {
+ height: 3em;
+ visibility: hidden;
+ }
+
+ hr.spacer-line {
+ margin: 1.5em 0;
+ border: none;
+ border-bottom: 0.1em solid #000;
+ }
+
+ p.spacer-asterisk {
+ padding: 0;
+ margin: 1.5em 0;
+ text-align: center;
+ }
+
+ div.person-list ol {
+ list-style: none;
+ padding: 0 0 0 1.5em;
+ }
+
+ p.place-and-time {
+ font-style: italic;
+ }
+
+ em.math, em.foreign-word, em.book-title, em.didaskalia {
+ font-style: italic;
+ }
+
+ em.author-emphasis {
+ letter-spacing: 0.1em;
+ }
+
+ em.person {
+ font-style: normal;
+ font-variant: small-caps;
+ }
+ </style>
+ <body> -->
+ <div id="book-text">
+ <xsl:apply-templates select="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny" />
+ <xsl:if test="count(descendant::*[self::pe or self::pa or self::pr or self::pt][not(parent::extra)])">
+ <div id="footnotes">
+ <h3>Przypisy</h3>
+ <xsl:for-each select="descendant::*[self::pe or self::pa or self::pr or self::pt][not(parent::extra)]">
+ <div>
+ <a name="{concat('footnote-', generate-id(.))}" />
+ <a href="{concat('#anchor-', generate-id(.))}" class="annotation">[<xsl:number value="count(preceding::*[self::pa or self::pe or self::pr or self::pt]) + 1" />]</a>
+ <xsl:choose>
+ <xsl:when test="count(akap|akap_cd|strofa) = 0">
+ <p><xsl:apply-templates select="text()|*" mode="inline" /></p>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="text()|*" mode="inline" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </div>
+ </xsl:for-each>
+ </div>
+ </xsl:if>
+ </div>
+ <!-- </body>
+ </html> -->
+</xsl:template>
+
+
+<!-- ============================================================================== -->
+<!-- = MASTER TAG = -->
+<!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
+<!-- ============================================================================== -->
+<xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny">
+ <xsl:if test="nazwa_utworu">
+ <h1>
+ <xsl:apply-templates select="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul" mode="header" />
+ </h1>
+ </xsl:if>
+ <xsl:apply-templates />
+</xsl:template>
+
+
+<!-- ==================================================================================== -->
+<!-- = BLOCK TAGS = -->
+<!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
+<!-- ==================================================================================== -->
+<xsl:template match="nota">
+ <div class="note"><xsl:apply-templates /></div>
+</xsl:template>
+
+<xsl:template match="lista_osob">
+ <div class="person-list">
+ <h3><xsl:value-of select="naglowek_listy" /></h3>
+ <ol>
+ <xsl:apply-templates select="lista_osoba" />
+ </ol>
+ </div>
+</xsl:template>
+
+<xsl:template match="dedykacja">
+ <div class="dedication"><xsl:apply-templates /></div>
+</xsl:template>
+
+<xsl:template match="kwestia">
+ <div class="kwestia">
+ <xsl:apply-templates select="strofa|akap|didaskalia" />
+ </div>
+</xsl:template>
+
+<xsl:template match="dlugi_cytat|poezja_cyt">
+ <blockquote><xsl:apply-templates /></blockquote>
+</xsl:template>
+
+<xsl:template match="motto">
+ <div class="motto"><xsl:apply-templates mode="inline" /></div>
+</xsl:template>
+
+
+<!-- ========================================== -->
+<!-- = PARAGRAPH TAGS = -->
+<!-- = (can contain inline and special tags) = -->
+<!-- ========================================== -->
+<!-- Title page -->
+<xsl:template match="autor_utworu" mode="header">
+ <span class="author editable"><xsl:apply-templates mode="inline" /></span>
+</xsl:template>
+
+<xsl:template match="nazwa_utworu" mode="header">
+ <span class="title editable"><xsl:apply-templates mode="inline" /></span>
+</xsl:template>
+
+<xsl:template match="dzielo_nadrzedne" mode="header">
+ <span class="collection"><xsl:apply-templates mode="inline" /></span>
+</xsl:template>
+
+<xsl:template match="podtytul" mode="header">
+ <span class="subtitle"><xsl:apply-templates mode="inline" /></span>
+</xsl:template>
+
+<!-- Section headers (included in index)-->
+<xsl:template match="naglowek_akt|naglowek_czesc|srodtytul">
+ <h2><xsl:apply-templates mode="inline" /></h2>
+</xsl:template>
+
+<xsl:template match="naglowek_scena|naglowek_rozdzial">
+ <h3><xsl:apply-templates mode="inline" /></h3>
+</xsl:template>
+
+<xsl:template match="naglowek_osoba|naglowek_podrozdzial">
+ <h4><xsl:apply-templates mode="inline" /></h4>
+</xsl:template>
+
+<!-- Other paragraph tags -->
+<xsl:template match="miejsce_czas">
+ <p class="place-and-time"><xsl:apply-templates mode="inline" /></p>
+</xsl:template>
+
+<xsl:template match="didaskalia">
+ <div class="didaskalia"><xsl:apply-templates mode="inline" /></div>
+</xsl:template>
+
+<xsl:template match="lista_osoba">
+ <li><xsl:apply-templates mode="inline" /></li>
+</xsl:template>
+
+<xsl:template match="akap|akap_dialog|akap_cd">
+ <p class="paragraph editable"><xsl:apply-templates mode="inline" /></p>
+</xsl:template>
+
+<xsl:template match="strofa">
+ <div class="stanza editable">
+ <xsl:choose>
+ <xsl:when test="count(br) > 0">
+ <xsl:call-template name="verse">
+ <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
+ <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
+ </xsl:call-template>
+ <xsl:for-each select="br">
+ <!-- Each BR tag "consumes" text after it -->
+ <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
+ <xsl:call-template name="verse">
+ <xsl:with-param name="verse-content"
+ select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
+ <xsl:with-param name="verse-type" select="following-sibling::*[count(preceding-sibling::br) = $lnum+1 and (name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd')][1]" />
+ </xsl:call-template>
+ </xsl:for-each>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="verse">
+ <xsl:with-param name="verse-content" select="text() | node()" />
+ <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </div>
+</xsl:template>
+
+<xsl:template name="verse">
+ <xsl:param name="verse-content" />
+ <xsl:param name="verse-type" />
+ <p class="verse">
+ <xsl:choose>
+ <xsl:when test="name($verse-type) = 'wers_akap'">
+ <xsl:attribute name="style">padding-left: 1em</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="name($verse-type) = 'wers_wciety'">
+ <xsl:choose>
+ <xsl:when test="$verse-content/@typ">
+ <xsl:attribute name="style">padding-left: <xsl:value-of select="$verse-content/@typ" />em</xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="style">padding-left: 1em</xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="name($verse-type) = 'wers_cd'">
+ <xsl:attribute name="style">padding-left: 12em</xsl:attribute>
+ </xsl:when>
+ </xsl:choose>
+ <xsl:apply-templates select="$verse-content" mode="inline" />
+ </p>
+</xsl:template>
+
+<xsl:template match="motto_podpis">
+ <p class="motto_podpis"><xsl:apply-templates mode="inline" /></p>
+</xsl:template>
+
+
+<!-- ================================================ -->
+<!-- = INLINE TAGS = -->
+<!-- = (contain other inline tags and special tags) = -->
+<!-- ================================================ -->
+<!-- Annotations -->
+<xsl:template match="pa|pe|pr|pt" mode="inline">
+ <a name="{concat('anchor-', generate-id(.))}" />
+ <a href="{concat('#footnote-', generate-id(.))}" class="annotation">[<xsl:number value="count(preceding::*[self::pa or self::pe or self::pr or self::pt]) + 1" />]</a>
+</xsl:template>
+
+<!-- Other inline tags -->
+<xsl:template match="mat" mode="inline">
+ <em class="math"><xsl:apply-templates mode="inline" /></em>
+</xsl:template>
+
+<xsl:template match="didask_tekst" mode="inline">
+ <em class="didaskalia"><xsl:apply-templates mode="inline" /></em>
+</xsl:template>
+
+<xsl:template match="slowo_obce" mode="inline">
+ <em class="foreign-word"><xsl:apply-templates mode="inline" /></em>
+</xsl:template>
+
+<xsl:template match="tytul_dziela" mode="inline">
+ <em class="book-title">
+ <xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
+ </em>
+</xsl:template>
+
+<xsl:template match="wyroznienie" mode="inline">
+ <em class="author-emphasis"><xsl:apply-templates mode="inline" /></em>
+</xsl:template>
+
+<xsl:template match="osoba" mode="inline">
+ <em class="person"><xsl:apply-templates mode="inline" /></em>
+</xsl:template>
+
+
+<!-- ============================================== -->
+<!-- = STANDALONE TAGS = -->
+<!-- = (cannot contain any other tags) = -->
+<!-- ============================================== -->
+<xsl:template match="sekcja_swiatlo">
+ <hr class="spacer" />
+</xsl:template>
+
+<xsl:template match="sekcja_asterysk">
+ <p class="spacer-asterisk">*</p>
+</xsl:template>
+
+<xsl:template match="separator_linia">
+ <hr class="spacer-line" />
+</xsl:template>
+
+
+<!-- ================ -->
+<!-- = SPECIAL TAGS = -->
+<!-- ================ -->
+<!-- Themes -->
+<xsl:template match="begin" mode="inline">
+ <xsl:variable name="mnum" select="concat('m', substring(@id, 2))" />
+ <a name="m{substring(@id, 2)}" class="theme-begin" fid="{substring(@id, 2)}">
+ <xsl:value-of select="string(following::motyw[@id=$mnum]/text())" />
+ </a>
+</xsl:template>
+
+<xsl:template match="end" mode="inline">
+ <span class="theme-end" fid="{substring(@id, 2)}"> </span>
+</xsl:template>
+
+<xsl:template match="begin|end">
+ <xsl:apply-templates select='.' mode="inline" />
+</xsl:template>
+
+<xsl:template match="motyw" mode="inline" />
+
+
+<!-- ================ -->
+<!-- = IGNORED TAGS = -->
+<!-- ================ -->
+<xsl:template match="extra|uwaga" />
+<xsl:template match="extra|uwaga" mode="inline" />
+
+
+<!-- ======== -->
+<!-- = TEXT = -->
+<!-- ======== -->
+<xsl:template match="text()" />
+<xsl:template match="text()" mode="inline">
+ <xsl:value-of select="wl:substitute_entities(.)" />
+</xsl:template>
+
+
+</xsl:stylesheet>
\ No newline at end of file
--- /dev/null
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:wl="http://wolnelektury.pl/functions" >
+
+<xsl:output encoding="utf-8" method="text" />
+
+<xsl:param name="wrapping" select="0" />
+
+<!-- ============================================================================== -->
+<!-- = MASTER TAG = -->
+<!-- = (can contain block tags, paragraph tags, standalone tags and special tags) = -->
+<!-- ============================================================================== -->
+<xsl:template match="powiesc|opowiadanie|liryka_l|liryka_lp|dramat_wierszowany_l|dramat_wierszowany_lp|dramat_wspolczesny">
+<xsl:if test="nazwa_utworu"><xsl:apply-templates select="autor_utworu|dzielo_nadrzedne|nazwa_utworu|podtytul" mode="header" /></xsl:if>
+<xsl:text>
+
+</xsl:text>
+<xsl:apply-templates />
+</xsl:template>
+
+
+<!-- ==================================================================================== -->
+<!-- = BLOCK TAGS = -->
+<!-- = (can contain other block tags, paragraph tags, standalone tags and special tags) = -->
+<!-- ==================================================================================== -->
+<xsl:template match="nota">
+<xsl:apply-templates />
+</xsl:template>
+
+<xsl:template match="lista_osob">
+<xsl:text>
+
+
+</xsl:text>
+<xsl:value-of select="naglowek_listy" />
+<xsl:apply-templates select="lista_osoba" />
+<xsl:text>
+</xsl:text>
+</xsl:template>
+
+<xsl:template match="dedykacja">
+<xsl:text>
+
+</xsl:text>
+<xsl:apply-templates />
+</xsl:template>
+
+<xsl:template match="kwestia">
+<xsl:apply-templates select="strofa|akap|didaskalia" />
+</xsl:template>
+
+<xsl:template match="dlugi_cytat|poezja_cyt">
+<xsl:text>
+</xsl:text>
+<xsl:apply-templates />
+</xsl:template>
+
+<xsl:template match="motto">
+<xsl:text>
+
+
+
+</xsl:text>
+<xsl:apply-templates /><xsl:text>
+
+</xsl:text>
+</xsl:template>
+
+
+<!-- ========================================== -->
+<!-- = PARAGRAPH TAGS = -->
+<!-- = (can contain inline and special tags) = -->
+<!-- ========================================== -->
+<!-- Title page -->
+<xsl:template match="autor_utworu" mode="header">
+<xsl:text>
+
+</xsl:text>
+<xsl:apply-templates mode="inline" />
+</xsl:template>
+
+<xsl:template match="nazwa_utworu" mode="header">
+<xsl:text>
+
+</xsl:text>
+<xsl:apply-templates mode="inline" />
+</xsl:template>
+
+<xsl:template match="dzielo_nadrzedne" mode="header">
+<xsl:text>
+
+</xsl:text>
+<xsl:apply-templates mode="inline" />
+</xsl:template>
+
+<xsl:template match="podtytul" mode="header">
+<xsl:text>
+</xsl:text>
+<xsl:apply-templates mode="inline" />
+</xsl:template>
+
+<!-- Section headers (included in index)-->
+<xsl:template match="naglowek_akt|naglowek_czesc|srodtytul">
+<xsl:text>
+
+
+
+
+</xsl:text>
+<xsl:apply-templates mode="inline" />
+</xsl:template>
+
+<xsl:template match="naglowek_scena|naglowek_rozdzial">
+<xsl:text>
+
+
+
+</xsl:text>
+<xsl:apply-templates mode="inline" />
+</xsl:template>
+
+<xsl:template match="naglowek_osoba|naglowek_podrozdzial">
+<xsl:text>
+
+
+</xsl:text>
+<xsl:apply-templates mode="inline" />
+</xsl:template>
+
+<!-- Other paragraph tags -->
+<xsl:template match="miejsce_czas">
+<xsl:text>
+
+
+
+</xsl:text>
+<xsl:apply-templates mode="inline" />
+</xsl:template>
+
+<xsl:template match="didaskalia">
+<xsl:variable name="content">
+ <xsl:apply-templates select="*|text()" mode="inline" />
+</xsl:variable>
+<xsl:text>
+
+/ </xsl:text><xsl:value-of select="wl:wrap_words(wl:strip($content), $wrapping)" /><xsl:text> /</xsl:text>
+</xsl:template>
+
+<xsl:template match="lista_osoba">
+<xsl:text>
+ * </xsl:text>
+<xsl:apply-templates mode="inline" />
+</xsl:template>
+
+<xsl:template match="akap|akap_dialog|akap_cd">
+<xsl:variable name="content">
+ <xsl:apply-templates select="*|text()" mode="inline" />
+</xsl:variable>
+<xsl:text>
+
+</xsl:text>
+<xsl:value-of select="wl:wrap_words(wl:strip($content), $wrapping)" />
+</xsl:template>
+
+<xsl:template match="strofa">
+<xsl:text>
+</xsl:text>
+ <xsl:choose>
+ <xsl:when test="count(br) > 0">
+ <xsl:call-template name="verse">
+ <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
+ <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
+ </xsl:call-template>
+ <xsl:for-each select="br">
+ <!-- Each BR tag "consumes" text after it -->
+ <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
+ <xsl:call-template name="verse">
+ <xsl:with-param name="verse-content"
+ select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
+ <xsl:with-param name="verse-type" select="following-sibling::*[count(preceding-sibling::br) = $lnum+1 and (name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd')][1]" />
+ </xsl:call-template>
+ </xsl:for-each>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="verse">
+ <xsl:with-param name="verse-content" select="text() | node()" />
+ <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template name="verse">
+ <xsl:param name="verse-content" />
+ <xsl:param name="verse-type" />
+<xsl:text>
+</xsl:text>
+ <xsl:variable name="content">
+ <xsl:apply-templates select="$verse-content" mode="inline" />
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="name($verse-type) = 'wers_akap'">
+ <xsl:text> </xsl:text>
+ </xsl:when>
+ <xsl:when test="name($verse-type) = 'wers_wciety'">
+ <xsl:choose>
+ <xsl:when test="$verse-content/@typ">
+ <xsl:text> </xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text> </xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+ <xsl:when test="name($verse-type) = 'wers_cd'">
+ <xsl:text> </xsl:text>
+ </xsl:when>
+ </xsl:choose>
+<xsl:value-of select="wl:strip($content)" />
+</xsl:template>
+
+<xsl:template match="motto_podpis">
+<xsl:apply-templates mode="inline" />
+</xsl:template>
+
+
+<!-- ================================================ -->
+<!-- = INLINE TAGS = -->
+<!-- = (contain other inline tags and special tags) = -->
+<!-- ================================================ -->
+<!-- Annotations -->
+<xsl:template match="pa|pe|pr|pt" mode="inline" />
+
+<!-- Other inline tags -->
+<xsl:template match="mat" mode="inline"><xsl:apply-templates mode="inline" /></xsl:template>
+
+<xsl:template match="didask_tekst" mode="inline"><xsl:apply-templates mode="inline" /></xsl:template>
+
+<xsl:template match="slowo_obce" mode="inline"><xsl:apply-templates mode="inline" /></xsl:template>
+
+<xsl:template match="tytul_dziela" mode="inline">
+<xsl:if test="@typ = '1'">„</xsl:if><xsl:apply-templates mode="inline" /><xsl:if test="@typ = '1'">”</xsl:if>
+</xsl:template>
+
+<xsl:template match="wyroznienie" mode="inline">
+<xsl:text>*</xsl:text><xsl:apply-templates mode="inline" /><xsl:text>*</xsl:text>
+</xsl:template>
+
+<xsl:template match="osoba" mode="inline">
+<xsl:apply-templates mode="inline" />
+</xsl:template>
+
+
+<!-- ============================================== -->
+<!-- = STANDALONE TAGS = -->
+<!-- = (cannot contain any other tags) = -->
+<!-- ============================================== -->
+<xsl:template match="sekcja_swiatlo">
+<xsl:text>
+
+
+
+</xsl:text>
+</xsl:template>
+
+<xsl:template match="sekcja_asterysk">
+<xsl:text>
+
+*
+
+</xsl:text>
+</xsl:template>
+
+<xsl:template match="separator_linia">
+<xsl:text>
+
+------------------------------------------------
+
+</xsl:text>
+</xsl:template>
+
+
+<!-- ================ -->
+<!-- = SPECIAL TAGS = -->
+<!-- ================ -->
+<!-- Themes -->
+<xsl:template match="begin" mode="inline" />
+
+<xsl:template match="end" mode="inline" />
+
+<xsl:template match="begin|end" />
+
+<xsl:template match="motyw" mode="inline" />
+
+
+<!-- ================ -->
+<!-- = IGNORED TAGS = -->
+<!-- ================ -->
+<xsl:template match="extra|uwaga" />
+<xsl:template match="extra|uwaga" mode="inline" />
+
+
+<!-- ======== -->
+<!-- = TEXT = -->
+<!-- ======== -->
+<xsl:template match="text()" />
+<xsl:template match="text()" mode="inline">
+ <xsl:value-of select="wl:substitute_entities(.)" />
+</xsl:template>
+
+
+</xsl:stylesheet>
+
--- /dev/null
+<config>
+ <types>
+ <structure element="div">
+ <!-- tagi głowne -->
+ <utwor />
+ <opowiadanie />
+ <liryka_l />
+ <liryka_lp />
+ <powiesc />
+ <dramat_wierszowany_l />
+ <dramat_wierszowany_lp />
+ <dramat_wspolczesny />
+ </structure>
+
+ <block element="div" mixed="true" >
+ <!-- inne tagi -->
+ <nota />
+ <dedykacja />
+ <kwestia />
+ <motto />
+ <didaskalia />
+ </block>
+
+ <inline-elements element="span" mixed="true">
+ <!-- with emphasis -->
+ <mat />
+ <didask_tekst />
+ <slowo_obce />
+ <wyroznienie />
+ <osoba />
+ <tytul_dziela />
+ </inline-elements>
+
+ <paragraph-elements element="p" mixed="true">
+ <!-- akapity -->
+ <akap />
+ <akap_cd />
+ <akap_dialog />
+ <miejsce_czas />
+ <motto_podpis />
+ <wers_cd />
+ <wers_akap />
+ <wers_wciety />
+ </paragraph-elements>
+
+ <header-1-elements element="h1" mixed="true">
+ <!-- placeholder -->
+ <dzielo_nadrzedne />
+ </header-1-elements>
+
+ <header-2-elements element="h2" mixed="true">
+ <naglowek_akt />
+ <naglowek_czesc />
+ <autor_utworu />
+ <nazwa_utworu />
+ <srodtytul />
+ </header-2-elements>
+
+ <header-3-elements element="h3" mixed="true">
+ <naglowek_scena />
+ <naglowek_rozdzial />
+ <podtytul />
+ </header-3-elements>
+
+ <header-4-elements element="h4" mixed="true">
+ <naglowek_osoba />
+ <naglowek_podrozdzial />
+ </header-4-elements>
+
+ <special-tags>
+ <strofa />
+ <lista_osob />
+ <lista_osoba />
+ <sekcja_swiatlo />
+ <sekcja_asterysk />
+ <separator_linia />
+ <zastepnik_wersu />
+ <dlugi_cytat />
+ </special-tags>
+
+ <annotations>
+ <pa />
+ <pe />
+ <pr />
+ <pt />
+ </annotations>
+
+ <no-show-elements>
+ <begin />
+ <end />
+ <extra />
+ <uwaga />
+ <motyw />
+ <br />
+ <pa />
+ <pe />
+ <pr />
+ <pt />
+ </no-show-elements>
+ </types>
+
+ <editable>
+ <strofa />
+ <akap />
+ <akap_cd />
+ <akap_dialog />
+ <dzielo_nadrzedne />
+
+ <naglowek_akt />
+ <naglowek_czesc />
+ <autor_utworu />
+ <nazwa_utworu />
+ <srodtytul />
+
+ <naglowek_scena />
+ <naglowek_rozdzial />
+ <podtytul />
+
+ <naglowek_osoba />
+ <naglowek_podrozdzial />
+
+ <lista_osoba />
+
+ <dlugi_cytat />
+ <poezja_cyt />
+
+ <didaskalia />
+ </editable>
+</config>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:stylesheet version="1.0"
+ xmlns="http://nowoczesnapolska.org.pl/ML/Lektury/1.1"
+
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:wlf="http://wolnelektury.pl/functions"
+
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+
+ exclude-result-prefixes="wlf xsl"
+>
+
+ <!-- Normalization Stylsheet for Wolne Lektury XML -->
+ <xsl:output method="xml" encoding="utf-8" indent="yes" />
+
+ <xsl:strip-space elements="rdf:RDF rdf:Description meta doc main-text strofa stanza drama-line wlml:*" />
+
+ <xsl:param name="normalize-text" select="boolean(1)" />
+
+ <!-- Main entry point -->
+ <xsl:template match="/">
+ <doc>
+ <meta>
+ <xsl:apply-templates select="//rdf:RDF" mode="meta"/>
+ </meta>
+
+ <xsl:variable name="body" select="/utwor/*[local-name() = name()]" />
+
+ <main-text class="{name($body)}">
+ <xsl:apply-templates select="$body/node()" />
+ </main-text>
+
+ <annotations>
+ <xsl:apply-templates select="//pr|pt|pe|pa" mode="annotations" />
+ </annotations>
+ </doc>
+ </xsl:template>
+
+ <xsl:template match="strofa">
+ <xsl:element name="stanza" namespace="http://nowoczesnapolska.org.pl/ML/Lektury/1.1">
+ <!-- normalize verses -->
+ <xsl:choose>
+ <xsl:when test="count(br) > 0">
+ <!-- First, collect all the tags up to first BR -->
+ <xsl:call-template name="verse">
+ <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::node()" />
+ <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
+ </xsl:call-template>
+
+ <!-- Collect the rest of verses -->
+ <xsl:for-each select="br">
+ <!-- Each BR tag "consumes" text after it -->
+ <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
+ <xsl:call-template name="verse">
+ <xsl:with-param name="verse-content"
+ select="following-sibling::node()[count(preceding-sibling::br) = $lnum+1 and name() != 'br']" />
+ <xsl:with-param name="verse-type" select="following-sibling::*[count(preceding-sibling::br) = $lnum+1 and (name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd')][1]" />
+ </xsl:call-template>
+ </xsl:for-each>
+ </xsl:when>
+
+ <!-- No BR's - collect the whole content -->
+ <xsl:otherwise>
+ <xsl:call-template name="verse">
+ <xsl:with-param name="verse-content" select="child::node()" />
+ <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
+ </xsl:call-template>
+ </xsl:otherwise>
+
+ </xsl:choose>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template name="verse">
+ <xsl:param name="verse-content" />
+ <xsl:param name="verse-type" />
+
+ <xsl:choose>
+ <xsl:when test="not($verse-type)">
+ <xsl:element name="v" namespace="http://nowoczesnapolska.org.pl/ML/Lektury/1.1">
+ <xsl:apply-templates select="$verse-content" />
+ </xsl:element>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:apply-templates select="$verse-content" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+
+ <!-- akapity -->
+ <xsl:template match="akap">
+ <xsl:element name="p">
+ <xsl:apply-templates select="@*|node()" />
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="akap_cd">
+ <xsl:element name="pc">
+ <xsl:apply-templates select="@*|node()" />
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="akap_dialog">
+ <xsl:element name="pd">
+ <xsl:variable name="prolog" select="./text()[1]" />
+ <xsl:value-of select="wlf:fix-dialog-line($prolog)" />
+ <xsl:apply-templates select="@*|*|text()[. != $prolog]" />
+ </xsl:element>
+ </xsl:template>
+
+ <!-- wersy -->
+ <xsl:template match="wers_cd">
+ <xsl:element name="vc">
+ <xsl:apply-templates select="@*|node()" />
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="wers_akap">
+ <xsl:element name="vi">
+ <xsl:attribute name="size">p</xsl:attribute>
+ <xsl:apply-templates select="@*|node()" />
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="wers_wciety">
+ <xsl:element name="vi">
+ <xsl:if test="@typ">
+ <xsl:attribute name="size"><xsl:value-of select="@typ" /></xsl:attribute>
+ </xsl:if>
+ <xsl:apply-templates select="@*[name() != 'typ']|node()" />
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="zastepnik_wersu">
+ <xsl:element name="verse-skip">
+ <xsl:choose>
+ <xsl:when test="starts-with(., '.')">
+ <xsl:attribute name="type">dot</xsl:attribute>
+ </xsl:when>
+ </xsl:choose>
+ </xsl:element>
+ </xsl:template>
+
+ <!-- Przypisy i motywy -->
+ <xsl:template match="begin">
+ <xsl:element name="mark">
+ <xsl:attribute name="starts">
+ <xsl:value-of select="substring(@id, 2)" />
+ </xsl:attribute>
+ <xsl:attribute name="themes">
+ <xsl:value-of select="following-sibling::motyw[1]/text()" />
+ </xsl:attribute>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="motyw" />
+
+ <xsl:template match="end">
+ <xsl:element name="mark">
+ <xsl:attribute name="ends">
+ <xsl:value-of select="substring(@id, 2)" />
+ </xsl:attribute>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="pa|pe|pr|pt">
+ <mark id="{generate-id(.)}" />
+ </xsl:template>
+
+
+ <xsl:template match="pa|pe|pr|pt" mode="annotations">
+ <annotation refs="{generate-id(.)}" type="{name(.)}">
+ <xsl:apply-templates select="@*|node()" />
+ </annotation>
+ </xsl:template>
+
+
+ <!-- Tytuły -->
+ <xsl:template match="autor_utworu">
+ <xsl:element name="author">
+ <xsl:apply-templates select="@*|node()" />
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="nazwa_utworu">
+ <xsl:element name="title">
+ <xsl:apply-templates select="@*|node()" />
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="naglowek_czesc">
+ <chapter>
+ <xsl:apply-templates select="@*|node()" />
+ </chapter>
+ </xsl:template>
+
+ <xsl:template match="naglowek_akt">
+ <act>
+ <xsl:apply-templates select="@*|node()" />
+ </act>
+ </xsl:template>
+
+ <xsl:template match="naglowek_scena">
+ <scene>
+ <xsl:apply-templates select="@*|node()" />
+ </scene>
+ </xsl:template>
+
+ <xsl:template match="podtytul">
+ <second-title>
+ <xsl:apply-templates select="@*|node()" />
+ </second-title>
+ </xsl:template>
+
+ <xsl:template match="srodtytul">
+ <part-title>
+ <xsl:apply-templates select="@*|node()" />
+ </part-title>
+ </xsl:template>
+
+ <!-- elementy dramatu -->
+ <xsl:template match="miejsce_czas">
+ <xsl:element name="time-and-date">
+ <xsl:apply-templates select="@*|node()" />
+ </xsl:element>
+ </xsl:template>
+
+
+ <xsl:template match="didaskalia|didask_tekst">
+ <xsl:element name="stage-directions">
+ <xsl:apply-templates select="@*|node()" />
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="motto">
+ <xsl:element name="motto">
+ <xsl:apply-templates select="@*|node()" />
+
+ <xsl:variable name="sign" select="following-sibling::*[1][name() = 'motto_podpis']" />
+ <signature>
+ <xsl:apply-templates select="$sign/node()" />
+ </signature>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="motto_podpis[preceding-sibling::*[1][name() = 'motto']]" />
+
+ <xsl:template match="lista_osob">
+ <person-list>
+ <xsl:apply-templates select="@*|node()" />
+ </person-list>
+ </xsl:template>
+
+ <xsl:template match="naglowek_listy">
+ <caption>
+ <xsl:apply-templates select="@*|node()" />
+ </caption>
+ </xsl:template>
+
+ <xsl:template match="lista_osoba">
+ <person>
+ <xsl:apply-templates select="@*|node()" />
+ </person>
+ </xsl:template>
+
+ <!-- Odstępy i prześwity -->
+ <xsl:template match="sekcja_swiatlo">
+ <vertical-space />
+ </xsl:template>
+
+ <xsl:template match="sekcja_asterysk">
+ <vertical-space type="asterisk" />
+ </xsl:template>
+
+ <xsl:template match="sekcja_asterysk">
+ <vertical-space type="line" />
+ </xsl:template>
+
+ <!-- pozostałe elementy blokowe -->
+ <xsl:template match="dlugi_cytat">
+ <block-quote>
+ <xsl:apply-templates select="@*|node()" />
+ </block-quote>`
+ </xsl:template>
+
+ <xsl:template match="poezja_cyt">
+ <block-quote>
+ <xsl:apply-templates select="@*|node()" />
+ </block-quote>`
+ </xsl:template>
+
+ <xsl:template match="kwestia">
+ <xsl:variable name="person" select="preceding-sibling::*[1][name() = 'naglowek_osoba']" />
+ <drama-line>
+ <person>
+ <xsl:apply-templates select="$person/node()" />
+ </person>
+ <xsl:apply-templates select="node()[. != $person]" />
+ </drama-line>
+ </xsl:template>
+
+ <xsl:template match="naglowek_osoba[following-sibling::*[1][name() = 'kwestia']]" />
+
+ <!-- Inne -->
+ <xsl:template match="osoba">
+ <xsl:element name="person-ref">
+ <xsl:apply-templates select="@*|node()" />
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="slowo_obce">
+ <xsl:element name="df">
+ <xsl:apply-templates select="@*|node()" />
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="wyroznienie">
+ <xsl:element name="em">
+ <xsl:apply-templates select="@*|node()" />
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="mat">
+ <xsl:element name="math">
+ <xsl:apply-templates select="@*|node()" />
+ </xsl:element>
+ </xsl:template>
+
+ <!-- oznaczenie tytulu innego utworu, wymienionego w tym -->
+ <xsl:template match="tytul_dziela">
+ <xsl:element name="book-ref">
+ <xsl:apply-templates select="@*|node()" />
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="extra">
+ <xsl:element name="comment">
+ <xsl:apply-templates select="@*|node()" />
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="uwaga">
+ <xsl:element name="edit-comment">
+ <xsl:apply-templates select="@*|node()" />
+ </xsl:element>
+ </xsl:template>
+
+ <!-- Copy attributes -->
+ <xsl:template match="@*|comment()">
+ <xsl:copy />
+ </xsl:template>
+
+ <!-- Inside RDF meta-data, leave the text unchanged -->
+ <xsl:template match="rdf:RDF//text()">
+ <xsl:value-of select="." />
+ </xsl:template>
+
+ <!-- Normalize text in other nodes -->
+ <xsl:template match="text()">
+ <xsl:choose>
+ <xsl:when test="$normalize-text">
+ <xsl:value-of select="wlf:normalize-text(.)" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="." />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <!-- Ignoruj RDF poza meta -->
+ <xsl:template match="rdf:*|dc:*" />
+
+ <xsl:template match="@*|node()" mode="meta">
+ <xsl:copy>
+ <xsl:apply-templates match="@*|node()" mode="meta" />
+ </xsl:copy>
+ </xsl:template>
+
+ <!-- Warn about non-matched elements -->
+ <xsl:template match="node()">
+ <xsl:message>
+ <xsl:text>Nieprzetworzony węzeł:</xsl:text>
+ <xsl:value-of select="." />
+ </xsl:message>
+ <unparsed-node>
+ <xsl:copy-of select="." />
+ </unparsed-node>
+ </xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:stylesheet
+ version="1.0"
+
+ xmlns:wlml="http://nowoczesnapolska.org.pl/ML/Lektury/1.1"
+
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xmlns:wl="http://wolnelektury.pl/functions" >
+
+ <xsl:output method="xml"
+ encoding="utf-8"
+ indent="yes"
+ omit-xml-declaration = "yes" />
+
+<!-- generic template parameters -->
+
+ <xsl:param name="verse-numbers-interval" select="5" />
+
+<!-- main templates -->
+
+ <xsl:template match="/">
+ <fo:root >
+
+ <fo:layout-master-set>
+ <!-- layout information -->
+ <fo:simple-page-master
+ master-name="title-page"
+ page-height="29.7cm"
+ page-width="21cm"
+ margin-top="2.5cm"
+ margin-bottom="2.5cm"
+ margin-left="2.5cm"
+ margin-right="2.5cm">
+ <fo:region-body />
+ </fo:simple-page-master>
+
+ <fo:simple-page-master
+ master-name="blank-page"
+ page-height="29.7cm"
+ page-width="21cm"
+
+ margin-top="2.5cm"
+ margin-bottom="2.5cm"
+ margin-left="2.5cm"
+ margin-right="2.5cm">
+ <fo:region-body />
+ </fo:simple-page-master>
+
+ <fo:simple-page-master
+ master-name="first-main"
+ page-height="29.7cm"
+ page-width="21cm"
+ margin-top="2cm"
+ margin-bottom="2cm"
+ margin-left="3cm"
+ margin-right="2cm">
+ <fo:region-body
+ margin-top="2cm"
+ margin-bottom="2cm" />
+ <fo:region-after
+ region-name="odd-after"
+ display-align="after"
+ extent="2cm" />
+ </fo:simple-page-master>
+
+ <fo:simple-page-master
+ master-name="odd"
+ page-height="29.7cm"
+ page-width="21cm"
+ margin-top="2cm"
+ margin-bottom="2cm"
+ margin-left="3cm"
+ margin-right="2cm">
+ <fo:region-body
+ margin-top="2cm"
+ margin-bottom="2cm" />
+
+ <fo:region-before
+ region-name="odd-before"
+ extent="2cm" />
+
+ <fo:region-after
+ region-name="odd-after"
+ display-align="after"
+ extent="2cm" />
+ </fo:simple-page-master>
+
+ <fo:simple-page-master
+ master-name="even"
+ page-height="29.7cm"
+ page-width="21cm"
+ margin-top="2cm"
+ margin-bottom="2cm"
+ margin-left="2cm"
+ margin-right="3cm">
+ <fo:region-body
+ margin-top="2cm"
+ margin-bottom="2cm" />
+
+ <fo:region-before
+ region-name="even-before"
+ extent="2cm" />
+
+ <fo:region-after
+ region-name="even-after"
+ display-align="after"
+ extent="2cm" />
+ </fo:simple-page-master>
+
+
+ <fo:page-sequence-master master-name="book-titles">
+ <fo:single-page-master-reference master-reference="title-page" />
+ <fo:repeatable-page-master-reference master-reference="blank-page" />
+ </fo:page-sequence-master>
+
+ <fo:page-sequence-master master-name="main">
+ <fo:repeatable-page-master-alternatives>
+ <fo:conditional-page-master-reference
+ master-reference="first-main"
+ page-position="first"
+ odd-or-even="odd" />
+
+ <fo:conditional-page-master-reference
+ master-reference="odd"
+ page-position="rest"
+ odd-or-even="odd" />
+
+ <fo:conditional-page-master-reference
+ master-reference="even"
+ page-position="any"
+ odd-or-even="even" />
+ </fo:repeatable-page-master-alternatives>
+
+ </fo:page-sequence-master>
+
+ </fo:layout-master-set>
+ <!-- end: defines page layout -->
+
+<!--
+ TITLE PAGE, COPYRIGHT, ETC. \
+-->
+ <fo:page-sequence
+ master-reference="book-titles">
+
+ <fo:flow flow-name="xsl-region-body"
+ font-family="Antique"
+ text-align="center"
+ >
+
+ <fo:block font-size="32pt" display-align="center" >
+ <fo:marker marker-class-name="author">
+ <xsl:value-of select="//wlml:author" />
+ </fo:marker>
+ <xsl:apply-templates select="//wlml:author/node()" mode="title"/>
+ </fo:block>
+
+ <fo:block font-size="48pt" display-align="center" >
+ <fo:marker marker-class-name="main-title">
+ <xsl:value-of select="//wlml:title" />
+ </fo:marker>
+ <xsl:apply-templates select="//wlml:title/node()" mode="title"/>
+ </fo:block>
+ </fo:flow>
+ </fo:page-sequence>
+
+<!--
+ MAIN BOOK CONTENT
+-->
+ <fo:page-sequence
+ master-reference="main"
+ initial-page-number="1"
+ force-page-count="even"
+ >
+
+ <fo:static-content
+ flow-name="xsl-footnote-separator">
+ <fo:block text-align-last="justify">
+ <fo:leader leader-pattern="rule"/>
+ </fo:block>
+ </fo:static-content>
+
+ <fo:static-content
+ flow-name="odd-after" font-family="Antique" text-align="center">
+ <fo:block>
+ <fo:page-number />
+ </fo:block>
+ </fo:static-content>
+
+ <fo:static-content
+ flow-name="even-after" font-family="Antique" text-align="center">
+ <fo:block>
+ <fo:page-number />
+ </fo:block>
+ </fo:static-content>
+
+
+ <fo:static-content
+ flow-name="even-before"
+ font-family="Antique"
+ text-align="right">
+
+ <fo:block border-bottom-width="0.2mm"
+ border-bottom-style="solid"
+ border-bottom-color="black">
+ <fo:retrieve-marker retrieve-class-name="main-title" />
+ </fo:block>
+ </fo:static-content>
+
+ <fo:static-content
+ flow-name="odd-before"
+ font-family="Antique"
+ text-align="left">
+
+ <fo:block border-after-width="0.2mm"
+ border-after-style="solid"
+ border-after-color="black">
+ <fo:retrieve-marker retrieve-class-name="chapter-title" />
+ </fo:block>
+ </fo:static-content>
+
+
+
+ <fo:flow flow-name="xsl-region-body" font-family="Antique">
+
+ <fo:marker marker-class-name="author">
+ <xsl:value-of select="//wlml:author" />
+ </fo:marker>
+ <fo:marker marker-class-name="main-title">
+ <xsl:value-of select="//wlml:title" />
+ </fo:marker>
+
+ <xsl:apply-templates select="//wlml:main-text" />
+ </fo:flow>
+
+ </fo:page-sequence>
+ </fo:root>
+ </xsl:template>
+
+ <xsl:template match="wlml:main-text">
+ <xsl:apply-templates select="child::*" />
+ </xsl:template>
+
+<!--
+ PROZA: elementy proste
+-->
+
+ <xsl:template match="wlml:chapter">
+ <fo:block text-align="left" font-size="32pt" font-weight="bold" font-variant="small-caps">
+ <fo:marker marker-class-name="chapter-title">
+ <xsl:apply-templates select="node()" />
+ </fo:marker>
+ <xsl:apply-templates select="node()" />
+ </fo:block>
+ </xsl:template>
+
+ <xsl:template match="wlml:p">
+ <fo:block
+ space-before="1em"
+ space-after="1em"
+ start-indent="1.5em">
+ <xsl:apply-templates select="child::node()" />
+ </fo:block>
+ </xsl:template>
+
+ <xsl:template match="wlml:pd">
+ <fo:block
+ space-before="1em"
+ space-after="1em"
+ start-indent="0em"
+ >— 
+ <xsl:apply-templates select="child::node()" />
+ </fo:block>
+ </xsl:template>
+
+ <xsl:template match="wlml:pd/text()[1]">
+ <xsl:value-of select="substring-after(., '— ')" />
+ </xsl:template>
+
+<!--
+ POEZJA
+-->
+ <xsl:template match="wlml:stanza">
+ <fo:list-block
+ space-before="1.5em" space-after="1.5em">
+ <xsl:apply-templates select="child::node()" />
+ </fo:list-block>
+ </xsl:template>
+
+ <xsl:template match="wlml:v|wlml:vi|wlml:vc">
+ <fo:list-item>
+ <xsl:attribute name="id"><xsl:value-of select="local-name()"/>-<xsl:value-of select="generate-id()"/></xsl:attribute>
+
+ <xsl:if test="count(preceding-sibling::wlml:v|preceding-sibling::wlml:vi|preceding-sibling::wlml:vc) < 2">
+ <xsl:attribute name="keep-with-previous.within-page">always</xsl:attribute>
+ </xsl:if>
+
+ <xsl:if test="count(following-sibling::wlml:v|following-sibling::wlml:vi|following-sibling::wlml:vc) < 2">
+ <xsl:attribute name="keep-with-next.within-page">always</xsl:attribute>
+ </xsl:if>
+
+ <xsl:variable name="vc"><xsl:number count="wlml:v|wlml:vi|wlml:vc" level="any" from="wlml:chapter" /></xsl:variable>
+
+ <fo:list-item-label start-indent="-1cm">
+ <fo:block><xsl:if test="($vc mod 5) = 0"><xsl:value-of select="$vc" /></xsl:if></fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="0cm">
+ <fo:block><xsl:apply-templates select="node()" /></fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ </xsl:template>
+
+<!--
+ Wyroznienia
+-->
+ <xsl:template match="wlml:df">
+ <fo:inline font-style="italic">
+ <xsl:apply-templates select="node()" />
+ </fo:inline>
+ </xsl:template>
+
+
+<!--
+ Przypisy
+-->
+<xsl:template match="wlml:mark[//wlml:annotation/@refs = @id]">
+ <xsl:variable name="annot" select="//wlml:annotation[@refs = current()/@id]" />
+ <fo:footnote>
+ <fo:inline><xsl:number level="any" /></fo:inline>
+ <fo:footnote-body>
+ <fo:block><xsl:apply-templates select="$annot/node()" /></fo:block>
+ </fo:footnote-body>
+ </fo:footnote>
+</xsl:template>
+
+<xsl:template match="*" />
+
+</xsl:stylesheet>
--- /dev/null
+
+<xsl:stylesheet
+ version="1.0"
+
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:wl="http://wolnelektury.pl/functions"
+
+ exclude-result-prefixes="wl" >
+
+ <xsl:variable name="config" select="document('config.xml')" />
+
+ <xsl:output method="xml"
+ encoding="utf-8"
+ indent="yes"
+ omit-xml-declaration = "yes" />
+
+ <!--
+ Dokument ten opisuje podstawowe przekształcenia potrzebne
+ do zamiany dokumentu WLML 1.0 na poprawnie sformatowany
+ dokument XHMTL.
+
+ -->
+
+ <xsl:template name="generic-attributes">
+ <xsl:param name="element" />
+ <xsl:param name="mypath" />
+ <xsl:variable name="tag" select="name($element)" />
+
+ <xsl:if test="$with-paths">
+ <xsl:attribute name="x-pointer">
+ <xsl:value-of select="$mypath" />
+ </xsl:attribute>
+ </xsl:if>
+
+ <xsl:if test="$config//editable/*[name() = $tag]">
+ <xsl:attribute name="x-editable">editable</xsl:attribute>
+ </xsl:if>
+
+ <xsl:attribute name="class">
+ <xsl:value-of select="$tag"/>
+ </xsl:attribute>
+ </xsl:template>
+
+ <xsl:template name="generic-descent">
+ <xsl:param name="element" />
+ <xsl:param name="mypath" />
+ <xsl:param name="mixed" />
+
+ <xsl:for-each select="child::node()">
+ <xsl:apply-templates select="." mode="element-tag">
+ <xsl:with-param name="offset" select="count(preceding-sibling::*)" />
+ <xsl:with-param name="parent-path" select="$mypath" />
+ <xsl:with-param name="mixed" select="$mixed" />
+ </xsl:apply-templates>
+ </xsl:for-each>
+ </xsl:template>
+
+ <xsl:template name="generic-content">
+ <xsl:param name="element" />
+ <xsl:param name="mypath" />
+ <xsl:param name="mixed" />
+
+ <xsl:call-template name="generic-attributes">
+ <xsl:with-param name="element" select="$element" />
+ <xsl:with-param name="mypath" select="$mypath" />
+ </xsl:call-template>
+
+ <xsl:call-template name="generic-descent">
+ <xsl:with-param name="element" select="$element" />
+ <xsl:with-param name="mypath" select="$mypath" />
+ <xsl:with-param name="mixed" select="$mixed" />
+ </xsl:call-template>
+ </xsl:template>
+
+ <!-- Generyczne szablony -->
+ <xsl:template name="generic" >
+ <xsl:param name="element" />
+ <xsl:param name="mypath" />
+ <xsl:param name="offset" />
+
+ <!-- <xsl:param name="parent-type" select="'block'" /> -->
+
+ <xsl:variable name="tag" select="name($element)" />
+ <xsl:variable name="group" select="$config//types/*[@element and child::*[local-name() = $tag]]" />
+
+ <xsl:choose>
+ <!-- ignore namespaced elements -->
+ <xsl:when test="namespace-uri()" />
+ <xsl:when test="$group/@element">
+
+ <xsl:element name="{$group/@element}" namespace="http://www.w3.org/1999/xhtml">
+ <xsl:apply-templates select="$element" mode="element-content" >
+ <xsl:with-param name="mypath" select="$mypath" />
+ <xsl:with-param name="mixed" select="boolean($group/@mixed)" />
+ </xsl:apply-templates>
+ </xsl:element>
+ </xsl:when>
+ <xsl:otherwise />
+ </xsl:choose>
+
+ </xsl:template>
+
+ <!--
+ Tagi niestandardowe
+ -->
+
+ <xsl:template match="pr|pa|pe|pt" mode="element-tag">
+ <a href="#annotation-{generate-id(.)}"><span class="annotation"/></a><a name="anchor-{generate-id(.)}" />
+ </xsl:template>
+
+ <xsl:template match="dlugi_cytat|poezja_cyt" mode="element-tag">
+ <xsl:param name="offset" />
+ <xsl:param name="parent-path" />
+ <xsl:variable name="mypath"
+ select="concat($parent-path, '/', name(), '[', string($offset),']')" />
+
+ <xsl:element name="blockquote" >
+ <xsl:call-template name="generic-attributes">
+ <xsl:with-param name="element" select="current()" />
+ <xsl:with-param name="mypath" select="$mypath" />
+ </xsl:call-template>
+ <xsl:call-template name="generic-descent">
+ <xsl:with-param name="element" select="current()" />
+ <xsl:with-param name="mypath" select="$mypath" />
+ <xsl:with-param name="mixed" select="true" />
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:template>
+
+
+ <xsl:template match="lista_osob" mode="element-tag">
+ <xsl:param name="offset" />
+ <xsl:param name="parent-path" />
+ <xsl:variable name="mypath"
+ select="concat($parent-path, '/', name(), '[', string($offset),']')" />
+
+ <xsl:element name="div" >
+ <xsl:call-template name="generic-attributes">
+ <xsl:with-param name="element" select="current()" />
+ <xsl:with-param name="mypath" select="$mypath" />
+ </xsl:call-template>
+
+ <xsl:apply-templates select="./naglowek-listy" mode="element-tag" />
+ <ul>
+ <xsl:for-each select="./lista_osoba">
+ <xsl:apply-templates select="." mode="element-tag">
+ <xsl:with-param name="offset" select="count(preceding-sibling::*)" />
+ <xsl:with-param name="parent-path" select="$mypath" />
+ <xsl:with-param name="mixed" select="false" />
+ </xsl:apply-templates>
+ </xsl:for-each>
+ </ul>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="lista_osoba" mode="element-tag">
+ <xsl:param name="offset" />
+ <xsl:param name="parent-path" />
+ <xsl:variable name="mypath"
+ select="concat($parent-path, '/', name(), '[', string($offset),']')" />
+
+ <xsl:element name="li" >
+ <xsl:call-template name="generic-attributes">
+ <xsl:with-param name="element" select="current()" />
+ <xsl:with-param name="mypath" select="$mypath" />
+ </xsl:call-template>
+ <xsl:call-template name="generic-descent">
+ <xsl:with-param name="element" select="current()" />
+ <xsl:with-param name="mypath" select="$mypath" />
+ <xsl:with-param name="mixed" select="true" />
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="separator_linia" mode="element-tag">
+ <xsl:param name="offset" />
+ <xsl:param name="parent-path" />
+ <xsl:variable name="mypath"
+ select="concat($parent-path, '/', name(), '[', string($offset),']')" />
+
+ <xsl:element name="hr" >
+ <xsl:call-template name="generic-attributes">
+ <xsl:with-param name="element" select="current()" />
+ <xsl:with-param name="mypath" select="$mypath" />
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="sekcja_swiatlo" mode="element-tag">
+ <xsl:param name="offset" />
+ <xsl:param name="parent-path" />
+ <xsl:variable name="mypath"
+ select="concat($parent-path, '/', name(), '[', string($offset),']')" />
+
+ <xsl:element name="br" >
+ <xsl:call-template name="generic-attributes">
+ <xsl:with-param name="element" select="current()" />
+ <xsl:with-param name="mypath" select="$mypath" />
+ </xsl:call-template>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="sekcja_asterysk" mode="element-tag">
+ <xsl:param name="offset" />
+ <xsl:param name="parent-path" />
+ <xsl:variable name="mypath"
+ select="concat($parent-path, '/', name(), '[', string($offset),']')" />
+
+ <xsl:element name="p" >
+ <xsl:call-template name="generic-attributes">
+ <xsl:with-param name="element" select="current()" />
+ <xsl:with-param name="mypath" select="$mypath" />
+ </xsl:call-template>
+ *
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="zastepnik_wersu|wers_akap|wers_cd|wers_wciety" mode="element-tag">
+ <xsl:param name="offset" />
+ <xsl:param name="parent-path" />
+
+ <xsl:variable name="mypath"
+ select="concat($parent-path, '/', name(), '[',string($offset),']')" />
+
+ <xsl:call-template name="generic-descent">
+ <xsl:with-param name="element" select="current()" />
+ <xsl:with-param name="mypath" select="$mypath" />
+ <xsl:with-param name="mixed" select="boolean(1)" />
+ </xsl:call-template>
+ </xsl:template>
+
+ <!-- strofy -->
+ <xsl:template match="strofa" mode="element-tag">
+ <xsl:param name="offset" />
+ <xsl:param name="parent-path" />
+
+ <xsl:variable name="mypath"
+ select="concat($parent-path, '/', name(), '[', string($offset),']')" />
+
+ <xsl:element name="div" >
+ <xsl:call-template name="generic-attributes">
+ <xsl:with-param name="element" select="current()" />
+ <xsl:with-param name="mypath" select="$mypath" />
+ </xsl:call-template>
+
+ <xsl:choose>
+ <xsl:when test="count(br) > 0">
+ <xsl:call-template name="verse">
+ <xsl:with-param name="verse-content" select="br[1]/preceding-sibling::text() | br[1]/preceding-sibling::node()" />
+ <xsl:with-param name="verse-type" select="br[1]/preceding-sibling::*[name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd'][1]" />
+ <xsl:with-param name="mypath" select="$mypath" />
+ </xsl:call-template>
+ <xsl:for-each select="br">
+ <!-- Each BR tag "consumes" text after it -->
+ <xsl:variable name="lnum" select="count(preceding-sibling::br)" />
+ <xsl:call-template name="verse">
+ <xsl:with-param name="verse-content"
+ select="following-sibling::text()[count(preceding-sibling::br) = $lnum+1] | following-sibling::node()[count(preceding-sibling::br) = $lnum+1]" />
+ <xsl:with-param name="verse-type" select="following-sibling::*[count(preceding-sibling::br) = $lnum+1 and (name() = 'wers_wciety' or name() = 'wers_akap' or name() = 'wers_cd')][1]" />
+ <xsl:with-param name="mypath" select="$mypath" />
+ </xsl:call-template>
+ </xsl:for-each>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="verse">
+ <xsl:with-param name="verse-content" select="child::node()" />
+ <xsl:with-param name="verse-type" select="wers_wciety|wers_akap|wers_cd[1]" />
+ <xsl:with-param name="mypath" select="$mypath" />
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template name="verse">
+ <xsl:param name="verse-content" />
+ <xsl:param name="verse-type" />
+ <xsl:param name="mypath" />
+
+ <xsl:element name="p">
+ <xsl:attribute name="class">
+ <xsl:value-of select="name($verse-type)" />
+ </xsl:attribute>
+ <xsl:for-each select="$verse-content">
+ <xsl:apply-templates select="." mode="element-tag">
+ <xsl:with-param name="offset" select="count(preceding-sibling::*)" />
+ <xsl:with-param name="parent-path" select="$mypath" />
+ <xsl:with-param name="mixed" select="boolean(1)" />
+ </xsl:apply-templates>
+ </xsl:for-each>
+ </xsl:element>
+ </xsl:template>
+
+
+<!-- default content processing -->
+ <xsl:template match="*" mode="element-content">
+ <xsl:param name="mypath" />
+ <xsl:param name="mixed" />
+
+ <xsl:call-template name="generic-content">
+ <xsl:with-param name="element" select="current()"/>
+ <xsl:with-param name="mypath" select="$mypath"/>
+ <xsl:with-param name="mixed" select="$mixed"/>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template match="*" mode="element-tag" >
+ <xsl:param name="offset" />
+ <xsl:param name="parent-path" />
+ <xsl:param name="mixed" />
+
+ <xsl:variable name="mypath"
+ select="concat($parent-path, '/', name(), '[', string($offset),']')" />
+
+ <xsl:call-template name="generic">
+ <xsl:with-param name="element" select="current()" />
+ <xsl:with-param name="offset" select="$offset" />
+ <xsl:with-param name="mypath" select="$mypath" />
+ <xsl:with-param name="mixed" select="$mixed"/>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template match="text()" mode="element-tag">
+ <xsl:param name="mixed" />
+
+ <xsl:choose>
+
+ <xsl:when test="not($mixed)">
+ <xsl:choose>
+ <xsl:when test="not(normalize-space(.))" />
+ <xsl:when test="normalize-space(.) = ''"/>
+
+ <xsl:otherwise>
+ <div class="parse-warning">
+ <p class="message">Uwaga! Tekst poza paragrafem</p>
+ <p>#<xsl:copy-of select="." />#</p>
+ </div>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:value-of select="wl:substitute_entities(.)">
+ <xsl:fallback>
+ <xsl:value-of select="." />
+ </xsl:fallback>
+ </xsl:value-of>
+ </xsl:otherwise>
+
+ </xsl:choose>
+
+ </xsl:template>
+
+ <xsl:template match="node()" />
+
+</xsl:stylesheet>
--- /dev/null
+<xsl:stylesheet version="1.0"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+ <xsl:param name="with-paths" select="boolean(0)" />
+ <xsl:param name="with-annotations" select="boolean(1)" />
+
+ <xsl:include href="wl2html_base.xslt" />
+ <xsl:output encoding="utf-8" indent="yes" omit-xml-declaration = "yes" />
+
+ <xsl:template match="/">
+ <div class="document">
+
+ <xsl:if test="with-toc" />
+
+ <xsl:apply-templates select="/utwor" mode="element-tag">
+ <xsl:with-param name="parentpath" select="''" />
+ <xsl:with-param name="offset" select="0" />
+ <xsl:with-param name="mixed" select="false()" />
+ </xsl:apply-templates>
+
+ <xsl:if test="with-annotations" />
+ </div>
+ </xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file
--- /dev/null
+<xsl:stylesheet version="1.0"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+ <xsl:param name="with-paths" select="boolean(0)" />
+ <xsl:param name="base-path" select="'.'"/>
+ <xsl:param name="base-offset" select="0" />
+
+ <xsl:include href="wl2html_base.xslt" />
+
+ <xsl:output
+ encoding="utf-8"
+ indent="yes"
+ omit-xml-declaration = "yes" />
+
+ <xsl:template match="/">
+ <chunk>
+ <xsl:apply-templates select="//chunk/child::node()" mode="element-tag">
+ <xsl:with-param name="offset" select="$base-offset" />
+ <xsl:with-param name="parent-path" select="$base-path" />
+ <xsl:with-param name="mixed" select="true()" />
+ </xsl:apply-templates>
+ </chunk>
+ </xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file
--- /dev/null
+#!/usr/bin/env python
+
+from __future__ import with_statement
+
+import re
+import sys
+import os.path
+
+sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
+
+from StringIO import StringIO
+from lxml import etree
+import librarian
+
+REPLACEMENTS = (
+ (u'---', u'\u2014'), # mdash
+ (u'--', u'\u2013'), # ndash
+ (u'...', u'\u2026'), # ldots
+ (u',,', u'\u201E'), # lower double back-quote
+ (u'"', u'\u201D'), # upper double quote
+)
+
+DIALOG_EXPR = re.compile(r"\s*---\s(.*)")
+
+def wl_normalize_text(context, text):
+ """XPath extension function converting all entites in passed text."""
+ if isinstance(text, list):
+ text = u''.join(text)
+
+ for code, ucode in REPLACEMENTS:
+ text = text.replace(code, ucode)
+
+ return text
+
+def wl_fix_dialog(context, data):
+
+ if isinstance(data, list):
+ text = u''.join(data)
+ else:
+ text = data
+
+ m = DIALOG_EXPR.match(text)
+
+ if m is not None:
+ return m.group(1)
+ else:
+ return text
+
+
+def filter_verse_ends(data):
+ return data.replace('/\n', '<br />')
+
+ns = etree.FunctionNamespace('http://wolnelektury.pl/functions')
+ns['normalize-text'] = wl_normalize_text
+ns['fix-dialog-line'] = wl_fix_dialog
+
+def normalize_stylesheet():
+ return etree.XSLT(etree.parse(os.path.join(os.path.dirname(librarian.__file__), 'xslt', 'normalize.xslt')))
+
+if __name__ == '__main__':
+ tran = normalize_stylesheet()
+ input = StringIO( f )
+ doc = trans( etree.parse(input) )
+ print etree.tostring(doc, pretty_print=True, encoding=unicode).encode('utf-8')
+
+ for err in trans.error_log:
+ sys.stderr.write( (u"%s\n" % err).encode('utf-8') )
+
+[egg_info]
+tag_build = .dev
+tag_date = 1
+
[aliases]
test = nosetests --detailed-errors --with-doctest --with-coverage --cover-package=librarian
setup(
name='librarian',
- version='1.2.5',
+ version='1.3',
description='Converter from WolneLektury.pl XML-based language to XHTML, TXT and other formats',
- author='Marek Stępniowski',
+ author='Marek Stepniowski',
author_email='marek@stepniowski.com',
url='http://redmine.nowoczesnapolska.org.pl/',
packages=find_packages(exclude=['tests']),