mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-30 22:43:14 +03:00
Added debugging code, a bit of parser cleanup, Daniel
This commit is contained in:
@ -1,3 +1,10 @@
|
|||||||
|
Tue Oct 27 17:54:00 EST 1998 Daniel Veillard <Daniel.Veillard@w3.org>
|
||||||
|
|
||||||
|
* debugXML.h debugXML.c: added debugging utilities.
|
||||||
|
* tester.c: added --debug switch.
|
||||||
|
* tree.c: patched an incorrect node->type assignment.
|
||||||
|
* parser.c: formatting, ensure that node->doc != NULL in attributes
|
||||||
|
|
||||||
Tue Oct 27 01:15:39 EST 1998 Daniel Veillard <Daniel.Veillard@w3.org>
|
Tue Oct 27 01:15:39 EST 1998 Daniel Veillard <Daniel.Veillard@w3.org>
|
||||||
|
|
||||||
* parser.[ch] SAX.c tree.[ch]: large amount of changes to improve
|
* parser.[ch] SAX.c tree.[ch]: large amount of changes to improve
|
||||||
|
@ -16,6 +16,7 @@ libxml_la_SOURCES = \
|
|||||||
error.h \
|
error.h \
|
||||||
parser.c \
|
parser.c \
|
||||||
tester.c \
|
tester.c \
|
||||||
|
debugXML.c \
|
||||||
tree.c
|
tree.c
|
||||||
|
|
||||||
xmlincdir = $(includedir)/gnome-xml
|
xmlincdir = $(includedir)/gnome-xml
|
||||||
@ -23,6 +24,7 @@ xmlinc_HEADERS = \
|
|||||||
entities.h \
|
entities.h \
|
||||||
encoding.h \
|
encoding.h \
|
||||||
parser.h \
|
parser.h \
|
||||||
|
debugXML.h \
|
||||||
tree.h
|
tree.h
|
||||||
|
|
||||||
DEPS = $(top_builddir)/libxml.la
|
DEPS = $(top_builddir)/libxml.la
|
||||||
|
268
debugXML.c
Normal file
268
debugXML.c
Normal file
@ -0,0 +1,268 @@
|
|||||||
|
/*
|
||||||
|
* debugXML.c : This is a set of routines used for debugging the tree
|
||||||
|
* produced by the XML parser.
|
||||||
|
*
|
||||||
|
* Daniel Veillard <Daniel.Veillard@w3.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "tree.h"
|
||||||
|
#include "parser.h"
|
||||||
|
#include "debugXML.h"
|
||||||
|
|
||||||
|
#define IS_BLANK(c) \
|
||||||
|
(((c) == '\n') || ((c) == '\r') || ((c) == '\t') || ((c) == ' '))
|
||||||
|
|
||||||
|
void xmlDebugDumpString(FILE *output, const CHAR *str) {
|
||||||
|
int i;
|
||||||
|
for (i = 0;i < 40;i++)
|
||||||
|
if (str[i] == 0) return;
|
||||||
|
else if (IS_BLANK(str[i])) fputc(' ', output);
|
||||||
|
else fputc(str[i], output);
|
||||||
|
fprintf(output, "...");
|
||||||
|
}
|
||||||
|
|
||||||
|
void xmlDebugDumpNamespace(FILE *output, xmlNsPtr ns, int depth) {
|
||||||
|
int i;
|
||||||
|
char shift[100];
|
||||||
|
|
||||||
|
for (i = 0;((i < depth) && (i < 25));i++)
|
||||||
|
shift[2 * i] = shift[2 * i + 1] = ' ';
|
||||||
|
shift[2 * i] = shift[2 * i + 1] = 0;
|
||||||
|
|
||||||
|
fprintf(output, shift);
|
||||||
|
if (ns->type == XML_GLOBAL_NAMESPACE)
|
||||||
|
fprintf(output, "old ");
|
||||||
|
fprintf(output, "namespace %s href=", ns->prefix);
|
||||||
|
xmlDebugDumpString(output, ns->href);
|
||||||
|
fprintf(output, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void xmlDebugDumpNamespaceList(FILE *output, xmlNsPtr ns, int depth) {
|
||||||
|
while (ns != NULL) {
|
||||||
|
xmlDebugDumpNamespace(output, ns, depth);
|
||||||
|
ns = ns->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void xmlDebugDumpEntity(FILE *output, xmlEntityPtr ent, int depth) {
|
||||||
|
int i;
|
||||||
|
char shift[100];
|
||||||
|
|
||||||
|
for (i = 0;((i < depth) && (i < 25));i++)
|
||||||
|
shift[2 * i] = shift[2 * i + 1] = ' ';
|
||||||
|
shift[2 * i] = shift[2 * i + 1] = 0;
|
||||||
|
|
||||||
|
fprintf(output, shift);
|
||||||
|
switch (ent->type) {
|
||||||
|
case XML_INTERNAL_GENERAL_ENTITY:
|
||||||
|
fprintf(output, "INTERNAL_GENERAL_ENTITY ");
|
||||||
|
break;
|
||||||
|
case XML_EXTERNAL_GENERAL_PARSED_ENTITY:
|
||||||
|
fprintf(output, "EXTERNAL_GENERAL_PARSED_ENTITY ");
|
||||||
|
break;
|
||||||
|
case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY:
|
||||||
|
fprintf(output, "EXTERNAL_GENERAL_UNPARSED_ENTITY ");
|
||||||
|
break;
|
||||||
|
case XML_INTERNAL_PARAMETER_ENTITY:
|
||||||
|
fprintf(output, "INTERNAL_PARAMETER_ENTITY ");
|
||||||
|
break;
|
||||||
|
case XML_EXTERNAL_PARAMETER_ENTITY:
|
||||||
|
fprintf(output, "EXTERNAL_PARAMETER_ENTITY ");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(output, "ENTITY_%d ! ", ent->type);
|
||||||
|
}
|
||||||
|
fprintf(output, "%s\n", ent->name);
|
||||||
|
if (ent->ExternalID) {
|
||||||
|
fprintf(output, shift);
|
||||||
|
fprintf(output, "ExternalID=%s\n", ent->ExternalID);
|
||||||
|
}
|
||||||
|
if (ent->SystemID) {
|
||||||
|
fprintf(output, shift);
|
||||||
|
fprintf(output, "SystemID=%s\n", ent->SystemID);
|
||||||
|
}
|
||||||
|
if (ent->content) {
|
||||||
|
fprintf(output, shift);
|
||||||
|
fprintf(output, "content=");
|
||||||
|
xmlDebugDumpString(output, ent->content);
|
||||||
|
fprintf(output, "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void xmlDebugDumpAttr(FILE *output, xmlAttrPtr attr, int depth) {
|
||||||
|
int i;
|
||||||
|
char shift[100];
|
||||||
|
|
||||||
|
for (i = 0;((i < depth) && (i < 25));i++)
|
||||||
|
shift[2 * i] = shift[2 * i + 1] = ' ';
|
||||||
|
shift[2 * i] = shift[2 * i + 1] = 0;
|
||||||
|
|
||||||
|
fprintf(output, shift);
|
||||||
|
fprintf(output, "ATTRIBUTE %s\n", attr->name);
|
||||||
|
if (attr->val != NULL)
|
||||||
|
xmlDebugDumpNodeList(output, attr->val, depth + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void xmlDebugDumpAttrList(FILE *output, xmlAttrPtr attr, int depth) {
|
||||||
|
while (attr != NULL) {
|
||||||
|
xmlDebugDumpAttr(output, attr, depth);
|
||||||
|
attr = attr->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void xmlDebugDumpNode(FILE *output, xmlNodePtr node, int depth) {
|
||||||
|
int i;
|
||||||
|
char shift[100];
|
||||||
|
|
||||||
|
for (i = 0;((i < depth) && (i < 25));i++)
|
||||||
|
shift[2 * i] = shift[2 * i + 1] = ' ';
|
||||||
|
shift[2 * i] = shift[2 * i + 1] = 0;
|
||||||
|
|
||||||
|
fprintf(output, shift);
|
||||||
|
switch (node->type) {
|
||||||
|
case XML_ELEMENT_NODE:
|
||||||
|
fprintf(output, "ELEMENT ");
|
||||||
|
if (node->ns != NULL)
|
||||||
|
fprintf(output, "%s:%s\n", node->ns->prefix, node->name);
|
||||||
|
else
|
||||||
|
fprintf(output, "%s\n", node->name);
|
||||||
|
break;
|
||||||
|
case XML_ATTRIBUTE_NODE:
|
||||||
|
fprintf(output, "Error, ATTRIBUTE found here\n");
|
||||||
|
break;
|
||||||
|
case XML_TEXT_NODE:
|
||||||
|
fprintf(output, "TEXT\n");
|
||||||
|
break;
|
||||||
|
case XML_CDATA_SECTION_NODE:
|
||||||
|
fprintf(output, "CDATA_SECTION\n");
|
||||||
|
break;
|
||||||
|
case XML_ENTITY_REF_NODE:
|
||||||
|
fprintf(output, "ENTITY_REF\n");
|
||||||
|
break;
|
||||||
|
case XML_ENTITY_NODE:
|
||||||
|
fprintf(output, "ENTITY\n");
|
||||||
|
break;
|
||||||
|
case XML_PI_NODE:
|
||||||
|
fprintf(output, "PI\n");
|
||||||
|
break;
|
||||||
|
case XML_COMMENT_NODE:
|
||||||
|
fprintf(output, "COMMENT\n");
|
||||||
|
break;
|
||||||
|
case XML_DOCUMENT_NODE:
|
||||||
|
fprintf(output, "Error, DOCUMENT found here\n");
|
||||||
|
break;
|
||||||
|
case XML_DOCUMENT_TYPE_NODE:
|
||||||
|
fprintf(output, "DOCUMENT_TYPE\n");
|
||||||
|
break;
|
||||||
|
case XML_DOCUMENT_FRAG_NODE:
|
||||||
|
fprintf(output, "DOCUMENT_FRAG\n");
|
||||||
|
break;
|
||||||
|
case XML_NOTATION_NODE:
|
||||||
|
fprintf(output, "NOTATION\n");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(output, "NODE_%d\n", node->type);
|
||||||
|
}
|
||||||
|
if (node->doc == NULL) {
|
||||||
|
fprintf(output, shift);
|
||||||
|
fprintf(output, "doc == NULL !!!\n");
|
||||||
|
}
|
||||||
|
if (node->nsDef != NULL)
|
||||||
|
xmlDebugDumpNamespaceList(output, node->nsDef, depth + 1);
|
||||||
|
if (node->properties != NULL)
|
||||||
|
xmlDebugDumpAttrList(output, node->properties, depth + 1);
|
||||||
|
if (node->type != XML_ENTITY_REF_NODE) {
|
||||||
|
if (node->content != NULL) {
|
||||||
|
fprintf(output, shift);
|
||||||
|
fprintf(output, "content=");
|
||||||
|
xmlDebugDumpString(output, node->content);
|
||||||
|
fprintf(output, "\n");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
xmlEntityPtr ent;
|
||||||
|
ent = xmlGetDocEntity(node->doc, node->name);
|
||||||
|
if (ent != NULL)
|
||||||
|
xmlDebugDumpEntity(output, ent, depth + 1);
|
||||||
|
}
|
||||||
|
if (node->childs != NULL)
|
||||||
|
xmlDebugDumpNodeList(output, node->childs, depth + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void xmlDebugDumpNodeList(FILE *output, xmlNodePtr node, int depth) {
|
||||||
|
while (node != NULL) {
|
||||||
|
xmlDebugDumpNode(output, node, depth);
|
||||||
|
node = node->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void xmlDebugDumpDocument(FILE *output, xmlDocPtr doc) {
|
||||||
|
if (output == NULL) output = stdout;
|
||||||
|
if (doc == NULL) {
|
||||||
|
fprintf(output, "DOCUMENT == NULL !\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (doc->type) {
|
||||||
|
case XML_ELEMENT_NODE:
|
||||||
|
fprintf(output, "Error, ELEMENT found here ");
|
||||||
|
break;
|
||||||
|
case XML_ATTRIBUTE_NODE:
|
||||||
|
fprintf(output, "Error, ATTRIBUTE found here\n");
|
||||||
|
break;
|
||||||
|
case XML_TEXT_NODE:
|
||||||
|
fprintf(output, "Error, TEXT\n");
|
||||||
|
break;
|
||||||
|
case XML_CDATA_SECTION_NODE:
|
||||||
|
fprintf(output, "Error, CDATA_SECTION\n");
|
||||||
|
break;
|
||||||
|
case XML_ENTITY_REF_NODE:
|
||||||
|
fprintf(output, "Error, ENTITY_REF\n");
|
||||||
|
break;
|
||||||
|
case XML_ENTITY_NODE:
|
||||||
|
fprintf(output, "Error, ENTITY\n");
|
||||||
|
break;
|
||||||
|
case XML_PI_NODE:
|
||||||
|
fprintf(output, "Error, PI\n");
|
||||||
|
break;
|
||||||
|
case XML_COMMENT_NODE:
|
||||||
|
fprintf(output, "Error, COMMENT\n");
|
||||||
|
break;
|
||||||
|
case XML_DOCUMENT_NODE:
|
||||||
|
fprintf(output, "DOCUMENT\n");
|
||||||
|
break;
|
||||||
|
case XML_DOCUMENT_TYPE_NODE:
|
||||||
|
fprintf(output, "Error, DOCUMENT_TYPE\n");
|
||||||
|
break;
|
||||||
|
case XML_DOCUMENT_FRAG_NODE:
|
||||||
|
fprintf(output, "Error, DOCUMENT_FRAG\n");
|
||||||
|
break;
|
||||||
|
case XML_NOTATION_NODE:
|
||||||
|
fprintf(output, "Error, NOTATION\n");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf(output, "NODE_%d\n", doc->type);
|
||||||
|
}
|
||||||
|
if (doc->name != NULL) {
|
||||||
|
fprintf(output, "name=");
|
||||||
|
xmlDebugDumpString(output, doc->name);
|
||||||
|
fprintf(output, "\n");
|
||||||
|
}
|
||||||
|
if (doc->version != NULL) {
|
||||||
|
fprintf(output, "version=");
|
||||||
|
xmlDebugDumpString(output, doc->version);
|
||||||
|
fprintf(output, "\n");
|
||||||
|
}
|
||||||
|
if (doc->encoding != NULL) {
|
||||||
|
fprintf(output, "encoding=");
|
||||||
|
xmlDebugDumpString(output, doc->encoding);
|
||||||
|
fprintf(output, "\n");
|
||||||
|
}
|
||||||
|
if (doc->standalone)
|
||||||
|
fprintf(output, "standalone=true\n");
|
||||||
|
if (doc->oldNs != NULL)
|
||||||
|
xmlDebugDumpNamespaceList(output, doc->oldNs, 0);
|
||||||
|
if (doc->root != NULL)
|
||||||
|
xmlDebugDumpNodeList(output, doc->root, 1);
|
||||||
|
}
|
18
debugXML.h
Normal file
18
debugXML.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* debugXML.h : Interfaces to a set of routines used for debugging the tree
|
||||||
|
* produced by the XML parser.
|
||||||
|
*
|
||||||
|
* Daniel Veillard <Daniel.Veillard@w3.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __DEBUG_XML__
|
||||||
|
#define __DEBUG_XML__
|
||||||
|
#include "tree.h"
|
||||||
|
|
||||||
|
extern void xmlDebugDumpString(FILE *output, const CHAR *str);
|
||||||
|
extern void xmlDebugDumpAttr(FILE *output, xmlAttrPtr attr, int depth);
|
||||||
|
extern void xmlDebugDumpAttrList(FILE *output, xmlAttrPtr attr, int depth);
|
||||||
|
extern void xmlDebugDumpNode(FILE *output, xmlNodePtr node, int depth);
|
||||||
|
extern void xmlDebugDumpNodeList(FILE *output, xmlNodePtr node, int depth);
|
||||||
|
extern void xmlDebugDumpDocument(FILE *output, xmlDocPtr doc);
|
||||||
|
#endif /* __DEBUG_XML__ */
|
18
include/libxml/debugXML.h
Normal file
18
include/libxml/debugXML.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* debugXML.h : Interfaces to a set of routines used for debugging the tree
|
||||||
|
* produced by the XML parser.
|
||||||
|
*
|
||||||
|
* Daniel Veillard <Daniel.Veillard@w3.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __DEBUG_XML__
|
||||||
|
#define __DEBUG_XML__
|
||||||
|
#include "tree.h"
|
||||||
|
|
||||||
|
extern void xmlDebugDumpString(FILE *output, const CHAR *str);
|
||||||
|
extern void xmlDebugDumpAttr(FILE *output, xmlAttrPtr attr, int depth);
|
||||||
|
extern void xmlDebugDumpAttrList(FILE *output, xmlAttrPtr attr, int depth);
|
||||||
|
extern void xmlDebugDumpNode(FILE *output, xmlNodePtr node, int depth);
|
||||||
|
extern void xmlDebugDumpNodeList(FILE *output, xmlNodePtr node, int depth);
|
||||||
|
extern void xmlDebugDumpDocument(FILE *output, xmlDocPtr doc);
|
||||||
|
#endif /* __DEBUG_XML__ */
|
18
tester.c
18
tester.c
@ -28,6 +28,9 @@
|
|||||||
|
|
||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
#include "tree.h"
|
#include "tree.h"
|
||||||
|
#include "debugXML.h"
|
||||||
|
|
||||||
|
static int debug = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Note: there is a couple of errors introduced on purpose.
|
* Note: there is a couple of errors introduced on purpose.
|
||||||
@ -65,7 +68,10 @@ void parseAndPrintFile(char *filename) {
|
|||||||
/*
|
/*
|
||||||
* print it.
|
* print it.
|
||||||
*/
|
*/
|
||||||
xmlDocDump(stdout, doc);
|
if (!debug)
|
||||||
|
xmlDocDump(stdout, doc);
|
||||||
|
else
|
||||||
|
xmlDebugDumpDocument(stdout, doc);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* free it.
|
* free it.
|
||||||
@ -84,7 +90,10 @@ void parseAndPrintBuffer(CHAR *buf) {
|
|||||||
/*
|
/*
|
||||||
* print it.
|
* print it.
|
||||||
*/
|
*/
|
||||||
xmlDocDump(stdout, doc);
|
if (!debug)
|
||||||
|
xmlDocDump(stdout, doc);
|
||||||
|
else
|
||||||
|
xmlDebugDumpDocument(stdout, doc);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* free it.
|
* free it.
|
||||||
@ -97,7 +106,10 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
for (i = 1; i < argc ; i++) {
|
for (i = 1; i < argc ; i++) {
|
||||||
parseAndPrintFile(argv[i]);
|
if ((strcmp(argv[i], "-debug")) && (strcmp(argv[i], "--debug")))
|
||||||
|
parseAndPrintFile(argv[i]);
|
||||||
|
else
|
||||||
|
debug++;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
parseAndPrintBuffer(buffer);
|
parseAndPrintBuffer(buffer);
|
||||||
|
182
tree.c
182
tree.c
@ -39,7 +39,8 @@ static int xmlCompressMode = 0;
|
|||||||
*
|
*
|
||||||
* Upgrade old style Namespaces (PI) and move them to the root of the document.
|
* Upgrade old style Namespaces (PI) and move them to the root of the document.
|
||||||
*/
|
*/
|
||||||
void xmlUpgradeOldNs(xmlDocPtr doc) {
|
void
|
||||||
|
xmlUpgradeOldNs(xmlDocPtr doc) {
|
||||||
xmlNsPtr cur;
|
xmlNsPtr cur;
|
||||||
|
|
||||||
if ((doc == NULL) || (doc->oldNs == NULL)) return;
|
if ((doc == NULL) || (doc->oldNs == NULL)) return;
|
||||||
@ -68,7 +69,8 @@ void xmlUpgradeOldNs(xmlDocPtr doc) {
|
|||||||
* Creation of a new Namespace.
|
* Creation of a new Namespace.
|
||||||
* return values: returns a new namespace pointer
|
* return values: returns a new namespace pointer
|
||||||
*/
|
*/
|
||||||
xmlNsPtr xmlNewNs(xmlNodePtr node, const CHAR *href, const CHAR *prefix) {
|
xmlNsPtr
|
||||||
|
xmlNewNs(xmlNodePtr node, const CHAR *href, const CHAR *prefix) {
|
||||||
xmlNsPtr cur;
|
xmlNsPtr cur;
|
||||||
|
|
||||||
if (href == NULL) {
|
if (href == NULL) {
|
||||||
@ -122,7 +124,8 @@ xmlNsPtr xmlNewNs(xmlNodePtr node, const CHAR *href, const CHAR *prefix) {
|
|||||||
* Creation of a Namespace, the old way using PI and without scoping, to AVOID.
|
* Creation of a Namespace, the old way using PI and without scoping, to AVOID.
|
||||||
* return values: returns a new namespace pointer
|
* return values: returns a new namespace pointer
|
||||||
*/
|
*/
|
||||||
xmlNsPtr xmlNewGlobalNs(xmlDocPtr doc, const CHAR *href, const CHAR *prefix) {
|
xmlNsPtr
|
||||||
|
xmlNewGlobalNs(xmlDocPtr doc, const CHAR *href, const CHAR *prefix) {
|
||||||
xmlNsPtr cur;
|
xmlNsPtr cur;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -169,7 +172,8 @@ xmlNsPtr xmlNewGlobalNs(xmlDocPtr doc, const CHAR *href, const CHAR *prefix) {
|
|||||||
*
|
*
|
||||||
* Associate a namespace to a node, a posteriori.
|
* Associate a namespace to a node, a posteriori.
|
||||||
*/
|
*/
|
||||||
void xmlSetNs(xmlNodePtr node, xmlNsPtr ns) {
|
void
|
||||||
|
xmlSetNs(xmlNodePtr node, xmlNsPtr ns) {
|
||||||
if (node == NULL) {
|
if (node == NULL) {
|
||||||
fprintf(stderr, "xmlSetNs: node == NULL\n");
|
fprintf(stderr, "xmlSetNs: node == NULL\n");
|
||||||
return;
|
return;
|
||||||
@ -183,7 +187,8 @@ void xmlSetNs(xmlNodePtr node, xmlNsPtr ns) {
|
|||||||
*
|
*
|
||||||
* Free up the structures associated to a namespace
|
* Free up the structures associated to a namespace
|
||||||
*/
|
*/
|
||||||
void xmlFreeNs(xmlNsPtr cur) {
|
void
|
||||||
|
xmlFreeNs(xmlNsPtr cur) {
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "xmlFreeNs : ns == NULL\n");
|
fprintf(stderr, "xmlFreeNs : ns == NULL\n");
|
||||||
return;
|
return;
|
||||||
@ -200,7 +205,8 @@ void xmlFreeNs(xmlNsPtr cur) {
|
|||||||
*
|
*
|
||||||
* Free up all the structures associated to the chained namespaces.
|
* Free up all the structures associated to the chained namespaces.
|
||||||
*/
|
*/
|
||||||
void xmlFreeNsList(xmlNsPtr cur) {
|
void
|
||||||
|
xmlFreeNsList(xmlNsPtr cur) {
|
||||||
xmlNsPtr next;
|
xmlNsPtr next;
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "xmlFreeNsList : ns == NULL\n");
|
fprintf(stderr, "xmlFreeNsList : ns == NULL\n");
|
||||||
@ -223,7 +229,8 @@ void xmlFreeNsList(xmlNsPtr cur) {
|
|||||||
* Creation of a new DTD.
|
* Creation of a new DTD.
|
||||||
* return values: a pointer to the new DTD structure
|
* return values: a pointer to the new DTD structure
|
||||||
*/
|
*/
|
||||||
xmlDtdPtr xmlNewDtd(xmlDocPtr doc, const CHAR *name,
|
xmlDtdPtr
|
||||||
|
xmlNewDtd(xmlDocPtr doc, const CHAR *name,
|
||||||
const CHAR *ExternalID, const CHAR *SystemID) {
|
const CHAR *ExternalID, const CHAR *SystemID) {
|
||||||
xmlDtdPtr cur;
|
xmlDtdPtr cur;
|
||||||
|
|
||||||
@ -266,7 +273,8 @@ xmlDtdPtr xmlNewDtd(xmlDocPtr doc, const CHAR *name,
|
|||||||
*
|
*
|
||||||
* Free a DTD structure.
|
* Free a DTD structure.
|
||||||
*/
|
*/
|
||||||
void xmlFreeDtd(xmlDtdPtr cur) {
|
void
|
||||||
|
xmlFreeDtd(xmlDtdPtr cur) {
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "xmlFreeDtd : DTD == NULL\n");
|
fprintf(stderr, "xmlFreeDtd : DTD == NULL\n");
|
||||||
return;
|
return;
|
||||||
@ -288,7 +296,8 @@ void xmlFreeDtd(xmlDtdPtr cur) {
|
|||||||
*
|
*
|
||||||
* Create a new document
|
* Create a new document
|
||||||
*/
|
*/
|
||||||
xmlDocPtr xmlNewDoc(const CHAR *version) {
|
xmlDocPtr
|
||||||
|
xmlNewDoc(const CHAR *version) {
|
||||||
xmlDocPtr cur;
|
xmlDocPtr cur;
|
||||||
|
|
||||||
if (version == NULL) {
|
if (version == NULL) {
|
||||||
@ -329,7 +338,8 @@ xmlDocPtr xmlNewDoc(const CHAR *version) {
|
|||||||
*
|
*
|
||||||
* Free up all the structures used by a document, tree included.
|
* Free up all the structures used by a document, tree included.
|
||||||
*/
|
*/
|
||||||
void xmlFreeDoc(xmlDocPtr cur) {
|
void
|
||||||
|
xmlFreeDoc(xmlDocPtr cur) {
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "xmlFreeDoc : document == NULL\n");
|
fprintf(stderr, "xmlFreeDoc : document == NULL\n");
|
||||||
return;
|
return;
|
||||||
@ -354,7 +364,8 @@ void xmlFreeDoc(xmlDocPtr cur) {
|
|||||||
* produce a flat tree with only TEXTs and ENTITY_REFs.
|
* produce a flat tree with only TEXTs and ENTITY_REFs.
|
||||||
* return values: a pointer to the first child
|
* return values: a pointer to the first child
|
||||||
*/
|
*/
|
||||||
xmlNodePtr xmlStringGetNodeList(xmlDocPtr doc, const CHAR *value) {
|
xmlNodePtr
|
||||||
|
xmlStringGetNodeList(xmlDocPtr doc, const CHAR *value) {
|
||||||
xmlNodePtr ret = NULL, last = NULL;
|
xmlNodePtr ret = NULL, last = NULL;
|
||||||
xmlNodePtr node;
|
xmlNodePtr node;
|
||||||
CHAR *val;
|
CHAR *val;
|
||||||
@ -367,7 +378,7 @@ xmlNodePtr xmlStringGetNodeList(xmlDocPtr doc, const CHAR *value) {
|
|||||||
while (*cur != 0) {
|
while (*cur != 0) {
|
||||||
if (*cur == '&') {
|
if (*cur == '&') {
|
||||||
if (cur != q) {
|
if (cur != q) {
|
||||||
node = xmlNewTextLen(q, cur - q);
|
node = xmlNewDocTextLen(doc, q, cur - q);
|
||||||
if (node == NULL) return(ret);
|
if (node == NULL) return(ret);
|
||||||
if (last == NULL)
|
if (last == NULL)
|
||||||
last = ret = node;
|
last = ret = node;
|
||||||
@ -402,7 +413,7 @@ xmlNodePtr xmlStringGetNodeList(xmlDocPtr doc, const CHAR *value) {
|
|||||||
cur++;
|
cur++;
|
||||||
}
|
}
|
||||||
if (cur != q) {
|
if (cur != q) {
|
||||||
node = xmlNewTextLen(q, cur - q);
|
node = xmlNewDocTextLen(doc, q, cur - q);
|
||||||
if (node == NULL) return(ret);
|
if (node == NULL) return(ret);
|
||||||
if (last == NULL)
|
if (last == NULL)
|
||||||
last = ret = node;
|
last = ret = node;
|
||||||
@ -424,7 +435,8 @@ xmlNodePtr xmlStringGetNodeList(xmlDocPtr doc, const CHAR *value) {
|
|||||||
* made of TEXTs and ENTITY_REFs
|
* made of TEXTs and ENTITY_REFs
|
||||||
* return values: a pointer to the string copy, the calller must free it.
|
* return values: a pointer to the string copy, the calller must free it.
|
||||||
*/
|
*/
|
||||||
CHAR *xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int inLine) {
|
CHAR *
|
||||||
|
xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int inLine) {
|
||||||
xmlNodePtr node = list;
|
xmlNodePtr node = list;
|
||||||
CHAR *ret = NULL;
|
CHAR *ret = NULL;
|
||||||
xmlEntityPtr ent;
|
xmlEntityPtr ent;
|
||||||
@ -473,7 +485,8 @@ CHAR *xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int inLine) {
|
|||||||
* Create a new property carried by a node.
|
* Create a new property carried by a node.
|
||||||
* return values: a pointer to the attribute
|
* return values: a pointer to the attribute
|
||||||
*/
|
*/
|
||||||
xmlAttrPtr xmlNewProp(xmlNodePtr node, const CHAR *name, const CHAR *value) {
|
xmlAttrPtr
|
||||||
|
xmlNewProp(xmlNodePtr node, const CHAR *name, const CHAR *value) {
|
||||||
xmlAttrPtr cur;
|
xmlAttrPtr cur;
|
||||||
|
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
@ -528,7 +541,8 @@ xmlAttrPtr xmlNewProp(xmlNodePtr node, const CHAR *name, const CHAR *value) {
|
|||||||
* Create a new property carried by a document.
|
* Create a new property carried by a document.
|
||||||
* return values: a pointer to the attribute
|
* return values: a pointer to the attribute
|
||||||
*/
|
*/
|
||||||
xmlAttrPtr xmlNewDocProp(xmlDocPtr doc, const CHAR *name, const CHAR *value) {
|
xmlAttrPtr
|
||||||
|
xmlNewDocProp(xmlDocPtr doc, const CHAR *name, const CHAR *value) {
|
||||||
xmlAttrPtr cur;
|
xmlAttrPtr cur;
|
||||||
|
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
@ -567,7 +581,8 @@ xmlAttrPtr xmlNewDocProp(xmlDocPtr doc, const CHAR *name, const CHAR *value) {
|
|||||||
*
|
*
|
||||||
* Free a property and all its siblings, all the childs are freed too.
|
* Free a property and all its siblings, all the childs are freed too.
|
||||||
*/
|
*/
|
||||||
void xmlFreePropList(xmlAttrPtr cur) {
|
void
|
||||||
|
xmlFreePropList(xmlAttrPtr cur) {
|
||||||
xmlAttrPtr next;
|
xmlAttrPtr next;
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "xmlFreePropList : property == NULL\n");
|
fprintf(stderr, "xmlFreePropList : property == NULL\n");
|
||||||
@ -586,7 +601,8 @@ void xmlFreePropList(xmlAttrPtr cur) {
|
|||||||
*
|
*
|
||||||
* Free one property, all the childs are freed too.
|
* Free one property, all the childs are freed too.
|
||||||
*/
|
*/
|
||||||
void xmlFreeProp(xmlAttrPtr cur) {
|
void
|
||||||
|
xmlFreeProp(xmlAttrPtr cur) {
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "xmlFreeProp : property == NULL\n");
|
fprintf(stderr, "xmlFreeProp : property == NULL\n");
|
||||||
return;
|
return;
|
||||||
@ -608,7 +624,8 @@ void xmlFreeProp(xmlAttrPtr cur) {
|
|||||||
* ENTITY_REFs node will be created.
|
* ENTITY_REFs node will be created.
|
||||||
* return values: a pointer to the new node object.
|
* return values: a pointer to the new node object.
|
||||||
*/
|
*/
|
||||||
xmlNodePtr xmlNewNode(xmlNsPtr ns, const CHAR *name) {
|
xmlNodePtr
|
||||||
|
xmlNewNode(xmlNsPtr ns, const CHAR *name) {
|
||||||
xmlNodePtr cur;
|
xmlNodePtr cur;
|
||||||
|
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
@ -632,7 +649,6 @@ xmlNodePtr xmlNewNode(xmlNsPtr ns, const CHAR *name) {
|
|||||||
cur->prev = NULL;
|
cur->prev = NULL;
|
||||||
cur->childs = NULL;
|
cur->childs = NULL;
|
||||||
cur->properties = NULL;
|
cur->properties = NULL;
|
||||||
cur->type = 0;
|
|
||||||
cur->name = xmlStrdup(name);
|
cur->name = xmlStrdup(name);
|
||||||
cur->ns = ns;
|
cur->ns = ns;
|
||||||
cur->nsDef = NULL;
|
cur->nsDef = NULL;
|
||||||
@ -655,7 +671,8 @@ xmlNodePtr xmlNewNode(xmlNsPtr ns, const CHAR *name) {
|
|||||||
* are optionnal (NULL).
|
* are optionnal (NULL).
|
||||||
* return values: a pointer to the new node object.
|
* return values: a pointer to the new node object.
|
||||||
*/
|
*/
|
||||||
xmlNodePtr xmlNewDocNode(xmlDocPtr doc, xmlNsPtr ns,
|
xmlNodePtr
|
||||||
|
xmlNewDocNode(xmlDocPtr doc, xmlNsPtr ns,
|
||||||
const CHAR *name, CHAR *content) {
|
const CHAR *name, CHAR *content) {
|
||||||
xmlNodePtr cur;
|
xmlNodePtr cur;
|
||||||
|
|
||||||
@ -676,7 +693,8 @@ xmlNodePtr xmlNewDocNode(xmlDocPtr doc, xmlNsPtr ns,
|
|||||||
* Creation of a new text node.
|
* Creation of a new text node.
|
||||||
* return values: a pointer to the new node object.
|
* return values: a pointer to the new node object.
|
||||||
*/
|
*/
|
||||||
xmlNodePtr xmlNewText(const CHAR *content) {
|
xmlNodePtr
|
||||||
|
xmlNewText(const CHAR *content) {
|
||||||
xmlNodePtr cur;
|
xmlNodePtr cur;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -714,7 +732,8 @@ xmlNodePtr xmlNewText(const CHAR *content) {
|
|||||||
* Creation of a new reference node.
|
* Creation of a new reference node.
|
||||||
* return values: a pointer to the new node object.
|
* return values: a pointer to the new node object.
|
||||||
*/
|
*/
|
||||||
xmlNodePtr xmlNewReference(xmlDocPtr doc, const CHAR *name) {
|
xmlNodePtr
|
||||||
|
xmlNewReference(xmlDocPtr doc, const CHAR *name) {
|
||||||
xmlNodePtr cur;
|
xmlNodePtr cur;
|
||||||
xmlEntityPtr ent;
|
xmlEntityPtr ent;
|
||||||
|
|
||||||
@ -763,7 +782,8 @@ xmlNodePtr xmlNewReference(xmlDocPtr doc, const CHAR *name) {
|
|||||||
* Creation of a new text node within a document.
|
* Creation of a new text node within a document.
|
||||||
* return values: a pointer to the new node object.
|
* return values: a pointer to the new node object.
|
||||||
*/
|
*/
|
||||||
xmlNodePtr xmlNewDocText(xmlDocPtr doc, const CHAR *content) {
|
xmlNodePtr
|
||||||
|
xmlNewDocText(xmlDocPtr doc, const CHAR *content) {
|
||||||
xmlNodePtr cur;
|
xmlNodePtr cur;
|
||||||
|
|
||||||
cur = xmlNewText(content);
|
cur = xmlNewText(content);
|
||||||
@ -779,7 +799,8 @@ xmlNodePtr xmlNewDocText(xmlDocPtr doc, const CHAR *content) {
|
|||||||
* Creation of a new text node with an extra parameter for the content's lenght
|
* Creation of a new text node with an extra parameter for the content's lenght
|
||||||
* return values: a pointer to the new node object.
|
* return values: a pointer to the new node object.
|
||||||
*/
|
*/
|
||||||
xmlNodePtr xmlNewTextLen(const CHAR *content, int len) {
|
xmlNodePtr
|
||||||
|
xmlNewTextLen(const CHAR *content, int len) {
|
||||||
xmlNodePtr cur;
|
xmlNodePtr cur;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -819,7 +840,8 @@ xmlNodePtr xmlNewTextLen(const CHAR *content, int len) {
|
|||||||
* text node pertain to a given document.
|
* text node pertain to a given document.
|
||||||
* return values: a pointer to the new node object.
|
* return values: a pointer to the new node object.
|
||||||
*/
|
*/
|
||||||
xmlNodePtr xmlNewDocTextLen(xmlDocPtr doc, const CHAR *content, int len) {
|
xmlNodePtr
|
||||||
|
xmlNewDocTextLen(xmlDocPtr doc, const CHAR *content, int len) {
|
||||||
xmlNodePtr cur;
|
xmlNodePtr cur;
|
||||||
|
|
||||||
cur = xmlNewTextLen(content, len);
|
cur = xmlNewTextLen(content, len);
|
||||||
@ -834,7 +856,8 @@ xmlNodePtr xmlNewDocTextLen(xmlDocPtr doc, const CHAR *content, int len) {
|
|||||||
* Creation of a new node containing a comment.
|
* Creation of a new node containing a comment.
|
||||||
* return values: a pointer to the new node object.
|
* return values: a pointer to the new node object.
|
||||||
*/
|
*/
|
||||||
xmlNodePtr xmlNewComment(CHAR *content) {
|
xmlNodePtr
|
||||||
|
xmlNewComment(CHAR *content) {
|
||||||
xmlNodePtr cur;
|
xmlNodePtr cur;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -872,7 +895,8 @@ xmlNodePtr xmlNewComment(CHAR *content) {
|
|||||||
* Creation of a new node containing a commentwithin a document.
|
* Creation of a new node containing a commentwithin a document.
|
||||||
* return values: a pointer to the new node object.
|
* return values: a pointer to the new node object.
|
||||||
*/
|
*/
|
||||||
xmlNodePtr xmlNewDocComment(xmlDocPtr doc, CHAR *content) {
|
xmlNodePtr
|
||||||
|
xmlNewDocComment(xmlDocPtr doc, CHAR *content) {
|
||||||
xmlNodePtr cur;
|
xmlNodePtr cur;
|
||||||
|
|
||||||
cur = xmlNewComment(content);
|
cur = xmlNewComment(content);
|
||||||
@ -893,7 +917,8 @@ xmlNodePtr xmlNewDocComment(xmlDocPtr doc, CHAR *content) {
|
|||||||
* a child list containing the TEXTs and ENTITY_REFs node will be created.
|
* a child list containing the TEXTs and ENTITY_REFs node will be created.
|
||||||
* return values: a pointer to the new node object.
|
* return values: a pointer to the new node object.
|
||||||
*/
|
*/
|
||||||
xmlNodePtr xmlNewChild(xmlNodePtr parent, xmlNsPtr ns,
|
xmlNodePtr
|
||||||
|
xmlNewChild(xmlNodePtr parent, xmlNsPtr ns,
|
||||||
const CHAR *name, CHAR *content) {
|
const CHAR *name, CHAR *content) {
|
||||||
xmlNodePtr cur, prev;
|
xmlNodePtr cur, prev;
|
||||||
|
|
||||||
@ -942,7 +967,8 @@ xmlNodePtr xmlNewChild(xmlNodePtr parent, xmlNsPtr ns,
|
|||||||
* Add a new child element, to @parent, at the end of the child list.
|
* Add a new child element, to @parent, at the end of the child list.
|
||||||
* return values: the child or NULL in case of error.
|
* return values: the child or NULL in case of error.
|
||||||
*/
|
*/
|
||||||
xmlNodePtr xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
|
xmlNodePtr
|
||||||
|
xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
|
||||||
xmlNodePtr prev;
|
xmlNodePtr prev;
|
||||||
|
|
||||||
if (parent == NULL) {
|
if (parent == NULL) {
|
||||||
@ -1001,7 +1027,8 @@ xmlNodePtr xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
|
|||||||
* Search the last child of a node.
|
* Search the last child of a node.
|
||||||
* return values: the last child or NULL if none.
|
* return values: the last child or NULL if none.
|
||||||
*/
|
*/
|
||||||
xmlNodePtr xmlGetLastChild(xmlNodePtr parent) {
|
xmlNodePtr
|
||||||
|
xmlGetLastChild(xmlNodePtr parent) {
|
||||||
xmlNodePtr last;
|
xmlNodePtr last;
|
||||||
|
|
||||||
if (parent == NULL) {
|
if (parent == NULL) {
|
||||||
@ -1028,7 +1055,8 @@ xmlNodePtr xmlGetLastChild(xmlNodePtr parent) {
|
|||||||
* Free a node and all its siblings, this is a recursive behaviour, all
|
* Free a node and all its siblings, this is a recursive behaviour, all
|
||||||
* the childs are freed too.
|
* the childs are freed too.
|
||||||
*/
|
*/
|
||||||
void xmlFreeNodeList(xmlNodePtr cur) {
|
void
|
||||||
|
xmlFreeNodeList(xmlNodePtr cur) {
|
||||||
xmlNodePtr next;
|
xmlNodePtr next;
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "xmlFreeNodeList : node == NULL\n");
|
fprintf(stderr, "xmlFreeNodeList : node == NULL\n");
|
||||||
@ -1047,7 +1075,8 @@ void xmlFreeNodeList(xmlNodePtr cur) {
|
|||||||
*
|
*
|
||||||
* Free a node, this is a recursive behaviour, all the childs are freed too.
|
* Free a node, this is a recursive behaviour, all the childs are freed too.
|
||||||
*/
|
*/
|
||||||
void xmlFreeNode(xmlNodePtr cur) {
|
void
|
||||||
|
xmlFreeNode(xmlNodePtr cur) {
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "xmlFreeNode : node == NULL\n");
|
fprintf(stderr, "xmlFreeNode : node == NULL\n");
|
||||||
return;
|
return;
|
||||||
@ -1079,7 +1108,8 @@ void xmlFreeNode(xmlNodePtr cur) {
|
|||||||
*
|
*
|
||||||
* Replace the content of a node.
|
* Replace the content of a node.
|
||||||
*/
|
*/
|
||||||
void xmlNodeSetContent(xmlNodePtr cur, const CHAR *content) {
|
void
|
||||||
|
xmlNodeSetContent(xmlNodePtr cur, const CHAR *content) {
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "xmlNodeSetContent : node == NULL\n");
|
fprintf(stderr, "xmlNodeSetContent : node == NULL\n");
|
||||||
return;
|
return;
|
||||||
@ -1099,7 +1129,8 @@ void xmlNodeSetContent(xmlNodePtr cur, const CHAR *content) {
|
|||||||
*
|
*
|
||||||
* Replace the content of a node.
|
* Replace the content of a node.
|
||||||
*/
|
*/
|
||||||
void xmlNodeSetContentLen(xmlNodePtr cur, const CHAR *content, int len) {
|
void
|
||||||
|
xmlNodeSetContentLen(xmlNodePtr cur, const CHAR *content, int len) {
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "xmlNodeSetContent : node == NULL\n");
|
fprintf(stderr, "xmlNodeSetContent : node == NULL\n");
|
||||||
return;
|
return;
|
||||||
@ -1118,7 +1149,8 @@ void xmlNodeSetContentLen(xmlNodePtr cur, const CHAR *content, int len) {
|
|||||||
*
|
*
|
||||||
* Append the extra substring to the node content.
|
* Append the extra substring to the node content.
|
||||||
*/
|
*/
|
||||||
void xmlNodeAddContent(xmlNodePtr cur, const CHAR *content) {
|
void
|
||||||
|
xmlNodeAddContent(xmlNodePtr cur, const CHAR *content) {
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "xmlNodeAddContent : node == NULL\n");
|
fprintf(stderr, "xmlNodeAddContent : node == NULL\n");
|
||||||
return;
|
return;
|
||||||
@ -1134,7 +1166,8 @@ void xmlNodeAddContent(xmlNodePtr cur, const CHAR *content) {
|
|||||||
*
|
*
|
||||||
* Append the extra substring to the node content.
|
* Append the extra substring to the node content.
|
||||||
*/
|
*/
|
||||||
void xmlNodeAddContentLen(xmlNodePtr cur, const CHAR *content, int len) {
|
void
|
||||||
|
xmlNodeAddContentLen(xmlNodePtr cur, const CHAR *content, int len) {
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "xmlNodeAddContent : node == NULL\n");
|
fprintf(stderr, "xmlNodeAddContent : node == NULL\n");
|
||||||
return;
|
return;
|
||||||
@ -1154,7 +1187,8 @@ void xmlNodeAddContentLen(xmlNodePtr cur, const CHAR *content, int len) {
|
|||||||
* @nameSpace can be NULL, this is a search for the default namespace.
|
* @nameSpace can be NULL, this is a search for the default namespace.
|
||||||
* return values: the namespace pointer or NULL.
|
* return values: the namespace pointer or NULL.
|
||||||
*/
|
*/
|
||||||
xmlNsPtr xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const CHAR *nameSpace) {
|
xmlNsPtr
|
||||||
|
xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const CHAR *nameSpace) {
|
||||||
xmlNsPtr cur;
|
xmlNsPtr cur;
|
||||||
|
|
||||||
while (node != NULL) {
|
while (node != NULL) {
|
||||||
@ -1191,7 +1225,8 @@ xmlNsPtr xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const CHAR *nameSpace) {
|
|||||||
* the defined namespace or return NULL otherwise.
|
* the defined namespace or return NULL otherwise.
|
||||||
* return values: the namespace pointer or NULL.
|
* return values: the namespace pointer or NULL.
|
||||||
*/
|
*/
|
||||||
xmlNsPtr xmlSearchNsByHref(xmlDocPtr doc, xmlNodePtr node, const CHAR *href) {
|
xmlNsPtr
|
||||||
|
xmlSearchNsByHref(xmlDocPtr doc, xmlNodePtr node, const CHAR *href) {
|
||||||
xmlNsPtr cur;
|
xmlNsPtr cur;
|
||||||
|
|
||||||
while (node != NULL) {
|
while (node != NULL) {
|
||||||
@ -1245,7 +1280,8 @@ const CHAR *xmlGetProp(xmlNodePtr node, const CHAR *name) {
|
|||||||
* Set (or reset) an attribute carried by a node.
|
* Set (or reset) an attribute carried by a node.
|
||||||
* return values: the attribute pointer.
|
* return values: the attribute pointer.
|
||||||
*/
|
*/
|
||||||
xmlAttrPtr xmlSetProp(xmlNodePtr node, const CHAR *name, const CHAR *value) {
|
xmlAttrPtr
|
||||||
|
xmlSetProp(xmlNodePtr node, const CHAR *name, const CHAR *value) {
|
||||||
xmlAttrPtr prop = node->properties;
|
xmlAttrPtr prop = node->properties;
|
||||||
|
|
||||||
while (prop != NULL) {
|
while (prop != NULL) {
|
||||||
@ -1270,7 +1306,8 @@ xmlAttrPtr xmlSetProp(xmlNodePtr node, const CHAR *name, const CHAR *value) {
|
|||||||
* Is this node a Text node ?
|
* Is this node a Text node ?
|
||||||
* return values: 1 yes, 0 no
|
* return values: 1 yes, 0 no
|
||||||
*/
|
*/
|
||||||
int xmlNodeIsText(xmlNodePtr node) {
|
int
|
||||||
|
xmlNodeIsText(xmlNodePtr node) {
|
||||||
if (node == NULL) return(0);
|
if (node == NULL) return(0);
|
||||||
|
|
||||||
if (node->type == XML_TEXT_NODE) return(1);
|
if (node->type == XML_TEXT_NODE) return(1);
|
||||||
@ -1286,7 +1323,8 @@ int xmlNodeIsText(xmlNodePtr node) {
|
|||||||
* Concat the given string at the end of the existing node content
|
* Concat the given string at the end of the existing node content
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void xmlTextConcat(xmlNodePtr node, const CHAR *content, int len) {
|
void
|
||||||
|
xmlTextConcat(xmlNodePtr node, const CHAR *content, int len) {
|
||||||
if (node == NULL) return;
|
if (node == NULL) return;
|
||||||
|
|
||||||
if (node->type != XML_TEXT_NODE) {
|
if (node->type != XML_TEXT_NODE) {
|
||||||
@ -1313,7 +1351,8 @@ static int buffer_size = 0;
|
|||||||
* routine which manage and grows an output buffer. This one add
|
* routine which manage and grows an output buffer. This one add
|
||||||
* CHARs at the end of the array.
|
* CHARs at the end of the array.
|
||||||
*/
|
*/
|
||||||
void xmlBufferWriteCHAR(const CHAR *string) {
|
void
|
||||||
|
xmlBufferWriteCHAR(const CHAR *string) {
|
||||||
const CHAR *cur;
|
const CHAR *cur;
|
||||||
|
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
@ -1347,7 +1386,8 @@ void xmlBufferWriteCHAR(const CHAR *string) {
|
|||||||
* routine which manage and grows an output buffer. This one add
|
* routine which manage and grows an output buffer. This one add
|
||||||
* C chars at the end of the array.
|
* C chars at the end of the array.
|
||||||
*/
|
*/
|
||||||
void xmlBufferWriteChar(const char *string) {
|
void
|
||||||
|
xmlBufferWriteChar(const char *string) {
|
||||||
const char *cur;
|
const char *cur;
|
||||||
|
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
@ -1380,7 +1420,8 @@ void xmlBufferWriteChar(const char *string) {
|
|||||||
*
|
*
|
||||||
* Dump a global Namespace, this is the old version based on PIs.
|
* Dump a global Namespace, this is the old version based on PIs.
|
||||||
*/
|
*/
|
||||||
static void xmlGlobalNsDump(xmlNsPtr cur) {
|
static void
|
||||||
|
xmlGlobalNsDump(xmlNsPtr cur) {
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "xmlGlobalNsDump : Ns == NULL\n");
|
fprintf(stderr, "xmlGlobalNsDump : Ns == NULL\n");
|
||||||
return;
|
return;
|
||||||
@ -1407,7 +1448,8 @@ static void xmlGlobalNsDump(xmlNsPtr cur) {
|
|||||||
*
|
*
|
||||||
* Dump a list of global Namespace, this is the old version based on PIs.
|
* Dump a list of global Namespace, this is the old version based on PIs.
|
||||||
*/
|
*/
|
||||||
static void xmlGlobalNsListDump(xmlNsPtr cur) {
|
static void
|
||||||
|
xmlGlobalNsListDump(xmlNsPtr cur) {
|
||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
xmlGlobalNsDump(cur);
|
xmlGlobalNsDump(cur);
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
@ -1421,7 +1463,8 @@ static void xmlGlobalNsListDump(xmlNsPtr cur) {
|
|||||||
* Dump a local Namespace definition.
|
* Dump a local Namespace definition.
|
||||||
* Should be called in the context of attributes dumps.
|
* Should be called in the context of attributes dumps.
|
||||||
*/
|
*/
|
||||||
static void xmlNsDump(xmlNsPtr cur) {
|
static void
|
||||||
|
xmlNsDump(xmlNsPtr cur) {
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "xmlNsDump : Ns == NULL\n");
|
fprintf(stderr, "xmlNsDump : Ns == NULL\n");
|
||||||
return;
|
return;
|
||||||
@ -1446,7 +1489,8 @@ static void xmlNsDump(xmlNsPtr cur) {
|
|||||||
* Dump a list of local Namespace definitions.
|
* Dump a list of local Namespace definitions.
|
||||||
* Should be called in the context of attributes dumps.
|
* Should be called in the context of attributes dumps.
|
||||||
*/
|
*/
|
||||||
static void xmlNsListDump(xmlNsPtr cur) {
|
static void
|
||||||
|
xmlNsListDump(xmlNsPtr cur) {
|
||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
xmlNsDump(cur);
|
xmlNsDump(cur);
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
@ -1459,7 +1503,8 @@ static void xmlNsListDump(xmlNsPtr cur) {
|
|||||||
*
|
*
|
||||||
* Dump the XML document DTD, if any.
|
* Dump the XML document DTD, if any.
|
||||||
*/
|
*/
|
||||||
static void xmlDtdDump(xmlDocPtr doc) {
|
static void
|
||||||
|
xmlDtdDump(xmlDocPtr doc) {
|
||||||
xmlDtdPtr cur = doc->dtd;
|
xmlDtdPtr cur = doc->dtd;
|
||||||
|
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
@ -1501,7 +1546,8 @@ static void xmlDtdDump(xmlDocPtr doc) {
|
|||||||
*
|
*
|
||||||
* Dump an XML attribute
|
* Dump an XML attribute
|
||||||
*/
|
*/
|
||||||
static void xmlAttrDump(xmlDocPtr doc, xmlAttrPtr cur) {
|
static void
|
||||||
|
xmlAttrDump(xmlDocPtr doc, xmlAttrPtr cur) {
|
||||||
CHAR *value;
|
CHAR *value;
|
||||||
|
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
@ -1526,7 +1572,8 @@ static void xmlAttrDump(xmlDocPtr doc, xmlAttrPtr cur) {
|
|||||||
*
|
*
|
||||||
* Dump a list of XML attributes
|
* Dump a list of XML attributes
|
||||||
*/
|
*/
|
||||||
static void xmlAttrListDump(xmlDocPtr doc, xmlAttrPtr cur) {
|
static void
|
||||||
|
xmlAttrListDump(xmlDocPtr doc, xmlAttrPtr cur) {
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "xmlAttrListDump : property == NULL\n");
|
fprintf(stderr, "xmlAttrListDump : property == NULL\n");
|
||||||
return;
|
return;
|
||||||
@ -1538,7 +1585,8 @@ static void xmlAttrListDump(xmlDocPtr doc, xmlAttrPtr cur) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void xmlNodeDump(xmlDocPtr doc, xmlNodePtr cur, int level);
|
static void
|
||||||
|
xmlNodeDump(xmlDocPtr doc, xmlNodePtr cur, int level);
|
||||||
/**
|
/**
|
||||||
* xmlNodeListDump:
|
* xmlNodeListDump:
|
||||||
* @doc: the document
|
* @doc: the document
|
||||||
@ -1547,7 +1595,8 @@ static void xmlNodeDump(xmlDocPtr doc, xmlNodePtr cur, int level);
|
|||||||
*
|
*
|
||||||
* Dump an XML node list, recursive behaviour,children are printed too.
|
* Dump an XML node list, recursive behaviour,children are printed too.
|
||||||
*/
|
*/
|
||||||
static void xmlNodeListDump(xmlDocPtr doc, xmlNodePtr cur, int level) {
|
static void
|
||||||
|
xmlNodeListDump(xmlDocPtr doc, xmlNodePtr cur, int level) {
|
||||||
int needIndent = 0, i;
|
int needIndent = 0, i;
|
||||||
|
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
@ -1578,7 +1627,8 @@ static void xmlNodeListDump(xmlDocPtr doc, xmlNodePtr cur, int level) {
|
|||||||
*
|
*
|
||||||
* Dump an XML node, recursive behaviour,children are printed too.
|
* Dump an XML node, recursive behaviour,children are printed too.
|
||||||
*/
|
*/
|
||||||
static void xmlNodeDump(xmlDocPtr doc, xmlNodePtr cur, int level) {
|
static void
|
||||||
|
xmlNodeDump(xmlDocPtr doc, xmlNodePtr cur, int level) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
@ -1646,7 +1696,8 @@ static void xmlNodeDump(xmlDocPtr doc, xmlNodePtr cur, int level) {
|
|||||||
*
|
*
|
||||||
* Dump an XML document.
|
* Dump an XML document.
|
||||||
*/
|
*/
|
||||||
static void xmlDocContentDump(xmlDocPtr cur) {
|
static void
|
||||||
|
xmlDocContentDump(xmlDocPtr cur) {
|
||||||
if (oldXMLWDcompatibility)
|
if (oldXMLWDcompatibility)
|
||||||
xmlBufferWriteChar("<?XML version=\"");
|
xmlBufferWriteChar("<?XML version=\"");
|
||||||
else
|
else
|
||||||
@ -1688,7 +1739,8 @@ static void xmlDocContentDump(xmlDocPtr cur) {
|
|||||||
* Dump an XML document in memory and return the CHAR * and it's size.
|
* Dump an XML document in memory and return the CHAR * and it's size.
|
||||||
* It's up to the caller to free the memory.
|
* It's up to the caller to free the memory.
|
||||||
*/
|
*/
|
||||||
void xmlDocDumpMemory(xmlDocPtr cur, CHAR**mem, int *size) {
|
void
|
||||||
|
xmlDocDumpMemory(xmlDocPtr cur, CHAR**mem, int *size) {
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "xmlDocDump : document == NULL\n");
|
fprintf(stderr, "xmlDocDump : document == NULL\n");
|
||||||
*mem = NULL;
|
*mem = NULL;
|
||||||
@ -1709,7 +1761,8 @@ void xmlDocDumpMemory(xmlDocPtr cur, CHAR**mem, int *size) {
|
|||||||
* get the compression ratio for a document, ZLIB based
|
* get the compression ratio for a document, ZLIB based
|
||||||
* return values: 0 (uncompressed) to 9 (max compression)
|
* return values: 0 (uncompressed) to 9 (max compression)
|
||||||
*/
|
*/
|
||||||
int xmlGetDocCompressMode (xmlDocPtr doc) {
|
int
|
||||||
|
xmlGetDocCompressMode (xmlDocPtr doc) {
|
||||||
if (doc == NULL) return(-1);
|
if (doc == NULL) return(-1);
|
||||||
return(doc->compression);
|
return(doc->compression);
|
||||||
}
|
}
|
||||||
@ -1722,7 +1775,8 @@ int xmlGetDocCompressMode (xmlDocPtr doc) {
|
|||||||
* set the compression ratio for a document, ZLIB based
|
* set the compression ratio for a document, ZLIB based
|
||||||
* Correct values: 0 (uncompressed) to 9 (max compression)
|
* Correct values: 0 (uncompressed) to 9 (max compression)
|
||||||
*/
|
*/
|
||||||
void xmlSetDocCompressMode (xmlDocPtr doc, int mode) {
|
void
|
||||||
|
xmlSetDocCompressMode (xmlDocPtr doc, int mode) {
|
||||||
if (doc == NULL) return;
|
if (doc == NULL) return;
|
||||||
if (mode < 0) doc->compression = 0;
|
if (mode < 0) doc->compression = 0;
|
||||||
else if (mode > 9) doc->compression = 9;
|
else if (mode > 9) doc->compression = 9;
|
||||||
@ -1735,7 +1789,8 @@ void xmlSetDocCompressMode (xmlDocPtr doc, int mode) {
|
|||||||
* get the default compression mode used, ZLIB based.
|
* get the default compression mode used, ZLIB based.
|
||||||
* return values: 0 (uncompressed) to 9 (max compression)
|
* return values: 0 (uncompressed) to 9 (max compression)
|
||||||
*/
|
*/
|
||||||
int xmlGetCompressMode(void) {
|
int
|
||||||
|
xmlGetCompressMode(void) {
|
||||||
return(xmlCompressMode);
|
return(xmlCompressMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1746,7 +1801,8 @@ int xmlGetCompressMode(void) {
|
|||||||
* set the default compression mode used, ZLIB based
|
* set the default compression mode used, ZLIB based
|
||||||
* Correct values: 0 (uncompressed) to 9 (max compression)
|
* Correct values: 0 (uncompressed) to 9 (max compression)
|
||||||
*/
|
*/
|
||||||
void xmlSetCompressMode(int mode) {
|
void
|
||||||
|
xmlSetCompressMode(int mode) {
|
||||||
if (mode < 0) xmlCompressMode = 0;
|
if (mode < 0) xmlCompressMode = 0;
|
||||||
else if (mode > 9) xmlCompressMode = 9;
|
else if (mode > 9) xmlCompressMode = 9;
|
||||||
else xmlCompressMode = mode;
|
else xmlCompressMode = mode;
|
||||||
@ -1759,7 +1815,8 @@ void xmlSetCompressMode(int mode) {
|
|||||||
*
|
*
|
||||||
* Dump an XML document to an open FILE.
|
* Dump an XML document to an open FILE.
|
||||||
*/
|
*/
|
||||||
void xmlDocDump(FILE *f, xmlDocPtr cur) {
|
void
|
||||||
|
xmlDocDump(FILE *f, xmlDocPtr cur) {
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
fprintf(stderr, "xmlDocDump : document == NULL\n");
|
fprintf(stderr, "xmlDocDump : document == NULL\n");
|
||||||
return;
|
return;
|
||||||
@ -1779,7 +1836,8 @@ void xmlDocDump(FILE *f, xmlDocPtr cur) {
|
|||||||
* compiled in and enabled.
|
* compiled in and enabled.
|
||||||
* returns: the number of file written or -1 in case of failure.
|
* returns: the number of file written or -1 in case of failure.
|
||||||
*/
|
*/
|
||||||
int xmlSaveFile(const char *filename, xmlDocPtr cur) {
|
int
|
||||||
|
xmlSaveFile(const char *filename, xmlDocPtr cur) {
|
||||||
#ifdef HAVE_ZLIB_H
|
#ifdef HAVE_ZLIB_H
|
||||||
gzFile zoutput = NULL;
|
gzFile zoutput = NULL;
|
||||||
char mode[15];
|
char mode[15];
|
||||||
|
Reference in New Issue
Block a user