mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2024-12-24 21:33:51 +03:00
Serious upgrade of internal subset support, setup for gtk-doc, Daniel
This commit is contained in:
parent
63dc42c681
commit
1e346af5e4
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
||||
Mon Feb 22 11:24:56 CET 1999 Daniel Veillard <Daniel.Veillard@w3.org>
|
||||
|
||||
* parserInternals.h: added this header giving access to the parser
|
||||
internal functions.
|
||||
* doc/Makefile.am : added a rebuild target which rebuilds the full
|
||||
set of documentations
|
||||
* parser.[ch] tree.[ch] valid.[ch]: serious updates w.r.t. parsing
|
||||
the internal subset.
|
||||
* *.c *.h: modifications needed to generate the documentation using
|
||||
gtk-doc, cleanup of functions blocks, reorganisation of struct
|
||||
declarations.
|
||||
|
||||
Tue Feb 16 17:27:29 CET 1999 Daniel Veillard <Daniel.Veillard@w3.org>
|
||||
|
||||
* Makefile.am, spec, doc/Makefile.am : upgrading to 0.99.8, fixing
|
||||
|
32
SAX.c
32
SAX.c
@ -21,7 +21,7 @@
|
||||
*
|
||||
* Return the public ID e.g. "-//SGMLSOURCE//DTD DEMO//EN"
|
||||
*
|
||||
* return values: a CHAR *
|
||||
* Returns a CHAR *
|
||||
*/
|
||||
const CHAR *
|
||||
getPublicId(xmlParserCtxtPtr ctxt)
|
||||
@ -36,7 +36,7 @@ getPublicId(xmlParserCtxtPtr ctxt)
|
||||
* Return the system ID, basically URI or filename e.g.
|
||||
* http://www.sgmlsource.com/dtds/memo.dtd
|
||||
*
|
||||
* return values: a CHAR *
|
||||
* Returns a CHAR *
|
||||
*/
|
||||
const CHAR *
|
||||
getSystemId(xmlParserCtxtPtr ctxt)
|
||||
@ -50,7 +50,7 @@ getSystemId(xmlParserCtxtPtr ctxt)
|
||||
*
|
||||
* Return the line number of the current parsing point.
|
||||
*
|
||||
* return values: an int
|
||||
* Returns an int
|
||||
*/
|
||||
int
|
||||
getLineNumber(xmlParserCtxtPtr ctxt)
|
||||
@ -64,7 +64,7 @@ getLineNumber(xmlParserCtxtPtr ctxt)
|
||||
*
|
||||
* Return the column number of the current parsing point.
|
||||
*
|
||||
* return values: an int
|
||||
* Returns an int
|
||||
*/
|
||||
int
|
||||
getColumnNumber(xmlParserCtxtPtr ctxt)
|
||||
@ -92,7 +92,7 @@ xmlSAXLocator xmlDefaultSAXLocator = {
|
||||
* the ENTITY_REF nodes are built in the structure (and the parameter
|
||||
* values).
|
||||
*
|
||||
* return values: the xmlParserInputPtr if inlined or NULL for DOM behaviour.
|
||||
* Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
|
||||
*/
|
||||
xmlParserInputPtr
|
||||
resolveEntity(xmlParserCtxtPtr ctxt, const CHAR *publicId, const CHAR *systemId)
|
||||
@ -114,8 +114,6 @@ resolveEntity(xmlParserCtxtPtr ctxt, const CHAR *publicId, const CHAR *systemId)
|
||||
*
|
||||
* What to do when a notation declaration has been parsed.
|
||||
* TODO Not handled currently.
|
||||
*
|
||||
* return values:
|
||||
*/
|
||||
void
|
||||
notationDecl(xmlParserCtxtPtr ctxt, const CHAR *name,
|
||||
@ -136,8 +134,6 @@ notationDecl(xmlParserCtxtPtr ctxt, const CHAR *name,
|
||||
*
|
||||
* What to do when an unparsed entity declaration is parsed
|
||||
* TODO Create an Entity node.
|
||||
*
|
||||
* return values:
|
||||
*/
|
||||
void
|
||||
unparsedEntityDecl(xmlParserCtxtPtr ctxt, const CHAR *name,
|
||||
@ -157,8 +153,6 @@ unparsedEntityDecl(xmlParserCtxtPtr ctxt, const CHAR *name,
|
||||
*
|
||||
* Receive the document locator at startup, actually xmlDefaultSAXLocator
|
||||
* Everything is available on the context, so this is useless in our case.
|
||||
*
|
||||
* return values:
|
||||
*/
|
||||
void
|
||||
setDocumentLocator(xmlParserCtxtPtr ctxt, xmlSAXLocatorPtr loc)
|
||||
@ -173,8 +167,6 @@ setDocumentLocator(xmlParserCtxtPtr ctxt, xmlSAXLocatorPtr loc)
|
||||
* @ctxt: An XML parser context
|
||||
*
|
||||
* called when the document start being processed.
|
||||
*
|
||||
* return values:
|
||||
*/
|
||||
void
|
||||
startDocument(xmlParserCtxtPtr ctxt)
|
||||
@ -189,8 +181,6 @@ startDocument(xmlParserCtxtPtr ctxt)
|
||||
* @ctxt: An XML parser context
|
||||
*
|
||||
* called when the document end has been detected.
|
||||
*
|
||||
* return values:
|
||||
*/
|
||||
void
|
||||
endDocument(xmlParserCtxtPtr ctxt)
|
||||
@ -207,8 +197,6 @@ endDocument(xmlParserCtxtPtr ctxt)
|
||||
*
|
||||
* called when an opening tag has been processed.
|
||||
* TODO We currently have a small pblm with the arguments ...
|
||||
*
|
||||
* return values:
|
||||
*/
|
||||
void
|
||||
startElement(xmlParserCtxtPtr ctxt, const CHAR *name)
|
||||
@ -224,8 +212,6 @@ startElement(xmlParserCtxtPtr ctxt, const CHAR *name)
|
||||
* @name: The element name
|
||||
*
|
||||
* called when the end of an element has been detected.
|
||||
*
|
||||
* return values:
|
||||
*/
|
||||
void
|
||||
endElement(xmlParserCtxtPtr ctxt, const CHAR *name)
|
||||
@ -245,8 +231,6 @@ endElement(xmlParserCtxtPtr ctxt, const CHAR *name)
|
||||
* The default handling is to convert the attribute into an
|
||||
* DOM subtree and past it in a new xmlAttr element added to
|
||||
* the element.
|
||||
*
|
||||
* return values:
|
||||
*/
|
||||
void
|
||||
attribute(xmlParserCtxtPtr ctxt, const CHAR *name, const CHAR *value)
|
||||
@ -265,8 +249,6 @@ attribute(xmlParserCtxtPtr ctxt, const CHAR *name, const CHAR *value)
|
||||
*
|
||||
* receiving some chars from the parser.
|
||||
* Question: how much at a time ???
|
||||
*
|
||||
* return values:
|
||||
*/
|
||||
void
|
||||
characters(xmlParserCtxtPtr ctxt, const CHAR *ch, int start, int len)
|
||||
@ -304,8 +286,6 @@ characters(xmlParserCtxtPtr ctxt, const CHAR *ch, int start, int len)
|
||||
*
|
||||
* receiving some ignorable whitespaces from the parser.
|
||||
* Question: how much at a time ???
|
||||
*
|
||||
* return values:
|
||||
*/
|
||||
void
|
||||
ignorableWhitespace(xmlParserCtxtPtr ctxt, const CHAR *ch, int start, int len)
|
||||
@ -323,8 +303,6 @@ ignorableWhitespace(xmlParserCtxtPtr ctxt, const CHAR *ch, int start, int len)
|
||||
* @len: the number of CHAR
|
||||
*
|
||||
* A processing instruction has been parsed.
|
||||
*
|
||||
* return values:
|
||||
*/
|
||||
void
|
||||
processingInstruction(xmlParserCtxtPtr ctxt, const CHAR *target,
|
||||
|
@ -34,6 +34,13 @@ maintainer-clean-local: clean
|
||||
docdatadir = $(datadir)/aclocal
|
||||
docdata_DATA = xml.html structure.gif DOM.gif
|
||||
|
||||
gnome-xml-decl-list.txt : templates
|
||||
|
||||
gnome-xml-sections.txt : scan
|
||||
cp gnome-xml-decl-list.txt gnome-xml-sections.txt
|
||||
|
||||
rebuild: gnome-xml-sections.txt templates sgml html
|
||||
|
||||
#install-data-local:
|
||||
# install -d -m 0755 $(TARGET_DIR)
|
||||
# install -m 0644 xml.html structure.gif DOM.gif $(TARGET_DIR)
|
||||
|
@ -41,7 +41,7 @@
|
||||
*
|
||||
* Take a block of ISO Latin 1 chars in and try to convert it to an UTF-8
|
||||
* block of chars out.
|
||||
* return values: number of byte written, or -1 by lack of space.
|
||||
* Returns the number of byte written, or -1 by lack of space.
|
||||
*/
|
||||
int
|
||||
isolat1ToUTF8(unsigned char* out, int outlen, unsigned char* in, int inlen)
|
||||
@ -77,7 +77,7 @@ isolat1ToUTF8(unsigned char* out, int outlen, unsigned char* in, int inlen)
|
||||
* Take a block of UTF-8 chars in and try to convert it to an ISO Latin 1
|
||||
* block of chars out.
|
||||
* TODO: need a fallback mechanism ...
|
||||
* return values: the number of byte written, or -1 by lack of space, or -2
|
||||
* Returns the number of byte written, or -1 by lack of space, or -2
|
||||
* if the transcoding failed.
|
||||
*/
|
||||
int
|
||||
@ -112,7 +112,7 @@ UTF8Toisolat1(unsigned char* out, int outlen, unsigned char* in, int inlen)
|
||||
*
|
||||
* Take a block of UTF-16 ushorts in and try to convert it to an UTF-8
|
||||
* block of chars out.
|
||||
* return values: number of byte written, or -1 by lack of space.
|
||||
* Returns the number of byte written, or -1 by lack of space.
|
||||
*/
|
||||
int
|
||||
UTF16ToUTF8(unsigned char* out, int outlen, unsigned short* in, int inlen)
|
||||
@ -161,7 +161,7 @@ UTF16ToUTF8(unsigned char* out, int outlen, unsigned short* in, int inlen)
|
||||
* Take a block of UTF-8 chars in and try to convert it to an UTF-16
|
||||
* block of chars out.
|
||||
* TODO: need a fallback mechanism ...
|
||||
* return values: the number of byte written, or -1 by lack of space, or -2
|
||||
* Returns the number of byte written, or -1 by lack of space, or -2
|
||||
* if the transcoding failed.
|
||||
*/
|
||||
int
|
||||
|
12
entities.c
12
entities.c
@ -154,7 +154,7 @@ void xmlInitializePredefinedEntities(void) {
|
||||
*
|
||||
* Check whether this name is an predefined entity.
|
||||
*
|
||||
* return values: NULL if not, othervise the entity
|
||||
* Returns NULL if not, othervise the entity
|
||||
*/
|
||||
xmlEntityPtr
|
||||
xmlGetPredefinedEntity(const CHAR *name) {
|
||||
@ -241,7 +241,7 @@ xmlAddDocEntity(xmlDocPtr doc, const CHAR *name, int type,
|
||||
* Do an entity lookup in the Dtd entity hash table and
|
||||
* returns the corresponding entity, if found.
|
||||
*
|
||||
* return values: A pointer to the entity structure or NULL if not found.
|
||||
* Returns A pointer to the entity structure or NULL if not found.
|
||||
*/
|
||||
xmlEntityPtr
|
||||
xmlGetDtdEntity(xmlDocPtr doc, const CHAR *name) {
|
||||
@ -268,7 +268,7 @@ xmlGetDtdEntity(xmlDocPtr doc, const CHAR *name) {
|
||||
* returns the corrsponding entity, otherwise a lookup is done
|
||||
* in the predefined entities too.
|
||||
*
|
||||
* return values: A pointer to the entity structure or NULL if not found.
|
||||
* Returns A pointer to the entity structure or NULL if not found.
|
||||
*/
|
||||
xmlEntityPtr
|
||||
xmlGetDocEntity(xmlDocPtr doc, const CHAR *name) {
|
||||
@ -317,7 +317,7 @@ xmlGetDocEntity(xmlDocPtr doc, const CHAR *name) {
|
||||
* TODO This routine is not reentrant and this will be changed, the interface
|
||||
* should not be modified though.
|
||||
*
|
||||
* return values: A newly allocated string with the substitution done.
|
||||
* Returns A newly allocated string with the substitution done.
|
||||
*/
|
||||
CHAR *
|
||||
xmlEncodeEntities(xmlDocPtr doc, const CHAR *input) {
|
||||
@ -423,7 +423,7 @@ xmlEncodeEntities(xmlDocPtr doc, const CHAR *input) {
|
||||
*
|
||||
* create and initialize an empty entities hash table.
|
||||
*
|
||||
* return values: the xmlEntitiesTablePtr just created or NULL in case of error.
|
||||
* Returns the xmlEntitiesTablePtr just created or NULL in case of error.
|
||||
*/
|
||||
xmlEntitiesTablePtr
|
||||
xmlCreateEntitiesTable(void) {
|
||||
@ -474,7 +474,7 @@ xmlFreeEntitiesTable(xmlEntitiesTablePtr table) {
|
||||
*
|
||||
* Build a copy of an entity table.
|
||||
*
|
||||
* return values: the new xmlEntitiesTablePtr or NULL in case of error.
|
||||
* Returns the new xmlEntitiesTablePtr or NULL in case of error.
|
||||
*/
|
||||
xmlEntitiesTablePtr
|
||||
xmlCopyEntitiesTable(xmlEntitiesTablePtr table) {
|
||||
|
30
entities.h
30
entities.h
@ -34,7 +34,8 @@ typedef struct xmlEntity {
|
||||
const CHAR *ExternalID; /* External identifier for PUBLIC Entity */
|
||||
const CHAR *SystemID; /* URI for a SYSTEM or PUBLIC Entity */
|
||||
CHAR *content; /* The entity content or ndata if unparsed */
|
||||
} xmlEntity, *xmlEntityPtr;
|
||||
} xmlEntity;
|
||||
typedef xmlEntity *xmlEntityPtr;
|
||||
|
||||
/*
|
||||
* ALl entities are stored in a table there is one table per DTD
|
||||
@ -47,28 +48,29 @@ typedef struct xmlEntitiesTable {
|
||||
int nb_entities; /* number of elements stored */
|
||||
int max_entities; /* maximum number of elements */
|
||||
xmlEntityPtr table; /* the table of entities */
|
||||
} xmlEntitiesTable, *xmlEntitiesTablePtr;
|
||||
} xmlEntitiesTable;
|
||||
typedef xmlEntitiesTable *xmlEntitiesTablePtr;
|
||||
|
||||
|
||||
/*
|
||||
* External functions :
|
||||
*/
|
||||
|
||||
extern void xmlAddDocEntity(xmlDocPtr doc, const CHAR *name, int type,
|
||||
void xmlAddDocEntity(xmlDocPtr doc, const CHAR *name, int type,
|
||||
const CHAR *ExternalID, const CHAR *SystemID, CHAR *content);
|
||||
extern void xmlAddDtdEntity(xmlDocPtr doc, const CHAR *name, int type,
|
||||
void xmlAddDtdEntity(xmlDocPtr doc, const CHAR *name, int type,
|
||||
const CHAR *ExternalID, const CHAR *SystemID, CHAR *content);
|
||||
extern xmlEntityPtr xmlGetPredefinedEntity(const CHAR *name);
|
||||
extern xmlEntityPtr xmlGetDocEntity(xmlDocPtr doc, const CHAR *name);
|
||||
extern xmlEntityPtr xmlGetDtdEntity(xmlDocPtr doc, const CHAR *name);
|
||||
extern CHAR *xmlEncodeEntities(xmlDocPtr doc, const CHAR *input);
|
||||
extern xmlEntitiesTablePtr xmlCreateEntitiesTable(void);
|
||||
extern xmlEntitiesTablePtr xmlCopyEntitiesTable(xmlEntitiesTablePtr table);
|
||||
extern void xmlFreeEntitiesTable(xmlEntitiesTablePtr table);
|
||||
extern void xmlDumpEntitiesTable(xmlEntitiesTablePtr table);
|
||||
extern xmlParserInputPtr xmlNewEntityInputStream(xmlParserCtxtPtr ctxt,
|
||||
xmlEntityPtr xmlGetPredefinedEntity(const CHAR *name);
|
||||
xmlEntityPtr xmlGetDocEntity(xmlDocPtr doc, const CHAR *name);
|
||||
xmlEntityPtr xmlGetDtdEntity(xmlDocPtr doc, const CHAR *name);
|
||||
CHAR *xmlEncodeEntities(xmlDocPtr doc, const CHAR *input);
|
||||
xmlEntitiesTablePtr xmlCreateEntitiesTable(void);
|
||||
xmlEntitiesTablePtr xmlCopyEntitiesTable(xmlEntitiesTablePtr table);
|
||||
void xmlFreeEntitiesTable(xmlEntitiesTablePtr table);
|
||||
void xmlDumpEntitiesTable(xmlEntitiesTablePtr table);
|
||||
xmlParserInputPtr xmlNewEntityInputStream(xmlParserCtxtPtr ctxt,
|
||||
xmlEntityPtr entity);
|
||||
extern xmlEntitiesTablePtr xmlCopyEntitiesTable(xmlEntitiesTablePtr table);
|
||||
xmlEntitiesTablePtr xmlCopyEntitiesTable(xmlEntitiesTablePtr table);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
6
error.c
6
error.c
@ -38,12 +38,12 @@ xmlParserError(xmlParserCtxtPtr ctxt, const char *msg, ...)
|
||||
va_end(ap);
|
||||
cur = ctxt->input->cur;
|
||||
base = ctxt->input->base;
|
||||
while ((*cur == '\n') || (*cur == '\r')) {
|
||||
while ((cur > base) && ((*cur == '\n') || (*cur == '\r'))) {
|
||||
cur--;
|
||||
base--;
|
||||
}
|
||||
n = 0;
|
||||
while ((n++ < 60) && (cur >= base) && (*cur != '\n') && (*cur != '\r'))
|
||||
while ((n++ < 60) && (cur > base) && (*cur != '\n') && (*cur != '\r'))
|
||||
cur--;
|
||||
if ((*cur == '\n') || (*cur == '\r')) cur++;
|
||||
base = cur;
|
||||
@ -93,7 +93,7 @@ xmlParserWarning(xmlParserCtxtPtr ctxt, const char *msg, ...)
|
||||
cur = ctxt->input->cur;
|
||||
base = ctxt->input->base;
|
||||
n = 0;
|
||||
while ((n++ < 60) && (cur >= base) && (*cur != '\n') && (*cur != '\r'))
|
||||
while ((n++ < 60) && (cur > base) && (*cur != '\n') && (*cur != '\r'))
|
||||
cur--;
|
||||
if ((*cur != '\n') || (*cur != '\r')) cur++;
|
||||
base = cur;
|
||||
|
@ -34,7 +34,8 @@ typedef struct xmlEntity {
|
||||
const CHAR *ExternalID; /* External identifier for PUBLIC Entity */
|
||||
const CHAR *SystemID; /* URI for a SYSTEM or PUBLIC Entity */
|
||||
CHAR *content; /* The entity content or ndata if unparsed */
|
||||
} xmlEntity, *xmlEntityPtr;
|
||||
} xmlEntity;
|
||||
typedef xmlEntity *xmlEntityPtr;
|
||||
|
||||
/*
|
||||
* ALl entities are stored in a table there is one table per DTD
|
||||
@ -47,28 +48,29 @@ typedef struct xmlEntitiesTable {
|
||||
int nb_entities; /* number of elements stored */
|
||||
int max_entities; /* maximum number of elements */
|
||||
xmlEntityPtr table; /* the table of entities */
|
||||
} xmlEntitiesTable, *xmlEntitiesTablePtr;
|
||||
} xmlEntitiesTable;
|
||||
typedef xmlEntitiesTable *xmlEntitiesTablePtr;
|
||||
|
||||
|
||||
/*
|
||||
* External functions :
|
||||
*/
|
||||
|
||||
extern void xmlAddDocEntity(xmlDocPtr doc, const CHAR *name, int type,
|
||||
void xmlAddDocEntity(xmlDocPtr doc, const CHAR *name, int type,
|
||||
const CHAR *ExternalID, const CHAR *SystemID, CHAR *content);
|
||||
extern void xmlAddDtdEntity(xmlDocPtr doc, const CHAR *name, int type,
|
||||
void xmlAddDtdEntity(xmlDocPtr doc, const CHAR *name, int type,
|
||||
const CHAR *ExternalID, const CHAR *SystemID, CHAR *content);
|
||||
extern xmlEntityPtr xmlGetPredefinedEntity(const CHAR *name);
|
||||
extern xmlEntityPtr xmlGetDocEntity(xmlDocPtr doc, const CHAR *name);
|
||||
extern xmlEntityPtr xmlGetDtdEntity(xmlDocPtr doc, const CHAR *name);
|
||||
extern CHAR *xmlEncodeEntities(xmlDocPtr doc, const CHAR *input);
|
||||
extern xmlEntitiesTablePtr xmlCreateEntitiesTable(void);
|
||||
extern xmlEntitiesTablePtr xmlCopyEntitiesTable(xmlEntitiesTablePtr table);
|
||||
extern void xmlFreeEntitiesTable(xmlEntitiesTablePtr table);
|
||||
extern void xmlDumpEntitiesTable(xmlEntitiesTablePtr table);
|
||||
extern xmlParserInputPtr xmlNewEntityInputStream(xmlParserCtxtPtr ctxt,
|
||||
xmlEntityPtr xmlGetPredefinedEntity(const CHAR *name);
|
||||
xmlEntityPtr xmlGetDocEntity(xmlDocPtr doc, const CHAR *name);
|
||||
xmlEntityPtr xmlGetDtdEntity(xmlDocPtr doc, const CHAR *name);
|
||||
CHAR *xmlEncodeEntities(xmlDocPtr doc, const CHAR *input);
|
||||
xmlEntitiesTablePtr xmlCreateEntitiesTable(void);
|
||||
xmlEntitiesTablePtr xmlCopyEntitiesTable(xmlEntitiesTablePtr table);
|
||||
void xmlFreeEntitiesTable(xmlEntitiesTablePtr table);
|
||||
void xmlDumpEntitiesTable(xmlEntitiesTablePtr table);
|
||||
xmlParserInputPtr xmlNewEntityInputStream(xmlParserCtxtPtr ctxt,
|
||||
xmlEntityPtr entity);
|
||||
extern xmlEntitiesTablePtr xmlCopyEntitiesTable(xmlEntitiesTablePtr table);
|
||||
xmlEntitiesTablePtr xmlCopyEntitiesTable(xmlEntitiesTablePtr table);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -26,24 +26,28 @@ typedef struct xmlParserInput {
|
||||
const CHAR *cur; /* Current char being parsed */
|
||||
int line; /* Current line */
|
||||
int col; /* Current column */
|
||||
} xmlParserInput, *xmlParserInputPtr;
|
||||
} xmlParserInput;
|
||||
typedef xmlParserInput *xmlParserInputPtr;
|
||||
|
||||
typedef struct xmlParserNodeInfo {
|
||||
typedef struct _xmlParserNodeInfo {
|
||||
const struct xmlNode* node;
|
||||
/* Position & line # that text that created the node begins & ends on */
|
||||
unsigned long begin_pos;
|
||||
unsigned long begin_line;
|
||||
unsigned long end_pos;
|
||||
unsigned long end_line;
|
||||
} xmlParserNodeInfo;
|
||||
} _xmlParserNodeInfo;
|
||||
typedef _xmlParserNodeInfo xmlParserNodeInfo;
|
||||
|
||||
typedef struct xmlParserNodeInfoSeq {
|
||||
unsigned long maximum;
|
||||
unsigned long length;
|
||||
xmlParserNodeInfo* buffer;
|
||||
} xmlParserNodeInfoSeq, *xmlParserNodeInfoSeqPtr;
|
||||
} _xmlParserNodeInfoSeq;
|
||||
typedef _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
|
||||
typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
|
||||
|
||||
typedef struct xmlParserCtxt {
|
||||
typedef struct _xmlParserCtxt {
|
||||
struct xmlSAXHandler *sax; /* The SAX handler */
|
||||
xmlDocPtr doc; /* the document being built */
|
||||
int wellFormed; /* is the document well formed */
|
||||
@ -62,7 +66,9 @@ typedef struct xmlParserCtxt {
|
||||
|
||||
int record_info; /* Whether node info should be kept */
|
||||
xmlParserNodeInfoSeq node_seq; /* info about each node parsed */
|
||||
} xmlParserCtxt, *xmlParserCtxtPtr;
|
||||
} _xmlParserCtxt;
|
||||
typedef _xmlParserCtxt xmlParserCtxt;
|
||||
typedef xmlParserCtxt *xmlParserCtxtPtr;
|
||||
|
||||
/*
|
||||
* a SAX Locator.
|
||||
@ -73,7 +79,9 @@ typedef struct xmlSAXLocator {
|
||||
const CHAR *(*getSystemId)(xmlParserCtxtPtr ctxt);
|
||||
int (*getLineNumber)(xmlParserCtxtPtr ctxt);
|
||||
int (*getColumnNumber)(xmlParserCtxtPtr ctxt);
|
||||
} xmlSAXLocator, *xmlSAXLocatorPtr;
|
||||
} _xmlSAXLocator;
|
||||
typedef _xmlSAXLocator xmlSAXLocator;
|
||||
typedef xmlSAXLocator *xmlSAXLocatorPtr;
|
||||
|
||||
/*
|
||||
* a SAX Exception.
|
||||
@ -120,7 +128,8 @@ typedef struct xmlSAXHandler {
|
||||
warningSAXFunc warning;
|
||||
errorSAXFunc error;
|
||||
fatalErrorSAXFunc fatalError;
|
||||
} xmlSAXHandler, *xmlSAXHandlerPtr;
|
||||
} xmlSAXHandler;
|
||||
typedef xmlSAXHandler *xmlSAXHandlerPtr;
|
||||
|
||||
/*
|
||||
* Global variables: just the SAX interface tables we are looking for full
|
||||
@ -130,61 +139,58 @@ extern xmlSAXLocator xmlDefaultSAXLocator;
|
||||
extern xmlSAXHandler xmlDefaultSAXHandler;
|
||||
|
||||
#include "entities.h"
|
||||
#include "error.h"
|
||||
|
||||
/*
|
||||
* CHAR handling
|
||||
*/
|
||||
extern CHAR *xmlStrdup(const CHAR *input);
|
||||
extern CHAR *xmlStrndup(const CHAR *input, int n);
|
||||
extern CHAR *xmlStrchr(const CHAR *str, CHAR val);
|
||||
extern int xmlStrcmp(const CHAR *str1, const CHAR *str2);
|
||||
extern int xmlStrncmp(const CHAR *str1, const CHAR *str2, int len);
|
||||
extern int xmlStrlen(const CHAR *str);
|
||||
extern CHAR *xmlStrcat(CHAR *cur, const CHAR *add);
|
||||
extern CHAR *xmlStrncat(CHAR *cur, const CHAR *add, int len);
|
||||
CHAR *xmlStrdup(const CHAR *cur);
|
||||
CHAR *xmlStrndup(const CHAR *cur, int len);
|
||||
CHAR *xmlStrchr(const CHAR *str, CHAR val);
|
||||
int xmlStrcmp(const CHAR *str1, const CHAR *str2);
|
||||
int xmlStrncmp(const CHAR *str1, const CHAR *str2, int len);
|
||||
int xmlStrlen(const CHAR *str);
|
||||
CHAR *xmlStrcat(CHAR *cur, const CHAR *add);
|
||||
CHAR *xmlStrncat(CHAR *cur, const CHAR *add, int len);
|
||||
|
||||
/*
|
||||
* Interfaces
|
||||
*/
|
||||
extern xmlDocPtr xmlParseDoc(CHAR *cur);
|
||||
extern xmlDocPtr xmlParseMemory(char *buffer, int size);
|
||||
extern xmlDocPtr xmlParseFile(const char *filename);
|
||||
xmlDocPtr xmlParseDoc(CHAR *cur);
|
||||
xmlDocPtr xmlParseMemory(char *buffer, int size);
|
||||
xmlDocPtr xmlParseFile(const char *filename);
|
||||
|
||||
/*
|
||||
* Recovery mode
|
||||
*/
|
||||
extern xmlDocPtr xmlRecoverDoc(CHAR *cur);
|
||||
extern xmlDocPtr xmlRecoverMemory(char *buffer, int size);
|
||||
extern xmlDocPtr xmlRecoverFile(const char *filename);
|
||||
xmlDocPtr xmlRecoverDoc(CHAR *cur);
|
||||
xmlDocPtr xmlRecoverMemory(char *buffer, int size);
|
||||
xmlDocPtr xmlRecoverFile(const char *filename);
|
||||
|
||||
/*
|
||||
* Internal routines
|
||||
*/
|
||||
extern int xmlParseDocument(xmlParserCtxtPtr ctxt);
|
||||
extern xmlDocPtr xmlSAXParseDoc(xmlSAXHandlerPtr sax, CHAR *cur, int recovery);
|
||||
extern xmlDocPtr xmlSAXParseMemory(xmlSAXHandlerPtr sax, char *buffer,
|
||||
int xmlParseDocument(xmlParserCtxtPtr ctxt);
|
||||
xmlDocPtr xmlSAXParseDoc(xmlSAXHandlerPtr sax, CHAR *cur, int recovery);
|
||||
xmlDocPtr xmlSAXParseMemory(xmlSAXHandlerPtr sax, char *buffer,
|
||||
int size, int recovery);
|
||||
extern xmlDocPtr xmlSAXParseFile(xmlSAXHandlerPtr sax, const char *filename,
|
||||
xmlDocPtr xmlSAXParseFile(xmlSAXHandlerPtr sax, const char *filename,
|
||||
int recovery);
|
||||
extern void xmlInitParserCtxt(xmlParserCtxtPtr ctx);
|
||||
extern void xmlClearParserCtxt(xmlParserCtxtPtr ctx);
|
||||
extern void xmlSetupParserForBuffer(xmlParserCtxtPtr ctx, const CHAR* buffer,
|
||||
void xmlInitParserCtxt(xmlParserCtxtPtr ctxt);
|
||||
void xmlClearParserCtxt(xmlParserCtxtPtr ctxt);
|
||||
void xmlSetupParserForBuffer(xmlParserCtxtPtr ctxt, const CHAR* buffer,
|
||||
const char* filename);
|
||||
|
||||
extern void xmlParserError(xmlParserCtxtPtr ctxt, const char *msg, ...);
|
||||
|
||||
extern const xmlParserNodeInfo* xmlParserFindNodeInfo(const xmlParserCtxt* c,
|
||||
const xmlNode* node);
|
||||
extern void xmlInitNodeInfoSeq(xmlParserNodeInfoSeqPtr seq);
|
||||
extern void xmlClearNodeInfoSeq(xmlParserNodeInfoSeqPtr seq);
|
||||
const xmlParserNodeInfo* xmlParserFindNodeInfo(const xmlParserCtxt* ctxt,
|
||||
const xmlNode* node);
|
||||
void xmlInitNodeInfoSeq(xmlParserNodeInfoSeqPtr seq);
|
||||
void xmlClearNodeInfoSeq(xmlParserNodeInfoSeqPtr seq);
|
||||
unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeq* seq,
|
||||
const xmlNode* node);
|
||||
extern void xmlParserAddNodeInfo(xmlParserCtxtPtr ctx,
|
||||
const xmlParserNodeInfo* info);
|
||||
void xmlParserAddNodeInfo(xmlParserCtxtPtr ctxt,
|
||||
const xmlParserNodeInfo* info);
|
||||
|
||||
extern void xmlParserWarning(xmlParserCtxtPtr ctxt, const char *msg, ...);
|
||||
extern void xmlParserError(xmlParserCtxtPtr ctxt, const char *msg, ...);
|
||||
extern void xmlDefaultSAXHandlerInit(void);
|
||||
void xmlDefaultSAXHandlerInit(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
128
include/libxml/parserInternals.h
Normal file
128
include/libxml/parserInternals.h
Normal file
@ -0,0 +1,128 @@
|
||||
/*
|
||||
* parserInternals.h : internals routines exported by the parser.
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __XML_PARSER_INTERNALS_H__
|
||||
#define __XML_PARSER_INTERNALS_H__
|
||||
|
||||
#include "parser.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Entities
|
||||
*/
|
||||
void
|
||||
xmlHandleEntity(xmlParserCtxtPtr ctxt, xmlEntityPtr entity);
|
||||
|
||||
/*
|
||||
* Namespaces.
|
||||
*/
|
||||
CHAR *
|
||||
xmlNamespaceParseNCName(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlNamespaceParseQName(xmlParserCtxtPtr ctxt, CHAR **prefix);
|
||||
CHAR *
|
||||
xmlNamespaceParseNSDef(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParseQuotedString(xmlParserCtxtPtr ctxt);
|
||||
void
|
||||
xmlParseNamespace(xmlParserCtxtPtr ctxt);
|
||||
|
||||
/*
|
||||
* Generic production rules
|
||||
*/
|
||||
CHAR *
|
||||
xmlParseName(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParseNmtoken(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParseEntityValue(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParseAttValue(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParseSystemLiteral(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParsePubidLiteral(xmlParserCtxtPtr ctxt);
|
||||
void
|
||||
xmlParseCharData(xmlParserCtxtPtr ctxt, int cdata);
|
||||
CHAR *
|
||||
xmlParseExternalID(xmlParserCtxtPtr ctxt, CHAR **publicID, int strict);
|
||||
xmlNodePtr
|
||||
xmlParseComment(xmlParserCtxtPtr ctxt, int create);
|
||||
CHAR *
|
||||
xmlParsePITarget(xmlParserCtxtPtr ctxt);
|
||||
void
|
||||
xmlParsePI(xmlParserCtxtPtr ctxt);
|
||||
void
|
||||
xmlParseNotationDecl(xmlParserCtxtPtr ctxt);
|
||||
void
|
||||
xmlParseEntityDecl(xmlParserCtxtPtr ctxt);
|
||||
int
|
||||
xmlParseDefaultDecl(xmlParserCtxtPtr ctxt, CHAR **value);
|
||||
xmlEnumerationPtr
|
||||
xmlParseNotationType(xmlParserCtxtPtr ctxt);
|
||||
xmlEnumerationPtr
|
||||
xmlParseEnumerationType(xmlParserCtxtPtr ctxt);
|
||||
int
|
||||
xmlParseEnumeratedType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree);
|
||||
int
|
||||
xmlParseAttributeType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree);
|
||||
void
|
||||
xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt);
|
||||
xmlElementContentPtr
|
||||
xmlParseElementMixedContentDecl(xmlParserCtxtPtr ctxt);
|
||||
xmlElementContentPtr
|
||||
xmlParseElementChildrenContentDecl(xmlParserCtxtPtr ctxt);
|
||||
int
|
||||
xmlParseElementContentDecl(xmlParserCtxtPtr ctxt, CHAR *name,
|
||||
xmlElementContentPtr *result);
|
||||
int
|
||||
xmlParseElementDecl(xmlParserCtxtPtr ctxt);
|
||||
void
|
||||
xmlParseMarkupDecl(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParseCharRef(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParseEntityRef(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParseReference(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParsePEReference(xmlParserCtxtPtr ctxt);
|
||||
void
|
||||
xmlParseDocTypeDecl(xmlParserCtxtPtr ctxt);
|
||||
xmlAttrPtr
|
||||
xmlParseAttribute(xmlParserCtxtPtr ctxt, xmlNodePtr node);
|
||||
xmlNodePtr
|
||||
xmlParseStartTag(xmlParserCtxtPtr ctxt);
|
||||
void
|
||||
xmlParseEndTag(xmlParserCtxtPtr ctxt, xmlNsPtr *nsPtr, CHAR **tagPtr);
|
||||
void
|
||||
xmlParseCDSect(xmlParserCtxtPtr ctxt);
|
||||
void
|
||||
xmlParseContent(xmlParserCtxtPtr ctxt);
|
||||
xmlNodePtr
|
||||
xmlParseElement(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParseVersionNum(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParseVersionInfo(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParseEncName(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParseEncodingDecl(xmlParserCtxtPtr ctxt);
|
||||
int
|
||||
xmlParseSDDecl(xmlParserCtxtPtr ctxt);
|
||||
void
|
||||
xmlParseXMLDecl(xmlParserCtxtPtr ctxt);
|
||||
void
|
||||
xmlParseMisc(xmlParserCtxtPtr ctxt);
|
||||
|
||||
|
||||
#endif /* __XML_PARSER_INTERNALS_H__ */
|
@ -55,41 +55,67 @@ typedef unsigned char CHAR;
|
||||
|
||||
/*
|
||||
* a DTD Notation definition
|
||||
* TODO !!!!
|
||||
*/
|
||||
|
||||
typedef struct xmlNotation {
|
||||
const CHAR *name; /* Notation name */
|
||||
const CHAR *PublicID; /* Public identifier, if any */
|
||||
const CHAR *SystemID; /* System identifier, if any */
|
||||
} xmlNotation;
|
||||
typedef xmlNotation *xmlNotationPtr;
|
||||
|
||||
/*
|
||||
* a DTD Attribute definition
|
||||
* TODO !!!!
|
||||
*/
|
||||
|
||||
#define XML_ATTRIBUTE_NONE 1
|
||||
#define XML_ATTRIBUTE_REQUIRED 2
|
||||
#define XML_ATTRIBUTE_IMPLIED 3
|
||||
#define XML_ATTRIBUTE_FIXED 4
|
||||
typedef enum {
|
||||
XML_ATTRIBUTE_CDATA = 1,
|
||||
XML_ATTRIBUTE_ID,
|
||||
XML_ATTRIBUTE_IDREF ,
|
||||
XML_ATTRIBUTE_IDREFS,
|
||||
XML_ATTRIBUTE_ENTITY,
|
||||
XML_ATTRIBUTE_ENTITIES,
|
||||
XML_ATTRIBUTE_NMTOKEN,
|
||||
XML_ATTRIBUTE_NMTOKENS,
|
||||
XML_ATTRIBUTE_ENUMERATION,
|
||||
XML_ATTRIBUTE_NOTATION
|
||||
} xmlAttributeType;
|
||||
|
||||
#define XML_ATTRIBUTE_STRING 1
|
||||
#define XML_ATTRIBUTE_ID 2
|
||||
#define XML_ATTRIBUTE_IDREF 3
|
||||
#define XML_ATTRIBUTE_IDREFS 4
|
||||
#define XML_ATTRIBUTE_ENTITY 5
|
||||
#define XML_ATTRIBUTE_ENTITIES 6
|
||||
#define XML_ATTRIBUTE_NMTOKEN 7
|
||||
#define XML_ATTRIBUTE_NMTOKENS 8
|
||||
#define XML_ATTRIBUTE_ENUMERATED 9
|
||||
typedef enum {
|
||||
XML_ATTRIBUTE_NONE = 1,
|
||||
XML_ATTRIBUTE_REQUIRED,
|
||||
XML_ATTRIBUTE_IMPLIED,
|
||||
XML_ATTRIBUTE_FIXED
|
||||
} xmlAttributeDefault;
|
||||
|
||||
typedef struct xmlEnumeration {
|
||||
struct xmlEnumeration *next; /* next one */
|
||||
const CHAR *name; /* Enumeration name */
|
||||
} xmlEnumeration;
|
||||
typedef xmlEnumeration *xmlEnumerationPtr;
|
||||
|
||||
typedef struct xmlAttribute {
|
||||
const CHAR *elem; /* Element holding the attribute */
|
||||
const CHAR *name; /* Attribute name */
|
||||
xmlAttributeType type; /* The type */
|
||||
xmlAttributeDefault def; /* the default */
|
||||
const CHAR *defaultValue;/* or the default value */
|
||||
xmlEnumerationPtr tree; /* or the enumeration tree if any */
|
||||
} xmlAttribute;
|
||||
typedef xmlAttribute *xmlAttributePtr;
|
||||
|
||||
/*
|
||||
* a DTD Element definition.
|
||||
*/
|
||||
typedef enum {
|
||||
XML_ELEMENT_CONTENT_PCDATA=1,
|
||||
XML_ELEMENT_CONTENT_PCDATA = 1,
|
||||
XML_ELEMENT_CONTENT_ELEMENT,
|
||||
XML_ELEMENT_CONTENT_SEQ,
|
||||
XML_ELEMENT_CONTENT_OR
|
||||
} xmlElementContentType;
|
||||
|
||||
typedef enum {
|
||||
XML_ELEMENT_CONTENT_ONCE=1,
|
||||
XML_ELEMENT_CONTENT_ONCE = 1,
|
||||
XML_ELEMENT_CONTENT_OPT,
|
||||
XML_ELEMENT_CONTENT_MULT,
|
||||
XML_ELEMENT_CONTENT_PLUS
|
||||
@ -101,10 +127,11 @@ typedef struct xmlElementContent {
|
||||
const CHAR *name; /* Element name */
|
||||
struct xmlElementContent *c1; /* first child */
|
||||
struct xmlElementContent *c2; /* second child */
|
||||
} xmlElementContent, *xmlElementContentPtr;
|
||||
} xmlElementContent;
|
||||
typedef xmlElementContent *xmlElementContentPtr;
|
||||
|
||||
typedef enum {
|
||||
XML_ELEMENT_TYPE_EMPTY=1,
|
||||
XML_ELEMENT_TYPE_EMPTY = 1,
|
||||
XML_ELEMENT_TYPE_ANY,
|
||||
XML_ELEMENT_TYPE_MIXED,
|
||||
XML_ELEMENT_TYPE_ELEMENT
|
||||
@ -114,7 +141,8 @@ typedef struct xmlElement {
|
||||
const CHAR *name; /* Element name */
|
||||
xmlElementTypeVal type; /* The type */
|
||||
xmlElementContentPtr content; /* the allowed element content */
|
||||
} xmlElement, *xmlElementPtr;
|
||||
} xmlElement;
|
||||
typedef xmlElement *xmlElementPtr;
|
||||
|
||||
/*
|
||||
* An XML namespace.
|
||||
@ -123,7 +151,7 @@ typedef struct xmlElement {
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
XML_GLOBAL_NAMESPACE=1, /* old style global namespace */
|
||||
XML_GLOBAL_NAMESPACE = 1, /* old style global namespace */
|
||||
XML_LOCAL_NAMESPACE /* new style local scoping */
|
||||
} xmlNsType;
|
||||
|
||||
@ -132,7 +160,8 @@ typedef struct xmlNs {
|
||||
xmlNsType type; /* global or local */
|
||||
const CHAR *href; /* URL for the namespace */
|
||||
const CHAR *prefix; /* prefix for the namespace */
|
||||
} xmlNs, *xmlNsPtr;
|
||||
} xmlNs;
|
||||
typedef xmlNs *xmlNsPtr;
|
||||
|
||||
/*
|
||||
* An XML DtD, as defined by <!DOCTYPE.
|
||||
@ -141,10 +170,13 @@ typedef struct xmlDtd {
|
||||
const CHAR *name; /* Name of the DTD */
|
||||
const CHAR *ExternalID; /* External identifier for PUBLIC DTD */
|
||||
const CHAR *SystemID; /* URI for a SYSTEM or PUBLIC DTD */
|
||||
void *notations; /* Hash table for notations if any */
|
||||
void *elements; /* Hash table for elements if any */
|
||||
void *attributes; /* Hash table for attributes if any */
|
||||
void *entities; /* Hash table for entities if any */
|
||||
/* struct xmlDtd *next; * next link for this document */
|
||||
} xmlDtd, *xmlDtdPtr;
|
||||
} xmlDtd;
|
||||
typedef xmlDtd *xmlDtdPtr;
|
||||
|
||||
/*
|
||||
* A attribute of an XML node.
|
||||
@ -159,7 +191,8 @@ typedef struct xmlAttr {
|
||||
struct xmlAttr *next; /* parent->childs link */
|
||||
const CHAR *name; /* the name of the property */
|
||||
struct xmlNode *val; /* the value of the property */
|
||||
} xmlAttr, *xmlAttrPtr;
|
||||
} xmlAttr;
|
||||
typedef xmlAttr *xmlAttrPtr;
|
||||
|
||||
/*
|
||||
* A node in an XML tree.
|
||||
@ -181,7 +214,9 @@ typedef struct xmlNode {
|
||||
xmlNs *ns; /* pointer to the associated namespace */
|
||||
xmlNs *nsDef; /* namespace definitions on this node */
|
||||
CHAR *content; /* the content */
|
||||
} xmlNode, *xmlNodePtr;
|
||||
} _xmlNode;
|
||||
typedef _xmlNode xmlNode;
|
||||
typedef _xmlNode *xmlNodePtr;
|
||||
|
||||
/*
|
||||
* An XML document.
|
||||
@ -201,7 +236,9 @@ typedef struct xmlDoc {
|
||||
struct xmlDtd *extSubset; /* the document external subset */
|
||||
struct xmlNs *oldNs; /* Global namespace, the old way */
|
||||
struct xmlNode *root; /* the document tree */
|
||||
} xmlDoc, *xmlDocPtr;
|
||||
} _xmlDoc;
|
||||
typedef _xmlDoc xmlDoc;
|
||||
typedef xmlDoc *xmlDocPtr;
|
||||
|
||||
/*
|
||||
* Variables.
|
||||
@ -213,110 +250,110 @@ extern int xmlIndentTreeOutput; /* try to indent the tree dumps */
|
||||
/*
|
||||
* Creating/freeing new structures
|
||||
*/
|
||||
extern xmlDtdPtr xmlCreateIntSubset(xmlDocPtr doc, const CHAR *name,
|
||||
xmlDtdPtr xmlCreateIntSubset(xmlDocPtr doc, const CHAR *name,
|
||||
const CHAR *ExternalID, const CHAR *SystemID);
|
||||
extern xmlDtdPtr xmlNewDtd(xmlDocPtr doc, const CHAR *name,
|
||||
xmlDtdPtr xmlNewDtd(xmlDocPtr doc, const CHAR *name,
|
||||
const CHAR *ExternalID, const CHAR *SystemID);
|
||||
extern void xmlFreeDtd(xmlDtdPtr cur);
|
||||
extern xmlNsPtr xmlNewGlobalNs(xmlDocPtr doc, const CHAR *href, const CHAR *AS);
|
||||
extern xmlNsPtr xmlNewNs(xmlNodePtr node, const CHAR *href, const CHAR *AS);
|
||||
extern void xmlFreeNs(xmlNsPtr cur);
|
||||
extern xmlDocPtr xmlNewDoc(const CHAR *version);
|
||||
extern void xmlFreeDoc(xmlDocPtr cur);
|
||||
extern xmlAttrPtr xmlNewDocProp(xmlDocPtr doc, const CHAR *name,
|
||||
void xmlFreeDtd(xmlDtdPtr cur);
|
||||
xmlNsPtr xmlNewGlobalNs(xmlDocPtr doc, const CHAR *href, const CHAR *prefix);
|
||||
xmlNsPtr xmlNewNs(xmlNodePtr node, const CHAR *href, const CHAR *prefix);
|
||||
void xmlFreeNs(xmlNsPtr cur);
|
||||
xmlDocPtr xmlNewDoc(const CHAR *version);
|
||||
void xmlFreeDoc(xmlDocPtr cur);
|
||||
xmlAttrPtr xmlNewDocProp(xmlDocPtr doc, const CHAR *name,
|
||||
const CHAR *value);
|
||||
extern xmlAttrPtr xmlNewProp(xmlNodePtr node, const CHAR *name,
|
||||
xmlAttrPtr xmlNewProp(xmlNodePtr node, const CHAR *name,
|
||||
const CHAR *value);
|
||||
extern void xmlFreePropList(xmlAttrPtr cur);
|
||||
extern void xmlFreeProp(xmlAttrPtr cur);
|
||||
extern xmlAttrPtr xmlCopyProp(xmlAttrPtr cur);
|
||||
extern xmlAttrPtr xmlCopyPropList(xmlAttrPtr cur);
|
||||
extern xmlDtdPtr xmlCopyDtd(xmlDtdPtr dtd);
|
||||
extern xmlDocPtr xmlCopyDoc(xmlDocPtr doc, int recursive);
|
||||
void xmlFreePropList(xmlAttrPtr cur);
|
||||
void xmlFreeProp(xmlAttrPtr cur);
|
||||
xmlAttrPtr xmlCopyProp(xmlAttrPtr cur);
|
||||
xmlAttrPtr xmlCopyPropList(xmlAttrPtr cur);
|
||||
xmlDtdPtr xmlCopyDtd(xmlDtdPtr dtd);
|
||||
xmlDocPtr xmlCopyDoc(xmlDocPtr doc, int recursive);
|
||||
|
||||
/*
|
||||
* Creating new nodes
|
||||
*/
|
||||
extern xmlNodePtr xmlNewDocNode(xmlDocPtr doc, xmlNsPtr ns,
|
||||
xmlNodePtr xmlNewDocNode(xmlDocPtr doc, xmlNsPtr ns,
|
||||
const CHAR *name, CHAR *content);
|
||||
extern xmlNodePtr xmlNewNode(xmlNsPtr ns, const CHAR *name);
|
||||
extern xmlNodePtr xmlNewChild(xmlNodePtr parent, xmlNsPtr ns,
|
||||
xmlNodePtr xmlNewNode(xmlNsPtr ns, const CHAR *name);
|
||||
xmlNodePtr xmlNewChild(xmlNodePtr parent, xmlNsPtr ns,
|
||||
const CHAR *name, CHAR *content);
|
||||
extern xmlNodePtr xmlNewDocText(xmlDocPtr doc, const CHAR *content);
|
||||
extern xmlNodePtr xmlNewText(const CHAR *content);
|
||||
extern xmlNodePtr xmlNewDocTextLen(xmlDocPtr doc, const CHAR *content, int len);
|
||||
extern xmlNodePtr xmlNewTextLen(const CHAR *content, int len);
|
||||
extern xmlNodePtr xmlNewDocComment(xmlDocPtr doc, CHAR *content);
|
||||
extern xmlNodePtr xmlNewComment(CHAR *content);
|
||||
extern xmlNodePtr xmlNewReference(xmlDocPtr doc, const CHAR *name);
|
||||
extern xmlNodePtr xmlCopyNode(xmlNodePtr node, int recursive);
|
||||
extern xmlNodePtr xmlCopyNodeList(xmlNodePtr node);
|
||||
xmlNodePtr xmlNewDocText(xmlDocPtr doc, const CHAR *content);
|
||||
xmlNodePtr xmlNewText(const CHAR *content);
|
||||
xmlNodePtr xmlNewDocTextLen(xmlDocPtr doc, const CHAR *content, int len);
|
||||
xmlNodePtr xmlNewTextLen(const CHAR *content, int len);
|
||||
xmlNodePtr xmlNewDocComment(xmlDocPtr doc, CHAR *content);
|
||||
xmlNodePtr xmlNewComment(CHAR *content);
|
||||
xmlNodePtr xmlNewReference(xmlDocPtr doc, const CHAR *name);
|
||||
xmlNodePtr xmlCopyNode(xmlNodePtr node, int recursive);
|
||||
xmlNodePtr xmlCopyNodeList(xmlNodePtr node);
|
||||
|
||||
/*
|
||||
* Navigating
|
||||
*/
|
||||
extern xmlNodePtr xmlGetLastChild(xmlNodePtr node);
|
||||
extern int xmlNodeIsText(xmlNodePtr node);
|
||||
xmlNodePtr xmlGetLastChild(xmlNodePtr parent);
|
||||
int xmlNodeIsText(xmlNodePtr node);
|
||||
|
||||
/*
|
||||
* Changing the structure
|
||||
*/
|
||||
extern xmlNodePtr xmlAddChild(xmlNodePtr parent, xmlNodePtr cur);
|
||||
extern void xmlUnlinkNode(xmlNodePtr cur);
|
||||
xmlNodePtr xmlAddChild(xmlNodePtr parent, xmlNodePtr cur);
|
||||
void xmlUnlinkNode(xmlNodePtr cur);
|
||||
|
||||
extern xmlNodePtr xmlTextMerge(xmlNodePtr first, xmlNodePtr second);
|
||||
extern void xmlTextConcat(xmlNodePtr node, const CHAR *content, int len);
|
||||
xmlNodePtr xmlTextMerge(xmlNodePtr first, xmlNodePtr second);
|
||||
void xmlTextConcat(xmlNodePtr node, const CHAR *content, int len);
|
||||
|
||||
extern void xmlFreeNodeList(xmlNodePtr cur);
|
||||
extern void xmlFreeNode(xmlNodePtr cur);
|
||||
void xmlFreeNodeList(xmlNodePtr cur);
|
||||
void xmlFreeNode(xmlNodePtr cur);
|
||||
|
||||
/*
|
||||
* Namespaces
|
||||
*/
|
||||
extern xmlNsPtr xmlSearchNs(xmlDocPtr doc, xmlNodePtr node,
|
||||
xmlNsPtr xmlSearchNs(xmlDocPtr doc, xmlNodePtr node,
|
||||
const CHAR *nameSpace);
|
||||
extern xmlNsPtr xmlSearchNsByHref(xmlDocPtr doc, xmlNodePtr node,
|
||||
xmlNsPtr xmlSearchNsByHref(xmlDocPtr doc, xmlNodePtr node,
|
||||
const CHAR *href);
|
||||
extern void xmlSetNs(xmlNodePtr node, xmlNsPtr ns);
|
||||
extern xmlNsPtr xmlCopyNamespace(xmlNsPtr cur);
|
||||
extern xmlNsPtr xmlCopyNamespaceList(xmlNsPtr cur);
|
||||
void xmlSetNs(xmlNodePtr node, xmlNsPtr ns);
|
||||
xmlNsPtr xmlCopyNamespace(xmlNsPtr cur);
|
||||
xmlNsPtr xmlCopyNamespaceList(xmlNsPtr cur);
|
||||
|
||||
/*
|
||||
* Changing the content.
|
||||
*/
|
||||
extern xmlAttrPtr xmlSetProp(xmlNodePtr node, const CHAR *name,
|
||||
xmlAttrPtr xmlSetProp(xmlNodePtr node, const CHAR *name,
|
||||
const CHAR *value);
|
||||
extern CHAR *xmlGetProp(xmlNodePtr node, const CHAR *name);
|
||||
extern xmlNodePtr xmlStringGetNodeList(xmlDocPtr doc, const CHAR *value);
|
||||
extern xmlNodePtr xmlStringLenGetNodeList(xmlDocPtr doc, const CHAR *value,
|
||||
CHAR *xmlGetProp(xmlNodePtr node, const CHAR *name);
|
||||
xmlNodePtr xmlStringGetNodeList(xmlDocPtr doc, const CHAR *value);
|
||||
xmlNodePtr xmlStringLenGetNodeList(xmlDocPtr doc, const CHAR *value,
|
||||
int len);
|
||||
extern CHAR *xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int inLine);
|
||||
extern void xmlNodeSetContent(xmlNodePtr cur, const CHAR *content);
|
||||
extern void xmlNodeSetContentLen(xmlNodePtr cur, const CHAR *content, int len);
|
||||
extern void xmlNodeAddContent(xmlNodePtr cur, const CHAR *content);
|
||||
extern void xmlNodeAddContentLen(xmlNodePtr cur, const CHAR *content, int len);
|
||||
extern CHAR *xmlNodeGetContent(xmlNodePtr cur);
|
||||
CHAR *xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int inLine);
|
||||
void xmlNodeSetContent(xmlNodePtr cur, const CHAR *content);
|
||||
void xmlNodeSetContentLen(xmlNodePtr cur, const CHAR *content, int len);
|
||||
void xmlNodeAddContent(xmlNodePtr cur, const CHAR *content);
|
||||
void xmlNodeAddContentLen(xmlNodePtr cur, const CHAR *content, int len);
|
||||
CHAR *xmlNodeGetContent(xmlNodePtr cur);
|
||||
|
||||
/*
|
||||
* Internal, don't use
|
||||
*/
|
||||
extern void xmlBufferWriteCHAR(const CHAR *string);
|
||||
extern void xmlBufferWriteChar(const char *string);
|
||||
void xmlBufferWriteCHAR(const CHAR *string);
|
||||
void xmlBufferWriteChar(const char *string);
|
||||
|
||||
/*
|
||||
* Saving
|
||||
*/
|
||||
extern void xmlDocDumpMemory(xmlDocPtr cur, CHAR**mem, int *size);
|
||||
extern void xmlDocDump(FILE *f, xmlDocPtr doc);
|
||||
void xmlDocDumpMemory(xmlDocPtr cur, CHAR**mem, int *size);
|
||||
void xmlDocDump(FILE *f, xmlDocPtr cur);
|
||||
int xmlSaveFile(const char *filename, xmlDocPtr cur);
|
||||
|
||||
/*
|
||||
* Compression
|
||||
*/
|
||||
extern int xmlGetDocCompressMode (xmlDocPtr doc);
|
||||
extern void xmlSetDocCompressMode (xmlDocPtr doc, int mode);
|
||||
extern int xmlGetCompressMode(void);
|
||||
extern void xmlSetCompressMode(int mode);
|
||||
int xmlGetDocCompressMode (xmlDocPtr doc);
|
||||
void xmlSetDocCompressMode (xmlDocPtr doc, int mode);
|
||||
int xmlGetCompressMode(void);
|
||||
void xmlSetCompressMode(int mode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -11,6 +11,20 @@
|
||||
#define __XML_VALID_H__
|
||||
#include "tree.h"
|
||||
|
||||
/*
|
||||
* ALl notation declarations are stored in a table
|
||||
* there is one table per DTD
|
||||
*/
|
||||
|
||||
#define XML_MIN_NOTATION_TABLE 32
|
||||
|
||||
typedef struct xmlNotationTable {
|
||||
int nb_notations; /* number of notations stored */
|
||||
int max_notations; /* maximum number of notations */
|
||||
xmlNotationPtr table; /* the table of attributes */
|
||||
} xmlNotationTable;
|
||||
typedef xmlNotationTable *xmlNotationTablePtr;
|
||||
|
||||
/*
|
||||
* ALl element declarations are stored in a table
|
||||
* there is one table per DTD
|
||||
@ -21,16 +35,54 @@
|
||||
typedef struct xmlElementTable {
|
||||
int nb_elements; /* number of elements stored */
|
||||
int max_elements; /* maximum number of elements */
|
||||
xmlElementPtr table; /* the table of entities */
|
||||
} xmlElementTable, *xmlElementTablePtr;
|
||||
xmlElementPtr table; /* the table of elements */
|
||||
} xmlElementTable;
|
||||
typedef xmlElementTable *xmlElementTablePtr;
|
||||
|
||||
extern xmlElementPtr xmlAddElementDecl(xmlDtdPtr dtd, char *name, int type,
|
||||
/*
|
||||
* ALl attribute declarations are stored in a table
|
||||
* there is one table per DTD
|
||||
*/
|
||||
|
||||
#define XML_MIN_ATTRIBUTE_TABLE 32
|
||||
|
||||
typedef struct xmlAttributeTable {
|
||||
int nb_attributes; /* number of attributes stored */
|
||||
int max_attributes; /* maximum number of attributes */
|
||||
xmlAttributePtr table; /* the table of attributes */
|
||||
} xmlAttributeTable;
|
||||
typedef xmlAttributeTable *xmlAttributeTablePtr;
|
||||
|
||||
/* Notation */
|
||||
xmlNotationPtr xmlAddNotationDecl(xmlDtdPtr dtd, CHAR *name,
|
||||
CHAR *PublicID, CHAR *SystemID);
|
||||
xmlNotationTablePtr xmlCopyNotationTable(xmlNotationTablePtr table);
|
||||
void xmlFreeNotationTable(xmlNotationTablePtr table);
|
||||
void xmlDumpNotationTable(xmlNotationTablePtr table);
|
||||
|
||||
/* Element Content */
|
||||
xmlElementContentPtr xmlNewElementContent(CHAR *name, int type);
|
||||
xmlElementContentPtr xmlCopyElementContent(xmlElementContentPtr content);
|
||||
void xmlFreeElementContent(xmlElementContentPtr cur);
|
||||
|
||||
/* Element */
|
||||
xmlElementPtr xmlAddElementDecl(xmlDtdPtr dtd, CHAR *name, int type,
|
||||
xmlElementContentPtr content);
|
||||
extern xmlElementContentPtr xmlNewElementContent(CHAR *name, int type);
|
||||
extern xmlElementContentPtr xmlCopyElementContent(xmlElementContentPtr content);
|
||||
extern void xmlFreeElementContent(xmlElementContentPtr cur);
|
||||
xmlElementTablePtr xmlCopyElementTable(xmlElementTablePtr table);
|
||||
void xmlFreeElementTable(xmlElementTablePtr table);
|
||||
void xmlDumpElementTable(xmlElementTablePtr table);
|
||||
|
||||
/* Enumeration */
|
||||
xmlEnumerationPtr xmlCreateEnumeration(CHAR *name);
|
||||
void xmlFreeEnumeration(xmlEnumerationPtr cur);
|
||||
xmlEnumerationPtr xmlCopyEnumeration(xmlEnumerationPtr cur);
|
||||
|
||||
/* Attribute */
|
||||
xmlAttributePtr xmlAddAttributeDecl(xmlDtdPtr dtd, CHAR *elem,
|
||||
CHAR *name, int type, int def,
|
||||
CHAR *defaultValue, xmlEnumerationPtr tree);
|
||||
xmlAttributeTablePtr xmlCopyAttributeTable(xmlAttributeTablePtr table);
|
||||
void xmlFreeAttributeTable(xmlAttributeTablePtr table);
|
||||
void xmlDumpAttributeTable(xmlAttributeTablePtr table);
|
||||
|
||||
extern xmlElementTablePtr xmlCopyElementTable(xmlElementTablePtr table);
|
||||
extern void xmlFreeElementTable(xmlElementTablePtr table);
|
||||
extern void xmlDumpElementTable(xmlElementTablePtr table);
|
||||
#endif /* __XML_VALID_H__ */
|
||||
|
86
parser.h
86
parser.h
@ -26,24 +26,28 @@ typedef struct xmlParserInput {
|
||||
const CHAR *cur; /* Current char being parsed */
|
||||
int line; /* Current line */
|
||||
int col; /* Current column */
|
||||
} xmlParserInput, *xmlParserInputPtr;
|
||||
} xmlParserInput;
|
||||
typedef xmlParserInput *xmlParserInputPtr;
|
||||
|
||||
typedef struct xmlParserNodeInfo {
|
||||
typedef struct _xmlParserNodeInfo {
|
||||
const struct xmlNode* node;
|
||||
/* Position & line # that text that created the node begins & ends on */
|
||||
unsigned long begin_pos;
|
||||
unsigned long begin_line;
|
||||
unsigned long end_pos;
|
||||
unsigned long end_line;
|
||||
} xmlParserNodeInfo;
|
||||
} _xmlParserNodeInfo;
|
||||
typedef _xmlParserNodeInfo xmlParserNodeInfo;
|
||||
|
||||
typedef struct xmlParserNodeInfoSeq {
|
||||
unsigned long maximum;
|
||||
unsigned long length;
|
||||
xmlParserNodeInfo* buffer;
|
||||
} xmlParserNodeInfoSeq, *xmlParserNodeInfoSeqPtr;
|
||||
} _xmlParserNodeInfoSeq;
|
||||
typedef _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;
|
||||
typedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;
|
||||
|
||||
typedef struct xmlParserCtxt {
|
||||
typedef struct _xmlParserCtxt {
|
||||
struct xmlSAXHandler *sax; /* The SAX handler */
|
||||
xmlDocPtr doc; /* the document being built */
|
||||
int wellFormed; /* is the document well formed */
|
||||
@ -62,7 +66,9 @@ typedef struct xmlParserCtxt {
|
||||
|
||||
int record_info; /* Whether node info should be kept */
|
||||
xmlParserNodeInfoSeq node_seq; /* info about each node parsed */
|
||||
} xmlParserCtxt, *xmlParserCtxtPtr;
|
||||
} _xmlParserCtxt;
|
||||
typedef _xmlParserCtxt xmlParserCtxt;
|
||||
typedef xmlParserCtxt *xmlParserCtxtPtr;
|
||||
|
||||
/*
|
||||
* a SAX Locator.
|
||||
@ -73,7 +79,9 @@ typedef struct xmlSAXLocator {
|
||||
const CHAR *(*getSystemId)(xmlParserCtxtPtr ctxt);
|
||||
int (*getLineNumber)(xmlParserCtxtPtr ctxt);
|
||||
int (*getColumnNumber)(xmlParserCtxtPtr ctxt);
|
||||
} xmlSAXLocator, *xmlSAXLocatorPtr;
|
||||
} _xmlSAXLocator;
|
||||
typedef _xmlSAXLocator xmlSAXLocator;
|
||||
typedef xmlSAXLocator *xmlSAXLocatorPtr;
|
||||
|
||||
/*
|
||||
* a SAX Exception.
|
||||
@ -120,7 +128,8 @@ typedef struct xmlSAXHandler {
|
||||
warningSAXFunc warning;
|
||||
errorSAXFunc error;
|
||||
fatalErrorSAXFunc fatalError;
|
||||
} xmlSAXHandler, *xmlSAXHandlerPtr;
|
||||
} xmlSAXHandler;
|
||||
typedef xmlSAXHandler *xmlSAXHandlerPtr;
|
||||
|
||||
/*
|
||||
* Global variables: just the SAX interface tables we are looking for full
|
||||
@ -130,61 +139,58 @@ extern xmlSAXLocator xmlDefaultSAXLocator;
|
||||
extern xmlSAXHandler xmlDefaultSAXHandler;
|
||||
|
||||
#include "entities.h"
|
||||
#include "error.h"
|
||||
|
||||
/*
|
||||
* CHAR handling
|
||||
*/
|
||||
extern CHAR *xmlStrdup(const CHAR *input);
|
||||
extern CHAR *xmlStrndup(const CHAR *input, int n);
|
||||
extern CHAR *xmlStrchr(const CHAR *str, CHAR val);
|
||||
extern int xmlStrcmp(const CHAR *str1, const CHAR *str2);
|
||||
extern int xmlStrncmp(const CHAR *str1, const CHAR *str2, int len);
|
||||
extern int xmlStrlen(const CHAR *str);
|
||||
extern CHAR *xmlStrcat(CHAR *cur, const CHAR *add);
|
||||
extern CHAR *xmlStrncat(CHAR *cur, const CHAR *add, int len);
|
||||
CHAR *xmlStrdup(const CHAR *cur);
|
||||
CHAR *xmlStrndup(const CHAR *cur, int len);
|
||||
CHAR *xmlStrchr(const CHAR *str, CHAR val);
|
||||
int xmlStrcmp(const CHAR *str1, const CHAR *str2);
|
||||
int xmlStrncmp(const CHAR *str1, const CHAR *str2, int len);
|
||||
int xmlStrlen(const CHAR *str);
|
||||
CHAR *xmlStrcat(CHAR *cur, const CHAR *add);
|
||||
CHAR *xmlStrncat(CHAR *cur, const CHAR *add, int len);
|
||||
|
||||
/*
|
||||
* Interfaces
|
||||
*/
|
||||
extern xmlDocPtr xmlParseDoc(CHAR *cur);
|
||||
extern xmlDocPtr xmlParseMemory(char *buffer, int size);
|
||||
extern xmlDocPtr xmlParseFile(const char *filename);
|
||||
xmlDocPtr xmlParseDoc(CHAR *cur);
|
||||
xmlDocPtr xmlParseMemory(char *buffer, int size);
|
||||
xmlDocPtr xmlParseFile(const char *filename);
|
||||
|
||||
/*
|
||||
* Recovery mode
|
||||
*/
|
||||
extern xmlDocPtr xmlRecoverDoc(CHAR *cur);
|
||||
extern xmlDocPtr xmlRecoverMemory(char *buffer, int size);
|
||||
extern xmlDocPtr xmlRecoverFile(const char *filename);
|
||||
xmlDocPtr xmlRecoverDoc(CHAR *cur);
|
||||
xmlDocPtr xmlRecoverMemory(char *buffer, int size);
|
||||
xmlDocPtr xmlRecoverFile(const char *filename);
|
||||
|
||||
/*
|
||||
* Internal routines
|
||||
*/
|
||||
extern int xmlParseDocument(xmlParserCtxtPtr ctxt);
|
||||
extern xmlDocPtr xmlSAXParseDoc(xmlSAXHandlerPtr sax, CHAR *cur, int recovery);
|
||||
extern xmlDocPtr xmlSAXParseMemory(xmlSAXHandlerPtr sax, char *buffer,
|
||||
int xmlParseDocument(xmlParserCtxtPtr ctxt);
|
||||
xmlDocPtr xmlSAXParseDoc(xmlSAXHandlerPtr sax, CHAR *cur, int recovery);
|
||||
xmlDocPtr xmlSAXParseMemory(xmlSAXHandlerPtr sax, char *buffer,
|
||||
int size, int recovery);
|
||||
extern xmlDocPtr xmlSAXParseFile(xmlSAXHandlerPtr sax, const char *filename,
|
||||
xmlDocPtr xmlSAXParseFile(xmlSAXHandlerPtr sax, const char *filename,
|
||||
int recovery);
|
||||
extern void xmlInitParserCtxt(xmlParserCtxtPtr ctx);
|
||||
extern void xmlClearParserCtxt(xmlParserCtxtPtr ctx);
|
||||
extern void xmlSetupParserForBuffer(xmlParserCtxtPtr ctx, const CHAR* buffer,
|
||||
void xmlInitParserCtxt(xmlParserCtxtPtr ctxt);
|
||||
void xmlClearParserCtxt(xmlParserCtxtPtr ctxt);
|
||||
void xmlSetupParserForBuffer(xmlParserCtxtPtr ctxt, const CHAR* buffer,
|
||||
const char* filename);
|
||||
|
||||
extern void xmlParserError(xmlParserCtxtPtr ctxt, const char *msg, ...);
|
||||
|
||||
extern const xmlParserNodeInfo* xmlParserFindNodeInfo(const xmlParserCtxt* c,
|
||||
const xmlNode* node);
|
||||
extern void xmlInitNodeInfoSeq(xmlParserNodeInfoSeqPtr seq);
|
||||
extern void xmlClearNodeInfoSeq(xmlParserNodeInfoSeqPtr seq);
|
||||
const xmlParserNodeInfo* xmlParserFindNodeInfo(const xmlParserCtxt* ctxt,
|
||||
const xmlNode* node);
|
||||
void xmlInitNodeInfoSeq(xmlParserNodeInfoSeqPtr seq);
|
||||
void xmlClearNodeInfoSeq(xmlParserNodeInfoSeqPtr seq);
|
||||
unsigned long xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeq* seq,
|
||||
const xmlNode* node);
|
||||
extern void xmlParserAddNodeInfo(xmlParserCtxtPtr ctx,
|
||||
const xmlParserNodeInfo* info);
|
||||
void xmlParserAddNodeInfo(xmlParserCtxtPtr ctxt,
|
||||
const xmlParserNodeInfo* info);
|
||||
|
||||
extern void xmlParserWarning(xmlParserCtxtPtr ctxt, const char *msg, ...);
|
||||
extern void xmlParserError(xmlParserCtxtPtr ctxt, const char *msg, ...);
|
||||
extern void xmlDefaultSAXHandlerInit(void);
|
||||
void xmlDefaultSAXHandlerInit(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
128
parserInternals.h
Normal file
128
parserInternals.h
Normal file
@ -0,0 +1,128 @@
|
||||
/*
|
||||
* parserInternals.h : internals routines exported by the parser.
|
||||
*
|
||||
* See Copyright for the status of this software.
|
||||
*
|
||||
* Daniel.Veillard@w3.org
|
||||
*/
|
||||
|
||||
#ifndef __XML_PARSER_INTERNALS_H__
|
||||
#define __XML_PARSER_INTERNALS_H__
|
||||
|
||||
#include "parser.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Entities
|
||||
*/
|
||||
void
|
||||
xmlHandleEntity(xmlParserCtxtPtr ctxt, xmlEntityPtr entity);
|
||||
|
||||
/*
|
||||
* Namespaces.
|
||||
*/
|
||||
CHAR *
|
||||
xmlNamespaceParseNCName(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlNamespaceParseQName(xmlParserCtxtPtr ctxt, CHAR **prefix);
|
||||
CHAR *
|
||||
xmlNamespaceParseNSDef(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParseQuotedString(xmlParserCtxtPtr ctxt);
|
||||
void
|
||||
xmlParseNamespace(xmlParserCtxtPtr ctxt);
|
||||
|
||||
/*
|
||||
* Generic production rules
|
||||
*/
|
||||
CHAR *
|
||||
xmlParseName(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParseNmtoken(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParseEntityValue(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParseAttValue(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParseSystemLiteral(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParsePubidLiteral(xmlParserCtxtPtr ctxt);
|
||||
void
|
||||
xmlParseCharData(xmlParserCtxtPtr ctxt, int cdata);
|
||||
CHAR *
|
||||
xmlParseExternalID(xmlParserCtxtPtr ctxt, CHAR **publicID, int strict);
|
||||
xmlNodePtr
|
||||
xmlParseComment(xmlParserCtxtPtr ctxt, int create);
|
||||
CHAR *
|
||||
xmlParsePITarget(xmlParserCtxtPtr ctxt);
|
||||
void
|
||||
xmlParsePI(xmlParserCtxtPtr ctxt);
|
||||
void
|
||||
xmlParseNotationDecl(xmlParserCtxtPtr ctxt);
|
||||
void
|
||||
xmlParseEntityDecl(xmlParserCtxtPtr ctxt);
|
||||
int
|
||||
xmlParseDefaultDecl(xmlParserCtxtPtr ctxt, CHAR **value);
|
||||
xmlEnumerationPtr
|
||||
xmlParseNotationType(xmlParserCtxtPtr ctxt);
|
||||
xmlEnumerationPtr
|
||||
xmlParseEnumerationType(xmlParserCtxtPtr ctxt);
|
||||
int
|
||||
xmlParseEnumeratedType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree);
|
||||
int
|
||||
xmlParseAttributeType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree);
|
||||
void
|
||||
xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt);
|
||||
xmlElementContentPtr
|
||||
xmlParseElementMixedContentDecl(xmlParserCtxtPtr ctxt);
|
||||
xmlElementContentPtr
|
||||
xmlParseElementChildrenContentDecl(xmlParserCtxtPtr ctxt);
|
||||
int
|
||||
xmlParseElementContentDecl(xmlParserCtxtPtr ctxt, CHAR *name,
|
||||
xmlElementContentPtr *result);
|
||||
int
|
||||
xmlParseElementDecl(xmlParserCtxtPtr ctxt);
|
||||
void
|
||||
xmlParseMarkupDecl(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParseCharRef(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParseEntityRef(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParseReference(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParsePEReference(xmlParserCtxtPtr ctxt);
|
||||
void
|
||||
xmlParseDocTypeDecl(xmlParserCtxtPtr ctxt);
|
||||
xmlAttrPtr
|
||||
xmlParseAttribute(xmlParserCtxtPtr ctxt, xmlNodePtr node);
|
||||
xmlNodePtr
|
||||
xmlParseStartTag(xmlParserCtxtPtr ctxt);
|
||||
void
|
||||
xmlParseEndTag(xmlParserCtxtPtr ctxt, xmlNsPtr *nsPtr, CHAR **tagPtr);
|
||||
void
|
||||
xmlParseCDSect(xmlParserCtxtPtr ctxt);
|
||||
void
|
||||
xmlParseContent(xmlParserCtxtPtr ctxt);
|
||||
xmlNodePtr
|
||||
xmlParseElement(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParseVersionNum(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParseVersionInfo(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParseEncName(xmlParserCtxtPtr ctxt);
|
||||
CHAR *
|
||||
xmlParseEncodingDecl(xmlParserCtxtPtr ctxt);
|
||||
int
|
||||
xmlParseSDDecl(xmlParserCtxtPtr ctxt);
|
||||
void
|
||||
xmlParseXMLDecl(xmlParserCtxtPtr ctxt);
|
||||
void
|
||||
xmlParseMisc(xmlParserCtxtPtr ctxt);
|
||||
|
||||
|
||||
#endif /* __XML_PARSER_INTERNALS_H__ */
|
109
tree.c
109
tree.c
@ -35,7 +35,7 @@ static int xmlCompressMode = 0;
|
||||
} else { \
|
||||
while (ulccur->next != NULL) ulccur = ulccur->next; \
|
||||
(n)->last = ulccur; \
|
||||
} }
|
||||
}}
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
@ -77,7 +77,7 @@ xmlUpgradeOldNs(xmlDocPtr doc) {
|
||||
* @prefix: the prefix for the namespace
|
||||
*
|
||||
* Creation of a new Namespace.
|
||||
* return values: returns a new namespace pointer
|
||||
* Returns returns a new namespace pointer
|
||||
*/
|
||||
xmlNsPtr
|
||||
xmlNewNs(xmlNodePtr node, const CHAR *href, const CHAR *prefix) {
|
||||
@ -132,7 +132,7 @@ xmlNewNs(xmlNodePtr node, const CHAR *href, const CHAR *prefix) {
|
||||
* @prefix: the prefix for the namespace
|
||||
*
|
||||
* Creation of a Namespace, the old way using PI and without scoping, to AVOID.
|
||||
* return values: returns a new namespace pointer
|
||||
* Returns returns a new namespace pointer
|
||||
*/
|
||||
xmlNsPtr
|
||||
xmlNewGlobalNs(xmlDocPtr doc, const CHAR *href, const CHAR *prefix) {
|
||||
@ -237,7 +237,7 @@ xmlFreeNsList(xmlNsPtr cur) {
|
||||
* @SystemID: the system ID
|
||||
*
|
||||
* Creation of a new DTD.
|
||||
* return values: a pointer to the new DTD structure
|
||||
* Returns a pointer to the new DTD structure
|
||||
*/
|
||||
xmlDtdPtr
|
||||
xmlNewDtd(xmlDocPtr doc, const CHAR *name,
|
||||
@ -271,7 +271,9 @@ xmlNewDtd(xmlDocPtr doc, const CHAR *name,
|
||||
cur->SystemID = xmlStrdup(SystemID);
|
||||
else
|
||||
cur->SystemID = NULL;
|
||||
cur->notations = NULL;
|
||||
cur->elements = NULL;
|
||||
cur->attributes = NULL;
|
||||
cur->entities = NULL;
|
||||
if (doc != NULL)
|
||||
doc->extSubset = cur;
|
||||
@ -286,8 +288,8 @@ xmlNewDtd(xmlDocPtr doc, const CHAR *name,
|
||||
* @ExternalID: the external ID
|
||||
* @SystemID: the system ID
|
||||
*
|
||||
* Creatte the internal subset of a document
|
||||
* return values: a pointer to the new DTD structure
|
||||
* Create the internal subset of a document
|
||||
* Returns a pointer to the new DTD structure
|
||||
*/
|
||||
xmlDtdPtr
|
||||
xmlCreateIntSubset(xmlDocPtr doc, const CHAR *name,
|
||||
@ -322,7 +324,9 @@ xmlCreateIntSubset(xmlDocPtr doc, const CHAR *name,
|
||||
cur->SystemID = xmlStrdup(SystemID);
|
||||
else
|
||||
cur->SystemID = NULL;
|
||||
cur->notations = NULL;
|
||||
cur->elements = NULL;
|
||||
cur->attributes = NULL;
|
||||
cur->entities = NULL;
|
||||
if (doc != NULL)
|
||||
doc->intSubset = cur;
|
||||
@ -345,8 +349,12 @@ xmlFreeDtd(xmlDtdPtr cur) {
|
||||
if (cur->name != NULL) free((char *) cur->name);
|
||||
if (cur->SystemID != NULL) free((char *) cur->SystemID);
|
||||
if (cur->ExternalID != NULL) free((char *) cur->ExternalID);
|
||||
if (cur->notations != NULL)
|
||||
xmlFreeNotationTable((xmlNotationTablePtr) cur->notations);
|
||||
if (cur->elements != NULL)
|
||||
xmlFreeElementTable((xmlElementTablePtr) cur->elements);
|
||||
if (cur->attributes != NULL)
|
||||
xmlFreeAttributeTable((xmlAttributeTablePtr) cur->attributes);
|
||||
if (cur->entities != NULL)
|
||||
xmlFreeEntitiesTable((xmlEntitiesTablePtr) cur->entities);
|
||||
memset(cur, -1, sizeof(xmlDtd));
|
||||
@ -357,7 +365,7 @@ xmlFreeDtd(xmlDtdPtr cur) {
|
||||
* xmlNewDoc:
|
||||
* @version: CHAR string giving the version of XML "1.0"
|
||||
*
|
||||
* Create a new document
|
||||
* Returns a new document
|
||||
*/
|
||||
xmlDocPtr
|
||||
xmlNewDoc(const CHAR *version) {
|
||||
@ -424,11 +432,11 @@ xmlFreeDoc(xmlDocPtr cur) {
|
||||
* xmlStringLenGetNodeList:
|
||||
* @doc: the document
|
||||
* @value: the value of the text
|
||||
* @int len: the length of the string value
|
||||
* @len: the length of the string value
|
||||
*
|
||||
* Parse the value string and build the node list associated. Should
|
||||
* produce a flat tree with only TEXTs and ENTITY_REFs.
|
||||
* return values: a pointer to the first child
|
||||
* Returns a pointer to the first child
|
||||
*/
|
||||
xmlNodePtr
|
||||
xmlStringLenGetNodeList(xmlDocPtr doc, const CHAR *value, int len) {
|
||||
@ -539,7 +547,7 @@ xmlStringLenGetNodeList(xmlDocPtr doc, const CHAR *value, int len) {
|
||||
*
|
||||
* Parse the value string and build the node list associated. Should
|
||||
* produce a flat tree with only TEXTs and ENTITY_REFs.
|
||||
* return values: a pointer to the first child
|
||||
* Returns a pointer to the first child
|
||||
*/
|
||||
xmlNodePtr
|
||||
xmlStringGetNodeList(xmlDocPtr doc, const CHAR *value) {
|
||||
@ -651,7 +659,7 @@ xmlStringGetNodeList(xmlDocPtr doc, const CHAR *value) {
|
||||
*
|
||||
* Returns the string equivalent to the text contained in the Node list
|
||||
* made of TEXTs and ENTITY_REFs
|
||||
* return values: a pointer to the string copy, the calller must free it.
|
||||
* Returns a pointer to the string copy, the calller must free it.
|
||||
*/
|
||||
CHAR *
|
||||
xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int inLine) {
|
||||
@ -701,7 +709,7 @@ xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int inLine) {
|
||||
* @value: the value of the attribute
|
||||
*
|
||||
* Create a new property carried by a node.
|
||||
* return values: a pointer to the attribute
|
||||
* Returns a pointer to the attribute
|
||||
*/
|
||||
xmlAttrPtr
|
||||
xmlNewProp(xmlNodePtr node, const CHAR *name, const CHAR *value) {
|
||||
@ -757,7 +765,7 @@ xmlNewProp(xmlNodePtr node, const CHAR *name, const CHAR *value) {
|
||||
* @value: the value of the attribute
|
||||
*
|
||||
* Create a new property carried by a document.
|
||||
* return values: a pointer to the attribute
|
||||
* Returns a pointer to the attribute
|
||||
*/
|
||||
xmlAttrPtr
|
||||
xmlNewDocProp(xmlDocPtr doc, const CHAR *name, const CHAR *value) {
|
||||
@ -835,12 +843,11 @@ xmlFreeProp(xmlAttrPtr cur) {
|
||||
* xmlNewNode:
|
||||
* @ns: namespace if any
|
||||
* @name: the node name
|
||||
* @content: the text content if any
|
||||
*
|
||||
* Creation of a new node element. @ns and @content are optionnal (NULL).
|
||||
* If content is non NULL, a child list containing the TEXTs and
|
||||
* ENTITY_REFs node will be created.
|
||||
* return values: a pointer to the new node object.
|
||||
* Returns a pointer to the new node object.
|
||||
*/
|
||||
xmlNodePtr
|
||||
xmlNewNode(xmlNsPtr ns, const CHAR *name) {
|
||||
@ -888,7 +895,7 @@ xmlNewNode(xmlNsPtr ns, const CHAR *name) {
|
||||
*
|
||||
* Creation of a new node element within a document. @ns and @content
|
||||
* are optionnal (NULL).
|
||||
* return values: a pointer to the new node object.
|
||||
* Returns a pointer to the new node object.
|
||||
*/
|
||||
xmlNodePtr
|
||||
xmlNewDocNode(xmlDocPtr doc, xmlNsPtr ns,
|
||||
@ -900,7 +907,7 @@ xmlNewDocNode(xmlDocPtr doc, xmlNsPtr ns,
|
||||
cur->doc = doc;
|
||||
if (content != NULL) {
|
||||
cur->childs = xmlStringGetNodeList(doc, content);
|
||||
UPDATE_LAST_CHILD(cur);
|
||||
UPDATE_LAST_CHILD(cur)
|
||||
}
|
||||
}
|
||||
return(cur);
|
||||
@ -912,7 +919,7 @@ xmlNewDocNode(xmlDocPtr doc, xmlNsPtr ns,
|
||||
* @content: the text content
|
||||
*
|
||||
* Creation of a new text node.
|
||||
* return values: a pointer to the new node object.
|
||||
* Returns a pointer to the new node object.
|
||||
*/
|
||||
xmlNodePtr
|
||||
xmlNewText(const CHAR *content) {
|
||||
@ -952,7 +959,7 @@ xmlNewText(const CHAR *content) {
|
||||
* @name: the reference name, or the reference string with & and ;
|
||||
*
|
||||
* Creation of a new reference node.
|
||||
* return values: a pointer to the new node object.
|
||||
* Returns a pointer to the new node object.
|
||||
*/
|
||||
xmlNodePtr
|
||||
xmlNewReference(xmlDocPtr doc, const CHAR *name) {
|
||||
@ -1003,7 +1010,7 @@ xmlNewReference(xmlDocPtr doc, const CHAR *name) {
|
||||
* @content: the text content
|
||||
*
|
||||
* Creation of a new text node within a document.
|
||||
* return values: a pointer to the new node object.
|
||||
* Returns a pointer to the new node object.
|
||||
*/
|
||||
xmlNodePtr
|
||||
xmlNewDocText(xmlDocPtr doc, const CHAR *content) {
|
||||
@ -1020,7 +1027,7 @@ xmlNewDocText(xmlDocPtr doc, const CHAR *content) {
|
||||
* @len: the text len.
|
||||
*
|
||||
* Creation of a new text node with an extra parameter for the content's lenght
|
||||
* return values: a pointer to the new node object.
|
||||
* Returns a pointer to the new node object.
|
||||
*/
|
||||
xmlNodePtr
|
||||
xmlNewTextLen(const CHAR *content, int len) {
|
||||
@ -1062,7 +1069,7 @@ xmlNewTextLen(const CHAR *content, int len) {
|
||||
*
|
||||
* Creation of a new text node with an extra content lenght parameter. The
|
||||
* text node pertain to a given document.
|
||||
* return values: a pointer to the new node object.
|
||||
* Returns a pointer to the new node object.
|
||||
*/
|
||||
xmlNodePtr
|
||||
xmlNewDocTextLen(xmlDocPtr doc, const CHAR *content, int len) {
|
||||
@ -1078,7 +1085,7 @@ xmlNewDocTextLen(xmlDocPtr doc, const CHAR *content, int len) {
|
||||
* @content: the comment content
|
||||
*
|
||||
* Creation of a new node containing a comment.
|
||||
* return values: a pointer to the new node object.
|
||||
* Returns a pointer to the new node object.
|
||||
*/
|
||||
xmlNodePtr
|
||||
xmlNewComment(CHAR *content) {
|
||||
@ -1113,12 +1120,12 @@ xmlNewComment(CHAR *content) {
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlNewComment:
|
||||
* xmlNewDocComment:
|
||||
* @doc: the document
|
||||
* @content: the comment content
|
||||
*
|
||||
* Creation of a new node containing a commentwithin a document.
|
||||
* return values: a pointer to the new node object.
|
||||
* Returns a pointer to the new node object.
|
||||
*/
|
||||
xmlNodePtr
|
||||
xmlNewDocComment(xmlDocPtr doc, CHAR *content) {
|
||||
@ -1140,7 +1147,7 @@ xmlNewDocComment(xmlDocPtr doc, CHAR *content) {
|
||||
* Creation of a new child element, added at the end of @parent childs list.
|
||||
* @ns and @content parameters are optionnal (NULL). If content is non NULL,
|
||||
* a child list containing the TEXTs and ENTITY_REFs node will be created.
|
||||
* return values: a pointer to the new node object.
|
||||
* Returns a pointer to the new node object.
|
||||
*/
|
||||
xmlNodePtr
|
||||
xmlNewChild(xmlNodePtr parent, xmlNsPtr ns,
|
||||
@ -1191,7 +1198,7 @@ xmlNewChild(xmlNodePtr parent, xmlNsPtr ns,
|
||||
* @cur: the child node
|
||||
*
|
||||
* Add a new child element, to @parent, at the end of the child list.
|
||||
* return values: the child or NULL in case of error.
|
||||
* Returns the child or NULL in case of error.
|
||||
*/
|
||||
xmlNodePtr
|
||||
xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
|
||||
@ -1231,7 +1238,7 @@ xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
|
||||
if (text->next != NULL)
|
||||
text->next->prev = text;
|
||||
parent->childs = text;
|
||||
UPDATE_LAST_CHILD(parent);
|
||||
UPDATE_LAST_CHILD(parent)
|
||||
free(parent->content);
|
||||
parent->content = NULL;
|
||||
}
|
||||
@ -1254,7 +1261,7 @@ xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
|
||||
* @parent: the parent node
|
||||
*
|
||||
* Search the last child of a node.
|
||||
* return values: the last child or NULL if none.
|
||||
* Returns the last child or NULL if none.
|
||||
*/
|
||||
xmlNodePtr
|
||||
xmlGetLastChild(xmlNodePtr parent) {
|
||||
@ -1534,7 +1541,7 @@ xmlStaticCopyNode(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
|
||||
}
|
||||
if (node->childs != NULL)
|
||||
ret->childs = xmlStaticCopyNodeList(node->childs, doc, ret);
|
||||
UPDATE_LAST_CHILD(ret);
|
||||
UPDATE_LAST_CHILD(ret)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@ -1636,6 +1643,15 @@ xmlCopyDtd(xmlDtdPtr dtd) {
|
||||
if (dtd->entities != NULL)
|
||||
ret->entities = (void *) xmlCopyEntitiesTable(
|
||||
(xmlEntitiesTablePtr) dtd->entities);
|
||||
if (dtd->notations != NULL)
|
||||
ret->notations = (void *) xmlCopyNotationTable(
|
||||
(xmlNotationTablePtr) dtd->notations);
|
||||
if (dtd->elements != NULL)
|
||||
ret->elements = (void *) xmlCopyElementTable(
|
||||
(xmlElementTablePtr) dtd->elements);
|
||||
if (dtd->attributes != NULL)
|
||||
ret->attributes = (void *) xmlCopyAttributeTable(
|
||||
(xmlAttributeTablePtr) dtd->attributes);
|
||||
/*
|
||||
* TODO: support for Element definitions.
|
||||
*/
|
||||
@ -1690,7 +1706,7 @@ xmlCopyDoc(xmlDocPtr doc, int recursive) {
|
||||
* directly by this node if it's a TEXT node or the aggregate string
|
||||
* of the values carried by this node child's (TEXT and ENTITY_REF).
|
||||
* Entity references are substitued.
|
||||
* Return value: a new CHAR * or NULL if no content is available.
|
||||
* Returns a new CHAR * or NULL if no content is available.
|
||||
*/
|
||||
CHAR *
|
||||
xmlNodeGetContent(xmlNodePtr cur) {
|
||||
@ -1740,7 +1756,7 @@ xmlNodeSetContent(xmlNodePtr cur, const CHAR *content) {
|
||||
}
|
||||
if (cur->childs != NULL) xmlFreeNode(cur->childs);
|
||||
cur->childs = xmlStringGetNodeList(cur->doc, content);
|
||||
UPDATE_LAST_CHILD(cur);
|
||||
UPDATE_LAST_CHILD(cur)
|
||||
break;
|
||||
case XML_ATTRIBUTE_NODE:
|
||||
break;
|
||||
@ -1788,7 +1804,7 @@ xmlNodeSetContentLen(xmlNodePtr cur, const CHAR *content, int len) {
|
||||
}
|
||||
if (cur->childs != NULL) xmlFreeNode(cur->childs);
|
||||
cur->childs = xmlStringLenGetNodeList(cur->doc, content, len);
|
||||
UPDATE_LAST_CHILD(cur);
|
||||
UPDATE_LAST_CHILD(cur)
|
||||
break;
|
||||
case XML_ATTRIBUTE_NODE:
|
||||
break;
|
||||
@ -1845,7 +1861,7 @@ xmlNodeAddContentLen(xmlNodePtr cur, const CHAR *content, int len) {
|
||||
} else {
|
||||
if (cur->content != NULL) {
|
||||
cur->childs = xmlStringGetNodeList(cur->doc, cur->content);
|
||||
UPDATE_LAST_CHILD(cur);
|
||||
UPDATE_LAST_CHILD(cur)
|
||||
free(cur->content);
|
||||
cur->content = NULL;
|
||||
last = cur->last;
|
||||
@ -1906,7 +1922,7 @@ xmlNodeAddContent(xmlNodePtr cur, const CHAR *content) {
|
||||
* @second: the second text node being merged
|
||||
*
|
||||
* Merge two text nodes into one
|
||||
* Return values: the first text node augmented
|
||||
* Returns the first text node augmented
|
||||
*/
|
||||
xmlNodePtr
|
||||
xmlTextMerge(xmlNodePtr first, xmlNodePtr second) {
|
||||
@ -1930,7 +1946,7 @@ xmlTextMerge(xmlNodePtr first, xmlNodePtr second) {
|
||||
* recurse on the parents until it finds the defined namespace
|
||||
* or return NULL otherwise.
|
||||
* @nameSpace can be NULL, this is a search for the default namespace.
|
||||
* return values: the namespace pointer or NULL.
|
||||
* Returns the namespace pointer or NULL.
|
||||
*/
|
||||
xmlNsPtr
|
||||
xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const CHAR *nameSpace) {
|
||||
@ -1968,7 +1984,7 @@ xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const CHAR *nameSpace) {
|
||||
*
|
||||
* Search a Ns aliasing a given URI. Recurse on the parents until it finds
|
||||
* the defined namespace or return NULL otherwise.
|
||||
* return values: the namespace pointer or NULL.
|
||||
* Returns the namespace pointer or NULL.
|
||||
*/
|
||||
xmlNsPtr
|
||||
xmlSearchNsByHref(xmlDocPtr doc, xmlNodePtr node, const CHAR *href) {
|
||||
@ -2003,7 +2019,7 @@ xmlSearchNsByHref(xmlDocPtr doc, xmlNodePtr node, const CHAR *href) {
|
||||
*
|
||||
* Search and get the value of an attribute associated to a node
|
||||
* This does the entity substitution.
|
||||
* return values: the attribute value or NULL if not found.
|
||||
* Returns the attribute value or NULL if not found.
|
||||
*/
|
||||
CHAR *xmlGetProp(xmlNodePtr node, const CHAR *name) {
|
||||
xmlAttrPtr prop = node->properties;
|
||||
@ -2028,7 +2044,7 @@ CHAR *xmlGetProp(xmlNodePtr node, const CHAR *name) {
|
||||
* @value: the attribute value
|
||||
*
|
||||
* Set (or reset) an attribute carried by a node.
|
||||
* return values: the attribute pointer.
|
||||
* Returns the attribute pointer.
|
||||
*/
|
||||
xmlAttrPtr
|
||||
xmlSetProp(xmlNodePtr node, const CHAR *name, const CHAR *value) {
|
||||
@ -2054,7 +2070,7 @@ xmlSetProp(xmlNodePtr node, const CHAR *name, const CHAR *value) {
|
||||
* @node: the node
|
||||
*
|
||||
* Is this node a Text node ?
|
||||
* return values: 1 yes, 0 no
|
||||
* Returns 1 yes, 0 no
|
||||
*/
|
||||
int
|
||||
xmlNodeIsText(xmlNodePtr node) {
|
||||
@ -2065,7 +2081,7 @@ xmlNodeIsText(xmlNodePtr node) {
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlNodeIsText:
|
||||
* xmlTextConcat:
|
||||
* @node: the node
|
||||
* @content: the content
|
||||
* @len: @content lenght
|
||||
@ -2274,15 +2290,20 @@ xmlDtdDump(xmlDocPtr doc) {
|
||||
xmlBufferWriteCHAR(cur->SystemID);
|
||||
xmlBufferWriteChar("\"");
|
||||
}
|
||||
if ((cur->entities == NULL) && (cur->elements == NULL)) {
|
||||
if ((cur->entities == NULL) && (cur->elements == NULL) &&
|
||||
(cur->attributes == NULL) && (cur->notations == NULL)) {
|
||||
xmlBufferWriteChar(">\n");
|
||||
return;
|
||||
}
|
||||
xmlBufferWriteChar(" [\n");
|
||||
if (cur->entities != NULL)
|
||||
xmlDumpEntitiesTable((xmlEntitiesTablePtr) cur->entities);
|
||||
if (cur->notations != NULL)
|
||||
xmlDumpNotationTable((xmlNotationTablePtr) cur->notations);
|
||||
if (cur->elements != NULL)
|
||||
xmlDumpElementTable((xmlElementTablePtr) cur->elements);
|
||||
if (cur->attributes != NULL)
|
||||
xmlDumpAttributeTable((xmlAttributeTablePtr) cur->attributes);
|
||||
xmlBufferWriteChar("]");
|
||||
|
||||
/* TODO !!! a lot more things to dump ... */
|
||||
@ -2513,7 +2534,7 @@ xmlDocDumpMemory(xmlDocPtr cur, CHAR**mem, int *size) {
|
||||
* @doc: the document
|
||||
*
|
||||
* get the compression ratio for a document, ZLIB based
|
||||
* return values: 0 (uncompressed) to 9 (max compression)
|
||||
* Returns 0 (uncompressed) to 9 (max compression)
|
||||
*/
|
||||
int
|
||||
xmlGetDocCompressMode (xmlDocPtr doc) {
|
||||
@ -2541,7 +2562,7 @@ xmlSetDocCompressMode (xmlDocPtr doc, int mode) {
|
||||
* xmlGetCompressMode:
|
||||
*
|
||||
* get the default compression mode used, ZLIB based.
|
||||
* return values: 0 (uncompressed) to 9 (max compression)
|
||||
* Returns 0 (uncompressed) to 9 (max compression)
|
||||
*/
|
||||
int
|
||||
xmlGetCompressMode(void) {
|
||||
|
207
tree.h
207
tree.h
@ -55,41 +55,67 @@ typedef unsigned char CHAR;
|
||||
|
||||
/*
|
||||
* a DTD Notation definition
|
||||
* TODO !!!!
|
||||
*/
|
||||
|
||||
typedef struct xmlNotation {
|
||||
const CHAR *name; /* Notation name */
|
||||
const CHAR *PublicID; /* Public identifier, if any */
|
||||
const CHAR *SystemID; /* System identifier, if any */
|
||||
} xmlNotation;
|
||||
typedef xmlNotation *xmlNotationPtr;
|
||||
|
||||
/*
|
||||
* a DTD Attribute definition
|
||||
* TODO !!!!
|
||||
*/
|
||||
|
||||
#define XML_ATTRIBUTE_NONE 1
|
||||
#define XML_ATTRIBUTE_REQUIRED 2
|
||||
#define XML_ATTRIBUTE_IMPLIED 3
|
||||
#define XML_ATTRIBUTE_FIXED 4
|
||||
typedef enum {
|
||||
XML_ATTRIBUTE_CDATA = 1,
|
||||
XML_ATTRIBUTE_ID,
|
||||
XML_ATTRIBUTE_IDREF ,
|
||||
XML_ATTRIBUTE_IDREFS,
|
||||
XML_ATTRIBUTE_ENTITY,
|
||||
XML_ATTRIBUTE_ENTITIES,
|
||||
XML_ATTRIBUTE_NMTOKEN,
|
||||
XML_ATTRIBUTE_NMTOKENS,
|
||||
XML_ATTRIBUTE_ENUMERATION,
|
||||
XML_ATTRIBUTE_NOTATION
|
||||
} xmlAttributeType;
|
||||
|
||||
#define XML_ATTRIBUTE_STRING 1
|
||||
#define XML_ATTRIBUTE_ID 2
|
||||
#define XML_ATTRIBUTE_IDREF 3
|
||||
#define XML_ATTRIBUTE_IDREFS 4
|
||||
#define XML_ATTRIBUTE_ENTITY 5
|
||||
#define XML_ATTRIBUTE_ENTITIES 6
|
||||
#define XML_ATTRIBUTE_NMTOKEN 7
|
||||
#define XML_ATTRIBUTE_NMTOKENS 8
|
||||
#define XML_ATTRIBUTE_ENUMERATED 9
|
||||
typedef enum {
|
||||
XML_ATTRIBUTE_NONE = 1,
|
||||
XML_ATTRIBUTE_REQUIRED,
|
||||
XML_ATTRIBUTE_IMPLIED,
|
||||
XML_ATTRIBUTE_FIXED
|
||||
} xmlAttributeDefault;
|
||||
|
||||
typedef struct xmlEnumeration {
|
||||
struct xmlEnumeration *next; /* next one */
|
||||
const CHAR *name; /* Enumeration name */
|
||||
} xmlEnumeration;
|
||||
typedef xmlEnumeration *xmlEnumerationPtr;
|
||||
|
||||
typedef struct xmlAttribute {
|
||||
const CHAR *elem; /* Element holding the attribute */
|
||||
const CHAR *name; /* Attribute name */
|
||||
xmlAttributeType type; /* The type */
|
||||
xmlAttributeDefault def; /* the default */
|
||||
const CHAR *defaultValue;/* or the default value */
|
||||
xmlEnumerationPtr tree; /* or the enumeration tree if any */
|
||||
} xmlAttribute;
|
||||
typedef xmlAttribute *xmlAttributePtr;
|
||||
|
||||
/*
|
||||
* a DTD Element definition.
|
||||
*/
|
||||
typedef enum {
|
||||
XML_ELEMENT_CONTENT_PCDATA=1,
|
||||
XML_ELEMENT_CONTENT_PCDATA = 1,
|
||||
XML_ELEMENT_CONTENT_ELEMENT,
|
||||
XML_ELEMENT_CONTENT_SEQ,
|
||||
XML_ELEMENT_CONTENT_OR
|
||||
} xmlElementContentType;
|
||||
|
||||
typedef enum {
|
||||
XML_ELEMENT_CONTENT_ONCE=1,
|
||||
XML_ELEMENT_CONTENT_ONCE = 1,
|
||||
XML_ELEMENT_CONTENT_OPT,
|
||||
XML_ELEMENT_CONTENT_MULT,
|
||||
XML_ELEMENT_CONTENT_PLUS
|
||||
@ -101,10 +127,11 @@ typedef struct xmlElementContent {
|
||||
const CHAR *name; /* Element name */
|
||||
struct xmlElementContent *c1; /* first child */
|
||||
struct xmlElementContent *c2; /* second child */
|
||||
} xmlElementContent, *xmlElementContentPtr;
|
||||
} xmlElementContent;
|
||||
typedef xmlElementContent *xmlElementContentPtr;
|
||||
|
||||
typedef enum {
|
||||
XML_ELEMENT_TYPE_EMPTY=1,
|
||||
XML_ELEMENT_TYPE_EMPTY = 1,
|
||||
XML_ELEMENT_TYPE_ANY,
|
||||
XML_ELEMENT_TYPE_MIXED,
|
||||
XML_ELEMENT_TYPE_ELEMENT
|
||||
@ -114,7 +141,8 @@ typedef struct xmlElement {
|
||||
const CHAR *name; /* Element name */
|
||||
xmlElementTypeVal type; /* The type */
|
||||
xmlElementContentPtr content; /* the allowed element content */
|
||||
} xmlElement, *xmlElementPtr;
|
||||
} xmlElement;
|
||||
typedef xmlElement *xmlElementPtr;
|
||||
|
||||
/*
|
||||
* An XML namespace.
|
||||
@ -123,7 +151,7 @@ typedef struct xmlElement {
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
XML_GLOBAL_NAMESPACE=1, /* old style global namespace */
|
||||
XML_GLOBAL_NAMESPACE = 1, /* old style global namespace */
|
||||
XML_LOCAL_NAMESPACE /* new style local scoping */
|
||||
} xmlNsType;
|
||||
|
||||
@ -132,7 +160,8 @@ typedef struct xmlNs {
|
||||
xmlNsType type; /* global or local */
|
||||
const CHAR *href; /* URL for the namespace */
|
||||
const CHAR *prefix; /* prefix for the namespace */
|
||||
} xmlNs, *xmlNsPtr;
|
||||
} xmlNs;
|
||||
typedef xmlNs *xmlNsPtr;
|
||||
|
||||
/*
|
||||
* An XML DtD, as defined by <!DOCTYPE.
|
||||
@ -141,10 +170,13 @@ typedef struct xmlDtd {
|
||||
const CHAR *name; /* Name of the DTD */
|
||||
const CHAR *ExternalID; /* External identifier for PUBLIC DTD */
|
||||
const CHAR *SystemID; /* URI for a SYSTEM or PUBLIC DTD */
|
||||
void *notations; /* Hash table for notations if any */
|
||||
void *elements; /* Hash table for elements if any */
|
||||
void *attributes; /* Hash table for attributes if any */
|
||||
void *entities; /* Hash table for entities if any */
|
||||
/* struct xmlDtd *next; * next link for this document */
|
||||
} xmlDtd, *xmlDtdPtr;
|
||||
} xmlDtd;
|
||||
typedef xmlDtd *xmlDtdPtr;
|
||||
|
||||
/*
|
||||
* A attribute of an XML node.
|
||||
@ -159,7 +191,8 @@ typedef struct xmlAttr {
|
||||
struct xmlAttr *next; /* parent->childs link */
|
||||
const CHAR *name; /* the name of the property */
|
||||
struct xmlNode *val; /* the value of the property */
|
||||
} xmlAttr, *xmlAttrPtr;
|
||||
} xmlAttr;
|
||||
typedef xmlAttr *xmlAttrPtr;
|
||||
|
||||
/*
|
||||
* A node in an XML tree.
|
||||
@ -181,7 +214,9 @@ typedef struct xmlNode {
|
||||
xmlNs *ns; /* pointer to the associated namespace */
|
||||
xmlNs *nsDef; /* namespace definitions on this node */
|
||||
CHAR *content; /* the content */
|
||||
} xmlNode, *xmlNodePtr;
|
||||
} _xmlNode;
|
||||
typedef _xmlNode xmlNode;
|
||||
typedef _xmlNode *xmlNodePtr;
|
||||
|
||||
/*
|
||||
* An XML document.
|
||||
@ -201,7 +236,9 @@ typedef struct xmlDoc {
|
||||
struct xmlDtd *extSubset; /* the document external subset */
|
||||
struct xmlNs *oldNs; /* Global namespace, the old way */
|
||||
struct xmlNode *root; /* the document tree */
|
||||
} xmlDoc, *xmlDocPtr;
|
||||
} _xmlDoc;
|
||||
typedef _xmlDoc xmlDoc;
|
||||
typedef xmlDoc *xmlDocPtr;
|
||||
|
||||
/*
|
||||
* Variables.
|
||||
@ -213,110 +250,110 @@ extern int xmlIndentTreeOutput; /* try to indent the tree dumps */
|
||||
/*
|
||||
* Creating/freeing new structures
|
||||
*/
|
||||
extern xmlDtdPtr xmlCreateIntSubset(xmlDocPtr doc, const CHAR *name,
|
||||
xmlDtdPtr xmlCreateIntSubset(xmlDocPtr doc, const CHAR *name,
|
||||
const CHAR *ExternalID, const CHAR *SystemID);
|
||||
extern xmlDtdPtr xmlNewDtd(xmlDocPtr doc, const CHAR *name,
|
||||
xmlDtdPtr xmlNewDtd(xmlDocPtr doc, const CHAR *name,
|
||||
const CHAR *ExternalID, const CHAR *SystemID);
|
||||
extern void xmlFreeDtd(xmlDtdPtr cur);
|
||||
extern xmlNsPtr xmlNewGlobalNs(xmlDocPtr doc, const CHAR *href, const CHAR *AS);
|
||||
extern xmlNsPtr xmlNewNs(xmlNodePtr node, const CHAR *href, const CHAR *AS);
|
||||
extern void xmlFreeNs(xmlNsPtr cur);
|
||||
extern xmlDocPtr xmlNewDoc(const CHAR *version);
|
||||
extern void xmlFreeDoc(xmlDocPtr cur);
|
||||
extern xmlAttrPtr xmlNewDocProp(xmlDocPtr doc, const CHAR *name,
|
||||
void xmlFreeDtd(xmlDtdPtr cur);
|
||||
xmlNsPtr xmlNewGlobalNs(xmlDocPtr doc, const CHAR *href, const CHAR *prefix);
|
||||
xmlNsPtr xmlNewNs(xmlNodePtr node, const CHAR *href, const CHAR *prefix);
|
||||
void xmlFreeNs(xmlNsPtr cur);
|
||||
xmlDocPtr xmlNewDoc(const CHAR *version);
|
||||
void xmlFreeDoc(xmlDocPtr cur);
|
||||
xmlAttrPtr xmlNewDocProp(xmlDocPtr doc, const CHAR *name,
|
||||
const CHAR *value);
|
||||
extern xmlAttrPtr xmlNewProp(xmlNodePtr node, const CHAR *name,
|
||||
xmlAttrPtr xmlNewProp(xmlNodePtr node, const CHAR *name,
|
||||
const CHAR *value);
|
||||
extern void xmlFreePropList(xmlAttrPtr cur);
|
||||
extern void xmlFreeProp(xmlAttrPtr cur);
|
||||
extern xmlAttrPtr xmlCopyProp(xmlAttrPtr cur);
|
||||
extern xmlAttrPtr xmlCopyPropList(xmlAttrPtr cur);
|
||||
extern xmlDtdPtr xmlCopyDtd(xmlDtdPtr dtd);
|
||||
extern xmlDocPtr xmlCopyDoc(xmlDocPtr doc, int recursive);
|
||||
void xmlFreePropList(xmlAttrPtr cur);
|
||||
void xmlFreeProp(xmlAttrPtr cur);
|
||||
xmlAttrPtr xmlCopyProp(xmlAttrPtr cur);
|
||||
xmlAttrPtr xmlCopyPropList(xmlAttrPtr cur);
|
||||
xmlDtdPtr xmlCopyDtd(xmlDtdPtr dtd);
|
||||
xmlDocPtr xmlCopyDoc(xmlDocPtr doc, int recursive);
|
||||
|
||||
/*
|
||||
* Creating new nodes
|
||||
*/
|
||||
extern xmlNodePtr xmlNewDocNode(xmlDocPtr doc, xmlNsPtr ns,
|
||||
xmlNodePtr xmlNewDocNode(xmlDocPtr doc, xmlNsPtr ns,
|
||||
const CHAR *name, CHAR *content);
|
||||
extern xmlNodePtr xmlNewNode(xmlNsPtr ns, const CHAR *name);
|
||||
extern xmlNodePtr xmlNewChild(xmlNodePtr parent, xmlNsPtr ns,
|
||||
xmlNodePtr xmlNewNode(xmlNsPtr ns, const CHAR *name);
|
||||
xmlNodePtr xmlNewChild(xmlNodePtr parent, xmlNsPtr ns,
|
||||
const CHAR *name, CHAR *content);
|
||||
extern xmlNodePtr xmlNewDocText(xmlDocPtr doc, const CHAR *content);
|
||||
extern xmlNodePtr xmlNewText(const CHAR *content);
|
||||
extern xmlNodePtr xmlNewDocTextLen(xmlDocPtr doc, const CHAR *content, int len);
|
||||
extern xmlNodePtr xmlNewTextLen(const CHAR *content, int len);
|
||||
extern xmlNodePtr xmlNewDocComment(xmlDocPtr doc, CHAR *content);
|
||||
extern xmlNodePtr xmlNewComment(CHAR *content);
|
||||
extern xmlNodePtr xmlNewReference(xmlDocPtr doc, const CHAR *name);
|
||||
extern xmlNodePtr xmlCopyNode(xmlNodePtr node, int recursive);
|
||||
extern xmlNodePtr xmlCopyNodeList(xmlNodePtr node);
|
||||
xmlNodePtr xmlNewDocText(xmlDocPtr doc, const CHAR *content);
|
||||
xmlNodePtr xmlNewText(const CHAR *content);
|
||||
xmlNodePtr xmlNewDocTextLen(xmlDocPtr doc, const CHAR *content, int len);
|
||||
xmlNodePtr xmlNewTextLen(const CHAR *content, int len);
|
||||
xmlNodePtr xmlNewDocComment(xmlDocPtr doc, CHAR *content);
|
||||
xmlNodePtr xmlNewComment(CHAR *content);
|
||||
xmlNodePtr xmlNewReference(xmlDocPtr doc, const CHAR *name);
|
||||
xmlNodePtr xmlCopyNode(xmlNodePtr node, int recursive);
|
||||
xmlNodePtr xmlCopyNodeList(xmlNodePtr node);
|
||||
|
||||
/*
|
||||
* Navigating
|
||||
*/
|
||||
extern xmlNodePtr xmlGetLastChild(xmlNodePtr node);
|
||||
extern int xmlNodeIsText(xmlNodePtr node);
|
||||
xmlNodePtr xmlGetLastChild(xmlNodePtr parent);
|
||||
int xmlNodeIsText(xmlNodePtr node);
|
||||
|
||||
/*
|
||||
* Changing the structure
|
||||
*/
|
||||
extern xmlNodePtr xmlAddChild(xmlNodePtr parent, xmlNodePtr cur);
|
||||
extern void xmlUnlinkNode(xmlNodePtr cur);
|
||||
xmlNodePtr xmlAddChild(xmlNodePtr parent, xmlNodePtr cur);
|
||||
void xmlUnlinkNode(xmlNodePtr cur);
|
||||
|
||||
extern xmlNodePtr xmlTextMerge(xmlNodePtr first, xmlNodePtr second);
|
||||
extern void xmlTextConcat(xmlNodePtr node, const CHAR *content, int len);
|
||||
xmlNodePtr xmlTextMerge(xmlNodePtr first, xmlNodePtr second);
|
||||
void xmlTextConcat(xmlNodePtr node, const CHAR *content, int len);
|
||||
|
||||
extern void xmlFreeNodeList(xmlNodePtr cur);
|
||||
extern void xmlFreeNode(xmlNodePtr cur);
|
||||
void xmlFreeNodeList(xmlNodePtr cur);
|
||||
void xmlFreeNode(xmlNodePtr cur);
|
||||
|
||||
/*
|
||||
* Namespaces
|
||||
*/
|
||||
extern xmlNsPtr xmlSearchNs(xmlDocPtr doc, xmlNodePtr node,
|
||||
xmlNsPtr xmlSearchNs(xmlDocPtr doc, xmlNodePtr node,
|
||||
const CHAR *nameSpace);
|
||||
extern xmlNsPtr xmlSearchNsByHref(xmlDocPtr doc, xmlNodePtr node,
|
||||
xmlNsPtr xmlSearchNsByHref(xmlDocPtr doc, xmlNodePtr node,
|
||||
const CHAR *href);
|
||||
extern void xmlSetNs(xmlNodePtr node, xmlNsPtr ns);
|
||||
extern xmlNsPtr xmlCopyNamespace(xmlNsPtr cur);
|
||||
extern xmlNsPtr xmlCopyNamespaceList(xmlNsPtr cur);
|
||||
void xmlSetNs(xmlNodePtr node, xmlNsPtr ns);
|
||||
xmlNsPtr xmlCopyNamespace(xmlNsPtr cur);
|
||||
xmlNsPtr xmlCopyNamespaceList(xmlNsPtr cur);
|
||||
|
||||
/*
|
||||
* Changing the content.
|
||||
*/
|
||||
extern xmlAttrPtr xmlSetProp(xmlNodePtr node, const CHAR *name,
|
||||
xmlAttrPtr xmlSetProp(xmlNodePtr node, const CHAR *name,
|
||||
const CHAR *value);
|
||||
extern CHAR *xmlGetProp(xmlNodePtr node, const CHAR *name);
|
||||
extern xmlNodePtr xmlStringGetNodeList(xmlDocPtr doc, const CHAR *value);
|
||||
extern xmlNodePtr xmlStringLenGetNodeList(xmlDocPtr doc, const CHAR *value,
|
||||
CHAR *xmlGetProp(xmlNodePtr node, const CHAR *name);
|
||||
xmlNodePtr xmlStringGetNodeList(xmlDocPtr doc, const CHAR *value);
|
||||
xmlNodePtr xmlStringLenGetNodeList(xmlDocPtr doc, const CHAR *value,
|
||||
int len);
|
||||
extern CHAR *xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int inLine);
|
||||
extern void xmlNodeSetContent(xmlNodePtr cur, const CHAR *content);
|
||||
extern void xmlNodeSetContentLen(xmlNodePtr cur, const CHAR *content, int len);
|
||||
extern void xmlNodeAddContent(xmlNodePtr cur, const CHAR *content);
|
||||
extern void xmlNodeAddContentLen(xmlNodePtr cur, const CHAR *content, int len);
|
||||
extern CHAR *xmlNodeGetContent(xmlNodePtr cur);
|
||||
CHAR *xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int inLine);
|
||||
void xmlNodeSetContent(xmlNodePtr cur, const CHAR *content);
|
||||
void xmlNodeSetContentLen(xmlNodePtr cur, const CHAR *content, int len);
|
||||
void xmlNodeAddContent(xmlNodePtr cur, const CHAR *content);
|
||||
void xmlNodeAddContentLen(xmlNodePtr cur, const CHAR *content, int len);
|
||||
CHAR *xmlNodeGetContent(xmlNodePtr cur);
|
||||
|
||||
/*
|
||||
* Internal, don't use
|
||||
*/
|
||||
extern void xmlBufferWriteCHAR(const CHAR *string);
|
||||
extern void xmlBufferWriteChar(const char *string);
|
||||
void xmlBufferWriteCHAR(const CHAR *string);
|
||||
void xmlBufferWriteChar(const char *string);
|
||||
|
||||
/*
|
||||
* Saving
|
||||
*/
|
||||
extern void xmlDocDumpMemory(xmlDocPtr cur, CHAR**mem, int *size);
|
||||
extern void xmlDocDump(FILE *f, xmlDocPtr doc);
|
||||
void xmlDocDumpMemory(xmlDocPtr cur, CHAR**mem, int *size);
|
||||
void xmlDocDump(FILE *f, xmlDocPtr cur);
|
||||
int xmlSaveFile(const char *filename, xmlDocPtr cur);
|
||||
|
||||
/*
|
||||
* Compression
|
||||
*/
|
||||
extern int xmlGetDocCompressMode (xmlDocPtr doc);
|
||||
extern void xmlSetDocCompressMode (xmlDocPtr doc, int mode);
|
||||
extern int xmlGetCompressMode(void);
|
||||
extern void xmlSetCompressMode(int mode);
|
||||
int xmlGetDocCompressMode (xmlDocPtr doc);
|
||||
void xmlSetDocCompressMode (xmlDocPtr doc, int mode);
|
||||
int xmlGetCompressMode(void);
|
||||
void xmlSetCompressMode(int mode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
681
valid.c
681
valid.c
@ -26,7 +26,7 @@
|
||||
*
|
||||
* Allocate an element content structure.
|
||||
*
|
||||
* return values: NULL if not, othervise the new element content structure
|
||||
* Returns NULL if not, othervise the new element content structure
|
||||
*/
|
||||
xmlElementContentPtr
|
||||
xmlNewElementContent(CHAR *name, int type) {
|
||||
@ -60,6 +60,7 @@ xmlNewElementContent(CHAR *name, int type) {
|
||||
ret->name = xmlStrdup(name);
|
||||
else
|
||||
ret->name = NULL;
|
||||
ret->c1 = ret->c2 = NULL;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@ -69,12 +70,17 @@ xmlNewElementContent(CHAR *name, int type) {
|
||||
*
|
||||
* Build a copy of an element content description.
|
||||
*
|
||||
* return values: the new xmlElementContentPtr or NULL in case of error.
|
||||
* Returns the new xmlElementContentPtr or NULL in case of error.
|
||||
*/
|
||||
xmlElementContentPtr
|
||||
xmlCopyElementContent(xmlElementContentPtr content) {
|
||||
/* TODO !!! */
|
||||
return(NULL);
|
||||
xmlCopyElementContent(xmlElementContentPtr cur) {
|
||||
xmlElementContentPtr ret;
|
||||
|
||||
if (cur == NULL) return(NULL);
|
||||
ret = xmlNewElementContent((CHAR *) cur->name, cur->type);
|
||||
if (cur->c1 != NULL) cur->c1 = xmlCopyElementContent(cur->c1);
|
||||
if (cur->c2 != NULL) cur->c2 = xmlCopyElementContent(cur->c2);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -85,7 +91,12 @@ xmlCopyElementContent(xmlElementContentPtr content) {
|
||||
*/
|
||||
void
|
||||
xmlFreeElementContent(xmlElementContentPtr cur) {
|
||||
/* TODO !!! */
|
||||
if (cur == NULL) return;
|
||||
if (cur->c1 != NULL) xmlFreeElementContent(cur->c1);
|
||||
if (cur->c2 != NULL) xmlFreeElementContent(cur->c2);
|
||||
if (cur->name != NULL) free((CHAR *) cur->name);
|
||||
memset(cur, -1, sizeof(xmlElementContent));
|
||||
free(cur);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -166,7 +177,7 @@ xmlDumpElementContent(xmlElementContentPtr content, int glob) {
|
||||
*
|
||||
* create and initialize an empty element hash table.
|
||||
*
|
||||
* return values: the xmlElementTablePtr just created or NULL in case of error.
|
||||
* Returns the xmlElementTablePtr just created or NULL in case of error.
|
||||
*/
|
||||
xmlElementTablePtr
|
||||
xmlCreateElementTable(void) {
|
||||
@ -179,7 +190,7 @@ xmlCreateElementTable(void) {
|
||||
sizeof(xmlElementTable));
|
||||
return(NULL);
|
||||
}
|
||||
ret->max_elements = XML_MIN_ENTITIES_TABLE;
|
||||
ret->max_elements = XML_MIN_ELEMENT_TABLE;
|
||||
ret->nb_elements = 0;
|
||||
ret->table = (xmlElementPtr )
|
||||
malloc(ret->max_elements * sizeof(xmlElement));
|
||||
@ -195,14 +206,17 @@ xmlCreateElementTable(void) {
|
||||
|
||||
/**
|
||||
* xmlAddElementDecl:
|
||||
* @dtd: pointer to the DTD
|
||||
* @name: the entity name
|
||||
* @type: the element type
|
||||
* @content: the element content tree or NULL
|
||||
*
|
||||
* Register a new element declaration
|
||||
*
|
||||
* return values: NULL if not, othervise the entity
|
||||
* Returns NULL if not, othervise the entity
|
||||
*/
|
||||
xmlElementPtr
|
||||
xmlAddElementDecl(xmlDtdPtr dtd, char *name, int type,
|
||||
xmlAddElementDecl(xmlDtdPtr dtd, CHAR *name, int type,
|
||||
xmlElementContentPtr content) {
|
||||
xmlElementPtr ret, cur;
|
||||
xmlElementTablePtr table;
|
||||
@ -318,14 +332,13 @@ xmlFreeElement(xmlElementPtr elem) {
|
||||
if (elem->name != NULL)
|
||||
free((CHAR *) elem->name);
|
||||
memset(elem, -1, sizeof(xmlElement));
|
||||
free(elem);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlFreeElementTable:
|
||||
* @table: An element table
|
||||
*
|
||||
* Deallocate the memory used by an entities hash table.
|
||||
* Deallocate the memory used by an element hash table.
|
||||
*/
|
||||
void
|
||||
xmlFreeElementTable(xmlElementTablePtr table) {
|
||||
@ -346,7 +359,7 @@ xmlFreeElementTable(xmlElementTablePtr table) {
|
||||
*
|
||||
* Build a copy of an element table.
|
||||
*
|
||||
* return values: the new xmlElementTablePtr or NULL in case of error.
|
||||
* Returns the new xmlElementTablePtr or NULL in case of error.
|
||||
*/
|
||||
xmlElementTablePtr
|
||||
xmlCopyElementTable(xmlElementTablePtr table) {
|
||||
@ -431,3 +444,645 @@ xmlDumpElementTable(xmlElementTablePtr table) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlCreateEnumeration:
|
||||
* @name: the enumeration name or NULL
|
||||
*
|
||||
* create and initialize an enumeration attribute node.
|
||||
*
|
||||
* Returns the xmlEnumerationPtr just created or NULL in case
|
||||
* of error.
|
||||
*/
|
||||
xmlEnumerationPtr
|
||||
xmlCreateEnumeration(CHAR *name) {
|
||||
xmlEnumerationPtr ret;
|
||||
|
||||
ret = (xmlEnumerationPtr) malloc(sizeof(xmlEnumeration));
|
||||
if (ret == NULL) {
|
||||
fprintf(stderr, "xmlCreateEnumeration : malloc(%d) failed\n",
|
||||
sizeof(xmlEnumeration));
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
if (name != NULL)
|
||||
ret->name = xmlStrdup(name);
|
||||
else
|
||||
ret->name = NULL;
|
||||
ret->next = NULL;
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlFreeEnumeration:
|
||||
* @cur: the tree to free.
|
||||
*
|
||||
* free an enumeration attribute node (recursive).
|
||||
*/
|
||||
void
|
||||
xmlFreeEnumeration(xmlEnumerationPtr cur) {
|
||||
if (cur == NULL) return;
|
||||
|
||||
if (cur->next != NULL) xmlFreeEnumeration(cur->next);
|
||||
|
||||
if (cur->name != NULL) free((CHAR *) cur->name);
|
||||
memset(cur, -1, sizeof(xmlEnumeration));
|
||||
free(cur);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlCopyEnumeration:
|
||||
* @cur: the tree to copy.
|
||||
*
|
||||
* Copy an enumeration attribute node (recursive).
|
||||
*
|
||||
* Returns the xmlEnumerationPtr just created or NULL in case
|
||||
* of error.
|
||||
*/
|
||||
xmlEnumerationPtr
|
||||
xmlCopyEnumeration(xmlEnumerationPtr cur) {
|
||||
xmlEnumerationPtr ret;
|
||||
|
||||
if (cur == NULL) return(NULL);
|
||||
ret = xmlCreateEnumeration((CHAR *) cur->name);
|
||||
|
||||
if (cur->next != NULL) ret->next = xmlCopyEnumeration(cur->next);
|
||||
else ret->next = NULL;
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlCreateAttributeTable:
|
||||
*
|
||||
* create and initialize an empty attribute hash table.
|
||||
*
|
||||
* Returns the xmlAttributeTablePtr just created or NULL in case
|
||||
* of error.
|
||||
*/
|
||||
xmlAttributeTablePtr
|
||||
xmlCreateAttributeTable(void) {
|
||||
xmlAttributeTablePtr ret;
|
||||
|
||||
ret = (xmlAttributeTablePtr)
|
||||
malloc(sizeof(xmlAttributeTable));
|
||||
if (ret == NULL) {
|
||||
fprintf(stderr, "xmlCreateAttributeTable : malloc(%d) failed\n",
|
||||
sizeof(xmlAttributeTable));
|
||||
return(NULL);
|
||||
}
|
||||
ret->max_attributes = XML_MIN_ATTRIBUTE_TABLE;
|
||||
ret->nb_attributes = 0;
|
||||
ret->table = (xmlAttributePtr )
|
||||
malloc(ret->max_attributes * sizeof(xmlAttribute));
|
||||
if (ret == NULL) {
|
||||
fprintf(stderr, "xmlCreateAttributeTable : malloc(%d) failed\n",
|
||||
ret->max_attributes * sizeof(xmlAttribute));
|
||||
free(ret);
|
||||
return(NULL);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* xmlAddAttributeDecl:
|
||||
* @dtd: pointer to the DTD
|
||||
* @elem: the element name
|
||||
* @name: the attribute name
|
||||
* @type: the attribute type
|
||||
* @def: the attribute default type
|
||||
* @defaultValue: the attribute default value
|
||||
* @tree: if it's an enumeration, the associated list
|
||||
*
|
||||
* Register a new attribute declaration
|
||||
*
|
||||
* Returns NULL if not, othervise the entity
|
||||
*/
|
||||
xmlAttributePtr
|
||||
xmlAddAttributeDecl(xmlDtdPtr dtd, CHAR *elem, CHAR *name, int type, int def,
|
||||
CHAR *defaultValue, xmlEnumerationPtr tree) {
|
||||
xmlAttributePtr ret, cur;
|
||||
xmlAttributeTablePtr table;
|
||||
int i;
|
||||
|
||||
if (dtd == NULL) {
|
||||
fprintf(stderr, "xmlAddAttributeDecl: dtd == NULL\n");
|
||||
return(NULL);
|
||||
}
|
||||
if (name == NULL) {
|
||||
fprintf(stderr, "xmlAddAttributeDecl: name == NULL\n");
|
||||
return(NULL);
|
||||
}
|
||||
if (elem == NULL) {
|
||||
fprintf(stderr, "xmlAddAttributeDecl: elem == NULL\n");
|
||||
return(NULL);
|
||||
}
|
||||
/* TODO: Lacks verifications !!! */
|
||||
switch (type) {
|
||||
case XML_ATTRIBUTE_CDATA:
|
||||
break;
|
||||
case XML_ATTRIBUTE_ID:
|
||||
break;
|
||||
case XML_ATTRIBUTE_IDREF:
|
||||
break;
|
||||
case XML_ATTRIBUTE_IDREFS:
|
||||
break;
|
||||
case XML_ATTRIBUTE_ENTITY:
|
||||
break;
|
||||
case XML_ATTRIBUTE_ENTITIES:
|
||||
break;
|
||||
case XML_ATTRIBUTE_NMTOKEN:
|
||||
break;
|
||||
case XML_ATTRIBUTE_NMTOKENS:
|
||||
break;
|
||||
case XML_ATTRIBUTE_ENUMERATION:
|
||||
break;
|
||||
case XML_ATTRIBUTE_NOTATION:
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "xmlAddAttributeDecl: unknown type %d\n", type);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the Attribute table if needed.
|
||||
*/
|
||||
table = dtd->attributes;
|
||||
if (table == NULL)
|
||||
table = dtd->attributes = xmlCreateAttributeTable();
|
||||
if (table == NULL) {
|
||||
fprintf(stderr, "xmlAddAttributeDecl: Table creation failed!\n");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validity Check:
|
||||
* Search the DTD for previous declarations of the ATTLIST
|
||||
*/
|
||||
for (i = 0;i < table->nb_attributes;i++) {
|
||||
cur = &table->table[i];
|
||||
if ((!xmlStrcmp(cur->name, name)) && (!xmlStrcmp(cur->elem, elem))) {
|
||||
/*
|
||||
* The attribute is already defined in this Dtd.
|
||||
*/
|
||||
fprintf(stderr,
|
||||
"xmlAddAttributeDecl: %s already defined\n", name);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Grow the table, if needed.
|
||||
*/
|
||||
if (table->nb_attributes >= table->max_attributes) {
|
||||
/*
|
||||
* need more attributes.
|
||||
*/
|
||||
table->max_attributes *= 2;
|
||||
table->table = (xmlAttributePtr)
|
||||
realloc(table->table, table->max_attributes * sizeof(xmlAttribute));
|
||||
if (table->table) {
|
||||
fprintf(stderr, "xmlAddAttributeDecl: out of memory\n");
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
ret = &table->table[table->nb_attributes];
|
||||
|
||||
/*
|
||||
* fill the structure.
|
||||
*/
|
||||
ret->type = type;
|
||||
ret->name = xmlStrdup(name);
|
||||
ret->elem = xmlStrdup(elem);
|
||||
ret->def = def;
|
||||
ret->tree = tree;
|
||||
if (defaultValue != NULL)
|
||||
ret->defaultValue = xmlStrdup(defaultValue);
|
||||
else
|
||||
ret->defaultValue = NULL;
|
||||
table->nb_attributes++;
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlFreeAttribute:
|
||||
* @elem: An attribute
|
||||
*
|
||||
* Deallocate the memory used by an attribute definition
|
||||
*/
|
||||
void
|
||||
xmlFreeAttribute(xmlAttributePtr attr) {
|
||||
if (attr == NULL) return;
|
||||
if (attr->tree != NULL)
|
||||
xmlFreeEnumeration(attr->tree);
|
||||
if (attr->elem != NULL)
|
||||
free((CHAR *) attr->elem);
|
||||
if (attr->name != NULL)
|
||||
free((CHAR *) attr->name);
|
||||
if (attr->defaultValue != NULL)
|
||||
free((CHAR *) attr->defaultValue);
|
||||
memset(attr, -1, sizeof(xmlAttribute));
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlFreeAttributeTable:
|
||||
* @table: An attribute table
|
||||
*
|
||||
* Deallocate the memory used by an entities hash table.
|
||||
*/
|
||||
void
|
||||
xmlFreeAttributeTable(xmlAttributeTablePtr table) {
|
||||
int i;
|
||||
|
||||
if (table == NULL) return;
|
||||
|
||||
for (i = 0;i < table->nb_attributes;i++) {
|
||||
xmlFreeAttribute(&table->table[i]);
|
||||
}
|
||||
free(table->table);
|
||||
free(table);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlCopyAttributeTable:
|
||||
* @table: An attribute table
|
||||
*
|
||||
* Build a copy of an attribute table.
|
||||
*
|
||||
* Returns the new xmlAttributeTablePtr or NULL in case of error.
|
||||
*/
|
||||
xmlAttributeTablePtr
|
||||
xmlCopyAttributeTable(xmlAttributeTablePtr table) {
|
||||
xmlAttributeTablePtr ret;
|
||||
xmlAttributePtr cur, attr;
|
||||
int i;
|
||||
|
||||
ret = (xmlAttributeTablePtr) malloc(sizeof(xmlAttributeTable));
|
||||
if (ret == NULL) {
|
||||
fprintf(stderr, "xmlCopyAttributeTable: out of memory !\n");
|
||||
return(NULL);
|
||||
}
|
||||
ret->table = (xmlAttributePtr) malloc(table->max_attributes *
|
||||
sizeof(xmlAttribute));
|
||||
if (ret->table == NULL) {
|
||||
fprintf(stderr, "xmlCopyAttributeTable: out of memory !\n");
|
||||
free(ret);
|
||||
return(NULL);
|
||||
}
|
||||
ret->max_attributes = table->max_attributes;
|
||||
ret->nb_attributes = table->nb_attributes;
|
||||
for (i = 0;i < ret->nb_attributes;i++) {
|
||||
cur = &ret->table[i];
|
||||
attr = &table->table[i];
|
||||
cur->type = attr->type;
|
||||
cur->def = attr->def;
|
||||
cur->tree = xmlCopyEnumeration(attr->tree);
|
||||
if (attr->elem != NULL)
|
||||
cur->elem = xmlStrdup(attr->elem);
|
||||
else
|
||||
cur->elem = NULL;
|
||||
if (attr->name != NULL)
|
||||
cur->name = xmlStrdup(attr->name);
|
||||
else
|
||||
cur->name = NULL;
|
||||
if (attr->defaultValue != NULL)
|
||||
cur->defaultValue = xmlStrdup(attr->defaultValue);
|
||||
else
|
||||
cur->defaultValue = NULL;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlDumpAttributeTable:
|
||||
* @table: An attribute table
|
||||
*
|
||||
* This will dump the content of the attribute table as an XML DTD definition
|
||||
*
|
||||
* NOTE: TODO an extra parameter allowing a reentant implementation will
|
||||
* be added.
|
||||
*/
|
||||
void
|
||||
xmlDumpAttributeTable(xmlAttributeTablePtr table) {
|
||||
int i;
|
||||
xmlAttributePtr cur;
|
||||
|
||||
if (table == NULL) return;
|
||||
|
||||
for (i = 0;i < table->nb_attributes;i++) {
|
||||
cur = &table->table[i];
|
||||
xmlBufferWriteChar("<!ATTLIST ");
|
||||
xmlBufferWriteCHAR(cur->elem);
|
||||
xmlBufferWriteChar(" ");
|
||||
xmlBufferWriteCHAR(cur->name);
|
||||
switch (cur->type) {
|
||||
case XML_ATTRIBUTE_CDATA:
|
||||
xmlBufferWriteChar(" CDATA");
|
||||
break;
|
||||
case XML_ATTRIBUTE_ID:
|
||||
xmlBufferWriteChar(" ID");
|
||||
break;
|
||||
case XML_ATTRIBUTE_IDREF:
|
||||
xmlBufferWriteChar(" IDREF");
|
||||
break;
|
||||
case XML_ATTRIBUTE_IDREFS:
|
||||
xmlBufferWriteChar(" IDREFS");
|
||||
break;
|
||||
case XML_ATTRIBUTE_ENTITY:
|
||||
xmlBufferWriteChar(" ENTITY");
|
||||
break;
|
||||
case XML_ATTRIBUTE_ENTITIES:
|
||||
xmlBufferWriteChar(" ENTITIES");
|
||||
break;
|
||||
case XML_ATTRIBUTE_NMTOKEN:
|
||||
xmlBufferWriteChar(" NMTOKEN");
|
||||
break;
|
||||
case XML_ATTRIBUTE_NMTOKENS:
|
||||
xmlBufferWriteChar(" NMTOKENS");
|
||||
break;
|
||||
case XML_ATTRIBUTE_ENUMERATION:
|
||||
xmlBufferWriteChar(" (pbm)");
|
||||
break;
|
||||
case XML_ATTRIBUTE_NOTATION:
|
||||
xmlBufferWriteChar(" NOTATION (pbm)");
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,
|
||||
"xmlDumpAttributeTable: internal: unknown type %d\n",
|
||||
cur->type);
|
||||
}
|
||||
switch (cur->def) {
|
||||
case XML_ATTRIBUTE_NONE:
|
||||
break;
|
||||
case XML_ATTRIBUTE_REQUIRED:
|
||||
xmlBufferWriteChar(" #REQUIRED");
|
||||
break;
|
||||
case XML_ATTRIBUTE_IMPLIED:
|
||||
xmlBufferWriteChar(" #IMPLIED");
|
||||
if (cur->defaultValue != NULL) {
|
||||
xmlBufferWriteChar(" \"");
|
||||
xmlBufferWriteCHAR(cur->defaultValue);
|
||||
xmlBufferWriteChar("\"");
|
||||
}
|
||||
break;
|
||||
case XML_ATTRIBUTE_FIXED:
|
||||
xmlBufferWriteChar(" #FIXED \"");
|
||||
xmlBufferWriteCHAR(cur->defaultValue);
|
||||
xmlBufferWriteChar("\"");
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,
|
||||
"xmlDumpAttributeTable: internal: unknown default %d\n",
|
||||
cur->def);
|
||||
}
|
||||
xmlBufferWriteChar(">\n");
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* NOTATIONs *
|
||||
* *
|
||||
************************************************************************/
|
||||
/**
|
||||
* xmlCreateNotationTable:
|
||||
*
|
||||
* create and initialize an empty notation hash table.
|
||||
*
|
||||
* Returns the xmlNotationTablePtr just created or NULL in case
|
||||
* of error.
|
||||
*/
|
||||
xmlNotationTablePtr
|
||||
xmlCreateNotationTable(void) {
|
||||
xmlNotationTablePtr ret;
|
||||
|
||||
ret = (xmlNotationTablePtr)
|
||||
malloc(sizeof(xmlNotationTable));
|
||||
if (ret == NULL) {
|
||||
fprintf(stderr, "xmlCreateNotationTable : malloc(%d) failed\n",
|
||||
sizeof(xmlNotationTable));
|
||||
return(NULL);
|
||||
}
|
||||
ret->max_notations = XML_MIN_NOTATION_TABLE;
|
||||
ret->nb_notations = 0;
|
||||
ret->table = (xmlNotationPtr )
|
||||
malloc(ret->max_notations * sizeof(xmlNotation));
|
||||
if (ret == NULL) {
|
||||
fprintf(stderr, "xmlCreateNotationTable : malloc(%d) failed\n",
|
||||
ret->max_notations * sizeof(xmlNotation));
|
||||
free(ret);
|
||||
return(NULL);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* xmlAddNotationDecl:
|
||||
* @dtd: pointer to the DTD
|
||||
* @name: the entity name
|
||||
* @PublicID: the public identifier or NULL
|
||||
* @SystemID: the system identifier or NULL
|
||||
*
|
||||
* Register a new notation declaration
|
||||
*
|
||||
* Returns NULL if not, othervise the entity
|
||||
*/
|
||||
xmlNotationPtr
|
||||
xmlAddNotationDecl(xmlDtdPtr dtd, CHAR *name, CHAR *PublicID, CHAR *SystemID) {
|
||||
xmlNotationPtr ret, cur;
|
||||
xmlNotationTablePtr table;
|
||||
int i;
|
||||
|
||||
if (dtd == NULL) {
|
||||
fprintf(stderr, "xmlAddNotationDecl: dtd == NULL\n");
|
||||
return(NULL);
|
||||
}
|
||||
if (name == NULL) {
|
||||
fprintf(stderr, "xmlAddNotationDecl: name == NULL\n");
|
||||
return(NULL);
|
||||
}
|
||||
if ((PublicID == NULL) && (SystemID == NULL)) {
|
||||
fprintf(stderr, "xmlAddNotationDecl: no PUBLIC ID nor SYSTEM ID\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the Notation table if needed.
|
||||
*/
|
||||
table = dtd->notations;
|
||||
if (table == NULL)
|
||||
table = dtd->notations = xmlCreateNotationTable();
|
||||
if (table == NULL) {
|
||||
fprintf(stderr, "xmlAddNotationDecl: Table creation failed!\n");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Validity Check:
|
||||
* Search the DTD for previous declarations of the ATTLIST
|
||||
*/
|
||||
for (i = 0;i < table->nb_notations;i++) {
|
||||
cur = &table->table[i];
|
||||
if (!xmlStrcmp(cur->name, name)) {
|
||||
/*
|
||||
* The notation is already defined in this Dtd.
|
||||
*/
|
||||
fprintf(stderr,
|
||||
"xmlAddNotationDecl: %s already defined\n", name);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Grow the table, if needed.
|
||||
*/
|
||||
if (table->nb_notations >= table->max_notations) {
|
||||
/*
|
||||
* need more notations.
|
||||
*/
|
||||
table->max_notations *= 2;
|
||||
table->table = (xmlNotationPtr)
|
||||
realloc(table->table, table->max_notations * sizeof(xmlNotation));
|
||||
if (table->table) {
|
||||
fprintf(stderr, "xmlAddNotationDecl: out of memory\n");
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
ret = &table->table[table->nb_notations];
|
||||
|
||||
/*
|
||||
* fill the structure.
|
||||
*/
|
||||
ret->name = xmlStrdup(name);
|
||||
if (SystemID != NULL)
|
||||
ret->SystemID = xmlStrdup(SystemID);
|
||||
else
|
||||
ret->SystemID = NULL;
|
||||
if (PublicID != NULL)
|
||||
ret->PublicID = xmlStrdup(PublicID);
|
||||
else
|
||||
ret->PublicID = NULL;
|
||||
table->nb_notations++;
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlFreeNotation:
|
||||
* @not: A notation
|
||||
*
|
||||
* Deallocate the memory used by an notation definition
|
||||
*/
|
||||
void
|
||||
xmlFreeNotation(xmlNotationPtr nota) {
|
||||
if (nota == NULL) return;
|
||||
if (nota->name != NULL)
|
||||
free((CHAR *) nota->name);
|
||||
if (nota->PublicID != NULL)
|
||||
free((CHAR *) nota->PublicID);
|
||||
if (nota->SystemID != NULL)
|
||||
free((CHAR *) nota->SystemID);
|
||||
memset(nota, -1, sizeof(xmlNotation));
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlFreeNotationTable:
|
||||
* @table: An notation table
|
||||
*
|
||||
* Deallocate the memory used by an entities hash table.
|
||||
*/
|
||||
void
|
||||
xmlFreeNotationTable(xmlNotationTablePtr table) {
|
||||
int i;
|
||||
|
||||
if (table == NULL) return;
|
||||
|
||||
for (i = 0;i < table->nb_notations;i++) {
|
||||
xmlFreeNotation(&table->table[i]);
|
||||
}
|
||||
free(table->table);
|
||||
free(table);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlCopyNotationTable:
|
||||
* @table: A notation table
|
||||
*
|
||||
* Build a copy of a notation table.
|
||||
*
|
||||
* Returns the new xmlNotationTablePtr or NULL in case of error.
|
||||
*/
|
||||
xmlNotationTablePtr
|
||||
xmlCopyNotationTable(xmlNotationTablePtr table) {
|
||||
xmlNotationTablePtr ret;
|
||||
xmlNotationPtr cur, nota;
|
||||
int i;
|
||||
|
||||
ret = (xmlNotationTablePtr) malloc(sizeof(xmlNotationTable));
|
||||
if (ret == NULL) {
|
||||
fprintf(stderr, "xmlCopyNotationTable: out of memory !\n");
|
||||
return(NULL);
|
||||
}
|
||||
ret->table = (xmlNotationPtr) malloc(table->max_notations *
|
||||
sizeof(xmlNotation));
|
||||
if (ret->table == NULL) {
|
||||
fprintf(stderr, "xmlCopyNotationTable: out of memory !\n");
|
||||
free(ret);
|
||||
return(NULL);
|
||||
}
|
||||
ret->max_notations = table->max_notations;
|
||||
ret->nb_notations = table->nb_notations;
|
||||
for (i = 0;i < ret->nb_notations;i++) {
|
||||
cur = &ret->table[i];
|
||||
nota = &table->table[i];
|
||||
if (nota->name != NULL)
|
||||
cur->name = xmlStrdup(nota->name);
|
||||
else
|
||||
cur->name = NULL;
|
||||
if (nota->PublicID != NULL)
|
||||
cur->PublicID = xmlStrdup(nota->PublicID);
|
||||
else
|
||||
cur->PublicID = NULL;
|
||||
if (nota->SystemID != NULL)
|
||||
cur->SystemID = xmlStrdup(nota->SystemID);
|
||||
else
|
||||
cur->SystemID = NULL;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlDumpNotationTable:
|
||||
* @table: A notation table
|
||||
*
|
||||
* This will dump the content of the notation table as an XML DTD definition
|
||||
*
|
||||
* NOTE: TODO an extra parameter allowing a reentant implementation will
|
||||
* be added.
|
||||
*/
|
||||
void
|
||||
xmlDumpNotationTable(xmlNotationTablePtr table) {
|
||||
int i;
|
||||
xmlNotationPtr cur;
|
||||
|
||||
if (table == NULL) return;
|
||||
|
||||
for (i = 0;i < table->nb_notations;i++) {
|
||||
cur = &table->table[i];
|
||||
xmlBufferWriteChar("<!NOTATION ");
|
||||
xmlBufferWriteCHAR(cur->name);
|
||||
if (cur->PublicID != NULL) {
|
||||
xmlBufferWriteChar(" PUBLIC \"");
|
||||
xmlBufferWriteCHAR(cur->PublicID);
|
||||
xmlBufferWriteChar("\"");
|
||||
if (cur->SystemID != NULL) {
|
||||
xmlBufferWriteChar(" ");
|
||||
xmlBufferWriteCHAR(cur->SystemID);
|
||||
}
|
||||
} else {
|
||||
xmlBufferWriteChar(" SYSTEM ");
|
||||
xmlBufferWriteCHAR(cur->SystemID);
|
||||
}
|
||||
xmlBufferWriteChar(" >\n");
|
||||
}
|
||||
}
|
||||
|
70
valid.h
70
valid.h
@ -11,6 +11,20 @@
|
||||
#define __XML_VALID_H__
|
||||
#include "tree.h"
|
||||
|
||||
/*
|
||||
* ALl notation declarations are stored in a table
|
||||
* there is one table per DTD
|
||||
*/
|
||||
|
||||
#define XML_MIN_NOTATION_TABLE 32
|
||||
|
||||
typedef struct xmlNotationTable {
|
||||
int nb_notations; /* number of notations stored */
|
||||
int max_notations; /* maximum number of notations */
|
||||
xmlNotationPtr table; /* the table of attributes */
|
||||
} xmlNotationTable;
|
||||
typedef xmlNotationTable *xmlNotationTablePtr;
|
||||
|
||||
/*
|
||||
* ALl element declarations are stored in a table
|
||||
* there is one table per DTD
|
||||
@ -21,16 +35,54 @@
|
||||
typedef struct xmlElementTable {
|
||||
int nb_elements; /* number of elements stored */
|
||||
int max_elements; /* maximum number of elements */
|
||||
xmlElementPtr table; /* the table of entities */
|
||||
} xmlElementTable, *xmlElementTablePtr;
|
||||
xmlElementPtr table; /* the table of elements */
|
||||
} xmlElementTable;
|
||||
typedef xmlElementTable *xmlElementTablePtr;
|
||||
|
||||
extern xmlElementPtr xmlAddElementDecl(xmlDtdPtr dtd, char *name, int type,
|
||||
/*
|
||||
* ALl attribute declarations are stored in a table
|
||||
* there is one table per DTD
|
||||
*/
|
||||
|
||||
#define XML_MIN_ATTRIBUTE_TABLE 32
|
||||
|
||||
typedef struct xmlAttributeTable {
|
||||
int nb_attributes; /* number of attributes stored */
|
||||
int max_attributes; /* maximum number of attributes */
|
||||
xmlAttributePtr table; /* the table of attributes */
|
||||
} xmlAttributeTable;
|
||||
typedef xmlAttributeTable *xmlAttributeTablePtr;
|
||||
|
||||
/* Notation */
|
||||
xmlNotationPtr xmlAddNotationDecl(xmlDtdPtr dtd, CHAR *name,
|
||||
CHAR *PublicID, CHAR *SystemID);
|
||||
xmlNotationTablePtr xmlCopyNotationTable(xmlNotationTablePtr table);
|
||||
void xmlFreeNotationTable(xmlNotationTablePtr table);
|
||||
void xmlDumpNotationTable(xmlNotationTablePtr table);
|
||||
|
||||
/* Element Content */
|
||||
xmlElementContentPtr xmlNewElementContent(CHAR *name, int type);
|
||||
xmlElementContentPtr xmlCopyElementContent(xmlElementContentPtr content);
|
||||
void xmlFreeElementContent(xmlElementContentPtr cur);
|
||||
|
||||
/* Element */
|
||||
xmlElementPtr xmlAddElementDecl(xmlDtdPtr dtd, CHAR *name, int type,
|
||||
xmlElementContentPtr content);
|
||||
extern xmlElementContentPtr xmlNewElementContent(CHAR *name, int type);
|
||||
extern xmlElementContentPtr xmlCopyElementContent(xmlElementContentPtr content);
|
||||
extern void xmlFreeElementContent(xmlElementContentPtr cur);
|
||||
xmlElementTablePtr xmlCopyElementTable(xmlElementTablePtr table);
|
||||
void xmlFreeElementTable(xmlElementTablePtr table);
|
||||
void xmlDumpElementTable(xmlElementTablePtr table);
|
||||
|
||||
/* Enumeration */
|
||||
xmlEnumerationPtr xmlCreateEnumeration(CHAR *name);
|
||||
void xmlFreeEnumeration(xmlEnumerationPtr cur);
|
||||
xmlEnumerationPtr xmlCopyEnumeration(xmlEnumerationPtr cur);
|
||||
|
||||
/* Attribute */
|
||||
xmlAttributePtr xmlAddAttributeDecl(xmlDtdPtr dtd, CHAR *elem,
|
||||
CHAR *name, int type, int def,
|
||||
CHAR *defaultValue, xmlEnumerationPtr tree);
|
||||
xmlAttributeTablePtr xmlCopyAttributeTable(xmlAttributeTablePtr table);
|
||||
void xmlFreeAttributeTable(xmlAttributeTablePtr table);
|
||||
void xmlDumpAttributeTable(xmlAttributeTablePtr table);
|
||||
|
||||
extern xmlElementTablePtr xmlCopyElementTable(xmlElementTablePtr table);
|
||||
extern void xmlFreeElementTable(xmlElementTablePtr table);
|
||||
extern void xmlDumpElementTable(xmlElementTablePtr table);
|
||||
#endif /* __XML_VALID_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user