Author: ks
Date: Mon Oct  1 17:46:38 2007
New Revision: 6322

Log:
- Initial implementation of "plain headers -> nested sections" conversion with 
XSLT.

Modified:
    experimental/Document/src/converters/xhtml_docbook.php
    experimental/Document/src/converters/xhtml_docbook.xsl

Modified: experimental/Document/src/converters/xhtml_docbook.php
==============================================================================
--- experimental/Document/src/converters/xhtml_docbook.php [iso-8859-1] 
(original)
+++ experimental/Document/src/converters/xhtml_docbook.php [iso-8859-1] Mon Oct 
 1 17:46:38 2007
@@ -72,11 +72,9 @@
         // Creates a DOMDocument instance
         $docbookDOM = $imp->createDocument( '', '', $dtd );
 
-        $roots = $resultDOM->getElementsByTagName( 'article' );
-        $docbookRoot = $docbookDOM->importNode( $roots->item(0), true );
-        $docbookRoot->setAttribute( 'xmlns', 
'http://www.oasis-open.org/docbook/xml/simple/1.0' );
+        $docbookRoot = $docbookDOM->importNode( 
$resultDOM->getElementsByTagName( 'article' )->item(0), true );
         $docbookDOM->appendChild( $docbookRoot );
-
+        
         $resultDoc = new ezcDocumentXML( 'docbook', $docbookDOM );
         return $resultDoc;
     }

Modified: experimental/Document/src/converters/xhtml_docbook.xsl
==============================================================================
--- experimental/Document/src/converters/xhtml_docbook.xsl [iso-8859-1] 
(original)
+++ experimental/Document/src/converters/xhtml_docbook.xsl [iso-8859-1] Mon Oct 
 1 17:46:38 2007
@@ -4,6 +4,8 @@
                 xmlns:fo="http://www.w3.org/1999/XSL/Format"; 
                 xmlns:html="http://www.w3.org/1999/xhtml"; 
                 xmlns:saxon="http://icl.com/saxon";
+                xmlns:set="http://exslt.org/sets";
+                extension-element-prefixes="set"
                 exclude-result-prefixes="xsl fo html saxon">
 
 <xsl:output method="xml" indent="no"/>
@@ -31,7 +33,7 @@
 </xsl:template>
 
 <!-- This template converts each HTML file encountered into a DocBook 
-     section.  For a title, it selects the first h1 element -->
+     section.  For a title, it selects the first h1 element
 <xsl:template match="html:body">
  <section>
   <xsl:if test="$filename != ''">
@@ -49,11 +51,36 @@
   <xsl:apply-templates select="*"/>
  </section>
 </xsl:template>
+-->
+
+<xsl:template match="html:body">
+     <xsl:apply-templates 
select='set:leading(following-sibling::*,following-sibling::html:h1)'/>
+     <xsl:apply-templates select="html:h1"/>
+</xsl:template>
+
+<xsl:template match="html:h1">
+  <section>
+   <title>
+    <xsl:apply-templates/>
+   </title>
+   <xsl:apply-templates 
select='set:leading(following-sibling::*,following-sibling::html:h1|following-sibling::html:h2)'/>
+   <xsl:apply-templates 
select='set:leading(following-sibling::html:h1|following-sibling::html:h2,following-sibling::html:h1)'/>
+  </section>
+</xsl:template>
+
+<xsl:template match="html:h2">
+  <section>
+   <title>
+    <xsl:apply-templates/>
+   </title>
+   <xsl:apply-templates 
select='set:leading(following-sibling::*,following-sibling::html:h1|following-sibling::html:h2)'/>
+  </section>
+</xsl:template>
 
 <!-- This template matches on all HTML header items and makes them into 
      bridgeheads. It attempts to assign an ID to each bridgehead by looking 
      for a named anchor as a child of the header or as the immediate preceding
-     or following sibling -->
+     or following sibling
 <xsl:template match="html:h1
               |html:h2
               |html:h3
@@ -80,7 +107,7 @@
   </xsl:choose>
   <xsl:apply-templates/>
  </bridgehead>
-</xsl:template>
+</xsl:template>-->
         
 <!-- These templates perform one-to-one conversions of HTML elements into
      DocBook elements -->
@@ -355,7 +382,7 @@
         
 <!-- Ignored elements -->
 <xsl:template match="html:hr"/>
-<xsl:template match="html:h1[1]|html:h2[1]|html:h3[1]" priority="1"/>
+<!--<xsl:template match="html:h1[1]|html:h2[1]|html:h3[1]" priority="1"/>-->
 <xsl:template match="html:br"/>
 <xsl:template match="html:p[normalize-space(.) = '' and count(*) = 0]"/>
 <xsl:template match="text()">


-- 
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to