patch to XML docbook output



Here is my initial patch to get gtk-doc to use xsltproc for the docbook -> html conversion when running in XML mode. The main changes are:

   * make gtkdoc-mkdb output XIncludes for the sample main document
     when in XML mode.
   * make gtkdoc-mkdb use character references rather than   when
     in XML mode.
   * make gtkdoc-mkhtml use xsltproc to create the output if the main
     document.
   * use my gtk-doc.xsl customisation layer, so that the index.sgml
     xref file is produced correctly.

The output currently looks fairly plain due to me not having only converted the cross reference portions of the gtk-doc DSSSL stylesheet. Would it be better to try and reimplement the output of the DSSSL stylesheets (the black,green,blue and red table headers), or go for something else?

James.

--
Email: james daa com au              | Linux.conf.au 2003 Call for Papers out
WWW:   http://www.daa.com.au/~james/ |   http://conf.linux.org.au/cfp.html


? autom4te.cache
? gtk-doc-xml.patch
? tmp
? examples/Makefile.in
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk-doc/ChangeLog,v
retrieving revision 1.113
diff -u -p -r1.113 ChangeLog
--- ChangeLog	28 May 2002 23:43:28 -0000	1.113
+++ ChangeLog	31 May 2002 14:15:41 -0000
@@ -1,3 +1,18 @@
+2002-05-31  James Henstridge  <james daa com au>
+
+	* gtkdoc-mkdb.in (OutputSGML): put XIncludes in the $book_bottom
+	variable.
+	(OutputBook): add the XInclude namespace declaration to the book
+	element.
+
+	* gtkdoc-mkhtml.in (declaration): if the document looks like XML,
+	process it with xsltproc.
+
+	* configure.in: check for xsltproc.
+
+	* gtk-doc.xsl: start of XSLT template for converting docbook/xml
+	to HTML.
+
 2002-05-29  Matthias Clasen  <maclas gmx de>
 
 	Fixes for #77193:
Index: Makefile.am
===================================================================
RCS file: /cvs/gnome/gtk-doc/Makefile.am,v
retrieving revision 1.16
diff -u -p -r1.16 Makefile.am
--- Makefile.am	17 May 2002 23:45:25 -0000	1.16
+++ Makefile.am	31 May 2002 14:15:41 -0000
@@ -15,11 +15,13 @@ gtkdocdata_DATA = \
 	gtkdoc-common.pl	\
         gtk-doc.dsl		\
 	gtk-doc.dcl		\
+	gtk-doc.xsl		\
 	xml.dcl
 
 EXTRA_DIST= \
 	gtk-doc.spec.in	\
 	gtk-doc.dcl  	\
+	gtk-doc.xsl	\
 	xml.dcl
 
 dist-hook:
Index: configure.in
===================================================================
RCS file: /cvs/gnome/gtk-doc/configure.in,v
retrieving revision 1.22
diff -u -p -r1.22 configure.in
--- configure.in	1 Feb 2002 23:05:39 -0000	1.22
+++ configure.in	31 May 2002 14:15:41 -0000
@@ -27,6 +27,13 @@ if test -z "$JADE"; then
   fi
 fi
 
+dnl
+dnl Check for xsltproc
+dnl
+AC_PATH_PROG(XSLTPROC, xsltproc)
+if test -z "$XSLTPROC"; then
+  AC_MSG_ERROR([xsltproc not found])
+fi
 
 dnl
 dnl Set PACKAGE_DATA_DIR so we can find the script containing common routines.
Index: gtkdoc-mkdb.in
===================================================================
RCS file: /cvs/gnome/gtk-doc/gtkdoc-mkdb.in,v
retrieving revision 1.49
diff -u -p -r1.49 gtkdoc-mkdb.in
--- gtkdoc-mkdb.in	28 May 2002 23:43:28 -0000	1.49
+++ gtkdoc-mkdb.in	31 May 2002 14:15:56 -0000
@@ -61,15 +61,17 @@ my %optctl = (module => \$MODULE,
 	      'output-format' => \$OUTPUT_FORMAT);
 GetOptions(\%optctl, "module=s", "source-dir:s", "output-dir:s", "version", "outputallsymbols", "main-sgml-file:s", "help", "sgml-mode", "output-format:s");
 
-my $empty_element_end;
+my ($empty_element_end, $nbsp);
 
 if (lc($OUTPUT_FORMAT) eq "xml") {
     $OUTPUT_FORMAT = "xml";
     $empty_element_end = "/>";
+    $nbsp = '&#xa0;';
 }
 else {
     $OUTPUT_FORMAT = "sgml";
     $empty_element_end = ">";
+    $nbsp = '&nbsp;'
 }
 
 if ($PRINT_VERSION) {
@@ -337,8 +339,12 @@ sub OutputSGML {
 	    }
 
 	    if ($num_symbols > 0) {
-		$book_top .= "<!ENTITY $section_id SYSTEM \"sgml/$file\">\n";
-		$book_bottom .= "    &$section_id;\n";
+		if (lc($OUTPUT_FORMAT) eq "xml") {
+		    $book_bottom .= "    <xi:include href=\"xml/$file.xml\"/>\n";
+		} else {
+		    $book_top.="<!ENTITY $section_id SYSTEM \"sgml/$file.sgml\">\n";
+		    $book_bottom .= "    &$section_id;\n";
+		}
 
 		if ($section_includes eq "") {
 		    $section_includes = $includes;
@@ -1074,13 +1080,13 @@ sub OutputParamDescriptions {
 		    $param_name = "...";
 		}
 		$param = &ExpandAbbreviations($param);
-		$params_desc .= "<row><entry align=\"right\"><parameter>$param_name</parameter>&nbsp;:</entry>\n<entry>$param</entry></row>\n";
+		$params_desc .= "<row><entry align=\"right\"><parameter>$param_name</parameter>${nbsp}:</entry>\n<entry>$param</entry></row>\n";
 	    }
 	}
 
 	# Signals have an implicit user_data parameter which we describe.
 	if ($symbol_type eq "SIGNAL") {
-	    $params_desc .= "<row><entry align=\"right\"><parameter>user_data</parameter>&nbsp;:</entry>\n<entry>user data set when the signal handler was connected.</entry></row>\n";
+	    $params_desc .= "<row><entry align=\"right\"><parameter>user_data</parameter>${nbsp}:</entry>\n<entry>user data set when the signal handler was connected.</entry></row>\n";
 	}
 
 	# Start a table if we need one.
@@ -1278,20 +1284,21 @@ sub OutputBook {
 	  print OUTPUT <<EOF;
 <?xml version="1.0"?>
 <!DOCTYPE book PUBLIC "-//OASIS//DTD Docbook XML V4.1.2//EN" 
-               "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"; [
+               "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd";>
+<book id="index" xmlns:xi="http://www.w3.org/2001/XInclude";>
 EOF
-      }
-      else {
+      } else {
 	print OUTPUT <<EOF;
 <!doctype book PUBLIC "-//DavenPort//DTD DocBook V3.0//EN" [
 EOF
-	}
-
-      print OUTPUT $book_top;
-
-      print OUTPUT <<EOF;
+        print OUTPUT $book_top;
+        print OUTPUT <<EOF;
 ]>
 <book id="index">
+EOF
+      }
+
+print OUTPUT <<EOF;
   <bookinfo>
     <title>[Insert name here] Reference Manual</title>
   </bookinfo>
Index: gtkdoc-mkhtml.in
===================================================================
RCS file: /cvs/gnome/gtk-doc/gtkdoc-mkhtml.in,v
retrieving revision 1.8
diff -u -p -r1.8 gtkdoc-mkhtml.in
--- gtkdoc-mkhtml.in	17 May 2002 23:45:25 -0000	1.8
+++ gtkdoc-mkhtml.in	31 May 2002 14:15:56 -0000
@@ -23,7 +23,9 @@ gtkdocdir= datadir@/gtk-doc
 declaration=$gtkdocdir/gtk-doc.dcl
 
 if head -1 $document | grep -q "<?xml"; then
-  declaration=$gtkdocdir/xml.dcl
+  is_xml=true
+else
+  is_xml=false
 fi
 
 # Delete the old index.sgml file, if it exists.
@@ -31,7 +33,13 @@ if test -f index.sgml; then
       rm -f index.sgml
 fi
 
- JADE@ -t sgml -w no-idref -d $gtkdocdir/gtk-doc.dsl $declaration $document
+if $is_xml; then
+  @XSLTPROC@ --xinclude $gtkdocdir/gtk-doc.xsl $document
+else
+  @JADE@ -t sgml -w no-idref -d $gtkdocdir/gtk-doc.dsl \
+      $gtkdocdir/gtk-doc.dcl $document
+fi
+
 sed s%href=\"%href=\"$module/% < index.sgml > index.sgml.tmp && mv index.sgml.tmp index.sgml
 
 echo "timestamp" > ../html.stamp
--- /dev/null	Fri Aug 31 04:30:55 2001
+++ gtk-doc.xsl	Fri May 31 15:02:54 2002
@@ -0,0 +1,69 @@
+<?xml version='1.0'?> <!--*- mode: xml -*-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
+                version='1.0'
+                xmlns="http://www.w3.org/TR/xhtml1/transitional";
+                exclude-result-prefixes="#default">
+
+  <!-- import the chunked XSL stylesheet -->
+  <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl"/>
+
+  <xsl:output method="xml" indent="yes"/>
+
+  <!-- change some parameters -->
+  <xsl:param name="toc.section.depth">1</xsl:param>
+
+  <xsl:param name="chapter.autolabel" select="0"/>
+  <xsl:param name="use.id.as.filename" select="'1'"/>
+  <xsl:param name="html.ext" select="'.html'"/>
+  <xsl:param name="shade.verbatim" select="1"/>
+
+  <!-- ========================================================= -->
+  <!-- template to create the index.sgml anchor index -->
+
+  <xsl:template match="book|article">
+    <xsl:apply-imports/>
+
+    <!-- generate the index.sgml href index -->
+    <xsl:call-template name="generate.index"/>
+  </xsl:template>    
+
+  <xsl:template name="generate.index">
+    <xsl:call-template name="write.text.chunk">
+      <xsl:with-param name="filename" select="'index.sgml'"/>
+      <xsl:with-param name="content">
+        <!-- check all anchor and refentry elements -->
+        <xsl:apply-templates select="//anchor|refentry"
+                             mode="generate.index.mode"/>
+      </xsl:with-param>
+      <xsl:with-param name="encoding" select="'utf-8'"/>
+    </xsl:call-template>
+  </xsl:template>
+
+  <xsl:template match="*" mode="generate.index.mode">
+    <xsl:if test="not(@href)">
+      <xsl:text>&lt;ANCHOR id=&quot;</xsl:text>
+      <xsl:value-of select="@id"/>
+      <xsl:text>&quot; href=&quot;</xsl:text>
+      <xsl:call-template name="href.target"/>
+      <xsl:text>&quot;&gt;
+</xsl:text>
+    </xsl:if>
+  </xsl:template>
+
+  <!-- ========================================================= -->
+  <!-- template to output gtkdoclink elements for the unknown targets -->
+
+  <xsl:template match="link">
+    <xsl:choose>
+      <xsl:when test="id(@linkend)">
+        <xsl:apply-imports/>
+      </xsl:when>
+      <xsl:otherwise>
+        <gtkdoclink href="{ linkend}">
+          <xsl:apply-templates/>
+        </gtkdoclink>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+</xsl:stylesheet>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]