The conversion to HTML creates proper XHTML. V0_6
authorarjen <arjen>
Thu, 18 Oct 2007 07:03:59 +0000 (07:03 +0000)
committerarjen <arjen>
Thu, 18 Oct 2007 07:03:59 +0000 (07:03 +0000)
Added support for embedded MathML and SVG.
New element: <example>.
Use standard XML Inclusion methods as opposed to a preprocessing stylesheet.
  - This means the <include> element will be deprecated.
New type styles: big and small.
Added colored text with a few predefined colors.

17 files changed:
ChangeLog
doc.dtd
doc/block.xml
doc/glossary.xml
doc/guide.xml
doc/inline.xml
doc/intro.xml
doc/main.css
doc/makefile
doc/multifiles.xml
doc/overall.xml
html.xsl
latex.xsl
xml2html
xml2latex
xml2text
xp.c

index 4dc4842..77379f6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+Version 0.6 - Oct 17, 2007
+===========================================================
+
+o The conversion to HTML creates proper XHTML.
+o Added support for embedded MathML and SVG.
+o New element: <example>.
+o Use standard XML Inclusion methods as opposed to a preprocessing stylesheet.
+  - This means the <include> element will be deprecated.
+o New output format for PHPWiki.
+o New type styles: big and small.
+o Added colored text with a few predefined colors.
+
 Version 0.5 - Aug 19, 2003
 ===========================================================
 
diff --git a/doc.dtd b/doc.dtd
index a5e83e9..aafb6b1 100644 (file)
--- a/doc.dtd
+++ b/doc.dtd
@@ -4,7 +4,8 @@
 
 <!ELEMENT doc (book | article | report)>
 <!ATTLIST doc
-    style  CDATA  #IMPLIED
+    style          CDATA  #IMPLIED
+    latexoptions   CDATA   "a4paper"
 >
 
 <!ELEMENT book (titlepage?, toc?, (chapter|include)*)>
index b102fed..4c05987 100644 (file)
@@ -5,7 +5,7 @@
 <!--
       XML documentation system
       Original author :  Arjen Baart - arjen@andromeda.nl
-      Version         : $Revision: 1.2 $
+      Version         : $Revision: 1.3 $
 -->
 
 <chapter>
@@ -23,6 +23,8 @@ in a <strong>para</strong> element.
 To make several separate paragraphs, you must enclose each paragraph
 in a <strong>para</strong> open tag and a <strong>para</strong> close tag.
 Here is an example of two small paragraphs:
+</para>
+
 <verbatim>
 
 &lt;para&gt;
@@ -34,11 +36,10 @@ Here is an example of two small paragraphs:
 
 </verbatim>
 
-</para>
-
 <para>
 A second type of paragraph is a <strong>quote</strong>.
 You can make a quote by using the <code>quote</code> element:
+</para>
 
 <verbatim>
    &lt;quote&gt;
@@ -48,14 +49,15 @@ You can make a quote by using the <code>quote</code> element:
    &lt;/quote&gt;
 </verbatim>
 
+<para>
 Which results in:
+</para>
 
 <quote>
 This is an example of a quote.
 The text within a quoted paragraph is usually slightly indented on both
 the left and the right margin.
 </quote>
-</para>
 
 <para>
 A special kind of paragraph is the <strong>verbatim</strong> environment.
@@ -63,6 +65,7 @@ Just as in LaTeX, this is used to include literal text output with spaces,
 indentation and line breaks preserved.
 The practical use for the <strong>verbatim</strong> element is to
 include coding examples, such as:
+</para>
 
 <verbatim>
    &lt;verbatim&gt;
@@ -74,7 +77,9 @@ include coding examples, such as:
    &lt;/verbatim&gt;
 </verbatim>
 
+<para>
 Which comes out like this:
+</para>
 
 <verbatim>
    struct complex
@@ -83,7 +88,41 @@ Which comes out like this:
       double   imaginary;
    };
 </verbatim>
+
+<para>
+A variation on the <strong>verbatim</strong> text is the <strong>example</strong>
+text.
+The only real difference is that <strong>example</strong> is placed inside
+a box to make it stand out a bit more.
+In fact, when converted to XHTML, only an attribute <code>class='example'</code>
+is added.
+It is up to the CSS linked to the XHTML page to add additional layout features.
+The default styling will only add a border.
+Here is the above example shown in an actual <strong>example</strong> element:
+</para>
+
+<example>
+   &lt;example&gt;
+      struct complex
+      {
+         double   real;
+         double   imaginary;
+      };
+   &lt;/example&gt;
+</example>
+
+<para>
+Which comes out like this:
 </para>
+
+<example>
+   struct complex
+   {
+      double   real;
+      double   imaginary;
+   };
+</example>
+
 </section>
 
 <section>
@@ -91,11 +130,13 @@ Which comes out like this:
 <para>
 Footnotes are created with the <strong>footnote</strong> element:
 <footnote>This is an example of a footnote</footnote>
+</para>
 
 <verbatim>
 &lt;footnote&gt;This is an example of a footnote&lt;/footnote&gt;
 </verbatim>
 
+<para>
 Within a footnote, you can use <emph>inline</emph> content <footnote>described in the
 next chapter</footnote> to format the type
 styles of the text in the footnote. 
@@ -114,18 +155,22 @@ running text referring to that footnote.
 <heading><label name='list'/>Lists</heading>
 <para>
 Three types of lists are supported:
+</para>
+
 <itemize>
 <item><code>itemize</code> for bulleted lists such as this one.</item>
 <item><code>enumerate</code> for numbered lists.</item>
 <item><code>description</code> for tagged lists.</item>
 </itemize>
 
+<para>
 Each item in such a list must be in an <code>item</code> element.
 In fact, an <code>item</code> is the only element allowed in an
 <code>itemize</code>, <code>enumerate</code> or <code>description</code> element.
 You should not put ordinary text or any other element in a list without
 enclosing them in <code>&lt;item&gt;</code> and <code>&lt;/item&gt;</code>.
 Here is an example of a numbered list:
+</para>
 
 <verbatim>
 
@@ -137,7 +182,9 @@ Here is an example of a numbered list:
 
 </verbatim>
 
+<para>
 And this is what the list turns into:
+</para>
 
 <enumerate>
    <item>First you need an enumerate, itemize or description tag.</item>
@@ -145,11 +192,13 @@ And this is what the list turns into:
    <item>Finally, put the content inside the items.</item>
 </enumerate>
 
+<para>
 In a description list, you make your own tags for each item instead
 of the automatically generated bullts or numbers.
 The tags for each item go in the <code>tag</code> attribute of the
 <code>item</code> element.
 So, repeating the above list as a description list:
+</para>
 
 <verbatim>
 &lt;description&gt;
@@ -159,7 +208,9 @@ So, repeating the above list as a description list:
 &lt;/description&gt;
 </verbatim>
 
+<para>
 Which creates the following output:
+</para>
 
 <description>
 <item tag='itemize'> for bulleted lists.</item>
@@ -167,6 +218,7 @@ Which creates the following output:
 <item tag='description'> for tagged lists such as this one.</item>
 </description>
 
+<para>
 An item can contain inline content as well as block-level content.
 </para>
 </section>
@@ -176,11 +228,13 @@ An item can contain inline content as well as block-level content.
 <para>
 The empty element <strong>picture</strong> is used to include
 graphics in your document, like this:
+</para>
 
 <verbatim>
    &lt;picture src='diagram.png' eps='diagram' scale='0.5'/&gt;
 </verbatim>
 
+<para>
 The two attributes are used in either HTML or LaTeX.
 </para>
 </section>
@@ -202,6 +256,7 @@ attribute in the <code>table</code> tag.
 
 <para>
 An example of a table is shown below:
+</para>
 
 <verbatim>
 
@@ -221,7 +276,6 @@ An example of a table is shown below:
   <row><col>Wine      </col><col> 2.20</col></row>
 </table>
 
-</para>
 </section>
 
 </chapter>
index 7598ed8..bf6963a 100644 (file)
@@ -5,7 +5,7 @@
 <!--
       XML documentation system
       Original author :  Arjen Baart - arjen@andromeda.nl
-      Version         : $Revision: 1.1 $
+      Version         : $Revision: 1.2 $
 -->
 
 <chapter>
    Creates a <ref to='list'>list</ref> of numbered items.
   </item>
 
+  <item tag='example'>
+   A <ref to='block'>block-level</ref> element to hold text with a
+   pre-determined layout. The block of text is surrounded by a border.
+  </item>
+
   <item tag='footnote'>
    Creates a numbered <ref to='footnote'>footnote</ref> at the bottom of the page.
   </item>
@@ -87,6 +92,7 @@
 
   <item tag='include'>
    Includes part of the document from another <ref to='include'>file</ref>.
+   <emph>Deprecated</emph>. Use the standard XML Inclusion method instead.
   </item>
 
   <item tag='infoitem'>
index f314395..60fa01d 100644 (file)
@@ -1,12 +1,13 @@
 <?xml version="1.0"?>
 <!DOCTYPE doc SYSTEM "../doc.dtd">
 <?xml-stylesheet type="text/xsl" href="../html.xsl"?>
-<doc style="main.css">
+<doc style="main.css"
+     xmlns:xi="http://www.w3.org/2001/XInclude">
 
 <!--
       XML documentation system
       Original author :  Arjen Baart - arjen@andromeda.nl
-      Version         : $Revision: 1.2 $
+      Version         : $Revision: 1.3 $
 
       This document is prepared for XMLDoc. Transform to HTML,
       LaTeX, Postscript or plain text with XMLDoc utilities and
@@ -19,9 +20,9 @@
    <subtitle>Document preparation and conversion in XML</subtitle>
 
    <author>Arjen Baart <code>&lt;arjen@andromeda.nl&gt;</code></author>
-   <date>Aug 18, 2003</date>
+   <date>Oct 17, 2007</date>
    <docinfo>
-      <infoitem label="Version">0.5</infoitem>
+      <infoitem label="Version">0.6</infoitem>
       <infoitem label="Organization">Andromeda Technology &amp; Automation</infoitem>
    </docinfo>
    <abstract>
 
 <toc/>
 
-<include href="intro.xml"/>
+<xi:include href="intro.xml"/>
 
-<include href="overall.xml"/>
+<xi:include href="overall.xml"/>
 
-<include href="block.xml"/>
+<xi:include href="block.xml"/>
 
-<include href="inline.xml"/>
+<xi:include href="inline.xml"/>
 
 <chapter>
 <heading>References</heading>
@@ -51,6 +52,8 @@ adheres to the <emph>XLink</emph> syntax.
 We need to add one more attribute to the usual <strong>href</strong>
 attribute.
 For example:
+</para>
+
 <verbatim>
 &lt;reference xml:link="simple"
     href="http://www.andromeda.nl/project/xmldoc/xmldoc.html"&gt;
@@ -58,6 +61,8 @@ The XMLDoc website
 &lt;/reference&gt;
 provide the installation instructions.
 </verbatim>
+
+<para>
 <reference xml:link="simple"
     href="http://www.andromeda.nl/projects/xmldoc/xmldoc.html">
 The XMLDoc website
@@ -77,11 +82,13 @@ the <code>name</code> of the label.
 Each <code>label</code> must have a <code>name</code> that is unique
 throughout the document.
 Here is an example of a label:
+</para>
 
 <verbatim>
    &lt;label name='example'/&gt;
 </verbatim>
 
+<para>
 You can refer to a label from any other place in the document by using a
 <code>ref</code> or a <code>page</code> element.
 The <code>page</code> element creates a reference to the page number on which
@@ -89,10 +96,13 @@ the <code>label</code> is printed.
 This is of course only usefull on printed media, such as LaTeX.
 The <code>ref</code> and <code>page</code> elements also require one
 attribute:
+</para>
 
 <verbatim>
    &lt;ref to='example'&gt;example reference&lt;/ref&gt;
 </verbatim>
+
+<para>
 The required attribute <code>to</code> holds the name of the
 label to which the reference refers.
 The <code>ref</code> element is usually not empty.
@@ -104,15 +114,66 @@ The content of the <code>page</code> element is only renedered in LaTeX output.
 </para>
 </chapter>
 
-<include href="multifiles.xml"/>
+<xi:include href="multifiles.xml"/>
+
+<xi:include href="glossary.xml"/>
 
-<include href="glossary.xml"/>
+<chapter>
+
+<heading>Other XML applications</heading>
+<section>
+<heading>MathML</heading>
+</section>
+<math>
+  <mrow>
+    <msup>
+      <mfenced open="[" close="]">
+        <mrow>
+          <mi>&theta;</mi>
+          <mo>+</mo>
+
+          <mi>b</mi>
+        </mrow>
+      </mfenced>
+      <mn>260</mn>
+    </msup>
+    <mo>+</mo>
+    <msub>
+
+      <mfenced open="{" close="}">
+        <mrow>
+          <mi>a</mi>
+          <mo>+</mo>
+          <mi>b</mi>
+        </mrow>
+      </mfenced>
+
+      <mi>i</mi>
+    </msub>
+  </mrow>
+</math>
+<section>
+<heading>SVG</heading>
+
+<svg>
+   <clipPath id="a">
+      <circle cy="90" cx="100" r="60"/>
+   </clipPath>
+   <circle fill="#AAAAAA" cy="90" cx="190"
+              r="60" style="clip-path:url(#a)"/>
+   <circle stroke="black" fill="none" cy="90" cx="100" r="60"/>
+   <circle stroke="black" fill="none" cy="90" cx="190" r="60"/>
+</svg>
+
+
+</section>
+</chapter>
 
 <chapter>
 
 <heading>Things to do</heading>
 <itemize>
-<item>Math</item>
+<item>MathML and SVG conversion to LaTeX</item>
 <item>XML Schema definition and validation</item>
 <item>Font sizes</item>
 <item>Center environment</item>
index 304846a..10cd5f9 100644 (file)
@@ -5,13 +5,14 @@
 <!--
       XML documentation system
       Original author :  Arjen Baart - arjen@andromeda.nl
-      Version         : $Revision: 1.2 $
+      Version         : $Revision: 1.3 $
 -->
 
 <chapter>
 <heading><label name='inline'/>Type styles and special characters</heading>
 <para>
 There are six type styles:
+</para>
 <enumerate>
    <item><code>emph</code> : <emph>Emphasized text</emph></item>
    <item><code>strong</code> : <strong>Usually bold face</strong></item>
@@ -20,7 +21,60 @@ There are six type styles:
    <item><code>sub</code> : For <sub>subscript</sub> text.</item>
    <item><code>sup</code> : For <sup>superscript</sup> text.</item>
 </enumerate>
+
+<section>
+<heading><label name='color'/>Color and size</heading>
+<para>
+Normally, if not redefined by additional style sheets, the text is
+printed in black on a white background.
+You can create text in other colors with the <strong>color</strong> element.
+Which color the output text should become is specified in the
+<strong>colorname</strong> attribute, for example:
+</para>
+
+<verbatim>
+  &lt;color colorname='red'&gt;Red text&lt;/color&gt;
+</verbatim>
+
+<para>
+It is not possible to create any color; there are just a few predefined
+colors available:
+<color colorname='red'>red</color>,
+<color colorname='green'>green</color>,
+<color colorname='blue'>blue</color>,
+<color colorname='cyan'>cyan</color>,
+<color colorname='magenta'>magenta</color>,
+<color colorname='yellow'>yellow</color>,
+<color colorname='orange'>orange</color>,
+<color colorname='violet'>violet</color>,
+<color colorname='purple'>purple</color>,
+<color colorname='brown'>brown</color>,
+<color colorname='pink'>pink</color>,
+<color colorname='olive'>olive</color>,
+<color colorname='black'>black</color>,
+<color colorname='darkgray'>darkgray</color>,
+<color colorname='gray'>gray</color>,
+<color colorname='lightgray'>lightgray</color> and
+<color colorname='white'>white</color>.
+The last, color (white) is probably invisible :-).
+</para>
+
+<para>
+NOTE: To make colored text work with LaTeX, you probably need to install
+the <emph>latex-xcolor</emph> package.
+</para>
+<para>
+Apart from the normal font size, there are two other sizes available:
+<strong>big</strong>and <strong>small</strong>.
+These element will make the text slightly bigger or smaller, like this:
 </para>
+<verbatim>
+Here is &lt;small&gt;some small text&lt;/small&gt; and &lt;big&gt;a big phrase&lt;/big&gt;.
+</verbatim>
+<para>
+Here is <small>some small text</small> and <big>a big phrase</big>.
+</para>
+</section>
 
 <section>
 <heading><label name='break'/>Line and page breaking</heading>
@@ -48,11 +102,13 @@ The content of its <code>command</code> attribute is copied literally
 into the output.
 One of the applications of the <code>LaTeX</code> escape element is to
 control the first line indent of a paragraph in LaTeX:
+</para>
 
 <verbatim>
 &lt;LaTeX command='\setlength{\parindent}{0cm}'/&gt;
 </verbatim>
 
+<para>
 Note that it is not possible to create HTML tags in this manner.
 </para>
 
index 5dc1c92..77e3a81 100644 (file)
@@ -5,7 +5,7 @@
 <!--
       XML documentation system
       Original author :  Arjen Baart - arjen@andromeda.nl
-      Version         : $Revision: 1.2 $
+      Version         : $Revision: 1.3 $
 -->
 
 <chapter>
@@ -62,11 +62,13 @@ All you need to do is create your XML source document and use one of these
 scripts to transform the document an another format.
 For example, to transform this guide into a LaTeX document, you could
 use:
+</para>
 
 <verbatim>
    xml2latex guide.xml >guide.tex
 </verbatim>
 
+<para>
 Note that the transformed document is written to standard output.
 </para>
 </section>
index dbb3494..bf4e975 100644 (file)
@@ -49,6 +49,13 @@ p
    font-size : 100%;
 }
 
+pre.example
+{
+   background : lightblue ;
+   width      : 90% ;
+   margin-left: 5% ;
+}
+
 span.remark
 {
    font-size : 90%;
index bdebd00..8fa353d 100644 (file)
@@ -12,7 +12,7 @@ IMAGES=
 
 PICTURES=
 
-html: guide.html
+html: guide.xhtml
 
 ps: guide.ps
 
@@ -20,31 +20,25 @@ txt: guide.txt
 
 all:  ps html txt
 
-guide.html : $(XMLS) $(IMAGES) ../html.xsl
-       ../xp ../preprocess.xsl guide.xml >guide.tmp
-       ../xp ../html.xsl guide.tmp > guide.html
-       rm guide.tmp
+guide.xhtml : $(XMLS) $(IMAGES) ../html.xsl
+       ../xp ../html.xsl guide.xml > guide.xhtml
 
 guide.ps : $(XMLS)  $(PICTURES) ../latex.xsl ../xp
-       ../xp ../preprocess.xsl guide.xml >guide.tmp
-       ../xp --latex ../latex.xsl guide.tmp > guide.tex 
+       ../xp --latex ../latex.xsl guide.xml > guide.tex 
        latex guide.tex
        dvips -o guide.ps guide.dvi
-       rm guide.tmp
 
 guide.pdf : $(XMLS)  $(PICTURES) ../latex.xsl ../xp
-       ../xp ../preprocess.xsl guide.xml >guide.tmp
-       ../xp --latex ../latex.xsl guide.tmp > guide.tex 
+       ../xp --latex ../latex.xsl guide.xml > guide.tex 
        pdflatex guide.tex
-       rm guide.tmp
 
 guide.txt : $(XMLS) ../text.xsl
-       ../xp ../preprocess.xsl guide.xml >guide.tmp
-       ../xp ../text.xsl guide.tmp > guide.txt
-       rm guide.tmp
+       ../xp ../text.xsl guide.xml > guide.txt
 
 check:
-       xmllint --noout --valid $(XMLS)
+       xmllint --noout --xinclude --loaddtd --noent --schema ../doc.xsd guide.xml
+#      xmllint --noout --valid $(XMLS)
+
 clean:
-       rm -f guide.html guide.ps guide.tex guide.dvi guide.log guide.txt guide.pdf
+       rm -f guide.xhtml guide.ps guide.tex guide.dvi guide.log guide.txt guide.pdf
        rm -f $(IMAGES) $(PICTURES)
index ea9c715..bfb1598 100644 (file)
@@ -5,7 +5,7 @@
 <!--
       XML documentation system
       Original author :  Arjen Baart - arjen@andromeda.nl
-      Version         : $Revision: 1.2 $
+      Version         : $Revision: 1.3 $
 -->
 
 <chapter>
@@ -29,19 +29,30 @@ As a matter of fact, this XMLDoc guide is organized in such a way.
 </para>
 <para>
 To include another XML file in your root document, use the
-<strong>include</strong> element with a single attribute to specify
+standard XML <strong>XInclude</strong> system with a single attribute to specify
 the name of the file to be included.
+Other attributes, as well as the <strong>fallback</strong> element,
+are of course supported as well.
+Refer to the <reference href='http://www.w3.org/TR/2006/REC-xinclude-20061115/'>
+XML Inclusions</reference> standard for more information.
 For example, this chapter is in a file called "multifiles.xml", which
 is included in the main document with:
+</para>
+
 <verbatim>
-&lt;include href="multifiles.xml"/&gt;
+&lt;xi:include href="multifiles.xml"
+    xmlns:xi="http://www.w3.org/2001/XInclude"/&gt;
 </verbatim>
-There is one restriction to including other files: The included files
-must be valid XML files as well.
-It is not possible to include other kinds of files, such as raw text
-or source code.
-So, the included XML file starts with the usual XML declaration, but has
+
+<para>
+Remember to put the <strong>xi:include</strong> in the proper namespace.
+Normally, the included files must be valid XML files as well.
+To include other kinds of files, such as raw text or source code, the attribute
+<strong>parse='text'</strong> must be added to the <strong>include</strong> element.
+When including another XML document, the included XML file starts with the
+usual XML declaration, but has
 a different root element declared in the &lt;!DOCTYPE...&gt; declaration:
+</para>
 
 <verbatim>
 &lt;?xml version="1.0"?&gt;
@@ -51,7 +62,6 @@ a different root element declared in the &lt;!DOCTYPE...&gt; declaration:
 &lt;/chapter&gt;
 </verbatim>
 
-</para>
 </section>
 <section>
 <heading>Multiple output files</heading>
index 22ac06c..a22f323 100644 (file)
@@ -5,7 +5,7 @@
 <!--
       XML documentation system
       Original author :  Arjen Baart - arjen@andromeda.nl
-      Version         : $Revision: 1.2 $
+      Version         : $Revision: 1.3 $
 -->
 
 
@@ -119,6 +119,7 @@ After the opening tag of the first chapter, the document really begins.
 The structure of the document is layed out by its chapters, sections
 within the chapters, subsections within the sections and so on.
 Just as in LaTeX and HTML, there are six levels of sectioning elements available:
+</para>
 <enumerate>
 <item><code>chapter</code>: For top-level chapters.</item>
 <item><code>section</code>: For second-level sections, i.e. 1.1, 1.2, 1.3
@@ -130,6 +131,7 @@ Just as in LaTeX and HTML, there are six levels of sectioning elements available
 <item><code>paragraph</code>: The fifth-level sections</item>
 <item><code>subparagraph</code>: The sixth and final level.</item>
 </enumerate>
+<para>
 Note that the names are equivalent to their counterparts in LaTeX.
 </para>
 
@@ -155,12 +157,12 @@ You can use a 'normal' CSS stylesheet with the HTML output from
 <strong>xml2html</strong>, by using the <strong>style</strong> attribute
 in the <strong>doc</strong> element.
 Here is an example:
+</para>
 <verbatim>
 
 &lt;doc style="main.css"&gt;
 
 </verbatim>
-</para>
 </section>
 </chapter>
 
index 828bc8e..43841a8 100644 (file)
--- a/html.xsl
+++ b/html.xsl
@@ -2,10 +2,13 @@
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
 
 <xsl:strip-space elements="doc chapter section"/>
-<xsl:output method="html" indent="yes" encoding="iso-8859-1"/>
+<xsl:output method="xml" indent="yes" encoding="iso-8859-1"
+            doctype-system="http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"
+            doctype-public="-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"/>
 
 <xsl:template match="doc">
 <html>
+  <xsl:attribute name='xmlns'>http://www.w3.org/1999/xhtml</xsl:attribute>
 <head>
    <link>
    <xsl:attribute name="rel">stylesheet</xsl:attribute>
    <title>
       <xsl:value-of select="*/titlepage/title"/>
    </title>
+   <style type="text/css">
+      .center
+      {
+         text-align : center ;
+      }
+      table.docinfo
+      {
+         margin-left  : 10% ;
+         margin-right : 10% ;
+         border-style : solid ;
+      }
+      th
+      {
+         border-style : solid ;
+         border-width : thin ;
+      }
+      h3.toc
+      {
+         margin-left : 2em ;
+      }
+      pre.example
+      {
+         border : solid ;
+         padding-bottom : 1em ;
+      }
+      span.red
+      {
+         color : red ;
+      }
+      span.green
+      {
+         color : green ;
+      }
+      span.blue
+      {
+         color : blue ;
+      }
+      span.cyan
+      {
+         color : cyan ;
+      }
+      span.magenta
+      {
+         color : magenta ;
+      }
+      span.yellow
+      {
+         color : yellow ;
+      }
+      span.orange
+      {
+         color : orange ;
+      }
+      span.violet
+      {
+         color : violet ;
+      }
+      span.purple
+      {
+         color : purple ;
+      }
+      span.brown
+      {
+         color : brown ;
+      }
+      span.pink
+      {
+         color : pink ;
+      }
+      span.olive
+      {
+         color : olive ;
+      }
+      span.black
+      {
+         color : black ;
+      }
+      span.darkgray
+      {
+         color : darkgray ;
+      }
+      span.gray
+      {
+         color : gray ;
+      }
+      span.lightgray
+      {
+         color : lightgray ;
+      }
+      span.white
+      {
+         color : white ;
+      }
+   </style>
 </head>
 <body>
    <xsl:apply-templates/>
 </xsl:template>
 
 <xsl:template match="docinfo">
-   <center><table border="2" width="90%">
+   <table class="docinfo">
    <tr><th colspan="2">Document Information</th></tr>
    <xsl:apply-templates/>
-   </table></center>
+   </table>
 </xsl:template>
 
 <xsl:template match="infoitem">
 
 <xsl:template match="abstract">
    <blockquote>
-   <b>Abstract:</b><br/>
+   <p><b>Abstract:</b></p>
+   <p>
    <xsl:apply-templates/>
+   </p>
    </blockquote>
 </xsl:template>
 
    <xsl:value-of select="heading"/>
    </a>
    </h2>
-   <ul>
    <xsl:for-each select="section">
-      <h3>
+      <h3 class="toc">
       <xsl:number count="chapter|section" level="multiple" format="1.1 "/>
       <a>
       <xsl:attribute name="href">#SEC<xsl:number count="chapter|section" level="multiple" format="1.1"/></xsl:attribute>
       </a>
       </h3>
    </xsl:for-each>
-   </ul>
 </xsl:for-each>
 <hr></hr>
 </xsl:template>
      <xsl:number count="chapter"/>
      <xsl:text>  </xsl:text>
       <a>
-      <xsl:attribute name="name">CH<xsl:number count="chapter"/></xsl:attribute>
+      <xsl:attribute name="id">CH<xsl:number count="chapter"/></xsl:attribute>
       </a>
      <xsl:apply-templates/>
    </h1>
    <h2>
      <xsl:number count="chapter|section" level="multiple" format="1.1 "/>
      <a>
-     <xsl:attribute name="name">SEC<xsl:number count="chapter|section" level="multiple" format="1.1"/></xsl:attribute>
+     <xsl:attribute name="id">SEC<xsl:number count="chapter|section" level="multiple" format="1.1"/></xsl:attribute>
      </a>
      <xsl:apply-templates/>
    </h2>
 </xsl:template>
 
 <xsl:template match="quote">
-   <blockquote>
+   <blockquote><p>
      <xsl:apply-templates/>
-   </blockquote>
+   </p></blockquote>
 </xsl:template>
 
 <xsl:template match="verbatim">
 </pre>
 </xsl:template>
 
+<xsl:template match="example">
+<pre class='example'>
+ <xsl:apply-templates/>
+</pre>
+</xsl:template>
+
 <xsl:template match="itemize">
 <ul>
    <xsl:apply-templates/>
 </xsl:template>
 
 <xsl:template match="footnote" mode="footnotes">
-<sup><a><xsl:attribute name='name'>footnote<xsl:number level='any'/></xsl:attribute>
-        <xsl:number level='any'/></a></sup> <xsl:apply-templates/><br/>
-
+<p>
+<sup><a><xsl:attribute name='id'>footnote<xsl:number level='any'/></xsl:attribute>
+        <xsl:number level='any'/></a></sup> <xsl:apply-templates/>
+</p>
 </xsl:template>
 
 <xsl:template match="emph">
 <sup><xsl:apply-templates/></sup>
 </xsl:template>
 
+<xsl:template match="color">
+<span><xsl:attribute name="class"><xsl:value-of select="@colorname"/></xsl:attribute><xsl:apply-templates/></span>
+</xsl:template>
+
+<xsl:template match="big">
+<big><xsl:apply-templates/></big>
+</xsl:template>
+
+<xsl:template match="small">
+<small><xsl:apply-templates/></small>
+</xsl:template>
+
 <xsl:template match="table">
 <table>
 <xsl:apply-templates/>
 </xsl:template>
 
 <xsl:template match="label">
-   <a><xsl:attribute name='name'>
+   <a><xsl:attribute name='id'>
       <xsl:value-of select="@name"/>
    </xsl:attribute></a>
 </xsl:template>
 </a>
 </xsl:template>
 
+<xsl:template match="math">
+<math>
+<xsl:attribute name="xmlns">http://www.w3.org/1998/Math/MathML</xsl:attribute>
+<xsl:copy-of select='./*'/>
+</math>
+</xsl:template>
+
+<xsl:template match="svg">
+<svg>
+<xsl:attribute name="xmlns">http://www.w3.org/2000/svg</xsl:attribute>
+<xsl:copy-of select='./*'/>
+</svg>
+</xsl:template>
+
 </xsl:stylesheet>
 
index 566bb4b..eb197ee 100644 (file)
--- a/latex.xsl
+++ b/latex.xsl
@@ -8,6 +8,7 @@
 
 <xsl:template match="article">
 \documentclass[a4paper]{article}
+\usepackage{xcolor}
 \usepackage{graphics}
 \usepackage{latexsym}
 \usepackage{marvosym}
@@ -18,6 +19,7 @@
 
 <xsl:template match="book">
 \documentclass[a4paper]{book}
+\usepackage{xcolor}
 \usepackage{graphics}
 \usepackage{latexsym}
 \usepackage{marvosym}
@@ -28,6 +30,7 @@
 
 <xsl:template match="report">
 \documentclass[a4paper]{report}
+\usepackage{xcolor}
 \usepackage{graphics}
 \usepackage{latexsym}
 \usepackage{marvosym}
 \end{verbatim}
 </xsl:template>
 
+<xsl:template match="example">
+\begin{verbatim} 
+\makebox{ <xsl:apply-templates/> }
+\end{verbatim}
+</xsl:template>
+
 <xsl:template match="itemize">
 \begin{itemize}
    <xsl:apply-templates/>
 <xsl:template match="sub">$_{<xsl:apply-templates/>}$</xsl:template>
 <xsl:template match="sup">$^{<xsl:apply-templates/>}$</xsl:template>
 
+<xsl:template match="color">\textcolor{<xsl:value-of select="@colorname"/>}{<xsl:apply-templates/>}</xsl:template>
+
+<xsl:template match="big">\large{<xsl:apply-templates/>}</xsl:template>
+<xsl:template match="small">\small{<xsl:apply-templates/>}</xsl:template>
+
 <xsl:template match="newline">\\</xsl:template>
 <xsl:template match="newpage">\newpage</xsl:template>
 
index b960d22..0619df7 100755 (executable)
--- a/xml2html
+++ b/xml2html
@@ -25,6 +25,6 @@ do
    esac
    shift
 done
-TMPFILE=`mktemp /tmp/xmldoc.XXXXXX`
-xp $XSLDIR/preprocess.xsl $inputs >$TMPFILE
-xp $stylesheet $TMPFILE
+#TMPFILE=`mktemp /tmp/xmldoc.XXXXXX`
+#xp $XSLDIR/preprocess.xsl $inputs >$TMPFILE
+xp $stylesheet $inputs
index fca54c2..f2629c7 100755 (executable)
--- a/xml2latex
+++ b/xml2latex
@@ -26,6 +26,6 @@ do
    esac
    shift
 done
-TMPFILE=`mktemp /tmp/xmldoc.XXXXXX`
-xp $XSLDIR/preprocess.xsl $inputs >$TMPFILE
-xp --latex $stylesheet $TMPFILE
+#TMPFILE=`mktemp /tmp/xmldoc.XXXXXX`
+#xp $XSLDIR/preprocess.xsl $inputs >$TMPFILE
+xp --latex $stylesheet $inputs
index 82c01da..e30c017 100755 (executable)
--- a/xml2text
+++ b/xml2text
@@ -25,6 +25,6 @@ do
    esac
    shift
 done
-TMPFILE=`mktemp /tmp/xmldoc.XXXXXX`
-xp $XSLDIR/preprocess.xsl $inputs >$TMPFILE
-xp $stylesheet $TMPFILE
+#TMPFILE=`mktemp /tmp/xmldoc.XXXXXX`
+#xp $XSLDIR/preprocess.xsl $inputs >$TMPFILE
+xp $stylesheet $inputs
diff --git a/xp.c b/xp.c
index e56e35a..fd997d4 100644 (file)
--- a/xp.c
+++ b/xp.c
@@ -23,9 +23,6 @@
 #include <libxml/debugXML.h>
 #include <libxml/HTMLtree.h>
 #include <libxml/xmlIO.h>
-#ifdef LIBXML_DOCB_ENABLED
-#include <libxml/DOCBparser.h>
-#endif
 #ifdef LIBXML_XINCLUDE_ENABLED
 #include <libxml/xinclude.h>
 #endif
@@ -68,15 +65,13 @@ static int docbook = 0;
 #ifdef LIBXML_HTML_ENABLED
 static int html = 0;
 #endif
-#ifdef LIBXML_XINCLUDE_ENABLED
-static int xinclude = 0;
-#endif
-static int profile = 0;
 
 static const char *params[16 + 1];
 static int nbparams = 0;
 static const char *output = NULL;
 
+void LatexEscape(xmlNodePtr node);
+
 /*
  *  The LaTeX translation table. Translate unicodes to LaTeX escape sequences.
  */
@@ -351,17 +346,16 @@ static void
 xsltProcess(xmlDocPtr doc, xsltStylesheetPtr cur, const char *filename) {
     xmlDocPtr res;
 
-#ifdef LIBXML_XINCLUDE_ENABLED
-    if (xinclude) {
-       xmlXIncludeProcess(doc);
+    xmlXIncludeProcessFlags(doc, XSLT_PARSE_OPTIONS);
+
+    if (latex)
+    {
+       LatexEscape(xmlDocGetRootElement(doc));
     }
-#endif
+
     if (output == NULL) {
-       if (profile) {
-           res = xsltProfileStylesheet(cur, doc, params, stderr);
-       } else {
-           res = xsltApplyStylesheet(cur, doc, params);
-       }
+       res = xsltApplyStylesheet(cur, doc, params);
+
        xmlFreeDoc(doc);
        if (res == NULL) {
            fprintf(stderr, "no result for %s\n", filename);
@@ -415,8 +409,8 @@ void LatexEscape(xmlNodePtr node)
    if (xmlNodeIsText(node))
    {
 #ifdef DEBUG
-      fprintf(stderr, "\n-------- Text node (%d bytes):\n%s",
-                      strlen(node->content), node->content);
+      fprintf(stderr, "\n-------- Text node at %p (%d bytes):\n%s",
+                      node, strlen(node->content), node->content);
 #endif
 
       textlen = strlen(node->content);
@@ -501,7 +495,7 @@ void LatexEscape(xmlNodePtr node)
    {
       for (child = node->children; child != 0; child = child->next)
       {
-         if (strcmp(child->name, "verbatim") != 0)
+         if (strcmp(child->name, "verbatim") != 0 )
          {
             LatexEscape(child);
          }
@@ -535,10 +529,6 @@ static void usage(const char *name)
     printf("\t             otherwise XML Catalogs starting from \n");
     printf("\t         file:///etc/xml/catalog are activated by default\n");
 #endif
-#ifdef LIBXML_XINCLUDE_ENABLED
-    printf("\t--xinclude : do XInclude processing on document intput\n");
-#endif
-    printf("\t--profile or --norman : dump profiling informations \n");
 }
 
 int
@@ -597,22 +587,11 @@ main(int argc, char **argv)
         } else if ((!strcmp(argv[i], "-noout")) ||
                    (!strcmp(argv[i], "--noout"))) {
             noout++;
-#ifdef LIBXML_DOCB_ENABLED
-        } else if ((!strcmp(argv[i], "-docbook")) ||
-                   (!strcmp(argv[i], "--docbook"))) {
-            docbook++;
-#endif
 #ifdef LIBXML_HTML_ENABLED
         } else if ((!strcmp(argv[i], "-html")) ||
                    (!strcmp(argv[i], "--html"))) {
             html++;
 #endif
-        } else if ((!strcmp(argv[i], "-profile")) ||
-                   (!strcmp(argv[i], "--profile"))) {
-            profile++;
-        } else if ((!strcmp(argv[i], "-norman")) ||
-                   (!strcmp(argv[i], "--norman"))) {
-            profile++;
         } else if ((!strcmp(argv[i], "-nonet")) ||
                    (!strcmp(argv[i], "--nonet"))) {
             xmlSetExternalEntityLoader(xmlNoNetExternalEntityLoader);
@@ -628,12 +607,6 @@ main(int argc, char **argv)
                 xmlLoadCatalogs(catalogs);
             }
 #endif
-#ifdef LIBXML_XINCLUDE_ENABLED
-        } else if ((!strcmp(argv[i], "-xinclude")) ||
-                   (!strcmp(argv[i], "--xinclude"))) {
-            xinclude++;
-            xsltSetXIncludeDefault(1);
-#endif
         } else if ((!strcmp(argv[i], "-param")) ||
                    (!strcmp(argv[i], "--param"))) {
             i++;
@@ -660,6 +633,7 @@ main(int argc, char **argv)
     }
     params[nbparams] = NULL;
 
+    xsltSetXIncludeDefault(1);
     /*
      * Replace entities with their content.
      */
@@ -730,20 +704,11 @@ main(int argc, char **argv)
                 doc = htmlParseFile(argv[i], NULL);
             else
 #endif
-#ifdef LIBXML_DOCB_ENABLED
-            if (docbook)
-                doc = docbParseFile(argv[i], NULL);
-            else
-#endif
                 doc = xmlParseFile(argv[i]);
             if (doc == NULL) {
                 fprintf(stderr, "unable to parse %s\n", argv[i]);
                 continue;
             }
-            if (latex)
-            {
-               LatexEscape(xmlDocGetRootElement(doc));
-            }
            xsltProcess(doc, cur, argv[i]);
         }
     }