Commit 5cb5ab8d authored by Daniel Veillard's avatar Daniel Veillard
Browse files

- release 1.8.2 - HTML handling improvement - new tree handling functions

- release 1.8.2
- HTML handling improvement
- new tree handling functions
- default namespace on attribute bug fixed
- libxml use for C++ fixed (for good this time !)
Daniel
parent f600e253
Tue Dec 21 14:29:34 CET 1999 Daniel Veillard <Daniel.Veillard@w3.org>
* configure.in, doc/xml.html : bug fix release 1.8.2
* debugXML.h nanohttp.h xml-error.h xmlmemory.h xpath.h :
Hopefully the end of that silly C++ include problem
* tree.[ch]: Added a few functions: xmlReplaceNode, xmlAddPrevSibling,
xmlAddNextSibling, xmlNodeSetName and xmlDocSetRootElement
* HTMLparser.c HTMLparser.h HTMLtree.c: When saving HTML try to avoid
troubles with autoclosed elements when the stree shape doesn't
follow the DtD specs. Added htmlIsAutoClosed() and
htmlAutoCloseTag()
* result/HTML/*.htm*: Updated the HTML examples regression tests output
* SAX.c tree.c: fixed bug on defaulting namespaces on attributes
* debugXML.c: fixed a bug on printing default namespaces.
* HTMLtree.c: fixed a problem when outputing XML parsed docs as HTML
Mon Dec 20 16:20:55 CET 1999 Daniel Veillard <Daniel.Veillard@w3.org>
* result/HTML/*.htm[l] : updated the HTML regression tests according
......
......@@ -466,6 +466,58 @@ htmlAutoClose(htmlParserCtxtPtr ctxt, const xmlChar *new) {
}
}
/**
* htmlAutoCloseTag:
* @doc: the HTML document
* @name: The tag name
* @elem: the HTML element
*
* The HTmL DtD allows a tag to implicitely close other tags.
* The list is kept in htmlStartClose array. This function checks
* if the element or one of it's children would autoclose the
* given tag.
*
* Returns 1 if autoclose, 0 otherwise
*/
int
htmlAutoCloseTag(htmlDocPtr doc, const xmlChar *name, htmlNodePtr elem) {
htmlNodePtr child;
if (elem == NULL) return(1);
if (!xmlStrcmp(name, elem->name)) return(0);
if (htmlCheckAutoClose(elem->name, name)) return(1);
child = elem->childs;
while (child != NULL) {
if (htmlAutoCloseTag(doc, name, child)) return(1);
child = child->next;
}
return(0);
}
/**
* htmlIsAutoClosed:
* @doc: the HTML document
* @elem: the HTML element
*
* The HTmL DtD allows a tag to implicitely close other tags.
* The list is kept in htmlStartClose array. This function checks
* if a tag is autoclosed by one of it's child
*
* Returns 1 if autoclosed, 0 otherwise
*/
int
htmlIsAutoClosed(htmlDocPtr doc, htmlNodePtr elem) {
htmlNodePtr child;
if (elem == NULL) return(1);
child = elem->childs;
while (child != NULL) {
if (htmlAutoCloseTag(doc, elem->name, child)) return(1);
child = child->next;
}
return(0);
}
/**
* htmlAutoCloseOnClose:
* @ctxt: an HTML parser context
......@@ -528,7 +580,6 @@ htmlEntityDesc html40EntitiesTable[] = {
*/
{ 34, "quot", "quotation mark = APL quote, U+0022 ISOnum" },
{ 38, "amp", "ampersand, U+0026 ISOnum" },
{ 39, "apos", "single quote" },
{ 60, "lt", "less-than sign, U+003C ISOnum" },
{ 62, "gt", "greater-than sign, U+003E ISOnum" },
......@@ -536,6 +587,7 @@ htmlEntityDesc html40EntitiesTable[] = {
* A bunch still in the 128-255 range
* Replacing them depend really on the charset used.
*/
{ 39, "apos", "single quote" },
{ 160, "nbsp", "no-break space = non-breaking space, U+00A0 ISOnum" },
{ 161, "iexcl","inverted exclamation mark, U+00A1 ISOnum" },
{ 162, "cent", "cent sign, U+00A2 ISOnum" },
......@@ -1166,7 +1218,13 @@ htmlNewDoc(const xmlChar *URI, const xmlChar *ExternalID) {
cur->type = XML_HTML_DOCUMENT_NODE;
cur->version = NULL;
cur->intSubset = NULL;
xmlCreateIntSubset(cur, BAD_CAST "HTML", ExternalID, URI);
if ((ExternalID == NULL) &&
(URI == NULL))
xmlCreateIntSubset(cur, BAD_CAST "HTML",
BAD_CAST "-//W3C//DTD HTML 4.0 Transitional//EN",
BAD_CAST "http://www.w3.org/TR/REC-html40/loose.dtd");
else
xmlCreateIntSubset(cur, BAD_CAST "HTML", ExternalID, URI);
cur->name = NULL;
cur->root = NULL;
cur->extSubset = NULL;
......
......@@ -11,7 +11,7 @@
#include "parser.h"
#ifdef __cplusplus
#define extern "C" {
extern "C" {
#endif
/*
......@@ -52,19 +52,31 @@ typedef struct htmlEntityDesc {
/*
* There is only few public functions.
*/
htmlElemDescPtr htmlTagLookup(const xmlChar *tag);
htmlEntityDescPtr htmlEntityLookup(const xmlChar *name);
htmlElemDescPtr htmlTagLookup (const xmlChar *tag);
htmlEntityDescPtr htmlEntityLookup(const xmlChar *name);
htmlEntityDescPtr htmlParseEntityRef(htmlParserCtxtPtr ctxt, xmlChar **str);
int htmlParseCharRef(htmlParserCtxtPtr ctxt);
void htmlParseElement(htmlParserCtxtPtr ctxt);
int htmlIsAutoClosed(htmlDocPtr doc,
htmlNodePtr elem);
int htmlAutoCloseTag(htmlDocPtr doc,
const xmlChar *name,
htmlNodePtr elem);
htmlEntityDescPtr htmlParseEntityRef(htmlParserCtxtPtr ctxt,
xmlChar **str);
int htmlParseCharRef(htmlParserCtxtPtr ctxt);
void htmlParseElement(htmlParserCtxtPtr ctxt);
htmlDocPtr htmlSAXParseDoc(xmlChar *cur, const char *encoding,
htmlSAXHandlerPtr sax, void *userData);
htmlDocPtr htmlParseDoc(xmlChar *cur, const char *encoding);
htmlDocPtr htmlSAXParseFile(const char *filename, const char *encoding,
htmlSAXHandlerPtr sax, void *userData);
htmlDocPtr htmlParseFile(const char *filename, const char *encoding);
htmlDocPtr htmlSAXParseDoc (xmlChar *cur,
const char *encoding,
htmlSAXHandlerPtr sax,
void *userData);
htmlDocPtr htmlParseDoc (xmlChar *cur,
const char *encoding);
htmlDocPtr htmlSAXParseFile(const char *filename,
const char *encoding,
htmlSAXHandlerPtr sax,
void *userData);
htmlDocPtr htmlParseFile (const char *filename,
const char *encoding);
#ifdef __cplusplus
}
......
......@@ -244,9 +244,11 @@ htmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur) {
(cur->childs != cur->last))
xmlBufferWriteChar(buf, "\n");
}
xmlBufferWriteChar(buf, "</");
xmlBufferWriteCHAR(buf, cur->name);
xmlBufferWriteChar(buf, ">");
if (!htmlIsAutoClosed(doc, cur)) {
xmlBufferWriteChar(buf, "</");
xmlBufferWriteCHAR(buf, cur->name);
xmlBufferWriteChar(buf, ">");
}
if (cur->next != NULL) {
if ((cur->next->type != HTML_TEXT_NODE) &&
(cur->next->type != HTML_ENTITY_REF_NODE))
......@@ -263,12 +265,25 @@ htmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur) {
*/
static void
htmlDocContentDump(xmlBufferPtr buf, xmlDocPtr cur) {
int type;
/*
* force to output the stuff as HTML, especially for entities
*/
type = cur->type;
cur->type = XML_HTML_DOCUMENT_NODE;
if (cur->intSubset != NULL)
htmlDtdDump(buf, cur);
else {
/* Default to HTML-4.0 transitionnal @@@@ */
xmlBufferWriteChar(buf, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">");
}
if (cur->root != NULL) {
htmlNodeListDump(buf, cur, cur->root);
}
xmlBufferWriteChar(buf, "\n");
cur->type = type;
}
/**
......
......@@ -548,7 +548,12 @@ attribute(void *ctx, const xmlChar *fullname, const xmlChar *value)
return;
}
namespace = xmlSearchNs(ctxt->myDoc, ctxt->node, ns);
if (ns != NULL)
namespace = xmlSearchNs(ctxt->myDoc, ctxt->node, ns);
else {
namespace = NULL;
}
/* !!!!!! <a toto:arg="" xmlns:toto="http://toto.com"> */
ret = xmlNewNsProp(ctxt->node, namespace, name, NULL);
......
......@@ -5,7 +5,7 @@ AM_CONFIG_HEADER(config.h)
LIBXML_MAJOR_VERSION=1
LIBXML_MINOR_VERSION=8
LIBXML_MICRO_VERSION=1
LIBXML_MICRO_VERSION=2
LIBXML_VERSION=$LIBXML_MAJOR_VERSION.$LIBXML_MINOR_VERSION.$LIBXML_MICRO_VERSION
LIBXML_VERSION_INFO=`expr $LIBXML_MAJOR_VERSION + $LIBXML_MINOR_VERSION`:$LIBXML_MICRO_VERSION:$LIBXML_MINOR_VERSION
......
......@@ -35,7 +35,11 @@ void xmlDebugDumpNamespace(FILE *output, xmlNsPtr ns, int depth) {
fprintf(output, shift);
if (ns->type == XML_GLOBAL_NAMESPACE)
fprintf(output, "old ");
fprintf(output, "namespace %s href=", ns->prefix);
if (ns->prefix != NULL)
fprintf(output, "namespace %s href=", ns->prefix);
else
fprintf(output, "default namespace href=", ns->prefix);
xmlDebugDumpString(output, ns->href);
fprintf(output, "\n");
}
......
......@@ -10,7 +10,7 @@
#include "tree.h"
#ifdef __cplusplus
#define extern "C" {
extern "C" {
#endif
extern void xmlDebugDumpString(FILE *output, const xmlChar *str);
extern void xmlDebugDumpAttr(FILE *output, xmlAttrPtr attr, int depth);
......
......@@ -115,4 +115,152 @@ HREF="libxml-lib.html"
><A
HREF="gnome-xml-parser.html"
>parser</A
> &#8212;
\ No newline at end of file
> &#8212; </DT
><DT
><A
HREF="gnome-xml-sax.html"
>SAX</A
> &#8212; </DT
><DT
><A
HREF="gnome-xml-tree.html"
>tree</A
> &#8212; </DT
><DT
><A
HREF="gnome-xml-entities.html"
>entities</A
> &#8212; </DT
><DT
><A
HREF="gnome-xml-valid.html"
>valid</A
> &#8212; </DT
><DT
><A
HREF="gnome-xml-xml-error.html"
>xml-error</A
> &#8212; </DT
><DT
><A
HREF="gnome-xml-htmlparser.html"
>HTMLparser</A
> &#8212; </DT
><DT
><A
HREF="gnome-xml-htmltree.html"
>HTMLtree</A
> &#8212; </DT
><DT
><A
HREF="gnome-xml-xpath.html"
>xpath</A
> &#8212; </DT
><DT
><A
HREF="gnome-xml-nanohttp.html"
>nanohttp</A
> &#8212; </DT
><DT
><A
HREF="gnome-xml-xmlio.html"
>xmlIO</A
> &#8212; </DT
><DT
><A
HREF="gnome-xml-parserinternals.html"
>parserInternals</A
> &#8212; </DT
><DT
><A
HREF="gnome-xml-encoding.html"
>encoding</A
> &#8212; </DT
><DT
><A
HREF="gnome-xml-debugxml.html"
>debugXML</A
> &#8212; </DT
><DT
><A
HREF="gnome-xml-xmlmemory.html"
>xmlmemory</A
> &#8212; </DT
></DL
></DD
></DL
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><BR
CLEAR="all"><BR><TABLE
WIDTH="100%"
BORDER="0"
BGCOLOR="#000000"
CELLPADDING="1"
CELLSPACING="0"
><TR
><TD
WIDTH="25%"
BGCOLOR="#C00000"
ALIGN="left"
>&nbsp;</TD
><TD
WIDTH="25%"
BGCOLOR="#0000C0"
ALIGN="center"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
>&nbsp;</B
></FONT
></TD
><TD
WIDTH="25%"
BGCOLOR="#00C000"
ALIGN="center"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
>&nbsp;</B
></FONT
></TD
><TD
WIDTH="25%"
BGCOLOR="#C00000"
ALIGN="right"
><A
HREF="libxml-notes.html"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
>Next Page &#62;&#62;&#62;</B
></FONT
></A
></TD
></TR
><TR
><TD
COLSPAN="2"
ALIGN="left"
>&nbsp;</TD
><TD
COLSPAN="2"
ALIGN="right"
><FONT
COLOR="#FFFFFF"
SIZE="3"
><B
>Libxml Programming Notes</B
></FONT
></TD
></TR
></TABLE
></DIV
></BODY
></HTML
>
\ No newline at end of file
......@@ -115,7 +115,7 @@ SIZE="3"
><DIV
CLASS="REFNAMEDIV"
><A
NAME="AEN5464"
NAME="AEN5587"
></A
><H2
>Name</H2
......@@ -123,7 +123,7 @@ NAME="AEN5464"
><DIV
CLASS="REFSYNOPSISDIV"
><A
NAME="AEN5467"
NAME="AEN5590"
></A
><H2
>Synopsis</H2
......@@ -348,7 +348,7 @@ HREF="gnome-xml-entities.html#XMLCLEANUPPREDEFINEDENTITIES"
><DIV
CLASS="REFSECT1"
><A
NAME="AEN5525"
NAME="AEN5648"
></A
><H2
>Description</H2
......@@ -358,14 +358,14 @@ NAME="AEN5525"
><DIV
CLASS="REFSECT1"
><A
NAME="AEN5528"
NAME="AEN5651"
></A
><H2
>Details</H2
><DIV
CLASS="REFSECT2"
><A
NAME="AEN5530"
NAME="AEN5653"
></A
><H3
><A
......@@ -381,7 +381,7 @@ CELLPADDING="6"
><TD
><PRE
CLASS="PROGRAMLISTING"
>#define XML_INTERNAL_GENERAL_ENTITY 1</PRE
>#define XML_INTERNAL_GENERAL_ENTITY</PRE
></TD
></TR
></TABLE
......@@ -391,7 +391,7 @@ CLASS="PROGRAMLISTING"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN5535"
NAME="AEN5658"
></A
><H3
><A
......@@ -407,7 +407,7 @@ CELLPADDING="6"
><TD
><PRE
CLASS="PROGRAMLISTING"
>#define XML_EXTERNAL_GENERAL_PARSED_ENTITY 2</PRE
>#define XML_EXTERNAL_GENERAL_PARSED_ENTITY</PRE
></TD
></TR
></TABLE
......@@ -417,7 +417,7 @@ CLASS="PROGRAMLISTING"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN5540"
NAME="AEN5663"
></A
><H3
><A
......@@ -433,7 +433,7 @@ CELLPADDING="6"
><TD
><PRE
CLASS="PROGRAMLISTING"
>#define XML_EXTERNAL_GENERAL_UNPARSED_ENTITY 3</PRE
>#define XML_EXTERNAL_GENERAL_UNPARSED_ENTITY</PRE
></TD
></TR
></TABLE
......@@ -443,7 +443,7 @@ CLASS="PROGRAMLISTING"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN5545"
NAME="AEN5668"
></A
><H3
><A
......@@ -459,7 +459,7 @@ CELLPADDING="6"
><TD
><PRE
CLASS="PROGRAMLISTING"
>#define XML_INTERNAL_PARAMETER_ENTITY 4</PRE
>#define XML_INTERNAL_PARAMETER_ENTITY</PRE
></TD
></TR
></TABLE
......@@ -469,7 +469,7 @@ CLASS="PROGRAMLISTING"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN5550"
NAME="AEN5673"
></A
><H3
><A
......@@ -485,7 +485,7 @@ CELLPADDING="6"
><TD
><PRE
CLASS="PROGRAMLISTING"
>#define XML_EXTERNAL_PARAMETER_ENTITY 5</PRE
>#define XML_EXTERNAL_PARAMETER_ENTITY</PRE
></TD
></TR
></TABLE
......@@ -495,7 +495,7 @@ CLASS="PROGRAMLISTING"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN5555"
NAME="AEN5678"
></A
><H3
><A
......@@ -511,7 +511,7 @@ CELLPADDING="6"
><TD
><PRE
CLASS="PROGRAMLISTING"
>#define XML_INTERNAL_PREDEFINED_ENTITY 6</PRE
>#define XML_INTERNAL_PREDEFINED_ENTITY</PRE
></TD
></TR
></TABLE
......@@ -521,33 +521,20 @@ CLASS="PROGRAMLISTING"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN5560"
NAME="AEN5683"
></A
><H3
><A
NAME="XMLENTITYPTR"
></A
>xmlEntityPtr</H3
><TABLE
BORDER="0"
BGCOLOR="#D6E8FF"
WIDTH="100%"
CELLPADDING="6"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>typedef xmlEntity *xmlEntityPtr;</PRE
></TD
></TR
></TABLE
><P
></P
></DIV
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN5565"
NAME="AEN5687"
></A
><H3
><A
......@@ -563,7 +550,7 @@ CELLPADDING="6"
><TD
><PRE
CLASS="PROGRAMLISTING"
>#define XML_MIN_ENTITIES_TABLE 32</PRE
>#define XML_MIN_ENTITIES_TABLE</PRE
></TD
></TR
></TABLE
......@@ -573,33 +560,20 @@ CLASS="PROGRAMLISTING"
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN5570"
NAME="AEN5692"
></A
><H3
><A
NAME="XMLENTITIESTABLEPTR"
></A
>xmlEntitiesTablePtr</H3
><TABLE
BORDER="0"
BGCOLOR="#D6E8FF"
WIDTH="100%"
CELLPADDING="6"
><TR
><TD
><PRE
CLASS="PROGRAMLISTING"
>typedef xmlEntitiesTable *xmlEntitiesTablePtr;</PRE
></TD
></TR
></TABLE
><P
></P
></DIV
><HR><DIV
CLASS="REFSECT2"
><A
NAME="AEN5575"
NAME="AEN5696"
></A
><H3
><A
......@@ -669,7 +643,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the document</TD
>&nbsp;</TD
></TR
><TR
><TD
......@@ -686,7 +660,7 @@ CLASS="PARAMETER"
WIDTH="80%"
ALIGN="LEFT"
VALIGN="TOP"
> the entity name</TD
>&nbsp;</TD
></TR
><TR
><TD
......@@ -703,7 +677,7 @@ CLASS="PARAMETER"
WIDTH="80%"