1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-21 14:53:44 +03:00

doc: Misc fixes

This commit is contained in:
Nick Wellnhofer
2025-05-16 16:54:09 +02:00
parent c4926b19d3
commit c5b45fbc07
12 changed files with 368 additions and 228 deletions

View File

@@ -2218,15 +2218,15 @@ static int areBlanks(htmlParserCtxtPtr ctxt, const xmlChar *str, int len) {
} }
/** /**
* Creates a new HTML document without a DTD node if `URI` and `ExternalID` * Creates a new HTML document without a DTD node if `URI` and `publicId`
* are NULL * are NULL
* *
* @param URI URI for the dtd, or NULL * @param URI system ID (URI) of the DTD (optional)
* @param ExternalID the external ID of the DTD, or NULL * @param publicId public ID of the DTD (optional)
* @returns a new document, do not initialize the DTD if not provided * @returns a new document, do not initialize the DTD if not provided
*/ */
xmlDoc * xmlDoc *
htmlNewDocNoDtD(const xmlChar *URI, const xmlChar *ExternalID) { htmlNewDocNoDtD(const xmlChar *URI, const xmlChar *publicId) {
xmlDocPtr cur; xmlDocPtr cur;
/* /*
@@ -2253,11 +2253,11 @@ htmlNewDocNoDtD(const xmlChar *URI, const xmlChar *ExternalID) {
cur->_private = NULL; cur->_private = NULL;
cur->charset = XML_CHAR_ENCODING_UTF8; cur->charset = XML_CHAR_ENCODING_UTF8;
cur->properties = XML_DOC_HTML | XML_DOC_USERBUILT; cur->properties = XML_DOC_HTML | XML_DOC_USERBUILT;
if ((ExternalID != NULL) || if ((publicId != NULL) ||
(URI != NULL)) { (URI != NULL)) {
xmlDtdPtr intSubset; xmlDtdPtr intSubset;
intSubset = xmlCreateIntSubset(cur, BAD_CAST "html", ExternalID, URI); intSubset = xmlCreateIntSubset(cur, BAD_CAST "html", publicId, URI);
if (intSubset == NULL) { if (intSubset == NULL) {
xmlFree(cur); xmlFree(cur);
return(NULL); return(NULL);
@@ -2271,18 +2271,18 @@ htmlNewDocNoDtD(const xmlChar *URI, const xmlChar *ExternalID) {
/** /**
* Creates a new HTML document * Creates a new HTML document
* *
* @param URI URI for the dtd, or NULL * @param URI system ID (URI) of the DTD (optional)
* @param ExternalID the external ID of the DTD, or NULL * @param publicId public ID of the DTD (optional)
* @returns a new document * @returns a new document
*/ */
xmlDoc * xmlDoc *
htmlNewDoc(const xmlChar *URI, const xmlChar *ExternalID) { htmlNewDoc(const xmlChar *URI, const xmlChar *publicId) {
if ((URI == NULL) && (ExternalID == NULL)) if ((URI == NULL) && (publicId == NULL))
return(htmlNewDocNoDtD( return(htmlNewDocNoDtD(
BAD_CAST "http://www.w3.org/TR/REC-html40/loose.dtd", BAD_CAST "http://www.w3.org/TR/REC-html40/loose.dtd",
BAD_CAST "-//W3C//DTD HTML 4.0 Transitional//EN")); BAD_CAST "-//W3C//DTD HTML 4.0 Transitional//EN"));
return(htmlNewDocNoDtD(URI, ExternalID)); return(htmlNewDocNoDtD(URI, publicId));
} }
@@ -5115,6 +5115,9 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
* *
* If the document isn't well-formed, `ctxt->myDoc` is set to NULL. * If the document isn't well-formed, `ctxt->myDoc` is set to NULL.
* *
* Since 2.14.0, xmlCtxtGetDocument() can be used to retrieve the
* result document.
*
* @param ctxt an HTML parser context * @param ctxt an HTML parser context
* @param chunk chunk of memory * @param chunk chunk of memory
* @param size size of chunk in bytes * @param size size of chunk in bytes

28
SAX2.c
View File

@@ -211,12 +211,12 @@ xmlSAX2HasExternalSubset(void *ctx)
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
* @param name the root element name * @param name the root element name
* @param ExternalID the external ID * @param publicId public identifier of the DTD (optional)
* @param SystemID the SYSTEM ID (e.g. filename or URL) * @param systemId system identifier (URL) of the DTD
*/ */
void void
xmlSAX2InternalSubset(void *ctx, const xmlChar *name, xmlSAX2InternalSubset(void *ctx, const xmlChar *name,
const xmlChar *ExternalID, const xmlChar *SystemID) const xmlChar *publicId, const xmlChar *systemId)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlDtdPtr dtd; xmlDtdPtr dtd;
@@ -233,7 +233,7 @@ xmlSAX2InternalSubset(void *ctx, const xmlChar *name,
ctxt->myDoc->intSubset = NULL; ctxt->myDoc->intSubset = NULL;
} }
ctxt->myDoc->intSubset = ctxt->myDoc->intSubset =
xmlCreateIntSubset(ctxt->myDoc, name, ExternalID, SystemID); xmlCreateIntSubset(ctxt->myDoc, name, publicId, systemId);
if (ctxt->myDoc->intSubset == NULL) if (ctxt->myDoc->intSubset == NULL)
xmlSAX2ErrMemory(ctxt); xmlSAX2ErrMemory(ctxt);
} }
@@ -243,16 +243,16 @@ xmlSAX2InternalSubset(void *ctx, const xmlChar *name,
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
* @param name the root element name * @param name the root element name
* @param ExternalID the external ID * @param publicId public identifier of the DTD (optional)
* @param SystemID the SYSTEM ID (e.g. filename or URL) * @param systemId system identifier (URL) of the DTD
*/ */
void void
xmlSAX2ExternalSubset(void *ctx, const xmlChar *name, xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
const xmlChar *ExternalID, const xmlChar *SystemID) const xmlChar *publicId, const xmlChar *systemId)
{ {
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
if (ctx == NULL) return; if (ctx == NULL) return;
if ((SystemID != NULL) && if ((systemId != NULL) &&
((ctxt->options & XML_PARSE_NO_XXE) == 0) && ((ctxt->options & XML_PARSE_NO_XXE) == 0) &&
(((ctxt->validate) || (ctxt->loadsubset)) && (((ctxt->validate) || (ctxt->loadsubset)) &&
(ctxt->wellFormed && ctxt->myDoc))) { (ctxt->wellFormed && ctxt->myDoc))) {
@@ -277,13 +277,13 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
* Ask the Entity resolver to load the damn thing * Ask the Entity resolver to load the damn thing
*/ */
if ((ctxt->sax != NULL) && (ctxt->sax->resolveEntity != NULL)) if ((ctxt->sax != NULL) && (ctxt->sax->resolveEntity != NULL))
input = ctxt->sax->resolveEntity(ctxt->userData, ExternalID, input = ctxt->sax->resolveEntity(ctxt->userData, publicId,
SystemID); systemId);
if (input == NULL) { if (input == NULL) {
return; return;
} }
if (xmlNewDtd(ctxt->myDoc, name, ExternalID, SystemID) == NULL) { if (xmlNewDtd(ctxt->myDoc, name, publicId, systemId) == NULL) {
xmlSAX2ErrMemory(ctxt); xmlSAX2ErrMemory(ctxt);
xmlFreeInputStream(input); xmlFreeInputStream(input);
return; return;
@@ -311,7 +311,7 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
goto error; goto error;
if (input->filename == NULL) if (input->filename == NULL)
input->filename = (char *) xmlCanonicPath(SystemID); input->filename = (char *) xmlCanonicPath(systemId);
input->line = 1; input->line = 1;
input->col = 1; input->col = 1;
input->base = ctxt->input->cur; input->base = ctxt->input->cur;
@@ -321,7 +321,7 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
/* /*
* let's parse that entity knowing it's an external subset. * let's parse that entity knowing it's an external subset.
*/ */
xmlParseExternalSubset(ctxt, ExternalID, SystemID); xmlParseExternalSubset(ctxt, publicId, systemId);
/* /*
* Free up the external entities * Free up the external entities
@@ -367,7 +367,7 @@ error:
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
* @param publicId The public ID of the entity * @param publicId The public ID of the entity
* @param systemId The system ID of the entity * @param systemId The system ID (URL) of the entity
* @returns a parser input. * @returns a parser input.
*/ */
xmlParserInput * xmlParserInput *

View File

@@ -115,7 +115,7 @@ xmlFreeEntity(xmlEntity *entity)
*/ */
static xmlEntityPtr static xmlEntityPtr
xmlCreateEntity(xmlDocPtr doc, const xmlChar *name, int type, xmlCreateEntity(xmlDocPtr doc, const xmlChar *name, int type,
const xmlChar *ExternalID, const xmlChar *SystemID, const xmlChar *publicId, const xmlChar *systemId,
const xmlChar *content) { const xmlChar *content) {
xmlEntityPtr ret; xmlEntityPtr ret;
@@ -136,13 +136,13 @@ xmlCreateEntity(xmlDocPtr doc, const xmlChar *name, int type,
ret->name = xmlDictLookup(doc->dict, name, -1); ret->name = xmlDictLookup(doc->dict, name, -1);
if (ret->name == NULL) if (ret->name == NULL)
goto error; goto error;
if (ExternalID != NULL) { if (publicId != NULL) {
ret->ExternalID = xmlStrdup(ExternalID); ret->ExternalID = xmlStrdup(publicId);
if (ret->ExternalID == NULL) if (ret->ExternalID == NULL)
goto error; goto error;
} }
if (SystemID != NULL) { if (systemId != NULL) {
ret->SystemID = xmlStrdup(SystemID); ret->SystemID = xmlStrdup(systemId);
if (ret->SystemID == NULL) if (ret->SystemID == NULL)
goto error; goto error;
} }
@@ -175,15 +175,15 @@ error:
* @param extSubset add to the external or internal subset * @param extSubset add to the external or internal subset
* @param name the entity name * @param name the entity name
* @param type an xmlEntityType value * @param type an xmlEntityType value
* @param ExternalID the entity external ID (optional) * @param publicId the publid identifier (optional)
* @param SystemID the entity system ID (optional) * @param systemId the system identifier (URL) (optional)
* @param content the entity content * @param content the entity content
* @param out pointer to resulting entity (optional) * @param out pointer to resulting entity (optional)
* @returns an xmlParserErrors error code. * @returns an xmlParserErrors error code.
*/ */
int int
xmlAddEntity(xmlDoc *doc, int extSubset, const xmlChar *name, int type, xmlAddEntity(xmlDoc *doc, int extSubset, const xmlChar *name, int type,
const xmlChar *ExternalID, const xmlChar *SystemID, const xmlChar *publicId, const xmlChar *systemId,
const xmlChar *content, xmlEntity **out) { const xmlChar *content, xmlEntity **out) {
xmlDtdPtr dtd; xmlDtdPtr dtd;
xmlDictPtr dict = NULL; xmlDictPtr dict = NULL;
@@ -261,7 +261,7 @@ xmlAddEntity(xmlDoc *doc, int extSubset, const xmlChar *name, int type,
default: default:
return(XML_ERR_ARGUMENT); return(XML_ERR_ARGUMENT);
} }
ret = xmlCreateEntity(dtd->doc, name, type, ExternalID, SystemID, content); ret = xmlCreateEntity(dtd->doc, name, type, publicId, systemId, content);
if (ret == NULL) if (ret == NULL)
return(XML_ERR_NO_MEMORY); return(XML_ERR_NO_MEMORY);
@@ -337,18 +337,18 @@ xmlGetPredefinedEntity(const xmlChar *name) {
* @param doc the document * @param doc the document
* @param name the entity name * @param name the entity name
* @param type an xmlEntityType value * @param type an xmlEntityType value
* @param ExternalID the entity external ID (optional) * @param publicId the publid identifier (optional)
* @param SystemID the entity system ID (optional) * @param systemId the system identifier (URL) (optional)
* @param content the entity content * @param content the entity content
* @returns a pointer to the entity or NULL in case of error * @returns a pointer to the entity or NULL in case of error
*/ */
xmlEntity * xmlEntity *
xmlAddDtdEntity(xmlDoc *doc, const xmlChar *name, int type, xmlAddDtdEntity(xmlDoc *doc, const xmlChar *name, int type,
const xmlChar *ExternalID, const xmlChar *SystemID, const xmlChar *publicId, const xmlChar *systemId,
const xmlChar *content) { const xmlChar *content) {
xmlEntityPtr ret; xmlEntityPtr ret;
xmlAddEntity(doc, 1, name, type, ExternalID, SystemID, content, &ret); xmlAddEntity(doc, 1, name, type, publicId, systemId, content, &ret);
return(ret); return(ret);
} }
@@ -360,18 +360,18 @@ xmlAddDtdEntity(xmlDoc *doc, const xmlChar *name, int type,
* @param doc the document * @param doc the document
* @param name the entity name * @param name the entity name
* @param type an xmlEntityType value * @param type an xmlEntityType value
* @param ExternalID the entity external ID (optional) * @param publicId the publid identifier (optional)
* @param SystemID the entity system ID (optional) * @param systemId the system identifier (URL) (optional)
* @param content the entity content * @param content the entity content
* @returns a pointer to the entity or NULL in case of error * @returns a pointer to the entity or NULL in case of error
*/ */
xmlEntity * xmlEntity *
xmlAddDocEntity(xmlDoc *doc, const xmlChar *name, int type, xmlAddDocEntity(xmlDoc *doc, const xmlChar *name, int type,
const xmlChar *ExternalID, const xmlChar *SystemID, const xmlChar *publicId, const xmlChar *systemId,
const xmlChar *content) { const xmlChar *content) {
xmlEntityPtr ret; xmlEntityPtr ret;
xmlAddEntity(doc, 0, name, type, ExternalID, SystemID, content, &ret); xmlAddEntity(doc, 0, name, type, publicId, systemId, content, &ret);
return(ret); return(ret);
} }
@@ -386,21 +386,21 @@ xmlAddDocEntity(xmlDoc *doc, const xmlChar *name, int type,
* @param doc the document (optional) * @param doc the document (optional)
* @param name the entity name * @param name the entity name
* @param type an xmlEntityType value * @param type an xmlEntityType value
* @param ExternalID the entity external ID (optional) * @param publicId the publid identifier (optional)
* @param SystemID the entity system ID (optional) * @param systemId the system identifier (URL) (optional)
* @param content the entity content * @param content the entity content
* @returns a pointer to the entity or NULL in case of error * @returns a pointer to the entity or NULL in case of error
*/ */
xmlEntity * xmlEntity *
xmlNewEntity(xmlDoc *doc, const xmlChar *name, int type, xmlNewEntity(xmlDoc *doc, const xmlChar *name, int type,
const xmlChar *ExternalID, const xmlChar *SystemID, const xmlChar *publicId, const xmlChar *systemId,
const xmlChar *content) { const xmlChar *content) {
if ((doc != NULL) && (doc->intSubset != NULL)) { if ((doc != NULL) && (doc->intSubset != NULL)) {
return(xmlAddDocEntity(doc, name, type, ExternalID, SystemID, content)); return(xmlAddDocEntity(doc, name, type, publicId, systemId, content));
} }
if (name == NULL) if (name == NULL)
return(NULL); return(NULL);
return(xmlCreateEntity(doc, name, type, ExternalID, SystemID, content)); return(xmlCreateEntity(doc, name, type, publicId, systemId, content));
} }
/** /**

View File

@@ -44,13 +44,13 @@ XMLPUBFUN int
XMLPUBFUN void XMLPUBFUN void
xmlSAX2InternalSubset (void *ctx, xmlSAX2InternalSubset (void *ctx,
const xmlChar *name, const xmlChar *name,
const xmlChar *ExternalID, const xmlChar *publicId,
const xmlChar *SystemID); const xmlChar *systemId);
XMLPUBFUN void XMLPUBFUN void
xmlSAX2ExternalSubset (void *ctx, xmlSAX2ExternalSubset (void *ctx,
const xmlChar *name, const xmlChar *name,
const xmlChar *ExternalID, const xmlChar *publicId,
const xmlChar *SystemID); const xmlChar *systemId);
XMLPUBFUN xmlEntity * XMLPUBFUN xmlEntity *
xmlSAX2GetEntity (void *ctx, xmlSAX2GetEntity (void *ctx,
const xmlChar *name); const xmlChar *name);

View File

@@ -95,8 +95,8 @@ XMLPUBFUN xmlEntity *
xmlNewEntity (xmlDoc *doc, xmlNewEntity (xmlDoc *doc,
const xmlChar *name, const xmlChar *name,
int type, int type,
const xmlChar *ExternalID, const xmlChar *publicId,
const xmlChar *SystemID, const xmlChar *systemId,
const xmlChar *content); const xmlChar *content);
XMLPUBFUN void XMLPUBFUN void
xmlFreeEntity (xmlEntity *entity); xmlFreeEntity (xmlEntity *entity);
@@ -105,23 +105,23 @@ XMLPUBFUN int
int extSubset, int extSubset,
const xmlChar *name, const xmlChar *name,
int type, int type,
const xmlChar *ExternalID, const xmlChar *publicId,
const xmlChar *SystemID, const xmlChar *systemId,
const xmlChar *content, const xmlChar *content,
xmlEntity **out); xmlEntity **out);
XMLPUBFUN xmlEntity * XMLPUBFUN xmlEntity *
xmlAddDocEntity (xmlDoc *doc, xmlAddDocEntity (xmlDoc *doc,
const xmlChar *name, const xmlChar *name,
int type, int type,
const xmlChar *ExternalID, const xmlChar *publicId,
const xmlChar *SystemID, const xmlChar *systemId,
const xmlChar *content); const xmlChar *content);
XMLPUBFUN xmlEntity * XMLPUBFUN xmlEntity *
xmlAddDtdEntity (xmlDoc *doc, xmlAddDtdEntity (xmlDoc *doc,
const xmlChar *name, const xmlChar *name,
int type, int type,
const xmlChar *ExternalID, const xmlChar *publicId,
const xmlChar *SystemID, const xmlChar *systemId,
const xmlChar *content); const xmlChar *content);
XMLPUBFUN xmlEntity * XMLPUBFUN xmlEntity *
xmlGetPredefinedEntity (const xmlChar *name); xmlGetPredefinedEntity (const xmlChar *name);

View File

@@ -246,6 +246,7 @@ struct _xmlParserCtxt {
/** /**
* user data for SAX interface, defaults to the context itself * user data for SAX interface, defaults to the context itself
*/ */
/* TODO: Add accessor */
void *userData; void *userData;
/** /**
* @deprecated Use xmlCtxtGetDocument() * @deprecated Use xmlCtxtGetDocument()
@@ -296,6 +297,7 @@ struct _xmlParserCtxt {
/** /**
* Current input stream * Current input stream
*/ */
/* TODO: Add accessors, see issue #762 */
xmlParserInput *input; xmlParserInput *input;
/* Number of current input streams */ /* Number of current input streams */
int inputNr; int inputNr;
@@ -306,8 +308,18 @@ struct _xmlParserCtxt {
/* Node analysis stack only used for DOM building */ /* Node analysis stack only used for DOM building */
/* Current parsed Node */ /**
xmlNode *node XML_DEPRECATED_MEMBER; * The current element.
*
* This is only valid and useful if the default SAX callbacks
* which build a document tree are intercepted. This mode of
* operation is fragile and discouraged.
*
* Contains the current element whose content is being parsed,
* or NULL if the parser is in top-level or DTD content.
*/
/* TODO: Add accessor */
xmlNode *node;
/* Depth of the parsing stack */ /* Depth of the parsing stack */
int nodeNr XML_DEPRECATED_MEMBER; int nodeNr XML_DEPRECATED_MEMBER;
/* Max depth of the parsing stack */ /* Max depth of the parsing stack */
@@ -358,7 +370,11 @@ struct _xmlParserCtxt {
/* unused */ /* unused */
int token XML_DEPRECATED_MEMBER; int token XML_DEPRECATED_MEMBER;
/* unused internally, still used downstream */ /**
* The main document URI, if available, with its last
* component stripped.
*/
/* TODO: Add accessor */
char *directory; char *directory;
/* Node name stack */ /* Node name stack */
@@ -388,13 +404,39 @@ struct _xmlParserCtxt {
* SAX callbacks are disabled * SAX callbacks are disabled
*/ */
int disableSAX XML_DEPRECATED_MEMBER; int disableSAX XML_DEPRECATED_MEMBER;
/* Parsing is in int 1/ext 2 subset */ /**
* Set if DTD content is parsed.
*
* - 0: not in DTD
* - 1: in internal DTD subset
* - 2: in external DTD subset
*/
/* TODO: Add accessor */
int inSubset; int inSubset;
/* name of subset */ /**
* @deprecated Use the `name` argument of the
* `internalSubset` SAX callback.
*
* Name of the internal subset (root element type).
*/
/* TODO: Add accessor */
const xmlChar *intSubName; const xmlChar *intSubName;
/* URI of external subset */ /**
* @deprecated Use the `systemId` argument of the
* `internalSubset` SAX callback.
*
* System identifier (URI) of external the subset.
*/
/* TODO: Add accessor */
xmlChar *extSubURI; xmlChar *extSubURI;
/* SYSTEM ID of external subset */ /**
* @deprecated Use the `publicId` argument of the
* `internalSubset` SAX callback.
*
* This member is MISNAMED. It contains the *public* identifier
* of the external subset.
*/
/* TODO: Add accessor */
xmlChar *extSubSystem; xmlChar *extSubSystem;
/* xml:space values */ /* xml:space values */
@@ -431,10 +473,18 @@ struct _xmlParserCtxt {
void *_private; void *_private;
/** /**
* @deprecated Use xmlParserOption XML_PARSE_DTDLOAD or * @deprecated Use xmlParserOption XML_PARSE_DTDLOAD or
* XML_PARSE_DTD_ATTR * XML_PARSE_DTDATTR
* *
* should the external subset be loaded * Control loading of the external subset. Other options like
* `validate` can override this value.
*
* - 0: Don't load external subset.
* - XML_DETECT_IDS: Load external subset and store IDs.
* - XML_COMPLETE_ATTRS: Load external subset, store IDs and
* process default attributes.
* - XML_SKIP_IDS: Load external subset and ignore IDs.
*/ */
/* TODO: See issue #873 */
int loadsubset; int loadsubset;
/* unused */ /* unused */
int linenumbers XML_DEPRECATED_MEMBER; int linenumbers XML_DEPRECATED_MEMBER;
@@ -505,16 +555,17 @@ struct _xmlParserCtxt {
*/ */
int options; int options;
/*
* Those fields are needed only for streaming parsing so far
*/
/** /**
* @deprecated Use inverted xmlParserOption XML_PARSE_NODICT * @deprecated Use inverted xmlParserOption XML_PARSE_NODICT
* *
* Use dictionary names for the tree * Use dictionary names for the tree
*/ */
int dictNames XML_DEPRECATED_MEMBER; int dictNames XML_DEPRECATED_MEMBER;
/*
* Those fields are needed only for streaming parsing so far
*/
/* number of freed element nodes */ /* number of freed element nodes */
int freeElemsNr XML_DEPRECATED_MEMBER; int freeElemsNr XML_DEPRECATED_MEMBER;
/* List of freed element nodes */ /* List of freed element nodes */
@@ -589,47 +640,45 @@ struct _xmlSAXLocator {
}; };
/** /**
* Callback: * SAX callback to resolve external entities.
* The entity loader, to control the loading of external entities, *
* the application can either: * This is only used to load DTDs. The preferred way to install
* - override this resolveEntity() callback in the SAX block * custom resolvers is xmlCtxtSetResourceLoader().
* - or better use the xmlSetExternalEntityLoader() function to
* set up it's own entity resolution routine
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
* @param publicId The public ID of the entity * @param publicId The public identifier of the entity
* @param systemId The system ID of the entity * @param systemId The system identifier of the entity (URL)
* @returns the xmlParserInput if inlined or NULL for DOM behaviour. * @returns the xmlParserInput if inlined or NULL for DOM behaviour.
*/ */
typedef xmlParserInput *(*resolveEntitySAXFunc) (void *ctx, typedef xmlParserInput *(*resolveEntitySAXFunc) (void *ctx,
const xmlChar *publicId, const xmlChar *publicId,
const xmlChar *systemId); const xmlChar *systemId);
/** /**
* Callback on internal subset declaration. * SAX callback for the internal subset.
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
* @param name the root element name * @param name the root element name
* @param ExternalID the external ID * @param publicId the public identifier
* @param SystemID the SYSTEM ID (e.g. filename or URL) * @param systemId the system identifier (e.g. filename or URL)
*/ */
typedef void (*internalSubsetSAXFunc) (void *ctx, typedef void (*internalSubsetSAXFunc) (void *ctx,
const xmlChar *name, const xmlChar *name,
const xmlChar *ExternalID, const xmlChar *publicId,
const xmlChar *SystemID); const xmlChar *systemId);
/** /**
* Callback on external subset declaration. * SAX callback for the external subset.
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
* @param name the root element name * @param name the root element name
* @param ExternalID the external ID * @param publicId the public identifier
* @param SystemID the SYSTEM ID (e.g. filename or URL) * @param systemId the system identifier (e.g. filename or URL)
*/ */
typedef void (*externalSubsetSAXFunc) (void *ctx, typedef void (*externalSubsetSAXFunc) (void *ctx,
const xmlChar *name, const xmlChar *name,
const xmlChar *ExternalID, const xmlChar *publicId,
const xmlChar *SystemID); const xmlChar *systemId);
/** /**
* Get an entity by name. * SAX callback to look up a general entity by name.
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
* @param name The entity name * @param name The entity name
@@ -638,7 +687,7 @@ typedef void (*externalSubsetSAXFunc) (void *ctx,
typedef xmlEntity *(*getEntitySAXFunc) (void *ctx, typedef xmlEntity *(*getEntitySAXFunc) (void *ctx,
const xmlChar *name); const xmlChar *name);
/** /**
* Get a parameter entity by name. * SAX callback to look up a parameter entity by name.
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
* @param name The entity name * @param name The entity name
@@ -647,7 +696,7 @@ typedef xmlEntity *(*getEntitySAXFunc) (void *ctx,
typedef xmlEntity *(*getParameterEntitySAXFunc) (void *ctx, typedef xmlEntity *(*getParameterEntitySAXFunc) (void *ctx,
const xmlChar *name); const xmlChar *name);
/** /**
* An entity definition has been parsed. * SAX callback for entity declarations.
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
* @param name the entity name * @param name the entity name
@@ -663,19 +712,19 @@ typedef void (*entityDeclSAXFunc) (void *ctx,
const xmlChar *systemId, const xmlChar *systemId,
xmlChar *content); xmlChar *content);
/** /**
* What to do when a notation declaration has been parsed. * SAX callback for notation declarations.
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
* @param name The name of the notation * @param name The name of the notation
* @param publicId The public ID of the entity * @param publicId The public ID of the notation
* @param systemId The system ID of the entity * @param systemId The system ID of the notation
*/ */
typedef void (*notationDeclSAXFunc)(void *ctx, typedef void (*notationDeclSAXFunc)(void *ctx,
const xmlChar *name, const xmlChar *name,
const xmlChar *publicId, const xmlChar *publicId,
const xmlChar *systemId); const xmlChar *systemId);
/** /**
* An attribute definition has been parsed. * SAX callback for attribute declarations.
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
* @param elem the name of the element * @param elem the name of the element
@@ -693,7 +742,7 @@ typedef void (*attributeDeclSAXFunc)(void *ctx,
const xmlChar *defaultValue, const xmlChar *defaultValue,
xmlEnumeration *tree); xmlEnumeration *tree);
/** /**
* An element definition has been parsed. * SAX callback for element declarations.
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
* @param name the element name * @param name the element name
@@ -705,7 +754,7 @@ typedef void (*elementDeclSAXFunc)(void *ctx,
int type, int type,
xmlElementContent *content); xmlElementContent *content);
/** /**
* What to do when an unparsed entity declaration is parsed. * SAX callback for unparsed entity declarations.
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
* @param name The name of the entity * @param name The name of the entity
@@ -719,8 +768,11 @@ typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
const xmlChar *systemId, const xmlChar *systemId,
const xmlChar *notationName); const xmlChar *notationName);
/** /**
* Receive the document locator at startup, actually xmlDefaultSAXLocator. * This callback receives the "document locator" at startup,
* Everything is available on the context, so this is useless in our case. * which is always the global xmlDefaultSAXLocator.
*
* Everything is available on the context, so this is useless in
* our case.
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
* @param loc A SAX Locator * @param loc A SAX Locator
@@ -728,19 +780,19 @@ typedef void (*unparsedEntityDeclSAXFunc)(void *ctx,
typedef void (*setDocumentLocatorSAXFunc) (void *ctx, typedef void (*setDocumentLocatorSAXFunc) (void *ctx,
xmlSAXLocator *loc); xmlSAXLocator *loc);
/** /**
* Called when the document start being processed. * SAX callback for start of document.
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
*/ */
typedef void (*startDocumentSAXFunc) (void *ctx); typedef void (*startDocumentSAXFunc) (void *ctx);
/** /**
* Called when the document end has been detected. * SAX callback for end of document.
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
*/ */
typedef void (*endDocumentSAXFunc) (void *ctx); typedef void (*endDocumentSAXFunc) (void *ctx);
/** /**
* Called when an opening tag has been processed. * SAX callback for start tags.
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
* @param name The element name, including namespace prefix * @param name The element name, including namespace prefix
@@ -750,7 +802,7 @@ typedef void (*startElementSAXFunc) (void *ctx,
const xmlChar *name, const xmlChar *name,
const xmlChar **atts); const xmlChar **atts);
/** /**
* Called when the end of an element has been detected. * SAX callback for end tags.
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
* @param name The element name * @param name The element name
@@ -758,10 +810,9 @@ typedef void (*startElementSAXFunc) (void *ctx,
typedef void (*endElementSAXFunc) (void *ctx, typedef void (*endElementSAXFunc) (void *ctx,
const xmlChar *name); const xmlChar *name);
/** /**
* Handle an attribute that has been read by the parser. * Callback for attributes.
* The default handling is to convert the attribute into an *
* DOM subtree and past it in a new xmlAttr element added to * @deprecated This typedef is unused.
* the element.
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
* @param name The attribute name, including namespace prefix * @param name The attribute name, including namespace prefix
@@ -771,7 +822,7 @@ typedef void (*attributeSAXFunc) (void *ctx,
const xmlChar *name, const xmlChar *name,
const xmlChar *value); const xmlChar *value);
/** /**
* Called when an entity reference is detected. * SAX callback for entity references.
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
* @param name The entity name * @param name The entity name
@@ -779,7 +830,7 @@ typedef void (*attributeSAXFunc) (void *ctx,
typedef void (*referenceSAXFunc) (void *ctx, typedef void (*referenceSAXFunc) (void *ctx,
const xmlChar *name); const xmlChar *name);
/** /**
* Receiving some chars from the parser. * SAX callback for character data.
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
* @param ch a xmlChar string * @param ch a xmlChar string
@@ -789,8 +840,7 @@ typedef void (*charactersSAXFunc) (void *ctx,
const xmlChar *ch, const xmlChar *ch,
int len); int len);
/** /**
* Receiving some ignorable whitespaces from the parser. * SAX callback for "ignorable" whitespace.
* UNUSED: by default the DOM building will use characters.
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
* @param ch a xmlChar string * @param ch a xmlChar string
@@ -800,7 +850,7 @@ typedef void (*ignorableWhitespaceSAXFunc) (void *ctx,
const xmlChar *ch, const xmlChar *ch,
int len); int len);
/** /**
* A processing instruction has been parsed. * SAX callback for processing instructions.
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
* @param target the target name * @param target the target name
@@ -810,7 +860,7 @@ typedef void (*processingInstructionSAXFunc) (void *ctx,
const xmlChar *target, const xmlChar *target,
const xmlChar *data); const xmlChar *data);
/** /**
* A comment has been parsed. * SAX callback for comments.
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
* @param value the comment content * @param value the comment content
@@ -818,7 +868,7 @@ typedef void (*processingInstructionSAXFunc) (void *ctx,
typedef void (*commentSAXFunc) (void *ctx, typedef void (*commentSAXFunc) (void *ctx,
const xmlChar *value); const xmlChar *value);
/** /**
* Called when a pcdata block has been parsed. * SAX callback for CDATA sections.
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
* @param value The pcdata content * @param value The pcdata content
@@ -829,7 +879,7 @@ typedef void (*cdataBlockSAXFunc) (
const xmlChar *value, const xmlChar *value,
int len); int len);
/** /**
* Display and format a warning messages, callback. * SAX callback for warning messages.
* *
* @param ctx an XML parser context * @param ctx an XML parser context
* @param msg the message to display/transmit * @param msg the message to display/transmit
@@ -838,7 +888,7 @@ typedef void (*cdataBlockSAXFunc) (
typedef void (*warningSAXFunc) (void *ctx, typedef void (*warningSAXFunc) (void *ctx,
const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
/** /**
* Display and format an error messages, callback. * SAX callback for error messages.
* *
* @param ctx an XML parser context * @param ctx an XML parser context
* @param msg the message to display/transmit * @param msg the message to display/transmit
@@ -847,10 +897,7 @@ typedef void (*warningSAXFunc) (void *ctx,
typedef void (*errorSAXFunc) (void *ctx, typedef void (*errorSAXFunc) (void *ctx,
const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
/** /**
* Display and format fatal error messages, callback. * SAX callback for fatal error messages.
* Note: so far fatalError() SAX callbacks are not used, error()
* get all the callbacks for errors.
*
* *
* @param ctx an XML parser context * @param ctx an XML parser context
* @param msg the message to display/transmit * @param msg the message to display/transmit
@@ -859,14 +906,14 @@ typedef void (*errorSAXFunc) (void *ctx,
typedef void (*fatalErrorSAXFunc) (void *ctx, typedef void (*fatalErrorSAXFunc) (void *ctx,
const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
/** /**
* Is this document tagged standalone? * SAX callback to get standalone status.
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
* @returns 1 if true * @returns 1 if true
*/ */
typedef int (*isStandaloneSAXFunc) (void *ctx); typedef int (*isStandaloneSAXFunc) (void *ctx);
/** /**
* Does this document has an internal subset. * SAX callback to get internal subset status.
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
* @returns 1 if true * @returns 1 if true
@@ -874,7 +921,7 @@ typedef int (*isStandaloneSAXFunc) (void *ctx);
typedef int (*hasInternalSubsetSAXFunc) (void *ctx); typedef int (*hasInternalSubsetSAXFunc) (void *ctx);
/** /**
* Does this document has an external subset? * SAX callback to get external subset status.
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
* @returns 1 if true * @returns 1 if true
@@ -887,12 +934,13 @@ typedef int (*hasExternalSubsetSAXFunc) (void *ctx);
* * * *
************************************************************************/ ************************************************************************/
/** /**
* Special constant found in SAX2 blocks initialized fields * Special constant required for SAX2 handlers.
*/ */
#define XML_SAX2_MAGIC 0xDEEDBEAF #define XML_SAX2_MAGIC 0xDEEDBEAF
/** /**
* SAX2 callback when an element start has been detected by the parser. * SAX2 callback for start tags.
*
* It provides the namespace information for the element, as well as * It provides the namespace information for the element, as well as
* the new namespace declarations on the element. * the new namespace declarations on the element.
* *
@@ -920,7 +968,8 @@ typedef void (*startElementNsSAX2Func) (void *ctx,
const xmlChar **attributes); const xmlChar **attributes);
/** /**
* SAX2 callback when an element end has been detected by the parser. * SAX2 callback for end tags.
*
* It provides the namespace information for the element. * It provides the namespace information for the element.
* *
* @param ctx the user data (XML parser context) * @param ctx the user data (XML parser context)
@@ -942,38 +991,89 @@ typedef void (*endElementNsSAX2Func) (void *ctx,
* ignored. * ignored.
*/ */
struct _xmlSAXHandler { struct _xmlSAXHandler {
/** DTD */ /**
* Called after the start of the document type declaration
* was parsed.
*
* Should typically not be modified.
*/
internalSubsetSAXFunc internalSubset; internalSubsetSAXFunc internalSubset;
/** unused */ /**
* Standalone status. Not invoked by the parser. Not supposed
* to be changed by applications.
*/
isStandaloneSAXFunc isStandalone; isStandaloneSAXFunc isStandalone;
/** DTD */ /**
* Internal subset availability. Not invoked by the parser.
* Not supposed to be changed by applications.
*/
hasInternalSubsetSAXFunc hasInternalSubset; hasInternalSubsetSAXFunc hasInternalSubset;
/** DTD */ /**
* External subset availability. Not invoked by the parser.
* Not supposed to be changed by applications.
*/
hasExternalSubsetSAXFunc hasExternalSubset; hasExternalSubsetSAXFunc hasExternalSubset;
/** DTD */ /**
* Only called when loading external DTDs. Not called to load
* external entities.
*
* Should typically not be modified.
*/
resolveEntitySAXFunc resolveEntity; resolveEntitySAXFunc resolveEntity;
/** DTD */ /**
* Called when looking up general entities.
*
* Should typically not be modified.
*/
getEntitySAXFunc getEntity; getEntitySAXFunc getEntity;
/** DTD */ /**
* Called after an entity declaration was parsed.
*
* Should typically not be modified.
*/
entityDeclSAXFunc entityDecl; entityDeclSAXFunc entityDecl;
/** DTD */ /**
* Called after a notation declaration was parsed.
*
* Should typically not be modified.
*/
notationDeclSAXFunc notationDecl; notationDeclSAXFunc notationDecl;
/** DTD */ /**
* Called after an attribute declaration was parsed.
*
* Should typically not be modified.
*/
attributeDeclSAXFunc attributeDecl; attributeDeclSAXFunc attributeDecl;
/** DTD */ /**
* Called after an element declaration was parsed.
*
* Should typically not be modified.
*/
elementDeclSAXFunc elementDecl; elementDeclSAXFunc elementDecl;
/** DTD */ /**
* Called after an unparsed entity declaration was parsed.
*
* Should typically not be modified.
*/
unparsedEntityDeclSAXFunc unparsedEntityDecl; unparsedEntityDeclSAXFunc unparsedEntityDecl;
/** useless */ /**
* This callback receives the "document locator" at startup,
* which is always the global xmlDefaultSAXLocator.
*
* Everything is available on the context, so this is useless in
* our case.
*/
setDocumentLocatorSAXFunc setDocumentLocator; setDocumentLocatorSAXFunc setDocumentLocator;
/** /**
* Called at the start of a document * Called after the XML declaration was parsed.
* *
* Use xmlCtxtGetVersion(), xmlCtxtGetDeclaredEncoding() and * Use xmlCtxtGetVersion(), xmlCtxtGetDeclaredEncoding() and
* xmlCtxtGetStandalone() to get data from the XML declaration. * xmlCtxtGetStandalone() to get data from the XML declaration.
*/ */
startDocumentSAXFunc startDocument; startDocumentSAXFunc startDocument;
/** End of document */ /**
* Called at the end of the document.
*/
endDocumentSAXFunc endDocument; endDocumentSAXFunc endDocument;
/** /**
* Legacy start tag handler * Legacy start tag handler
@@ -991,34 +1091,61 @@ struct _xmlSAXHandler {
* together with custom SAX callbacks. * together with custom SAX callbacks.
*/ */
startElementSAXFunc startElement; startElementSAXFunc startElement;
/** See _xmlSAXHandler.startElement */ /**
* See _xmlSAXHandler.startElement
*/
endElementSAXFunc endElement; endElementSAXFunc endElement;
/** Entity reference */ /**
* Called after an entity reference was parsed.
*/
referenceSAXFunc reference; referenceSAXFunc reference;
/** Text */ /**
* Called after a character data was parsed.
*/
charactersSAXFunc characters; charactersSAXFunc characters;
/** /**
* Ignorable whitespace * Called after "ignorable" whitespace was parsed.
* *
* `ignorableWhitespace` should always be set to the same value * `ignorableWhitespace` should always be set to the same value
* as `characters`. Otherwise, the parser will try to detect * as `characters`. Otherwise, the parser will try to detect
* whitespace which is unreliable. * whitespace which is unreliable.
*/ */
ignorableWhitespaceSAXFunc ignorableWhitespace; ignorableWhitespaceSAXFunc ignorableWhitespace;
/** Processing instruction */ /**
* Called after a processing instruction was parsed.
*/
processingInstructionSAXFunc processingInstruction; processingInstructionSAXFunc processingInstruction;
/** Comment */ /**
* Called after a comment was parsed.
*/
commentSAXFunc comment; commentSAXFunc comment;
/** Warning message */ /**
* Callback for warning messages.
*/
warningSAXFunc warning; warningSAXFunc warning;
/** Error message */ /**
* Callback for error messages.
*/
errorSAXFunc error; errorSAXFunc error;
/** Unused, all errors go to `error`. */ /**
* Unused, all errors go to `error`.
*/
fatalErrorSAXFunc fatalError; fatalErrorSAXFunc fatalError;
/** DTD */ /**
* Called when looking up parameter entities.
*
* Should typically not be modified.
*/
getParameterEntitySAXFunc getParameterEntity; getParameterEntitySAXFunc getParameterEntity;
/**
* Called after a CDATA section was parsed.
*/
cdataBlockSAXFunc cdataBlock; cdataBlockSAXFunc cdataBlock;
/** DTD */ /**
* Called to parse the external subset.
*
* Should typically not be modified.
*/
externalSubsetSAXFunc externalSubset; externalSubsetSAXFunc externalSubset;
/** /**
* Legacy magic value * Legacy magic value
@@ -1027,11 +1154,17 @@ struct _xmlSAXHandler {
* enable the modern SAX2 interface. * enable the modern SAX2 interface.
*/ */
unsigned int initialized; unsigned int initialized;
/** Application data */ /**
* Application data
*/
void *_private; void *_private;
/** Start tag */ /**
* Called after a start tag was parsed.
*/
startElementNsSAX2Func startElementNs; startElementNsSAX2Func startElementNs;
/** End tag */ /**
* Called after an end tag was parsed.
*/
endElementNsSAX2Func endElementNs; endElementNsSAX2Func endElementNs;
/** /**
* Structured error handler. * Structured error handler.
@@ -1045,7 +1178,9 @@ struct _xmlSAXHandler {
typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1; typedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1;
typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr; typedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr;
/** /**
* SAX Version 1 * SAX handler, version 1.
*
* @deprecated Use version 2 handlers.
*/ */
struct _xmlSAXHandlerV1 { struct _xmlSAXHandlerV1 {
internalSubsetSAXFunc internalSubset; internalSubsetSAXFunc internalSubset;
@@ -1080,7 +1215,7 @@ struct _xmlSAXHandlerV1 {
/** /**
* External entity loaders types. * External entity loader.
* *
* @param URL The System ID of the resource requested * @param URL The System ID of the resource requested
* @param ID The Public ID of the resource requested * @param ID The Public ID of the resource requested
@@ -1367,8 +1502,8 @@ XMLPUBFUN xmlDoc *
XMLPUBFUN xmlDtd * XMLPUBFUN xmlDtd *
xmlCtxtParseDtd (xmlParserCtxt *ctxt, xmlCtxtParseDtd (xmlParserCtxt *ctxt,
xmlParserInput *input, xmlParserInput *input,
const xmlChar *ExternalID, const xmlChar *publicId,
const xmlChar *SystemID); const xmlChar *systemId);
XMLPUBFUN int XMLPUBFUN int
xmlCtxtValidateDocument (xmlParserCtxt *ctxt, xmlCtxtValidateDocument (xmlParserCtxt *ctxt,
xmlDoc *doc); xmlDoc *doc);
@@ -1379,11 +1514,11 @@ XMLPUBFUN int
XML_DEPRECATED XML_DEPRECATED
XMLPUBFUN xmlDtd * XMLPUBFUN xmlDtd *
xmlSAXParseDTD (xmlSAXHandler *sax, xmlSAXParseDTD (xmlSAXHandler *sax,
const xmlChar *ExternalID, const xmlChar *publicId,
const xmlChar *SystemID); const xmlChar *systemId);
XMLPUBFUN xmlDtd * XMLPUBFUN xmlDtd *
xmlParseDTD (const xmlChar *ExternalID, xmlParseDTD (const xmlChar *publicId,
const xmlChar *SystemID); const xmlChar *systemId);
XMLPUBFUN xmlDtd * XMLPUBFUN xmlDtd *
xmlIOParseDTD (xmlSAXHandler *sax, xmlIOParseDTD (xmlSAXHandler *sax,
xmlParserInputBuffer *input, xmlParserInputBuffer *input,

View File

@@ -358,7 +358,7 @@ XMLPUBFUN void
XML_DEPRECATED XML_DEPRECATED
XMLPUBFUN xmlChar * XMLPUBFUN xmlChar *
xmlParseExternalID (xmlParserCtxt *ctxt, xmlParseExternalID (xmlParserCtxt *ctxt,
xmlChar **publicID, xmlChar **publicId,
int strict); int strict);
XML_DEPRECATED XML_DEPRECATED
XMLPUBFUN void XMLPUBFUN void
@@ -479,8 +479,8 @@ XMLPUBFUN void
XML_DEPRECATED XML_DEPRECATED
XMLPUBFUN void XMLPUBFUN void
xmlParseExternalSubset (xmlParserCtxt *ctxt, xmlParseExternalSubset (xmlParserCtxt *ctxt,
const xmlChar *ExternalID, const xmlChar *publicId,
const xmlChar *SystemID); const xmlChar *systemId);
/** @cond ignore */ /** @cond ignore */
#define XML_SUBSTITUTE_NONE 0 #define XML_SUBSTITUTE_NONE 0

View File

@@ -791,13 +791,13 @@ XMLPUBFUN const xmlChar *
XMLPUBFUN xmlDtd * XMLPUBFUN xmlDtd *
xmlCreateIntSubset (xmlDoc *doc, xmlCreateIntSubset (xmlDoc *doc,
const xmlChar *name, const xmlChar *name,
const xmlChar *ExternalID, const xmlChar *publicId,
const xmlChar *SystemID); const xmlChar *systemId);
XMLPUBFUN xmlDtd * XMLPUBFUN xmlDtd *
xmlNewDtd (xmlDoc *doc, xmlNewDtd (xmlDoc *doc,
const xmlChar *name, const xmlChar *name,
const xmlChar *ExternalID, const xmlChar *publicId,
const xmlChar *SystemID); const xmlChar *systemId);
XMLPUBFUN xmlDtd * XMLPUBFUN xmlDtd *
xmlGetIntSubset (const xmlDoc *doc); xmlGetIntSubset (const xmlDoc *doc);
XMLPUBFUN void XMLPUBFUN void

View File

@@ -112,8 +112,8 @@ XMLPUBFUN xmlNotation *
xmlAddNotationDecl (xmlValidCtxt *ctxt, xmlAddNotationDecl (xmlValidCtxt *ctxt,
xmlDtd *dtd, xmlDtd *dtd,
const xmlChar *name, const xmlChar *name,
const xmlChar *PublicID, const xmlChar *publicId,
const xmlChar *SystemID); const xmlChar *systemId);
XML_DEPRECATED XML_DEPRECATED
XMLPUBFUN xmlNotationTable * XMLPUBFUN xmlNotationTable *
xmlCopyNotationTable (xmlNotationTable *table); xmlCopyNotationTable (xmlNotationTable *table);

View File

@@ -4913,7 +4913,7 @@ xmlParseCharData(xmlParserCtxt *ctxt, ATTRIBUTE_UNUSED int cdata) {
* [83] PublicID ::= 'PUBLIC' S PubidLiteral * [83] PublicID ::= 'PUBLIC' S PubidLiteral
* *
* @param ctxt an XML parser context * @param ctxt an XML parser context
* @param publicID a xmlChar** receiving PubidLiteral * @param publicId a xmlChar** receiving PubidLiteral
* @param strict indicate whether we should restrict parsing to only * @param strict indicate whether we should restrict parsing to only
* production [75], see NOTE below * production [75], see NOTE below
* @returns the function returns SystemLiteral and in the second * @returns the function returns SystemLiteral and in the second
@@ -4922,10 +4922,10 @@ xmlParseCharData(xmlParserCtxt *ctxt, ATTRIBUTE_UNUSED int cdata) {
*/ */
xmlChar * xmlChar *
xmlParseExternalID(xmlParserCtxt *ctxt, xmlChar **publicID, int strict) { xmlParseExternalID(xmlParserCtxt *ctxt, xmlChar **publicId, int strict) {
xmlChar *URI = NULL; xmlChar *URI = NULL;
*publicID = NULL; *publicId = NULL;
if (CMP6(CUR_PTR, 'S', 'Y', 'S', 'T', 'E', 'M')) { if (CMP6(CUR_PTR, 'S', 'Y', 'S', 'T', 'E', 'M')) {
SKIP(6); SKIP(6);
if (SKIP_BLANKS == 0) { if (SKIP_BLANKS == 0) {
@@ -4942,8 +4942,8 @@ xmlParseExternalID(xmlParserCtxt *ctxt, xmlChar **publicID, int strict) {
xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
"Space required after 'PUBLIC'\n"); "Space required after 'PUBLIC'\n");
} }
*publicID = xmlParsePubidLiteral(ctxt); *publicId = xmlParsePubidLiteral(ctxt);
if (*publicID == NULL) { if (*publicId == NULL) {
xmlFatalErr(ctxt, XML_ERR_PUBID_REQUIRED, NULL); xmlFatalErr(ctxt, XML_ERR_PUBID_REQUIRED, NULL);
} }
if (strict) { if (strict) {
@@ -7104,12 +7104,12 @@ xmlParseTextDecl(xmlParserCtxt *ctxt) {
* [31] extSubsetDecl ::= (markupdecl | conditionalSect | * [31] extSubsetDecl ::= (markupdecl | conditionalSect |
* PEReference | S) * * PEReference | S) *
* @param ctxt an XML parser context * @param ctxt an XML parser context
* @param ExternalID the external identifier * @param publicId the public identifier
* @param SystemID the system identifier (or URL) * @param systemId the system identifier (URL)
*/ */
void void
xmlParseExternalSubset(xmlParserCtxt *ctxt, const xmlChar *ExternalID, xmlParseExternalSubset(xmlParserCtxt *ctxt, const xmlChar *publicId,
const xmlChar *SystemID) { const xmlChar *systemId) {
int oldInputNr; int oldInputNr;
xmlCtxtInitializeLate(ctxt); xmlCtxtInitializeLate(ctxt);
@@ -7128,7 +7128,7 @@ xmlParseExternalSubset(xmlParserCtxt *ctxt, const xmlChar *ExternalID,
ctxt->myDoc->properties = XML_DOC_INTERNAL; ctxt->myDoc->properties = XML_DOC_INTERNAL;
} }
if ((ctxt->myDoc != NULL) && (ctxt->myDoc->intSubset == NULL) && if ((ctxt->myDoc != NULL) && (ctxt->myDoc->intSubset == NULL) &&
(xmlCreateIntSubset(ctxt->myDoc, NULL, ExternalID, SystemID) == NULL)) { (xmlCreateIntSubset(ctxt->myDoc, NULL, publicId, systemId) == NULL)) {
xmlErrMemory(ctxt); xmlErrMemory(ctxt);
} }
@@ -7996,7 +7996,7 @@ xmlParseStringPEReference(xmlParserCtxtPtr ctxt, const xmlChar **str) {
void void
xmlParseDocTypeDecl(xmlParserCtxt *ctxt) { xmlParseDocTypeDecl(xmlParserCtxt *ctxt) {
const xmlChar *name = NULL; const xmlChar *name = NULL;
xmlChar *ExternalID = NULL; xmlChar *publicId = NULL;
xmlChar *URI = NULL; xmlChar *URI = NULL;
/* /*
@@ -8022,15 +8022,15 @@ xmlParseDocTypeDecl(xmlParserCtxt *ctxt) {
SKIP_BLANKS; SKIP_BLANKS;
/* /*
* Check for SystemID and ExternalID * Check for public and system identifier (URI)
*/ */
URI = xmlParseExternalID(ctxt, &ExternalID, 1); URI = xmlParseExternalID(ctxt, &publicId, 1);
if ((URI != NULL) || (ExternalID != NULL)) { if ((URI != NULL) || (publicId != NULL)) {
ctxt->hasExternalSubset = 1; ctxt->hasExternalSubset = 1;
} }
ctxt->extSubURI = URI; ctxt->extSubURI = URI;
ctxt->extSubSystem = ExternalID; ctxt->extSubSystem = publicId;
SKIP_BLANKS; SKIP_BLANKS;
@@ -8039,7 +8039,7 @@ xmlParseDocTypeDecl(xmlParserCtxt *ctxt) {
*/ */
if ((ctxt->sax != NULL) && (ctxt->sax->internalSubset != NULL) && if ((ctxt->sax != NULL) && (ctxt->sax->internalSubset != NULL) &&
(!ctxt->disableSAX)) (!ctxt->disableSAX))
ctxt->sax->internalSubset(ctxt->userData, name, ExternalID, URI); ctxt->sax->internalSubset(ctxt->userData, name, publicId, URI);
if ((RAW != '[') && (RAW != '>')) { if ((RAW != '[') && (RAW != '>')) {
xmlFatalErr(ctxt, XML_ERR_DOCTYPE_NOT_FINISHED, NULL); xmlFatalErr(ctxt, XML_ERR_DOCTYPE_NOT_FINISHED, NULL);
@@ -11262,6 +11262,9 @@ done:
* ctxt->myDoc. So ctxt->myDoc should be set to NULL after extracting * ctxt->myDoc. So ctxt->myDoc should be set to NULL after extracting
* the document. * the document.
* *
* Since 2.14.0, xmlCtxtGetDocument() can be used to retrieve the
* result document.
*
* @param ctxt an XML parser context * @param ctxt an XML parser context
* @param chunk chunk of memory * @param chunk chunk of memory
* @param size size of chunk in bytes * @param size size of chunk in bytes
@@ -11615,20 +11618,20 @@ xmlIOParseDTD(xmlSAXHandler *sax, xmlParserInputBuffer *input,
* @deprecated Use xmlCtxtParseDtd(). * @deprecated Use xmlCtxtParseDtd().
* *
* @param sax the SAX handler block * @param sax the SAX handler block
* @param ExternalID a NAME* containing the External ID of the DTD * @param publicId public identifier of the DTD (optional)
* @param SystemID a NAME* containing the URL to the DTD * @param systemId system identifier (URL) of the DTD
* @returns the resulting xmlDtd or NULL in case of error. * @returns the resulting xmlDtd or NULL in case of error.
*/ */
xmlDtd * xmlDtd *
xmlSAXParseDTD(xmlSAXHandler *sax, const xmlChar *ExternalID, xmlSAXParseDTD(xmlSAXHandler *sax, const xmlChar *publicId,
const xmlChar *SystemID) { const xmlChar *systemId) {
xmlDtdPtr ret = NULL; xmlDtdPtr ret = NULL;
xmlParserCtxtPtr ctxt; xmlParserCtxtPtr ctxt;
xmlParserInputPtr input = NULL; xmlParserInputPtr input = NULL;
xmlChar* systemIdCanonic; xmlChar* systemIdCanonic;
if ((ExternalID == NULL) && (SystemID == NULL)) return(NULL); if ((publicId == NULL) && (systemId == NULL)) return(NULL);
ctxt = xmlNewSAXParserCtxt(sax, NULL); ctxt = xmlNewSAXParserCtxt(sax, NULL);
if (ctxt == NULL) { if (ctxt == NULL) {
@@ -11639,8 +11642,8 @@ xmlSAXParseDTD(xmlSAXHandler *sax, const xmlChar *ExternalID,
/* /*
* Canonicalise the system ID * Canonicalise the system ID
*/ */
systemIdCanonic = xmlCanonicPath(SystemID); systemIdCanonic = xmlCanonicPath(systemId);
if ((SystemID != NULL) && (systemIdCanonic == NULL)) { if ((systemId != NULL) && (systemIdCanonic == NULL)) {
xmlFreeParserCtxt(ctxt); xmlFreeParserCtxt(ctxt);
return(NULL); return(NULL);
} }
@@ -11650,7 +11653,7 @@ xmlSAXParseDTD(xmlSAXHandler *sax, const xmlChar *ExternalID,
*/ */
if ((ctxt->sax != NULL) && (ctxt->sax->resolveEntity != NULL)) if ((ctxt->sax != NULL) && (ctxt->sax->resolveEntity != NULL))
input = ctxt->sax->resolveEntity(ctxt->userData, ExternalID, input = ctxt->sax->resolveEntity(ctxt->userData, publicId,
systemIdCanonic); systemIdCanonic);
if (input == NULL) { if (input == NULL) {
xmlFreeParserCtxt(ctxt); xmlFreeParserCtxt(ctxt);
@@ -11664,7 +11667,7 @@ xmlSAXParseDTD(xmlSAXHandler *sax, const xmlChar *ExternalID,
else else
xmlFree(systemIdCanonic); xmlFree(systemIdCanonic);
ret = xmlCtxtParseDtd(ctxt, input, ExternalID, SystemID); ret = xmlCtxtParseDtd(ctxt, input, publicId, systemId);
xmlFreeParserCtxt(ctxt); xmlFreeParserCtxt(ctxt);
return(ret); return(ret);
@@ -11674,14 +11677,14 @@ xmlSAXParseDTD(xmlSAXHandler *sax, const xmlChar *ExternalID,
/** /**
* Load and parse an external subset. * Load and parse an external subset.
* *
* @param ExternalID a NAME* containing the External ID of the DTD * @param publicId public identifier of the DTD (optional)
* @param SystemID a NAME* containing the URL to the DTD * @param systemId system identifier (URL) of the DTD
* @returns the resulting xmlDtd or NULL in case of error. * @returns the resulting xmlDtd or NULL in case of error.
*/ */
xmlDtd * xmlDtd *
xmlParseDTD(const xmlChar *ExternalID, const xmlChar *SystemID) { xmlParseDTD(const xmlChar *publicId, const xmlChar *systemId) {
return(xmlSAXParseDTD(NULL, ExternalID, SystemID)); return(xmlSAXParseDTD(NULL, publicId, systemId));
} }
#endif /* LIBXML_VALID_ENABLED */ #endif /* LIBXML_VALID_ENABLED */

32
tree.c
View File

@@ -780,14 +780,14 @@ xmlFreeNsList(xmlNs *cur) {
* *
* @param doc the document pointer (optional) * @param doc the document pointer (optional)
* @param name the DTD name (optional) * @param name the DTD name (optional)
* @param ExternalID the external ID (optional) * @param publicId public identifier of the DTD (optional)
* @param SystemID the system ID (optional) * @param systemId system identifier (URL) of the DTD (optional)
* @returns a pointer to the new DTD object or NULL if arguments are * @returns a pointer to the new DTD object or NULL if arguments are
* invalid or a memory allocation failed. * invalid or a memory allocation failed.
*/ */
xmlDtd * xmlDtd *
xmlNewDtd(xmlDoc *doc, const xmlChar *name, xmlNewDtd(xmlDoc *doc, const xmlChar *name, const xmlChar *publicId,
const xmlChar *ExternalID, const xmlChar *SystemID) { const xmlChar *systemId) {
xmlDtdPtr cur; xmlDtdPtr cur;
if ((doc != NULL) && (doc->extSubset != NULL)) { if ((doc != NULL) && (doc->extSubset != NULL)) {
@@ -808,13 +808,13 @@ xmlNewDtd(xmlDoc *doc, const xmlChar *name,
if (cur->name == NULL) if (cur->name == NULL)
goto error; goto error;
} }
if (ExternalID != NULL) { if (publicId != NULL) {
cur->ExternalID = xmlStrdup(ExternalID); cur->ExternalID = xmlStrdup(publicId);
if (cur->ExternalID == NULL) if (cur->ExternalID == NULL)
goto error; goto error;
} }
if (SystemID != NULL) { if (systemId != NULL) {
cur->SystemID = xmlStrdup(SystemID); cur->SystemID = xmlStrdup(systemId);
if (cur->SystemID == NULL) if (cur->SystemID == NULL)
goto error; goto error;
} }
@@ -862,14 +862,14 @@ xmlGetIntSubset(const xmlDoc *doc) {
* *
* @param doc the document pointer (optional) * @param doc the document pointer (optional)
* @param name the DTD name (optional) * @param name the DTD name (optional)
* @param ExternalID the external (PUBLIC) ID (optional) * @param publicId public identifier of the DTD (optional)
* @param SystemID the system ID (optional) * @param systemId system identifier (URL) of the DTD (optional)
* @returns a pointer to the new or existing DTD object or NULL if * @returns a pointer to the new or existing DTD object or NULL if
* arguments are invalid or a memory allocation failed. * arguments are invalid or a memory allocation failed.
*/ */
xmlDtd * xmlDtd *
xmlCreateIntSubset(xmlDoc *doc, const xmlChar *name, xmlCreateIntSubset(xmlDoc *doc, const xmlChar *name, const xmlChar *publicId,
const xmlChar *ExternalID, const xmlChar *SystemID) { const xmlChar *systemId) {
xmlDtdPtr cur; xmlDtdPtr cur;
if (doc != NULL) { if (doc != NULL) {
@@ -892,13 +892,13 @@ xmlCreateIntSubset(xmlDoc *doc, const xmlChar *name,
if (cur->name == NULL) if (cur->name == NULL)
goto error; goto error;
} }
if (ExternalID != NULL) { if (publicId != NULL) {
cur->ExternalID = xmlStrdup(ExternalID); cur->ExternalID = xmlStrdup(publicId);
if (cur->ExternalID == NULL) if (cur->ExternalID == NULL)
goto error; goto error;
} }
if (SystemID != NULL) { if (systemId != NULL) {
cur->SystemID = xmlStrdup(SystemID); cur->SystemID = xmlStrdup(systemId);
if (cur->SystemID == NULL) if (cur->SystemID == NULL)
goto error; goto error;
} }

19
valid.c
View File

@@ -2022,14 +2022,13 @@ xmlFreeNotation(xmlNotationPtr nota) {
* @param dtd pointer to the DTD * @param dtd pointer to the DTD
* @param ctxt the validation context * @param ctxt the validation context
* @param name the entity name * @param name the entity name
* @param PublicID the public identifier or NULL * @param publicId the public identifier or NULL
* @param SystemID the system identifier or NULL * @param systemId the system identifier or NULL
* @returns the notation or NULL on error. * @returns the notation or NULL on error.
*/ */
xmlNotation * xmlNotation *
xmlAddNotationDecl(xmlValidCtxt *ctxt, xmlDtd *dtd, xmlAddNotationDecl(xmlValidCtxt *ctxt, xmlDtd *dtd, const xmlChar *name,
const xmlChar *name, const xmlChar *publicId, const xmlChar *systemId) {
const xmlChar *PublicID, const xmlChar *SystemID) {
xmlNotationPtr ret = NULL; xmlNotationPtr ret = NULL;
xmlNotationTablePtr table; xmlNotationTablePtr table;
int res; int res;
@@ -2040,7 +2039,7 @@ xmlAddNotationDecl(xmlValidCtxt *ctxt, xmlDtd *dtd,
if (name == NULL) { if (name == NULL) {
return(NULL); return(NULL);
} }
if ((PublicID == NULL) && (SystemID == NULL)) { if ((publicId == NULL) && (systemId == NULL)) {
return(NULL); return(NULL);
} }
@@ -2069,13 +2068,13 @@ xmlAddNotationDecl(xmlValidCtxt *ctxt, xmlDtd *dtd,
ret->name = xmlStrdup(name); ret->name = xmlStrdup(name);
if (ret->name == NULL) if (ret->name == NULL)
goto mem_error; goto mem_error;
if (SystemID != NULL) { if (systemId != NULL) {
ret->SystemID = xmlStrdup(SystemID); ret->SystemID = xmlStrdup(systemId);
if (ret->SystemID == NULL) if (ret->SystemID == NULL)
goto mem_error; goto mem_error;
} }
if (PublicID != NULL) { if (publicId != NULL) {
ret->PublicID = xmlStrdup(PublicID); ret->PublicID = xmlStrdup(publicId);
if (ret->PublicID == NULL) if (ret->PublicID == NULL)
goto mem_error; goto mem_error;
} }