Re: patch to XML docbook output



On Fri, 2002-05-31 at 11:06, James Henstridge wrote:
> On second thought, I could probably didn't need to get rid of the   
> entities.  I only made that change because xsltproc was complaining, and 
> I read your earlier post about the entity.  A better solution would have 
> been to add a correct <!DOCTYPE> header to each of the document 
> fragments, which allows us to use any entity valid in docbook markup 
> (because the doctype is missing, only the standard XML entities are valid).
> 
> Since the <!DOCTYPE> line is stripped when performing an xinclude, we 
> still end up with a valid document after the xinclude processing.  I 
> will include them in the next version of my patch.
> 

I've been experimenting with getting &percent; et al working and from
what I can tell XInclude can't handle entities properly yet -- if I
define &percent; at the top of foo-docs.sgml, it still isn't defined in
xml/foo-topic.xml.

It does work to stuff the entity definitions in xml/*.xml, but that
seems a bit unpleasant. Here's a patch (combined with jamesh's) that
does that. So much faster than jade...

Peter

-- 
Peter Williams     peter newton cx / peterw ximian com

"Why should I have to change my name? He's the one who 
sucks!"                              -- Michael Bolton
? gtk-doc.xsl
? gtk-ents.diff
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk-doc/ChangeLog,v
retrieving revision 1.113
diff -u -r1.113 ChangeLog
--- ChangeLog	28 May 2002 23:43:28 -0000	1.113
+++ ChangeLog	1 Jun 2002 17:33:16 -0000
@@ -1,3 +1,23 @@
+2002-06-01  Peter Williams  <peterw ximian com>
+
+	* gtkdoc-mkdb.in (OutputSGMLFile): Define &hash; and &percent; with
+	the DTD here.
+
+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 -r1.16 Makefile.am
--- Makefile.am	17 May 2002 23:45:25 -0000	1.16
+++ Makefile.am	1 Jun 2002 17:33:16 -0000
@@ -15,11 +15,13 @@
 	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 -r1.22 configure.in
--- configure.in	1 Feb 2002 23:05:39 -0000	1.22
+++ configure.in	1 Jun 2002 17:33:16 -0000
@@ -27,6 +27,13 @@
   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 -r1.49 gtkdoc-mkdb.in
--- gtkdoc-mkdb.in	28 May 2002 23:43:28 -0000	1.49
+++ gtkdoc-mkdb.in	1 Jun 2002 17:33:16 -0000
@@ -61,13 +61,12 @@
 	      '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);
 
 if (lc($OUTPUT_FORMAT) eq "xml") {
     $OUTPUT_FORMAT = "xml";
     $empty_element_end = "/>";
-}
-else {
+} else {
     $OUTPUT_FORMAT = "sgml";
     $empty_element_end = ">";
 }
@@ -337,8 +336,12 @@
 	    }
 
 	    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;
@@ -1188,6 +1191,17 @@
     # since it changes every day (and it is only used in the man pages):
     # "<refentry id="$section_id" revision="$mday $month $year">"
 
+    if (lc($OUTPUT_FORMAT) eq "xml") {
+        print OUTPUT <<EOF;
+<?xml version="1.0"?>
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD Docbook XML V4.1.2//EN" 
+                   "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"; [
+  <!ENTITY hash "&#x23;">
+  <!ENTITY percent "&#x25;">
+]>
+EOF
+    }
+
     print OUTPUT <<EOF;
 <refentry id="$section_id">
 <refmeta>
@@ -1278,20 +1292,21 @@
 	  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 -r1.8 gtkdoc-mkhtml.in
--- gtkdoc-mkhtml.in	17 May 2002 23:45:25 -0000	1.8
+++ gtkdoc-mkhtml.in	1 Jun 2002 17:33:16 -0000
@@ -23,7 +23,9 @@
 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 @@
       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


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