diff --git a/ChangeLog b/ChangeLog index d1051ec8..c983233c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +Tue Dec 21 14:29:34 CET 1999 Daniel Veillard + + * 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 * result/HTML/*.htm[l] : updated the HTML regression tests according diff --git a/HTMLparser.c b/HTMLparser.c index c2177c82..0215b7a7 100644 --- a/HTMLparser.c +++ b/HTMLparser.c @@ -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; diff --git a/HTMLparser.h b/HTMLparser.h index eed7924b..a90b217a 100644 --- a/HTMLparser.h +++ b/HTMLparser.h @@ -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 } diff --git a/HTMLtree.c b/HTMLtree.c index 4b24f7d9..1265a0ab 100644 --- a/HTMLtree.c +++ b/HTMLtree.c @@ -244,9 +244,11 @@ htmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur) { (cur->childs != cur->last)) xmlBufferWriteChar(buf, "\n"); } - xmlBufferWriteChar(buf, "name); - xmlBufferWriteChar(buf, ">"); + if (!htmlIsAutoClosed(doc, cur)) { + xmlBufferWriteChar(buf, "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, ""); + + } if (cur->root != NULL) { htmlNodeListDump(buf, cur, cur->root); } xmlBufferWriteChar(buf, "\n"); + cur->type = type; } /** diff --git a/SAX.c b/SAX.c index 527efc0e..6d95d44b 100644 --- a/SAX.c +++ b/SAX.c @@ -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; + } + /* !!!!!! */ ret = xmlNewNsProp(ctxt->node, namespace, name, NULL); diff --git a/configure.in b/configure.in index 53ac7a9f..f52084c8 100644 --- a/configure.in +++ b/configure.in @@ -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 diff --git a/debugXML.c b/debugXML.c index 650fc596..37213f6e 100644 --- a/debugXML.c +++ b/debugXML.c @@ -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"); } diff --git a/debugXML.h b/debugXML.h index 5bec396f..9c77496e 100644 --- a/debugXML.h +++ b/debugXML.h @@ -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); diff --git a/doc/html/book1.html b/doc/html/book1.html index 0eae983c..b3e5fdd4 100644 --- a/doc/html/book1.html +++ b/doc/html/book1.html @@ -115,4 +115,152 @@ HREF="libxml-lib.html" >parser — \ No newline at end of file +> —
SAX
tree
entities
valid
xml-error
HTMLparser
HTMLtree
xpath
nanohttp
xmlIO
parserInternals
encoding
debugXML
xmlmemory


   Next Page >>>
 Libxml Programming Notes
\ No newline at end of file diff --git a/doc/html/gnome-xml-entities.html b/doc/html/gnome-xml-entities.html index 119396df..91722814 100644 --- a/doc/html/gnome-xml-entities.html +++ b/doc/html/gnome-xml-entities.html @@ -115,7 +115,7 @@ SIZE="3" >

Name

Synopsis

Description

Details

#define XML_INTERNAL_GENERAL_ENTITY		1
#define XML_INTERNAL_GENERAL_ENTITY

#define XML_EXTERNAL_GENERAL_PARSED_ENTITY	2
#define XML_EXTERNAL_GENERAL_PARSED_ENTITY

#define XML_EXTERNAL_GENERAL_UNPARSED_ENTITY	3
#define XML_EXTERNAL_GENERAL_UNPARSED_ENTITY

#define XML_INTERNAL_PARAMETER_ENTITY		4
#define XML_INTERNAL_PARAMETER_ENTITY

#define XML_EXTERNAL_PARAMETER_ENTITY		5
#define XML_EXTERNAL_PARAMETER_ENTITY

#define XML_INTERNAL_PREDEFINED_ENTITY		6
#define XML_INTERNAL_PREDEFINED_ENTITY

xmlEntityPtr

typedef xmlEntity *xmlEntityPtr;


#define XML_MIN_ENTITIES_TABLE	32
#define XML_MIN_ENTITIES_TABLE

xmlEntitiesTablePtr

typedef xmlEntitiesTable *xmlEntitiesTablePtr;


the document  the entity name  the entity type XML_xxx_yyy_ENTITY  the entity external ID if available  the entity system ID if available  the entity content 


the document  the entity name  the entity type XML_xxx_yyy_ENTITY  the entity external ID if available  the entity system ID if available  the entity content 


the entity name NULL if not, othervise the entity 


the document referencing the entity  the entity name A pointer to the entity structure or NULL if not found. 


the document referencing the entity  the entity name A pointer to the entity structure or NULL if not found. 


the document referencing the entity  the entity name A pointer to the entity structure or NULL if not found. 


the document containing the string  A string to convert to XML. A newly allocated string with the substitution done. 


the document containing the string  A string to convert to XML. A newly allocated string with the substitution done. 


the xmlEntitiesTablePtr just created or NULL in case of error. 


An entity table the new xmlEntitiesTablePtr or NULL in case of error. 


An entity table 


An XML buffer.  An entity table 


Name

Synopsis

-#define extern typedef htmlParserCtxtxmlChar *name); +int htmlIsAutoClosed (htmlDocPtr doc, + htmlNodePtr elem); +int htmlAutoCloseTag (htmlDocPtr doc, + const xmlChar *name, + htmlNodePtr elem); htmlEntityDescPtr

Description

Details

extern

#define     extern


htmlParserCtxt

typedef xmlParserCtxt htmlParserCtxt;


htmlParserCtxtPtr

typedef xmlParserCtxtPtr htmlParserCtxtPtr;


htmlParserNodeInfo

typedef xmlParserNodeInfo htmlParserNodeInfo;


htmlSAXHandler

typedef xmlSAXHandler htmlSAXHandler;


htmlSAXHandlerPtr

typedef xmlSAXHandlerPtr htmlSAXHandlerPtr;


htmlParserInput

typedef xmlParserInput htmlParserInput;


htmlParserInputPtr

typedef xmlParserInputPtr htmlParserInputPtr;


htmlDocPtr

typedef xmlDocPtr htmlDocPtr;


htmlNodePtr

typedef xmlNodePtr htmlNodePtr;


The tag name the related htmlElemDescPtr or NULL if not found. 


the entity name the associated htmlEntityDescPtr if found, NULL otherwise. 


htmlIsAutoClosed ()

int         htmlIsAutoClosed                (htmlDocPtr doc,
+                                             htmlNodePtr elem);

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

doc : 
elem : 
Returns : 


htmlAutoCloseTag ()

int         htmlAutoCloseTag                (htmlDocPtr doc,
+                                             const xmlChar *name,
+                                             htmlNodePtr elem);

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.

doc : 
name : 
elem : 
Returns : 


an HTML parser context  location to store the entity name the associated htmlEntityDescPtr if found, or NULL otherwise, -if non-NULL *str will have to be freed by the caller. 


an HTML parser context the value parsed (as an int) 


an HTML parser context 


a pointer to an array of xmlChar  a free form C string describing the HTML document encoding, or NULL  the SAX handler block  if using SAX, this pointer will be provided on callbacks.  the resulting document tree 


a pointer to an array of xmlChar  a free form C string describing the HTML document encoding, or NULL the resulting document tree 


the filename  a free form C string describing the HTML document encoding, or NULL  the SAX handler block  if using SAX, this pointer will be provided on callbacks.  the resulting document tree 


the filename  a free form C string describing the HTML document encoding, or NULL the resulting document tree 

Name

Synopsis

Description

Details

#define HTML_TEXT_NODE		XML_TEXT_NODE
#define HTML_TEXT_NODE

#define HTML_ENTITY_REF_NODE	XML_ENTITY_REF_NODE
#define HTML_ENTITY_REF_NODE

#define HTML_COMMENT_NODE	XML_COMMENT_NODE
#define HTML_COMMENT_NODE

the document  OUT: the memory pointer  OUT: the memory lenght 


the FILE*  the document 


the filename  the document  the number of byte written or -1 in case of failure. 

Name

Synopsis

-#define extern int xmlNanoHTTPFetch

Description

Details

extern

#define     extern


The URL to load  the filename where the content should be saved  if available the Content-Type information will be -returned at that location -1 in case of failure, 0 incase of success. The contentType, -if provided must be freed by the caller 


The URL to load  the HTTP method to use  the input string if any  the Content-Type information IN and OUT  the extra headers 


The URL to load  if available the Content-Type information will be -returned at that location 


the HTTP context the HTTP return code for the request. 


the HTTP context  a buffer  the buffer length the number of byte read. 0 is an indication of an end of connection. --1 indicates a parameter error. 


the HTTP context  the filename where the content should be saved -1 in case of failure, 0 incase of success. 


the HTTP context 

#define XML_DEFAULT_VERSION	"1.0"
#define XML_DEFAULT_VERSION
xmlParserInputPtr

typedef xmlParserInput *xmlParserInputPtr;



xmlParserNodeInfo

typedef _xmlParserNodeInfo xmlParserNodeInfo;


xmlParserNodeInfoSeq

typedef _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;


xmlParserNodeInfoSeqPtr

typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;



xmlParserCtxt

typedef _xmlParserCtxt xmlParserCtxt;


xmlParserCtxtPtr

typedef xmlParserCtxt *xmlParserCtxtPtr;


xmlSAXLocator

typedef _xmlSAXLocator xmlSAXLocator;


xmlSAXLocatorPtr

typedef xmlSAXLocator *xmlSAXLocatorPtr;





























xmlSAXHandlerPtr

typedef xmlSAXHandler *xmlSAXHandlerPtr;








an XML parser input  an indicative size for the lookahead the number of xmlChars read, or -1 in case of error, 0 indicate the -end of this entity 


an XML parser input  an indicative size for the lookahead the number of xmlChars read, or -1 in case of error, 0 indicate the -end of this entity 


the input xmlChar * a new xmlChar * or NULL 


the input xmlChar *  the len of cur a new xmlChar * or NULL 


the xmlChar * array (haystack)  the index of the first char (zero based)  the length of the substring the xmlChar * for the first occurence or NULL. 


the xmlChar * array  the xmlChar to search the xmlChar * for the first occurence or NULL. 


the xmlChar * array (haystack)  the xmlChar to search (needle) the xmlChar * for the first occurence or NULL. 


the first xmlChar *  the second xmlChar * the integer result of the comparison 


the first xmlChar *  the second xmlChar *  the max comparison length the integer result of the comparison 


the xmlChar * array the number of xmlChar contained in the ARRAY. 


the original xmlChar * array  the xmlChar * array added a new xmlChar * containing the concatenated string. 


the original xmlChar * array  the xmlChar * array added  the length of add a new xmlChar * containing the concatenated string. 


a pointer to an array of xmlChar the resulting document tree 


an pointer to a char array  the size of the array the resulting document tree 


the filename the resulting document tree 


int 0 or 1  the last value for 0 for no substitution, 1 for substitution. 


a pointer to an array of xmlChar the resulting document tree 


an pointer to a char array  the size of the array the resulting document tree 


the filename the resulting document tree 


an XML parser context 0, -1 in case of error. the parser context is augmented -as a result of the parsing. 


the SAX handler block  a pointer to an array of xmlChar  work in recovery mode, i.e. tries to read no Well Formed -documents the resulting document tree 


a SAX handler  The user data returned on SAX callbacks  a file name 0 in case of success or a error number otherwise 


a SAX handler  The user data returned on SAX callbacks  an in-memory XML document input  the length of the XML document in bytes 0 in case of success or a error number otherwise 


the SAX handler block  an pointer to a char array  the size of the array  work in recovery mode, i.e. tries to read not Well Formed -documents the resulting document tree 


the SAX handler block  the filename  work in recovery mode, i.e. tries to read no Well Formed -documents the resulting document tree 


a NAME* containing the External ID of the DTD  a NAME* containing the URL to the DTD the resulting xmlDtdPtr or NULL in case of error. 


the SAX handler block  a NAME* containing the External ID of the DTD  a NAME* containing the URL to the DTD the resulting xmlDtdPtr or NULL in case of error. 


an HTML parser context 


an XML parser context 


an XML parser context  a xmlChar * buffer  a file name 




an XML parser context  an XML node within the tree an xmlParserNodeInfo block pointer or NULL 


a node info sequence pointer 


a node info sequence pointer 


a node info sequence pointer  an XML node pointer a long indicating the position of the record 


an XML parser context  a node info sequence pointer 




Name

Synopsis

Description

Details

#define XML_MAX_NAMELEN 1000
#define XML_MAX_NAMELEN



#define SKIPCHARVAL(p) (p)++;
#define SKIPCHARVAL(p)













a pointer to an array of xmlChar the new parser context or NULL 


the filename the new parser context or NULL 


an pointer to a char array  the size of the array the new parser context or NULL 


an XML parser context 


the xmlParserCtxtPtr or NULL 


the parser context  the encoding value (number) 


an XML parser context  an XML entity pointer. 


an XML parser context  an Entity pointer the new input stream or NULL 


an XML parser context  an XML parser input fragment (entity, XML fragment ...). 


an XML parser context the current xmlChar in the parser context 


an xmlParserInputPtr 


an XML parser context  the filename to use as entity the new input stream or NULL in case of error 


an XML parser context  a xmlChar **  the local part, and prefix is updated -to get the Prefix if any. 


an XML parser context the namespace name or NULL 


an XML parser context  a xmlChar **  the local part, and prefix is updated -to get the Prefix if any. 


an XML parser context the namespace name 


an XML parser context the string parser or NULL. 


an XML parser context 


an XML parser context the Name parsed or NULL 


an XML parser context the Name parsed or NULL 


an XML parser context the Nmtoken parsed or NULL 


an XML parser context  if non-NULL store a copy of the original entity value the EntityValue parsed with reference substitued or NULL 


an XML parser context the AttValue parsed or NULL. The value has to be freed by the caller. 


an XML parser context the SystemLiteral parsed or NULL 


an XML parser context the PubidLiteral parsed or NULL. 


an XML parser context  int indicating whether we are within a CDATA section 


an XML parser context  a xmlChar** receiving PubidLiteral  indicate whether we should restrict parsing to only -production [75], see NOTE below the function returns SystemLiteral and in the second -case publicID receives PubidLiteral, is strict is off -it is possible to return NULL and have publicID set. 


an XML parser context 


an XML parser context the PITarget name or NULL 


an XML parser context 


an XML parser context 


an XML parser context 


an XML parser context  Receive a possible fixed default value for the attribute  XML_ATTRIBUTE_NONE, XML_ATTRIBUTE_REQUIRED, XML_ATTRIBUTE_IMPLIED -or XML_ATTRIBUTE_FIXED.  


an XML parser context  the notation attribute tree built while parsing 


an XML parser context  the enumeration attribute tree built while parsing 


an XML parser context  the enumeration tree built while parsing  XML_ATTRIBUTE_ENUMERATION or XML_ATTRIBUTE_NOTATION 


an XML parser context  the enumeration tree built while parsing the attribute type 


an XML parser context 


an XML parser context  the list of the xmlElementContentPtr describing the element choices 


an XML parser context  the tree of xmlElementContentPtr describing the element -hierarchy. 


an XML parser context  the name of the element being defined.  the Element Content pointer will be stored here if any  the type of element content XML_ELEMENT_TYPE_xxx 


an XML parser context the type of the element, or -1 in case of error 


an XML parser context 


an XML parser context the value parsed (as an int), 0 in case of error 


an XML parser context the xmlEntityPtr if found, or NULL otherwise. 


an XML parser context 


an XML parser context 


an XML parser context 


an XML parser context  a xmlChar ** used to store the value of the attribute the attribute name, and the value in *value. 


an XML parser context 

an XML parser context  the tag name as parsed in the opening tag. 


an XML parser context 


an XML parser context 


an XML parser context 


an XML parser context the string giving the XML version number, or NULL 


an XML parser context the version string, e.g. "1.0" 


an XML parser context the encoding name value or NULL 


an XML parser context the encoding value or NULL 


an XML parser context 1 if standalone, 0 otherwise 


an XML parser context 


an XML parser context 


an XML parser context  the external identifier  the system identifier (or URL) 


#define XML_SUBSTITUTE_NONE	0
#define XML_SUBSTITUTE_NONE

#define XML_SUBSTITUTE_REF	1
#define XML_SUBSTITUTE_REF

#define XML_SUBSTITUTE_PEREF	2
#define XML_SUBSTITUTE_PEREF

#define XML_SUBSTITUTE_BOTH 	3
#define XML_SUBSTITUTE_BOTH

the parser context  the len to decode (in bytes !), -1 for no size limit  combination of XML_SUBSTITUTE_REF and XML_SUBSTITUTE_PEREF  an end marker xmlChar, 0 if none  an end marker xmlChar, 0 if none  an end marker xmlChar, 0 if none A newly allocated string with the substitution done. The caller -must deallocate it ! 





Name

Synopsis

xmlNodePtr xmlDocSetRootElement (xmlDocPtr doc, + xmlNodePtr root); +void xmlNodeSetName (xmlNodePtr cur, + const xmlChar *name); +xmlNodePtr xmlAddChild (xmlNodePtr xmlReplaceNode (xmlNodePtr old, + xmlNodePtr cur); +xmlNodePtr xmlAddSibling (xmlNodePtr elem); +xmlNodePtr xmlAddPrevSibling (xmlNodePtr cur, + xmlNodePtr elem); +xmlNodePtr xmlAddNextSibling (xmlNodePtr cur, + xmlNodePtr elem); void xmlUnlinkNode

Description

Details



#define CHAR xmlChar
#define CHAR

#define BAD_CAST (xmlChar *)
#define BAD_CAST

xmlNotationPtr

typedef xmlNotation *xmlNotationPtr;




xmlEnumerationPtr

typedef xmlEnumeration *xmlEnumerationPtr;


xmlAttributePtr

typedef xmlAttribute *xmlAttributePtr;




xmlElementContentPtr

typedef xmlElementContent *xmlElementContentPtr;



xmlElementPtr

typedef xmlElement *xmlElementPtr;



xmlNsPtr

typedef xmlNs *xmlNsPtr;


xmlDtdPtr

typedef xmlDtd *xmlDtdPtr;


xmlAttrPtr

typedef xmlAttr *xmlAttrPtr;

xmlIDPtr

typedef xmlID *xmlIDPtr;
xmlAttrPtr


xmlIDPtr


xmlRefPtr

typedef xmlRef *xmlRefPtr;



xmlBuffer

typedef _xmlBuffer xmlBuffer;


xmlBufferPtr

typedef xmlBuffer *xmlBufferPtr;

xmlNode

typedef _xmlNode xmlNode;


xmlNodePtr

typedef _xmlNode *xmlNodePtr;


xmlDoc

typedef _xmlDoc xmlDoc;


xmlDocPtr

typedef xmlDoc *xmlDocPtr;






the new structure. 


initial size of buffer the new structure. 


the buffer to free 


the file output  the buffer to dump the number of xmlChar written 


the buffer to dump  the xmlChar string  the number of xmlChar to add 


the buffer to dump  the xmlChar string 


the buffer to dump  the C char string 


the buffer to dump  the number of xmlChar to remove the number of xmlChar removed, or -1 in case of failure. 


the buffer 


the buffer to resize the internal content 




the buffer  the length of data in the internal content 


the document pointer  the DTD name  the external ID  the system ID a pointer to the new DTD structure 


the document pointer  the DTD name  the external ID  the system ID a pointer to the new DTD structure 


the DTD structure to free up 


the document carrying the namespace  the URI associated  the prefix for the namespace returns a new namespace pointer 


the element carrying the namespace  the URI associated  the prefix for the namespace returns a new namespace pointer 


the namespace pointer 


xmlChar string giving the version of XML "1.0" a new document 


pointer to the document -@:  


the document  the name of the attribute  the value of the attribute a pointer to the attribute 


the holding node  the name of the attribute  the value of the attribute a pointer to the attribute 


the holding node  the namespace  the name of the attribute  the value of the attribute a pointer to the attribute 


the first property in the list 


the first property in the list 


the element where the attribute will be grafted  the attribute  a new xmlAttrPtr, or NULL in case of error. 


the element where the attributes will be grafted  the first attribute  a new xmlAttrPtr, or NULL in case of error. 


the dtd  a new xmlDtdPtr, or NULL in case of error. 


the document  if 1 do a recursive copy.  a new xmlDocPtr, or NULL in case of error. 


the document  namespace if any  the node name  the XML text content if any a pointer to the new node object. 


the document  namespace if any  the node name  the text content if any a pointer to the new node object. 


namespace if any  the node name a pointer to the new node object. 


the parent node  a namespace if any  the name of the child  the XML content of the child if any. a pointer to the new node object. 


the parent node  a namespace if any  the name of the child  the text content of the child if any. a pointer to the new node object. 


the document  the text content a pointer to the new node object. 


the text content a pointer to the new node object. 


the processing instruction name  the PI content a pointer to the new node object. 


the document  the text content  the text len. a pointer to the new node object. 


the text content  the text len. a pointer to the new node object. 


the document  the comment content a pointer to the new node object. 


the comment content a pointer to the new node object. 


the document  the CData block content content  the length of the block a pointer to the new node object. 


the document  the reference name, or the reference string with & and ; a pointer to the new node object. 


the node  if 1 do a recursive copy.  a new xmlNodePtr, or NULL in case of error. 


the first node in the list.  a new xmlNodePtr, or NULL in case of error. 


the document the xmlNodePtr for the root or NULL 


the parent node the last child or NULL if none. 


the node 1 yes, 0 no 


xmlDocSetRootElement ()

xmlNodePtr  xmlDocSetRootElement            (xmlDocPtr doc,
+                                             xmlNodePtr root);

Set the root element of the document (doc->root is a list +containing possibly comments, PIs, etc ...).

doc : 
root : 
Returns : 


xmlNodeSetName ()

void        xmlNodeSetName                  (xmlNodePtr cur,
+                                             const xmlChar *name);

Searches the language of a node, i.e. the values of the xml:lang +attribute or the one carried by the nearest ancestor.

cur : 
name : 


the parent node  the child node the child or NULL in case of error. 


xmlReplaceNode ()

xmlNodePtr  xmlReplaceNode                  (xmlNodePtr old,
+                                             xmlNodePtr cur);

Unlink the old node from it's current context, prune the new one +at the same place. If cur was already inserted in a document it is +first unlinked from its existing context.

old : 
cur : 
Returns : 


Add a new element to the list of siblings of Add a new element elem to the list of siblings of cur

+If the new element was already inserted in a document it is +first unlinked from its existing context.

the child node  the new node the element or NULL in case of error. 


xmlAddPrevSibling ()

xmlNodePtr  xmlAddPrevSibling               (xmlNodePtr cur,
+                                             xmlNodePtr elem);

Add a new element elem as the previous siblings of cur +If the new element was already inserted in a document it is +first unlinked from its existing context.

cur : 
elem : 
Returns : 


xmlAddNextSibling ()

xmlNodePtr  xmlAddNextSibling               (xmlNodePtr cur,
+                                             xmlNodePtr elem);

Add a new element elem as the next siblings of cur +If the new element was already inserted in a document it is +first unlinked from its existing context.

cur : 
elem : 
Returns : 


the node 


the first text node  the second text node being merged the first text node augmented 


the node  the content  content lenght 


the first node in the list 


the node 


the document  the current node  the namespace string the namespace pointer or NULL. 


the document  the current node  the namespace value the namespace pointer or NULL. 


the document  the current node an NULL terminated array of all the xmlNsPtr found -that need to be freed by the caller or NULL if no -namespace if defined 


a node in the document  a namespace pointer 


the namespace  a new xmlNsPtr, or NULL in case of error. 


the first namespace  a new xmlNsPtr, or NULL in case of error. 


the node  the attribute name  the attribute value the attribute pointer. 


the node  the attribute name the attribute value or NULL if not found. -It's up to the caller to free the memory. 


the node  the attribute name  the URI of the namespace the attribute value or NULL if not found. -It's up to the caller to free the memory. 


the document  the value of the attribute a pointer to the first child 


the document  the value of the text  the length of the string value a pointer to the first child 


the document  a Node list  should we replace entity contents or show their external form a pointer to the string copy, the calller must free it. 


the node being modified  the new value of the content 


the node being modified  the new value of the content  the size of content 


the node being modified  extra content 


the node being modified  extra content  the size of content 


the node being read a new xmlChar * or NULL if no content is available. -It's up to the caller to free the memory. 


the node being checked a pointer to the lang value, or NULL if not found -It's up to the caller to free the memory. 


Searches the language of a node, i.e. the values of the xml:lang -attribute or the one carried by the nearest ancestor.

Set the language of a node, i.e. the values of the xml:lang +attribute.

the node being changed  the langage description 


the document the node pertains to  the node being checked a pointer to the base URL, or NULL if not found -It's up to the caller to free the memory. 




the XML buffer  the string to add 


the XML buffer output  the string to add 


the XML buffer output  the string to add 


the document  OUT: the memory pointer  OUT: the memory lenght 


the FILE*  the document 


the filename  the document  the number of file written or -1 in case of failure. 


the document 0 (uncompressed) to 9 (max compression) 


the document  the compression ratio 


0 (uncompressed) to 9 (max compression) 


the compression ratio 

Name

Synopsis

Description

Details



#define XML_MIN_NOTATION_TABLE	32
#define XML_MIN_NOTATION_TABLE

xmlNotationTablePtr

typedef xmlNotationTable *xmlNotationTablePtr;


#define XML_MIN_ELEMENT_TABLE	32
#define XML_MIN_ELEMENT_TABLE

xmlElementTablePtr

typedef xmlElementTable *xmlElementTablePtr;


#define XML_MIN_ATTRIBUTE_TABLE	32
#define XML_MIN_ATTRIBUTE_TABLE

xmlAttributeTablePtr

typedef xmlAttributeTable *xmlAttributeTablePtr;


#define XML_MIN_ID_TABLE	32
#define XML_MIN_ID_TABLE

xmlIDTablePtr

typedef xmlIDTable *xmlIDTablePtr;


#define XML_MIN_REF_TABLE	32
#define XML_MIN_REF_TABLE

xmlRefTablePtr

typedef xmlRefTable *xmlRefTablePtr;


the validation context  pointer to the DTD  the entity name  the public identifier or NULL  the system identifier or NULL NULL if not, othervise the entity 


A notation table the new xmlNotationTablePtr or NULL in case of error. 


An notation table 


the XML buffer output  A notation table 


the subelement name or NULL  the type of element content decl NULL if not, othervise the new element content structure 


An element content pointer. the new xmlElementContentPtr or NULL in case of error. 


the element content tree to free 


the validation context  pointer to the DTD  the entity name  the element type  the element content tree or NULL NULL if not, othervise the entity 


An element table the new xmlElementTablePtr or NULL in case of error. 


An element table 


the XML buffer output  An element table 


the enumeration name or NULL the xmlEnumerationPtr just created or NULL in case -of error. 


the tree to free. 


the tree to copy. the xmlEnumerationPtr just created or NULL in case -of error. 


the validation context  pointer to the DTD  the element name  the attribute name  the attribute type  the attribute default type  the attribute default value  if it's an enumeration, the associated list NULL if not, othervise the entity 


An attribute table the new xmlAttributeTablePtr or NULL in case of error. 


An attribute table 


the XML buffer output  An attribute table 


the validation context  pointer to the document  the value name  the attribute holding the ID NULL if not, othervise the new xmlIDPtr 



An id table 


pointer to the document  the ID value NULL if not found, otherwise the xmlAttrPtr defining the ID 


the document  the element carrying the attribute  the attribute 0 or 1 depending on the lookup result 


the validation context  pointer to the document  the value name  the attribute holding the Ref NULL if not, othervise the new xmlRefPtr 



An ref table 


the document  the element carrying the attribute  the attribute 0 or 1 depending on the lookup result 


the validation context  a document instance 1 if valid or 0 otherwise 


the validation context  a document instance  an element definition 1 if valid or 0 otherwise 


the validation context  a document instance  an attribute definition 1 if valid or 0 otherwise 


an attribute type  an attribute value 1 if valid or 0 otherwise 


the validation context  a document instance  a notation definition 1 if valid or 0 otherwise 


the validation context  a document instance  a dtd instance 1 if valid or 0 otherwise 


the validation context  a document instance 1 if valid or 0 otherwise 


the validation context  a document instance  an element instance 1 if valid or 0 otherwise 


the validation context  a document instance  an element instance 1 if valid or 0 otherwise 


the validation context  a document instance  an element instance  an attribute instance  the attribute value (without entities processing) 1 if valid or 0 otherwise 


the validation context  a document instance 1 if valid or 0 otherwise 


the validation context  the document  the notation name to check 1 if valid or 0 otherwise 


the document  the element name 0 if no, 1 if yes, and -1 if no element description is available 


a pointer to the DtD to search  the element name  the attribute name the xmlAttributePtr if found or NULL 


a pointer to the DtD to search  the notation name the xmlNotationPtr if found or NULL 


a pointer to the DtD to search  the element name the xmlElementPtr if found or NULL 


an element to insert after  an element to insert next  an array to store the list of child names  the size of the array the number of element in the list, or -1 in case of error. If -the function returns the value max the caller is invited to grow the -receiving array and retry. 


an element content tree  an array to store the list of child names  a pointer to the number of element in the list  the size of the array the number of element in the list, or -1 in case of error. 

Name

Synopsis

-#define extern enum xmlParserErrors

Description

Details

extern

#define     extern



an XML parser context  the message to display/transmit  extra parameters for the message display 


an XML parser context  the message to display/transmit  extra parameters for the message display 


an XML parser context  the message to display/transmit  extra parameters for the message display 


an XML parser context  the message to display/transmit  extra parameters for the message display 


an xmlParserInputPtr input 


an xmlParserInputPtr input 

Name

Synopsis

Description

Details

#define NO_DEBUG_MEMORY
#define NO_DEBUG_MEMORY




a pointer to the new string or NULL if allocation error occured. 


0 on success 


an int representing the amount of memory allocated. 



a FILE descriptor used as the output file, if NULL, the result is - 8 written to the file .memorylist 


#define DEBUG_MEMORY_LOCATION
#define DEBUG_MEMORY_LOCATION

#define DEBUG_MEMORY
#define DEBUG_MEMORY

#define MEM_LIST /* keep a list of all the allocated memory blocks */
#define MEM_LIST

an int specifying the size in byte to allocate.  the file name or NULL - file: the line number 

the initial memory block pointer  an int specifying the size in byte to allocate.  the file name or NULL the line number

the file name or NULL the line numbera pointer to the new string or NULL if allocation error occured. 

Name

Synopsis

-#define extern #define XPATH_UNDEFINED

Description

Details

extern

#define     extern


#define XPATH_UNDEFINED	0
#define XPATH_UNDEFINED

#define XPATH_NODESET	1
#define XPATH_NODESET

#define XPATH_BOOLEAN	2
#define XPATH_BOOLEAN

#define XPATH_NUMBER	3
#define XPATH_NUMBER

#define XPATH_STRING	4
#define XPATH_STRING

#define XPATH_USERS	5
#define XPATH_USERS





the XML document the xmlXPathContext just allocated. 


the context to free 


the XPath expression  the XPath context the xmlXPathObjectPtr resulting from the eveluation or NULL. -the caller has to free the object. 


the object to free 


the XPath expression  the XPath context the xmlXPathObjectPtr resulting from the evaluation or NULL. -the caller has to free the object. 

+ + + + + @@ -324,7 +329,6 @@ - @@ -333,7 +337,6 @@ - @@ -345,6 +348,8 @@ + + @@ -360,7 +365,6 @@ - @@ -377,7 +381,6 @@ - @@ -496,7 +499,6 @@ - diff --git a/doc/xml.html b/doc/xml.html index 819585e1..40d6e0c3 100644 --- a/doc/xml.html +++ b/doc/xml.html @@ -128,8 +128,17 @@ for really accurate description

  • working on HTML and XML links recognition layers, get in touch with me if you want to test those.
  • +
+ +

1.8.2: Dec 21 1999

+

1.8.1: Dec 18 1999

@@ -420,7 +429,7 @@ beginning of the second attribute of the root element "EXAMPLE".

NOTE: XML allows PIs and comments to be present before the document root, so doc->root may point to an element which is not the document Root Element, a function -xmlDocGetRootElement() was added for this purpose.

+xmlDocGetRootElement() was added for this purpose.

Modifying the tree

@@ -892,6 +901,6 @@ base under gnome-xml/example

Daniel Veillard

-

$Id: xml.html,v 1.15 1999/12/18 15:32:46 veillard Exp $

+

$Id: xml.html,v 1.16 1997/01/04 02:49:42 veillard Exp $

diff --git a/include/libxml/HTMLparser.h b/include/libxml/HTMLparser.h index eed7924b..a90b217a 100644 --- a/include/libxml/HTMLparser.h +++ b/include/libxml/HTMLparser.h @@ -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 } diff --git a/include/libxml/debugXML.h b/include/libxml/debugXML.h index 5bec396f..9c77496e 100644 --- a/include/libxml/debugXML.h +++ b/include/libxml/debugXML.h @@ -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); diff --git a/include/libxml/nanohttp.h b/include/libxml/nanohttp.h index 7b2fd3d8..aeefe405 100644 --- a/include/libxml/nanohttp.h +++ b/include/libxml/nanohttp.h @@ -9,7 +9,7 @@ #ifndef __NANO_HTTP_H__ #define __NANO_HTTP_H__ #ifdef __cplusplus -#define extern "C" { +extern "C" { #endif int xmlNanoHTTPFetch (const char *URL, const char *filename, diff --git a/include/libxml/tree.h b/include/libxml/tree.h index 9928089a..3a0285bc 100644 --- a/include/libxml/tree.h +++ b/include/libxml/tree.h @@ -427,10 +427,20 @@ int xmlNodeIsText (xmlNodePtr node); /* * Changing the structure */ +xmlNodePtr xmlDocSetRootElement (xmlDocPtr doc, + xmlNodePtr root); +void xmlNodeSetName (xmlNodePtr cur, + const xmlChar *name); xmlNodePtr xmlAddChild (xmlNodePtr parent, xmlNodePtr cur); +xmlNodePtr xmlReplaceNode (xmlNodePtr old, + xmlNodePtr cur); xmlNodePtr xmlAddSibling (xmlNodePtr cur, xmlNodePtr elem); +xmlNodePtr xmlAddPrevSibling (xmlNodePtr cur, + xmlNodePtr elem); +xmlNodePtr xmlAddNextSibling (xmlNodePtr cur, + xmlNodePtr elem); void xmlUnlinkNode (xmlNodePtr cur); xmlNodePtr xmlTextMerge (xmlNodePtr first, xmlNodePtr second); diff --git a/include/libxml/xmlmemory.h b/include/libxml/xmlmemory.h index d28b526c..5c1b4774 100644 --- a/include/libxml/xmlmemory.h +++ b/include/libxml/xmlmemory.h @@ -40,6 +40,9 @@ #define MEM_LIST /* keep a list of all the allocated memory blocks */ +#ifdef __cplusplus +extern "C" { +#endif int xmlInitMemory (void); void * xmlMalloc (int size); void * xmlRealloc (void *ptr, @@ -59,6 +62,9 @@ int xmlInitMemory (void); extern void * xmlMallocLoc(int size, const char *file, int line); extern void * xmlReallocLoc(void *ptr,int size, const char *file, int line); extern char * xmlMemStrdupLoc(const char *str, const char *file, int line); +#ifdef __cplusplus +} +#endif #endif /* DEBUG_MEMORY_LOCATION */ #endif /* ! NO_DEBUG_MEMORY */ diff --git a/include/libxml/xpath.h b/include/libxml/xpath.h index 505fa845..149b0beb 100644 --- a/include/libxml/xpath.h +++ b/include/libxml/xpath.h @@ -15,7 +15,7 @@ #include "tree.h" #ifdef __cplusplus -#define extern "C" { +extern "C" { #endif typedef struct xmlXPathParserContext *xmlXPathParserContextPtr; diff --git a/nanohttp.h b/nanohttp.h index 7b2fd3d8..aeefe405 100644 --- a/nanohttp.h +++ b/nanohttp.h @@ -9,7 +9,7 @@ #ifndef __NANO_HTTP_H__ #define __NANO_HTTP_H__ #ifdef __cplusplus -#define extern "C" { +extern "C" { #endif int xmlNanoHTTPFetch (const char *URL, const char *filename, diff --git a/result/HTML/reg1.html b/result/HTML/reg1.html index 176d01f1..2cd9257f 100644 --- a/result/HTML/reg1.html +++ b/result/HTML/reg1.html @@ -1,4 +1,4 @@ - + Regression test 1 diff --git a/result/HTML/reg2.html b/result/HTML/reg2.html index fff29f44..4e4d59a5 100644 --- a/result/HTML/reg2.html +++ b/result/HTML/reg2.html @@ -1,4 +1,4 @@ - + Regression test 2 diff --git a/result/HTML/reg3.html b/result/HTML/reg3.html index f631634d..01cd943f 100644 --- a/result/HTML/reg3.html +++ b/result/HTML/reg3.html @@ -1,4 +1,4 @@ - + Regression test 3 diff --git a/result/HTML/reg4.html b/result/HTML/reg4.html index e17bca9a..0dcf3f03 100644 --- a/result/HTML/reg4.html +++ b/result/HTML/reg4.html @@ -1,4 +1,4 @@ - + Regression test 4 diff --git a/result/HTML/test3.html b/result/HTML/test3.html index 7f730c5f..ad979574 100644 --- a/result/HTML/test3.html +++ b/result/HTML/test3.html @@ -1,4 +1,4 @@ - +

Component Package diagram ProblemDomain

diff --git a/result/HTML/wired.html b/result/HTML/wired.html index 05bc16d3..e8614509 100644 --- a/result/HTML/wired.html +++ b/result/HTML/wired.html @@ -1,4 +1,4 @@ - + Top Stories News from Wired News @@ -65,7 +65,7 @@ - + True to the Original @@ -100,7 +100,7 @@ - + WIRED MAGAZINE @@ -583,7 +583,7 @@ Contruction workers in Berlin opened an old wound in the German psyche this week

- + diff --git a/test/HTML/Down.html b/test/HTML/Down.html index 0f366479..92eca21b 100644 --- a/test/HTML/Down.html +++ b/test/HTML/Down.html @@ -1,5 +1,3 @@ - This service is temporary down diff --git a/tree.c b/tree.c index 86dd6b34..83bed92b 100644 --- a/tree.c +++ b/tree.c @@ -1577,13 +1577,86 @@ xmlNewChild(xmlNodePtr parent, xmlNsPtr ns, return(cur); } +/** + * xmlAddNextSibling: + * @cur: the child node + * @elem: the new node + * + * Add a new element @elem as the next siblings of @cur + * If the new element was already inserted in a document it is + * first unlinked from its existing context. + * + * Returns the new element or NULL in case of error. + */ +xmlNodePtr +xmlAddNextSibling(xmlNodePtr cur, xmlNodePtr elem) { + if (cur == NULL) { + fprintf(stderr, "xmlAddNextSibling : cur == NULL\n"); + return(NULL); + } + if (elem == NULL) { + fprintf(stderr, "xmlAddNextSibling : elem == NULL\n"); + return(NULL); + } + + xmlUnlinkNode(elem); + elem->doc = cur->doc; + elem->parent = cur->parent; + elem->next = cur; + elem->prev = cur->prev; + cur->prev = elem; + if (elem->prev != NULL) + elem->prev->next = elem; + if ((elem->parent != NULL) && (elem->parent->childs == cur)) + elem->parent->childs = elem; + return(elem); +} + +/** + * xmlAddPrevSibling: + * @cur: the child node + * @elem: the new node + * + * Add a new element @elem as the previous siblings of @cur + * If the new element was already inserted in a document it is + * first unlinked from its existing context. + * + * Returns the new element or NULL in case of error. + */ +xmlNodePtr +xmlAddPrevSibling(xmlNodePtr cur, xmlNodePtr elem) { + if (cur == NULL) { + fprintf(stderr, "xmlAddPrevSibling : cur == NULL\n"); + return(NULL); + } + if (elem == NULL) { + fprintf(stderr, "xmlAddPrevSibling : elem == NULL\n"); + return(NULL); + } + + xmlUnlinkNode(elem); + elem->doc = cur->doc; + elem->parent = cur->parent; + elem->prev = cur; + elem->next = cur->next; + cur->next = elem; + if (elem->next != NULL) + elem->next->prev = elem; + if ((elem->parent != NULL) && (elem->parent->last == cur)) + elem->parent->last = elem; + return(elem); +} + /** * xmlAddSibling: * @cur: the child node * @elem: the new node * - * Add a new element to the list of siblings of @cur - * Returns the element or NULL in case of error. + * Add a new element @elem to the list of siblings of @cur + * If the new element was already inserted in a document it is + * first unlinked from its existing context. + * + * Returns the new element or NULL in case of error. */ xmlNodePtr xmlAddSibling(xmlNodePtr cur, xmlNodePtr elem) { @@ -1599,14 +1672,20 @@ xmlAddSibling(xmlNodePtr cur, xmlNodePtr elem) { return(NULL); } - if ((cur->doc != NULL) && (elem->doc != NULL) && - (cur->doc != elem->doc)) { - fprintf(stderr, - "xmlAddSibling: Elements moved to a different document\n"); + /* + * Constant time is we can rely on the ->parent->last to find + * the last sibling. + */ + if ((cur->parent != NULL) && + (cur->parent->childs != NULL) && + (cur->parent->last != NULL) && + (cur->parent->last->next == NULL)) { + cur = cur->parent->last; + } else { + while (cur->next != NULL) cur = cur->next; } - while (cur->next != NULL) cur = cur->next; - + xmlUnlinkNode(elem); if (elem->doc == NULL) elem->doc = cur->doc; /* the parent may not be linked to a doc ! */ @@ -1784,6 +1863,47 @@ xmlUnlinkNode(xmlNodePtr cur) { cur->parent = NULL; } +/** + * xmlReplaceNode: + * @old: the old node + * @cur: the node + * + * Unlink the old node from it's current context, prune the new one + * at the same place. If cur was already inserted in a document it is + * first unlinked from its existing context. + * + * Returns the old node + */ +xmlNodePtr +xmlReplaceNode(xmlNodePtr old, xmlNodePtr cur) { + if (old == NULL) { + fprintf(stderr, "xmlReplaceNode : old == NULL\n"); + return(NULL); + } + if (cur == NULL) { + xmlUnlinkNode(old); + return(old); + } + xmlUnlinkNode(cur); + cur->doc = old->doc; + cur->parent = old->parent; + cur->next = old->next; + if (cur->next != NULL) + cur->next->prev = cur; + cur->prev = old->prev; + if (cur->prev != NULL) + cur->prev->next = cur; + if (cur->parent != NULL) { + if (cur->parent->childs == old) + cur->parent->childs = cur; + if (cur->parent->last == old) + cur->parent->last = cur; + } + old->next = old->prev = NULL; + old->parent = NULL; + return(old); +} + /************************************************************************ * * * Copy operations * @@ -2179,17 +2299,67 @@ xmlDocGetRootElement(xmlDocPtr doc) { return(ret); } +/** + * xmlDocSetRootElement: + * @doc: the document + * @root: the new document root element + * + * Set the root element of the document (doc->root is a list + * containing possibly comments, PIs, etc ...). + * + * Returns the old root element if any was found + */ +xmlNodePtr +xmlDocSetRootElement(xmlDocPtr doc, xmlNodePtr root) { + xmlNodePtr old = NULL; + + if (doc == NULL) return(NULL); + old = doc->root; + while (old != NULL) { + if (old->type == XML_ELEMENT_NODE) + break; + old = old->next; + } + if (old == NULL) { + if (doc->root == NULL) { + doc->root = root; + } else { + xmlAddSibling(doc->root, root); + } + } else { + xmlReplaceNode(old, root); + } + return(old); +} + /** * xmlNodeSetLang: * @cur: the node being changed * @lang: the langage description * - * Searches the language of a node, i.e. the values of the xml:lang - * attribute or the one carried by the nearest ancestor. + * Set the language of a node, i.e. the values of the xml:lang + * attribute. */ void xmlNodeSetLang(xmlNodePtr cur, const xmlChar *lang) { - /* TODO xmlNodeSetLang check against the production [33] LanguageID */ + if (cur == NULL) return; + switch(cur->type) { + case XML_TEXT_NODE: + case XML_CDATA_SECTION_NODE: + case XML_COMMENT_NODE: + case XML_DOCUMENT_NODE: + case XML_DOCUMENT_TYPE_NODE: + case XML_DOCUMENT_FRAG_NODE: + case XML_NOTATION_NODE: + case XML_HTML_DOCUMENT_NODE: + return; + case XML_ELEMENT_NODE: + case XML_ATTRIBUTE_NODE: + case XML_PI_NODE: + case XML_ENTITY_REF_NODE: + case XML_ENTITY_NODE: + break; + } xmlSetProp(cur, BAD_CAST "xml:lang", lang); } @@ -2216,6 +2386,39 @@ xmlNodeGetLang(xmlNodePtr cur) { return(NULL); } +/** + * xmlNodeSetName: + * @cur: the node being changed + * @name: the new tag name + * + * Searches the language of a node, i.e. the values of the xml:lang + * attribute or the one carried by the nearest ancestor. + */ +void +xmlNodeSetName(xmlNodePtr cur, const xmlChar *name) { + if (cur == NULL) return; + if (name == NULL) return; + switch(cur->type) { + case XML_TEXT_NODE: + case XML_CDATA_SECTION_NODE: + case XML_COMMENT_NODE: + case XML_DOCUMENT_NODE: + case XML_DOCUMENT_TYPE_NODE: + case XML_DOCUMENT_FRAG_NODE: + case XML_NOTATION_NODE: + case XML_HTML_DOCUMENT_NODE: + return; + case XML_ELEMENT_NODE: + case XML_ATTRIBUTE_NODE: + case XML_PI_NODE: + case XML_ENTITY_REF_NODE: + case XML_ENTITY_NODE: + break; + } + if (cur->name != NULL) xmlFree((xmlChar *) cur->name); + cur->name = xmlStrdup(name); +} + /** * xmlNodeGetBase: * @doc: the document the node pertains to @@ -2787,8 +2990,17 @@ xmlGetNsProp(xmlNodePtr node, const xmlChar *name, const xmlChar *namespace) { if (namespace == NULL) return(xmlGetProp(node, name)); while (prop != NULL) { + /* + * One need to have + * - same attribute names + * - and the attribute carrying that namespace + * or + * no namespace on the attribute and the element carrying it + */ if ((!xmlStrcmp(prop->name, name)) && - (prop->ns != NULL) && (!xmlStrcmp(prop->ns->href, namespace))) { + (((prop->ns == NULL) && (node->ns != NULL) && + (!xmlStrcmp(node->ns->href, namespace))) || + (prop->ns != NULL) && (!xmlStrcmp(prop->ns->href, namespace)))) { xmlChar *ret; ret = xmlNodeListGetString(node->doc, prop->val, 1); diff --git a/tree.h b/tree.h index 9928089a..3a0285bc 100644 --- a/tree.h +++ b/tree.h @@ -427,10 +427,20 @@ int xmlNodeIsText (xmlNodePtr node); /* * Changing the structure */ +xmlNodePtr xmlDocSetRootElement (xmlDocPtr doc, + xmlNodePtr root); +void xmlNodeSetName (xmlNodePtr cur, + const xmlChar *name); xmlNodePtr xmlAddChild (xmlNodePtr parent, xmlNodePtr cur); +xmlNodePtr xmlReplaceNode (xmlNodePtr old, + xmlNodePtr cur); xmlNodePtr xmlAddSibling (xmlNodePtr cur, xmlNodePtr elem); +xmlNodePtr xmlAddPrevSibling (xmlNodePtr cur, + xmlNodePtr elem); +xmlNodePtr xmlAddNextSibling (xmlNodePtr cur, + xmlNodePtr elem); void xmlUnlinkNode (xmlNodePtr cur); xmlNodePtr xmlTextMerge (xmlNodePtr first, xmlNodePtr second); diff --git a/xml-error.h b/xml-error.h index 169166fd..d7e09f47 100644 --- a/xml-error.h +++ b/xml-error.h @@ -3,7 +3,7 @@ #include "parser.h" #ifdef __cplusplus -#define extern "C" { +extern "C" { #endif typedef enum { diff --git a/xmlmemory.h b/xmlmemory.h index d28b526c..5c1b4774 100644 --- a/xmlmemory.h +++ b/xmlmemory.h @@ -40,6 +40,9 @@ #define MEM_LIST /* keep a list of all the allocated memory blocks */ +#ifdef __cplusplus +extern "C" { +#endif int xmlInitMemory (void); void * xmlMalloc (int size); void * xmlRealloc (void *ptr, @@ -59,6 +62,9 @@ int xmlInitMemory (void); extern void * xmlMallocLoc(int size, const char *file, int line); extern void * xmlReallocLoc(void *ptr,int size, const char *file, int line); extern char * xmlMemStrdupLoc(const char *str, const char *file, int line); +#ifdef __cplusplus +} +#endif #endif /* DEBUG_MEMORY_LOCATION */ #endif /* ! NO_DEBUG_MEMORY */ diff --git a/xpath.h b/xpath.h index 505fa845..149b0beb 100644 --- a/xpath.h +++ b/xpath.h @@ -15,7 +15,7 @@ #include "tree.h" #ifdef __cplusplus -#define extern "C" { +extern "C" { #endif typedef struct xmlXPathParserContext *xmlXPathParserContextPtr;