From: arjen Date: Thu, 18 Oct 2007 07:03:59 +0000 (+0000) Subject: The conversion to HTML creates proper XHTML. X-Git-Tag: V0_6 X-Git-Url: http://www.andromeda.nl/gitweb/?p=xmldoc.git;a=commitdiff_plain;h=e31293cc60eebadba25f7d7188782ab5bdf15077 The conversion to HTML creates proper XHTML. Added support for embedded MathML and SVG. New element: . Use standard XML Inclusion methods as opposed to a preprocessing stylesheet. - This means the element will be deprecated. New type styles: big and small. Added colored text with a few predefined colors. --- diff --git a/ChangeLog b/ChangeLog index 4dc4842..77379f6 100644 --- 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: . +o Use standard XML Inclusion methods as opposed to a preprocessing stylesheet. + - This means the 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 --- a/doc.dtd +++ b/doc.dtd @@ -4,7 +4,8 @@ diff --git a/doc/block.xml b/doc/block.xml index b102fed..4c05987 100644 --- a/doc/block.xml +++ b/doc/block.xml @@ -5,7 +5,7 @@ @@ -23,6 +23,8 @@ in a para element. To make several separate paragraphs, you must enclose each paragraph in a para open tag and a para close tag. Here is an example of two small paragraphs: + + <para> @@ -34,11 +36,10 @@ Here is an example of two small paragraphs: - - A second type of paragraph is a quote. You can make a quote by using the quote element: + <quote> @@ -48,14 +49,15 @@ You can make a quote by using the quote element: </quote> + Which results in: + 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. - A special kind of paragraph is the verbatim 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 verbatim element is to include coding examples, such as: + <verbatim> @@ -74,7 +77,9 @@ include coding examples, such as: </verbatim> + Which comes out like this: + struct complex @@ -83,7 +88,41 @@ Which comes out like this: double imaginary; }; + + +A variation on the verbatim text is the example +text. +The only real difference is that example is placed inside +a box to make it stand out a bit more. +In fact, when converted to XHTML, only an attribute class='example' +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 example element: + + + + <example> + struct complex + { + double real; + double imaginary; + }; + </example> + + + +Which comes out like this: + + + struct complex + { + double real; + double imaginary; + }; + +
@@ -91,11 +130,13 @@ Which comes out like this: Footnotes are created with the footnote element: This is an example of a footnote + <footnote>This is an example of a footnote</footnote> + Within a footnote, you can use inline content described in the next chapter to format the type styles of the text in the footnote. @@ -114,18 +155,22 @@ running text referring to that footnote. Three types of lists are supported: + + itemize for bulleted lists such as this one. enumerate for numbered lists. description for tagged lists. + Each item in such a list must be in an item element. In fact, an item is the only element allowed in an itemize, enumerate or description element. You should not put ordinary text or any other element in a list without enclosing them in <item> and </item>. Here is an example of a numbered list: + @@ -137,7 +182,9 @@ Here is an example of a numbered list: + And this is what the list turns into: + First you need an enumerate, itemize or description tag. @@ -145,11 +192,13 @@ And this is what the list turns into: Finally, put the content inside the items. + 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 tag attribute of the item element. So, repeating the above list as a description list: + <description> @@ -159,7 +208,9 @@ So, repeating the above list as a description list: </description> + Which creates the following output: + for bulleted lists. @@ -167,6 +218,7 @@ Which creates the following output: for tagged lists such as this one. + An item can contain inline content as well as block-level content.
@@ -176,11 +228,13 @@ An item can contain inline content as well as block-level content. The empty element picture is used to include graphics in your document, like this: + <picture src='diagram.png' eps='diagram' scale='0.5'/> + The two attributes are used in either HTML or LaTeX. @@ -202,6 +256,7 @@ attribute in the table tag. An example of a table is shown below: + @@ -221,7 +276,6 @@ An example of a table is shown below: Wine 2.20 -
diff --git a/doc/glossary.xml b/doc/glossary.xml index 7598ed8..bf6963a 100644 --- a/doc/glossary.xml +++ b/doc/glossary.xml @@ -5,7 +5,7 @@ @@ -75,6 +75,11 @@ Creates a list of numbered items. + + A block-level element to hold text with a + pre-determined layout. The block of text is surrounded by a border. + + Creates a numbered footnote at the bottom of the page. @@ -87,6 +92,7 @@ Includes part of the document from another file. + Deprecated. Use the standard XML Inclusion method instead. diff --git a/doc/guide.xml b/doc/guide.xml index f314395..60fa01d 100644 --- a/doc/guide.xml +++ b/doc/guide.xml @@ -1,12 +1,13 @@ - + There are six type styles: + emph : Emphasized text strong : Usually bold face @@ -20,7 +21,60 @@ There are six type styles: sub : For subscript text. sup : For superscript text. + +
+ + +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 color element. +Which color the output text should become is specified in the +colorname attribute, for example: + + + + <color colorname='red'>Red text</color> + + + +It is not possible to create any color; there are just a few predefined +colors available: +red, +green, +blue, +cyan, +magenta, +yellow, +orange, +violet, +purple, +brown, +pink, +olive, +black, +darkgray, +gray, +lightgray and +white. +The last, color (white) is probably invisible :-). + + + +NOTE: To make colored text work with LaTeX, you probably need to install +the latex-xcolor package. + + +Apart from the normal font size, there are two other sizes available: +bigand small. +These element will make the text slightly bigger or smaller, like this: + +Here is <small>some small text</small> and <big>a big phrase</big>. + + +Here is some small text and a big phrase. + +
@@ -48,11 +102,13 @@ The content of its command attribute is copied literally into the output. One of the applications of the LaTeX escape element is to control the first line indent of a paragraph in LaTeX: + <LaTeX command='\setlength{\parindent}{0cm}'/> + Note that it is not possible to create HTML tags in this manner. diff --git a/doc/intro.xml b/doc/intro.xml index 5dc1c92..77e3a81 100644 --- a/doc/intro.xml +++ b/doc/intro.xml @@ -5,7 +5,7 @@ @@ -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: + xml2latex guide.xml >guide.tex + Note that the transformed document is written to standard output.
diff --git a/doc/main.css b/doc/main.css index dbb3494..bf4e975 100644 --- a/doc/main.css +++ b/doc/main.css @@ -49,6 +49,13 @@ p font-size : 100%; } +pre.example +{ + background : lightblue ; + width : 90% ; + margin-left: 5% ; +} + span.remark { font-size : 90%; diff --git a/doc/makefile b/doc/makefile index bdebd00..8fa353d 100644 --- a/doc/makefile +++ b/doc/makefile @@ -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) diff --git a/doc/multifiles.xml b/doc/multifiles.xml index ea9c715..bfb1598 100644 --- a/doc/multifiles.xml +++ b/doc/multifiles.xml @@ -5,7 +5,7 @@ @@ -29,19 +29,30 @@ As a matter of fact, this XMLDoc guide is organized in such a way. To include another XML file in your root document, use the -include element with a single attribute to specify +standard XML XInclude system with a single attribute to specify the name of the file to be included. +Other attributes, as well as the fallback element, +are of course supported as well. +Refer to the +XML Inclusions standard for more information. For example, this chapter is in a file called "multifiles.xml", which is included in the main document with: + + -<include href="multifiles.xml"/> +<xi:include href="multifiles.xml" + xmlns:xi="http://www.w3.org/2001/XInclude"/> -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 + + +Remember to put the xi:include 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 +parse='text' must be added to the include 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 <!DOCTYPE...> declaration: + <?xml version="1.0"?> @@ -51,7 +62,6 @@ a different root element declared in the <!DOCTYPE...> declaration: </chapter> -
Multiple output files diff --git a/doc/overall.xml b/doc/overall.xml index 22ac06c..a22f323 100644 --- a/doc/overall.xml +++ b/doc/overall.xml @@ -5,7 +5,7 @@ @@ -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: + chapter: For top-level chapters. section: 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 paragraph: The fifth-level sections subparagraph: The sixth and final level. + Note that the names are equivalent to their counterparts in LaTeX. @@ -155,12 +157,12 @@ You can use a 'normal' CSS stylesheet with the HTML output from xml2html, by using the style attribute in the doc element. Here is an example: + <doc style="main.css"> -
diff --git a/html.xsl b/html.xsl index 828bc8e..43841a8 100644 --- a/html.xsl +++ b/html.xsl @@ -2,10 +2,13 @@ - + + http://www.w3.org/1999/xhtml stylesheet @@ -15,6 +18,100 @@ <xsl:value-of select="*/titlepage/title"/> + @@ -54,10 +151,10 @@ -
+
-
Document Information
+
@@ -69,8 +166,10 @@
- Abstract:
+

Abstract:

+

+

@@ -93,9 +192,8 @@ -
@@ -115,7 +212,7 @@ - CH + CH @@ -125,7 +222,7 @@

- SEC + SEC

@@ -173,9 +270,9 @@ -
+

-

+

@@ -184,6 +281,12 @@ + +
+ 
+
+
+
    @@ -229,9 +332,10 @@ -footnote -
    - +

    +footnote + +

    @@ -258,6 +362,18 @@ + + + + + + + + + + + + @@ -288,7 +404,7 @@ - + @@ -313,5 +429,19 @@ + + +http://www.w3.org/1998/Math/MathML + + + + + + +http://www.w3.org/2000/svg + + + + diff --git a/latex.xsl b/latex.xsl index 566bb4b..eb197ee 100644 --- a/latex.xsl +++ b/latex.xsl @@ -8,6 +8,7 @@ \documentclass[a4paper]{article} +\usepackage{xcolor} \usepackage{graphics} \usepackage{latexsym} \usepackage{marvosym} @@ -18,6 +19,7 @@ \documentclass[a4paper]{book} +\usepackage{xcolor} \usepackage{graphics} \usepackage{latexsym} \usepackage{marvosym} @@ -28,6 +30,7 @@ \documentclass[a4paper]{report} +\usepackage{xcolor} \usepackage{graphics} \usepackage{latexsym} \usepackage{marvosym} @@ -137,6 +140,12 @@ \end{verbatim} + +\begin{verbatim} +\makebox{ } +\end{verbatim} + + \begin{itemize} @@ -180,6 +189,11 @@ $_{}$ $^{}$ +\textcolor{}{} + +\large{} +\small{} + \\ \newpage diff --git a/xml2html b/xml2html index b960d22..0619df7 100755 --- 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 diff --git a/xml2latex b/xml2latex index fca54c2..f2629c7 100755 --- 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 diff --git a/xml2text b/xml2text index 82c01da..e30c017 100755 --- 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 --- a/xp.c +++ b/xp.c @@ -23,9 +23,6 @@ #include #include #include -#ifdef LIBXML_DOCB_ENABLED -#include -#endif #ifdef LIBXML_XINCLUDE_ENABLED #include #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]); } }