patch to add XSL support (take 2)



Here is a new version of the patch. This version adds the doctype header to the generated xml files, so that the standard docbook/xml entities can be used (including  ). The libglade docs can build with this version okay. The other character entities Matthias mentioned in his previous email should work fine with this patch as well.

You should have the Docbook/XML 4.1.2 DTD and the Docbook XSL stylesheets in your XML catalog so that the files don't need to be downloaded over the network. I haven't done any autoconf checks to make sure that they are available (yet).

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


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 15:35:58 -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 15:35:58 -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 15:35:58 -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 15:36:15 -0000
@@ -61,13 +61,12 @@ 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);
 
 if (lc($OUTPUT_FORMAT) eq "xml") {
     $OUTPUT_FORMAT = "xml";
     $empty_element_end = "/>";
-}
-else {
+} else {
     $OUTPUT_FORMAT = "sgml";
     $empty_element_end = ">";
 }
@@ -337,8 +336,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;
@@ -1188,6 +1191,14 @@ sub OutputSGMLFile {
     # 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";>
+EOF
+    }
+
     print OUTPUT <<EOF;
 <refentry id="$section_id">
 <refmeta>
@@ -1278,20 +1289,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 15:36:15 -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]