Generating HTML div instead of whole page.
authorMarek Stępniowski <marek@stepniowski.com>
Tue, 16 Sep 2008 18:42:38 +0000 (20:42 +0200)
committerMarek Stępniowski <marek@stepniowski.com>
Tue, 16 Sep 2008 18:42:38 +0000 (20:42 +0200)
lib/librarian/book2html.xslt
lib/librarian/html.py

index 827c696..c8cf2c9 100644 (file)
@@ -1,17 +1,18 @@
 <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" doctype-public="-//W3C//DTD XHTML 1.1//EN" doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" indent="yes" />
+<xsl:output encoding="utf-8" indent="yes" omit-xml-declaration = "yes" />
 
 
 <xsl:template match="utwor">
-    <html>
+    <!-- <html>
         <head>
             <title>book2html output</title>
             <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
             <link rel="stylesheet" href="master.css" type="text/css" media="all" charset="utf-8" />
         </head>
-        <body>
+        <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">
@@ -32,8 +33,9 @@
                     </xsl:for-each>
                 </div>
             </xsl:if>
-        </body>
-    </html>
+        </div>
+        <!-- </body>
+    </html> -->
 </xsl:template>
 
 
index 3dd70f5..9763428 100644 (file)
@@ -55,7 +55,7 @@ def transform(input_filename, output_filename):
     result = doc.xslt(style)
     add_anchors(result.getroot())
     add_table_of_contents(result.getroot())
-    result.write(output_filename, xml_declaration=True, pretty_print=True, encoding='utf-8')
+    result.write(output_filename, xml_declaration=False, pretty_print=True, encoding='utf-8')
 
 
 class Fragment(object):
@@ -117,9 +117,9 @@ def extract_fragments(input_filename):
                 fragment = Fragment(id=element.get('fid'), themes=element.text)
 
                 # Append parents
-                if element.getparent().tag != 'body':
+                if element.getparent().get('id', None) != 'book-text':
                     parents = [element.getparent()]
-                    while parents[-1].getparent().tag != 'body':
+                    while parents[-1].getparent().get('id', None) != 'book-text':
                         parents.append(parents[-1].getparent())
 
                     parents.reverse()