SAX.c revision 3473f88a7abdf4e585e267288fb77e898c580d2b
13473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/*
23473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * SAX.c : Default SAX handler to build a tree.
33473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
43473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * See Copyright for the status of this software.
53473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
63473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Daniel Veillard <Daniel.Veillard@w3.org>
73473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
83473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
93473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
103473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef WIN32
113473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#include "win32config.h"
123473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#else
133473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#include "config.h"
143473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
153473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#include <stdio.h>
163473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#include <stdlib.h>
173473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#include <string.h>
183473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#include <libxml/xmlmemory.h>
193473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#include <libxml/tree.h>
203473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#include <libxml/parser.h>
213473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#include <libxml/parserInternals.h>
223473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#include <libxml/valid.h>
233473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#include <libxml/entities.h>
243473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#include <libxml/xmlerror.h>
253473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#include <libxml/debugXML.h>
263473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#include <libxml/xmlIO.h>
273473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#include <libxml/SAX.h>
283473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#include <libxml/uri.h>
293473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#include <libxml/HTMLtree.h>
303473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
313473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/* #define DEBUG_SAX */
323473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/* #define DEBUG_SAX_TREE */
333473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
343473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
353473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * getPublicId:
363473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
373473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
383473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Return the public ID e.g. "-//SGMLSOURCE//DTD DEMO//EN"
393473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
403473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Returns a xmlChar *
413473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
423473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorconst xmlChar *
433473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorgetPublicId(void *ctx)
443473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
453473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
463473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    return(NULL);
473473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
483473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
493473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
503473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * getSystemId:
513473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
523473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
533473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Return the system ID, basically URL or filename e.g.
543473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * http://www.sgmlsource.com/dtds/memo.dtd
553473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
563473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Returns a xmlChar *
573473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
583473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorconst xmlChar *
593473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorgetSystemId(void *ctx)
603473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
613473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
623473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    return(BAD_CAST ctxt->input->filename);
633473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
643473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
653473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
663473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * getLineNumber:
673473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
683473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
693473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Return the line number of the current parsing point.
703473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
713473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Returns an int
723473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
733473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorint
743473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorgetLineNumber(void *ctx)
753473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
763473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
773473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    return(ctxt->input->line);
783473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
793473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
803473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
813473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * getColumnNumber:
823473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
833473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
843473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Return the column number of the current parsing point.
853473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
863473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Returns an int
873473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
883473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorint
893473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorgetColumnNumber(void *ctx)
903473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
913473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
923473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    return(ctxt->input->col);
933473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
943473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
953473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/*
963473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * The default SAX Locator.
973473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
983473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
993473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorxmlSAXLocator xmlDefaultSAXLocator = {
1003473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    getPublicId, getSystemId, getLineNumber, getColumnNumber
1013473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor};
1023473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
1033473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
1043473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * isStandalone:
1053473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
1063473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
1073473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Is this document tagged standalone ?
1083473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
1093473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Returns 1 if true
1103473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
1113473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorint
1123473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorisStandalone(void *ctx)
1133473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
1143473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
1153473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    return(ctxt->myDoc->standalone == 1);
1163473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
1173473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
1183473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
1193473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * hasInternalSubset:
1203473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
1213473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
1223473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Does this document has an internal subset
1233473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
1243473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Returns 1 if true
1253473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
1263473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorint
1273473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorhasInternalSubset(void *ctx)
1283473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
1293473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
1303473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    return(ctxt->myDoc->intSubset != NULL);
1313473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
1323473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
1333473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
1343473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * hasExternalSubset:
1353473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
1363473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
1373473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Does this document has an external subset
1383473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
1393473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Returns 1 if true
1403473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
1413473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorint
1423473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorhasExternalSubset(void *ctx)
1433473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
1443473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
1453473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    return(ctxt->myDoc->extSubset != NULL);
1463473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
1473473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
1483473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
1493473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * internalSubset:
1503473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx:  the user data (XML parser context)
1513473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @name:  the root element name
1523473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ExternalID:  the external ID
1533473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @SystemID:  the SYSTEM ID (e.g. filename or URL)
1543473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
1553473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Callback on internal subset declaration.
1563473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
1573473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid
1583473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorinternalSubset(void *ctx, const xmlChar *name,
1593473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	       const xmlChar *ExternalID, const xmlChar *SystemID)
1603473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
1613473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
1623473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDtdPtr dtd;
1633473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX
1643473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext,
1653473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    "SAX.internalSubset(%s, %s, %s)\n",
1663473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor            name, ExternalID, SystemID);
1673473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
1683473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
1693473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (ctxt->myDoc == NULL)
1703473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	return;
1713473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    dtd = xmlGetIntSubset(ctxt->myDoc);
1723473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (dtd != NULL) {
1733473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	if (ctxt->html)
1743473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    return;
1753473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlUnlinkNode((xmlNodePtr) dtd);
1763473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlFreeDtd(dtd);
1773473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ctxt->myDoc->intSubset = NULL;
1783473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
1793473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    ctxt->myDoc->intSubset =
1803473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlCreateIntSubset(ctxt->myDoc, name, ExternalID, SystemID);
1813473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
1823473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
1833473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
1843473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * externalSubset:
1853473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
1863473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @name:  the root element name
1873473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ExternalID:  the external ID
1883473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @SystemID:  the SYSTEM ID (e.g. filename or URL)
1893473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
1903473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Callback on external subset declaration.
1913473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
1923473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid
1933473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorexternalSubset(void *ctx, const xmlChar *name,
1943473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	       const xmlChar *ExternalID, const xmlChar *SystemID)
1953473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
1963473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
1973473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX
1983473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext,
1993473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    "SAX.externalSubset(%s, %s, %s)\n",
2003473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor            name, ExternalID, SystemID);
2013473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
2023473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (((ExternalID != NULL) || (SystemID != NULL)) &&
2033473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        (((ctxt->validate) || (ctxt->loadsubset)) &&
2043473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 (ctxt->wellFormed && ctxt->myDoc))) {
2053473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	/*
2063473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 * Try to fetch and parse the external subset.
2073473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 */
2083473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlParserInputPtr oldinput;
2093473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	int oldinputNr;
2103473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	int oldinputMax;
2113473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlParserInputPtr *oldinputTab;
2123473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	int oldwellFormed;
2133473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlParserInputPtr input = NULL;
2143473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlCharEncoding enc;
2153473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	int oldcharset;
2163473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
2173473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	/*
2183473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 * Ask the Entity resolver to load the damn thing
2193473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 */
2203473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	if ((ctxt->sax != NULL) && (ctxt->sax->resolveEntity != NULL))
2213473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    input = ctxt->sax->resolveEntity(ctxt->userData, ExternalID,
2223473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	                                        SystemID);
2233473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	if (input == NULL) {
2243473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    return;
2253473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	}
2263473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
2273473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlNewDtd(ctxt->myDoc, name, ExternalID, SystemID);
2283473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
2293473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	/*
2303473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 * make sure we won't destroy the main document context
2313473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 */
2323473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	oldinput = ctxt->input;
2333473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	oldinputNr = ctxt->inputNr;
2343473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	oldinputMax = ctxt->inputMax;
2353473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	oldinputTab = ctxt->inputTab;
2363473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	oldwellFormed = ctxt->wellFormed;
2373473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	oldcharset = ctxt->charset;
2383473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
2393473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ctxt->inputTab = (xmlParserInputPtr *)
2403473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	                 xmlMalloc(5 * sizeof(xmlParserInputPtr));
2413473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	if (ctxt->inputTab == NULL) {
2423473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ctxt->errNo = XML_ERR_NO_MEMORY;
2433473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
2443473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		ctxt->sax->error(ctxt->userData,
2453473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		     "externalSubset: out of memory\n");
2463473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ctxt->errNo = XML_ERR_NO_MEMORY;
2473473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ctxt->input = oldinput;
2483473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ctxt->inputNr = oldinputNr;
2493473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ctxt->inputMax = oldinputMax;
2503473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ctxt->inputTab = oldinputTab;
2513473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ctxt->charset = oldcharset;
2523473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    return;
2533473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	}
2543473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ctxt->inputNr = 0;
2553473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ctxt->inputMax = 5;
2563473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ctxt->input = NULL;
2573473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlPushInput(ctxt, input);
2583473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
2593473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	/*
2603473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 * On the fly encoding conversion if needed
2613473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 */
2623473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	enc = xmlDetectCharEncoding(ctxt->input->cur, 4);
2633473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlSwitchEncoding(ctxt, enc);
2643473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
2653473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	if (input->filename == NULL)
2663473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    input->filename = (char *) xmlStrdup(SystemID);
2673473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	input->line = 1;
2683473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	input->col = 1;
2693473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	input->base = ctxt->input->cur;
2703473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	input->cur = ctxt->input->cur;
2713473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	input->free = NULL;
2723473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
2733473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	/*
2743473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 * let's parse that entity knowing it's an external subset.
2753473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 */
2763473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlParseExternalSubset(ctxt, ExternalID, SystemID);
2773473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
2783473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        /*
2793473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 * Free up the external entities
2803473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 */
2813473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
2823473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	while (ctxt->inputNr > 1)
2833473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    xmlPopInput(ctxt);
2843473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlFreeInputStream(ctxt->input);
2853473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        xmlFree(ctxt->inputTab);
2863473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
2873473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	/*
2883473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 * Restore the parsing context of the main entity
2893473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 */
2903473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ctxt->input = oldinput;
2913473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ctxt->inputNr = oldinputNr;
2923473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ctxt->inputMax = oldinputMax;
2933473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ctxt->inputTab = oldinputTab;
2943473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ctxt->charset = oldcharset;
2953473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	/* ctxt->wellFormed = oldwellFormed; */
2963473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
2973473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
2983473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
2993473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
3003473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * resolveEntity:
3013473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
3023473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @publicId: The public ID of the entity
3033473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @systemId: The system ID of the entity
3043473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
3053473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * The entity loader, to control the loading of external entities,
3063473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * the application can either:
3073473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *    - override this resolveEntity() callback in the SAX block
3083473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *    - or better use the xmlSetExternalEntityLoader() function to
3093473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *      set up it's own entity resolution routine
3103473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
3113473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.
3123473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
3133473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorxmlParserInputPtr
3143473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorresolveEntity(void *ctx, const xmlChar *publicId, const xmlChar *systemId)
3153473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
3163473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
3173473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserInputPtr ret;
3183473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlChar *URI;
3193473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    const char *base = NULL;
3203473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
3213473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (ctxt->input != NULL)
3223473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	base = ctxt->input->filename;
3233473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (base == NULL)
3243473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	base = ctxt->directory;
3253473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
3263473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    URI = xmlBuildURI(systemId, (const xmlChar *) base);
3273473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
3283473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX
3293473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext,
3303473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    "SAX.resolveEntity(%s, %s)\n", publicId, systemId);
3313473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
3323473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
3333473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    ret = xmlLoadExternalEntity((const char *) URI,
3343473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor				(const char *) publicId, ctxt);
3353473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (URI != NULL)
3363473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlFree(URI);
3373473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    return(ret);
3383473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
3393473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
3403473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
3413473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * getEntity:
3423473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
3433473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @name: The entity name
3443473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
3453473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Get an entity by name
3463473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
3473473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Returns the xmlEntityPtr if found.
3483473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
3493473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorxmlEntityPtr
3503473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorgetEntity(void *ctx, const xmlChar *name)
3513473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
3523473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
3533473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlEntityPtr ret;
3543473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
3553473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX
3563473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext,
3573473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    "SAX.getEntity(%s)\n", name);
3583473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
3593473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
3603473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    ret = xmlGetDocEntity(ctxt->myDoc, name);
3613473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if ((ret != NULL) && (ctxt->validate) && (ret->children == NULL) &&
3623473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	(ret->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)) {
3633473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	/*
3643473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 * for validation purposes we really need to fetch and
3653473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 * parse the external entity
3663473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 */
3673473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	int parse;
3683473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlNodePtr children;
3693473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
3703473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        parse = xmlParseCtxtExternalEntity(ctxt,
3713473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		  ret->SystemID, ret->ExternalID, &children);
3723473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlAddChildList((xmlNodePtr) ret, children);
3733473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
3743473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    return(ret);
3753473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
3763473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
3773473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
3783473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * getParameterEntity:
3793473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
3803473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @name: The entity name
3813473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
3823473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Get a parameter entity by name
3833473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
3843473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Returns the xmlEntityPtr if found.
3853473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
3863473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorxmlEntityPtr
3873473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorgetParameterEntity(void *ctx, const xmlChar *name)
3883473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
3893473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
3903473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlEntityPtr ret;
3913473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
3923473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX
3933473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext,
3943473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    "SAX.getParameterEntity(%s)\n", name);
3953473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
3963473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
3973473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    ret = xmlGetParameterEntity(ctxt->myDoc, name);
3983473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    return(ret);
3993473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
4003473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
4013473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
4023473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
4033473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * entityDecl:
4043473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
4053473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @name:  the entity name
4063473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @type:  the entity type
4073473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @publicId: The public ID of the entity
4083473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @systemId: The system ID of the entity
4093473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @content: the entity value (without processing).
4103473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
4113473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * An entity definition has been parsed
4123473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
4133473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid
4143473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorentityDecl(void *ctx, const xmlChar *name, int type,
4153473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor          const xmlChar *publicId, const xmlChar *systemId, xmlChar *content)
4163473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
4173473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlEntityPtr ent;
4183473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
4193473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
4203473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX
4213473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext,
4223473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    "SAX.entityDecl(%s, %d, %s, %s, %s)\n",
4233473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor            name, type, publicId, systemId, content);
4243473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
4253473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (ctxt->inSubset == 1) {
4263473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ent = xmlAddDocEntity(ctxt->myDoc, name, type, publicId,
4273473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		              systemId, content);
4283473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	if ((ent == NULL) && (ctxt->pedantic) &&
4293473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    (ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
4303473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ctxt->sax->warning(ctxt,
4313473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	     "Entity(%s) already defined in the internal subset\n", name);
4323473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	if ((ent != NULL) && (ent->URI == NULL) && (systemId != NULL)) {
4333473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    xmlChar *URI;
4343473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    const char *base = NULL;
4353473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
4363473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    if (ctxt->input != NULL)
4373473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		base = ctxt->input->filename;
4383473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    if (base == NULL)
4393473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		base = ctxt->directory;
4403473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
4413473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    URI = xmlBuildURI(systemId, (const xmlChar *) base);
4423473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ent->URI = URI;
4433473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	}
4443473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    } else if (ctxt->inSubset == 2) {
4453473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ent = xmlAddDtdEntity(ctxt->myDoc, name, type, publicId,
4463473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		              systemId, content);
4473473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	if ((ent == NULL) && (ctxt->pedantic) &&
4483473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    (ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
4493473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ctxt->sax->warning(ctxt,
4503473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	     "Entity(%s) already defined in the external subset\n", name);
4513473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	if ((ent != NULL) && (ent->URI == NULL) && (systemId != NULL)) {
4523473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    xmlChar *URI;
4533473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    const char *base = NULL;
4543473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
4553473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    if (ctxt->input != NULL)
4563473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		base = ctxt->input->filename;
4573473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    if (base == NULL)
4583473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		base = ctxt->directory;
4593473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
4603473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    URI = xmlBuildURI(systemId, (const xmlChar *) base);
4613473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ent->URI = URI;
4623473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	}
4633473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    } else {
4643473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
4653473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ctxt->sax->error(ctxt,
4663473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	     "SAX.entityDecl(%s) called while not in subset\n", name);
4673473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
4683473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
4693473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
4703473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
4713473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * attributeDecl:
4723473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
4733473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @elem:  the name of the element
4743473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @fullname:  the attribute name
4753473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @type:  the attribute type
4763473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @def:  the type of default value
4773473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @defaultValue: the attribute default value
4783473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @tree:  the tree of enumerated value set
4793473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
4803473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * An attribute definition has been parsed
4813473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
4823473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid
4833473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorattributeDecl(void *ctx, const xmlChar *elem, const xmlChar *fullname,
4843473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor              int type, int def, const xmlChar *defaultValue,
4853473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	      xmlEnumerationPtr tree)
4863473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
4873473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
4883473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlAttributePtr attr;
4893473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlChar *name = NULL, *prefix = NULL;
4903473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
4913473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX
4923473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext,
4933473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    "SAX.attributeDecl(%s, %s, %d, %d, %s, ...)\n",
4943473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor            elem, fullname, type, def, defaultValue);
4953473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
4963473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    name = xmlSplitQName(ctxt, fullname, &prefix);
4973473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (ctxt->inSubset == 1)
4983473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	attr = xmlAddAttributeDecl(&ctxt->vctxt, ctxt->myDoc->intSubset, elem,
4993473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	       name, prefix, (xmlAttributeType) type,
5003473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	       (xmlAttributeDefault) def, defaultValue, tree);
5013473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    else if (ctxt->inSubset == 2)
5023473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	attr = xmlAddAttributeDecl(&ctxt->vctxt, ctxt->myDoc->extSubset, elem,
5033473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	   name, prefix, (xmlAttributeType) type,
5043473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	   (xmlAttributeDefault) def, defaultValue, tree);
5053473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    else {
5063473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
5073473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ctxt->sax->error(ctxt,
5083473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	     "SAX.attributeDecl(%s) called while not in subset\n", name);
5093473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	return;
5103473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
5113473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (attr == 0) ctxt->valid = 0;
5123473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (ctxt->validate && ctxt->wellFormed &&
5133473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        ctxt->myDoc && ctxt->myDoc->intSubset)
5143473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ctxt->valid &= xmlValidateAttributeDecl(&ctxt->vctxt, ctxt->myDoc,
5153473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	                                        attr);
5163473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (prefix != NULL)
5173473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlFree(prefix);
5183473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (name != NULL)
5193473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlFree(name);
5203473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
5213473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
5223473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
5233473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * elementDecl:
5243473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
5253473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @name:  the element name
5263473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @type:  the element type
5273473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @content: the element value tree
5283473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
5293473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * An element definition has been parsed
5303473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
5313473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid
5323473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorelementDecl(void *ctx, const xmlChar *name, int type,
5333473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    xmlElementContentPtr content)
5343473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
5353473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
5363473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlElementPtr elem = NULL;
5373473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
5383473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX
5393473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext,
5403473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    "SAX.elementDecl(%s, %d, ...)\n",
5413473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor            fullname, type);
5423473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
5433473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
5443473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (ctxt->inSubset == 1)
5453473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	elem = xmlAddElementDecl(&ctxt->vctxt, ctxt->myDoc->intSubset,
5463473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor                             name, (xmlElementTypeVal) type, content);
5473473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    else if (ctxt->inSubset == 2)
5483473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	elem = xmlAddElementDecl(&ctxt->vctxt, ctxt->myDoc->extSubset,
5493473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor                             name, (xmlElementTypeVal) type, content);
5503473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    else {
5513473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
5523473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ctxt->sax->error(ctxt,
5533473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	     "SAX.elementDecl(%s) called while not in subset\n", name);
5543473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	return;
5553473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
5563473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (elem == NULL) ctxt->valid = 0;
5573473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (ctxt->validate && ctxt->wellFormed &&
5583473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        ctxt->myDoc && ctxt->myDoc->intSubset)
5593473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ctxt->valid &= xmlValidateElementDecl(&ctxt->vctxt, ctxt->myDoc, elem);
5603473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
5613473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
5623473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
5633473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * notationDecl:
5643473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
5653473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @name: The name of the notation
5663473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @publicId: The public ID of the entity
5673473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @systemId: The system ID of the entity
5683473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
5693473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * What to do when a notation declaration has been parsed.
5703473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
5713473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid
5723473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylornotationDecl(void *ctx, const xmlChar *name,
5733473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	     const xmlChar *publicId, const xmlChar *systemId)
5743473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
5753473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
5763473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlNotationPtr nota = NULL;
5773473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
5783473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX
5793473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext,
5803473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    "SAX.notationDecl(%s, %s, %s)\n", name, publicId, systemId);
5813473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
5823473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
5833473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (ctxt->inSubset == 1)
5843473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	nota = xmlAddNotationDecl(&ctxt->vctxt, ctxt->myDoc->intSubset, name,
5853473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor                              publicId, systemId);
5863473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    else if (ctxt->inSubset == 2)
5873473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	nota = xmlAddNotationDecl(&ctxt->vctxt, ctxt->myDoc->intSubset, name,
5883473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor                              publicId, systemId);
5893473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    else {
5903473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
5913473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ctxt->sax->error(ctxt,
5923473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	     "SAX.notationDecl(%s) called while not in subset\n", name);
5933473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	return;
5943473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
5953473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (nota == NULL) ctxt->valid = 0;
5963473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (ctxt->validate && ctxt->wellFormed &&
5973473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        ctxt->myDoc && ctxt->myDoc->intSubset)
5983473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ctxt->valid &= xmlValidateNotationDecl(&ctxt->vctxt, ctxt->myDoc,
5993473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	                                       nota);
6003473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
6013473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
6023473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
6033473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * unparsedEntityDecl:
6043473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
6053473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @name: The name of the entity
6063473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @publicId: The public ID of the entity
6073473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @systemId: The system ID of the entity
6083473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @notationName: the name of the notation
6093473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
6103473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * What to do when an unparsed entity declaration is parsed
6113473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
6123473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid
6133473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorunparsedEntityDecl(void *ctx, const xmlChar *name,
6143473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		   const xmlChar *publicId, const xmlChar *systemId,
6153473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		   const xmlChar *notationName)
6163473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
6173473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
6183473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX
6193473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext,
6203473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    "SAX.unparsedEntityDecl(%s, %s, %s, %s)\n",
6213473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor            name, publicId, systemId, notationName);
6223473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
6233473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (ctxt->validate && ctxt->wellFormed &&
6243473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        ctxt->myDoc && ctxt->myDoc->intSubset)
6253473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ctxt->valid &= xmlValidateNotationUse(&ctxt->vctxt, ctxt->myDoc,
6263473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	                                      notationName);
6273473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlAddDocEntity(ctxt->myDoc, name,
6283473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor                    XML_EXTERNAL_GENERAL_UNPARSED_ENTITY,
6293473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		    publicId, systemId, notationName);
6303473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
6313473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
6323473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
6333473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * setDocumentLocator:
6343473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
6353473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @loc: A SAX Locator
6363473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
6373473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Receive the document locator at startup, actually xmlDefaultSAXLocator
6383473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Everything is available on the context, so this is useless in our case.
6393473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
6403473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid
6413473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorsetDocumentLocator(void *ctx, xmlSAXLocatorPtr loc)
6423473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
6433473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
6443473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX
6453473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext,
6463473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    "SAX.setDocumentLocator()\n");
6473473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
6483473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
6493473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
6503473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
6513473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * startDocument:
6523473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
6533473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
6543473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * called when the document start being processed.
6553473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
6563473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid
6573473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorstartDocument(void *ctx)
6583473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
6593473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
6603473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDocPtr doc;
6613473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
6623473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX
6633473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext,
6643473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    "SAX.startDocument()\n");
6653473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
6663473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (ctxt->html) {
6673473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	if (ctxt->myDoc == NULL)
6683473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef LIBXML_HTML_ENABLED
6693473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ctxt->myDoc = htmlNewDocNoDtD(NULL, NULL);
6703473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#else
6713473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        xmlGenericError(xmlGenericErrorContext,
6723473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		"libxml2 built without HTML support\n");
6733473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
6743473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    } else {
6753473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	doc = ctxt->myDoc = xmlNewDoc(ctxt->version);
6763473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	if (doc != NULL) {
6773473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    if (ctxt->encoding != NULL)
6783473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		doc->encoding = xmlStrdup(ctxt->encoding);
6793473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    else
6803473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		doc->encoding = NULL;
6813473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    doc->standalone = ctxt->standalone;
6823473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	}
6833473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
6843473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if ((ctxt->myDoc != NULL) && (ctxt->myDoc->URL == NULL) &&
6853473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	(ctxt->input != NULL) && (ctxt->input->filename != NULL)) {
6863473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        ctxt->myDoc->URL = xmlStrdup((xmlChar *) ctxt->input->filename);
6873473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
6883473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
6893473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
6903473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
6913473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * endDocument:
6923473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
6933473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
6943473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * called when the document end has been detected.
6953473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
6963473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid
6973473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorendDocument(void *ctx)
6983473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
6993473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
7003473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX
7013473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext,
7023473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    "SAX.endDocument()\n");
7033473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
7043473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (ctxt->validate && ctxt->wellFormed &&
7053473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        ctxt->myDoc && ctxt->myDoc->intSubset)
7063473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ctxt->valid &= xmlValidateDocumentFinal(&ctxt->vctxt, ctxt->myDoc);
7073473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
7083473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    /*
7093473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     * Grab the encoding if it was added on-the-fly
7103473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     */
7113473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if ((ctxt->encoding != NULL) && (ctxt->myDoc != NULL) &&
7123473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	(ctxt->myDoc->encoding == NULL)) {
7133473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ctxt->myDoc->encoding = ctxt->encoding;
7143473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ctxt->encoding = NULL;
7153473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
7163473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if ((ctxt->inputTab[0]->encoding != NULL) && (ctxt->myDoc != NULL) &&
7173473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	(ctxt->myDoc->encoding == NULL)) {
7183473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ctxt->myDoc->encoding = xmlStrdup(ctxt->inputTab[0]->encoding);
7193473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
7203473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if ((ctxt->charset != XML_CHAR_ENCODING_NONE) && (ctxt->myDoc != NULL) &&
7213473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	(ctxt->myDoc->charset == XML_CHAR_ENCODING_NONE)) {
7223473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ctxt->myDoc->charset = ctxt->charset;
7233473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
7243473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
7253473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
7263473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
7273473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * attribute:
7283473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
7293473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @fullname:  The attribute name, including namespace prefix
7303473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @value:  The attribute value
7313473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
7323473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Handle an attribute that has been read by the parser.
7333473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * The default handling is to convert the attribute into an
7343473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * DOM subtree and past it in a new xmlAttr element added to
7353473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * the element.
7363473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
7373473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid
7383473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorattribute(void *ctx, const xmlChar *fullname, const xmlChar *value)
7393473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
7403473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
7413473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlAttrPtr ret;
7423473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlChar *name;
7433473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlChar *ns;
7443473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlChar *nval;
7453473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlNsPtr namespace;
7463473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
7473473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/****************
7483473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX
7493473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext,
7503473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    "SAX.attribute(%s, %s)\n", fullname, value);
7513473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
7523473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor ****************/
7533473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    /*
7543473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     * Split the full name into a namespace prefix and the tag name
7553473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     */
7563473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    name = xmlSplitQName(ctxt, fullname, &ns);
7573473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
7583473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    /*
7593473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     * Do the last stage of the attribute normalization
7603473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     * Needed for HTML too:
7613473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     *   http://www.w3.org/TR/html4/types.html#h-6.2
7623473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     */
7633473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    nval = xmlValidNormalizeAttributeValue(ctxt->myDoc, ctxt->node,
7643473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor					   fullname, value);
7653473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (nval != NULL)
7663473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	value = nval;
7673473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
7683473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    /*
7693473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     * Check whether it's a namespace definition
7703473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     */
7713473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if ((!ctxt->html) && (ns == NULL) &&
7723473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        (name[0] == 'x') && (name[1] == 'm') && (name[2] == 'l') &&
7733473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        (name[3] == 'n') && (name[4] == 's') && (name[5] == 0)) {
7743473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	if (value[0] != 0) {
7753473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    xmlURIPtr uri;
7763473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
7773473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    uri = xmlParseURI((const char *)value);
7783473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    if (uri == NULL) {
7793473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		if ((ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
7803473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		    ctxt->sax->warning(ctxt->userData,
7813473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor			 "nmlns: %s not a valid URI\n", value);
7823473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    } else {
7833473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		if (uri->scheme == NULL) {
7843473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		    if ((ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
7853473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor			ctxt->sax->warning(ctxt->userData,
7863473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor			     "nmlns: URI %s is not absolute\n", value);
7873473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		}
7883473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		xmlFreeURI(uri);
7893473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    }
7903473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	}
7913473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
7923473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	/* a default namespace definition */
7933473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlNewNs(ctxt->node, value, NULL);
7943473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	if (name != NULL)
7953473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    xmlFree(name);
7963473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	if (nval != NULL)
7973473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    xmlFree(nval);
7983473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	return;
7993473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
8003473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if ((!ctxt->html) &&
8013473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	(ns != NULL) && (ns[0] == 'x') && (ns[1] == 'm') && (ns[2] == 'l') &&
8023473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        (ns[3] == 'n') && (ns[4] == 's') && (ns[5] == 0)) {
8033473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	/*
8043473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 * Validate also for namespace decls, they are attributes from
8053473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 * an XML-1.0 perspective
8063473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 TODO ... doesn't map well with current API
8073473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        if (ctxt->validate && ctxt->wellFormed &&
8083473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ctxt->myDoc && ctxt->myDoc->intSubset)
8093473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt, ctxt->myDoc,
8103473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor					       ctxt->node, ret, value);
8113473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 */
8123473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	/* a standard namespace definition */
8133473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlNewNs(ctxt->node, value, name);
8143473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlFree(ns);
8153473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	if (name != NULL)
8163473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    xmlFree(name);
8173473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	if (nval != NULL)
8183473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    xmlFree(nval);
8193473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	return;
8203473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
8213473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
8223473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (ns != NULL)
8233473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	namespace = xmlSearchNs(ctxt->myDoc, ctxt->node, ns);
8243473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    else {
8253473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	namespace = NULL;
8263473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
8273473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
8283473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    /* !!!!!! <a toto:arg="" xmlns:toto="http://toto.com"> */
8293473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    ret = xmlNewNsProp(ctxt->node, namespace, name, NULL);
8303473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
8313473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (ret != NULL) {
8323473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        if ((ctxt->replaceEntities == 0) && (!ctxt->html)) {
8333473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    xmlNodePtr tmp;
8343473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
8353473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ret->children = xmlStringGetNodeList(ctxt->myDoc, value);
8363473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    tmp = ret->children;
8373473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    while (tmp != NULL) {
8383473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		tmp->parent = (xmlNodePtr) ret;
8393473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		if (tmp->next == NULL)
8403473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		    ret->last = tmp;
8413473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		tmp = tmp->next;
8423473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    }
8433473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	} else if (value != NULL) {
8443473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ret->children = xmlNewDocText(ctxt->myDoc, value);
8453473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ret->last = ret->children;
8463473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    if (ret->children != NULL)
8473473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		ret->children->parent = (xmlNodePtr) ret;
8483473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	}
8493473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
8503473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
8513473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if ((!ctxt->html) && ctxt->validate && ctxt->wellFormed &&
8523473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        ctxt->myDoc && ctxt->myDoc->intSubset) {
8533473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
8543473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	/*
8553473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 * If we don't substitute entities, the validation should be
8563473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 * done on a value with replaced entities anyway.
8573473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 */
8583473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        if (!ctxt->replaceEntities) {
8593473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    xmlChar *val;
8603473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
8613473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ctxt->depth++;
8623473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    val = xmlStringDecodeEntities(ctxt, value, XML_SUBSTITUTE_REF,
8633473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		                          0,0,0);
8643473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ctxt->depth--;
8653473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    if (val == NULL)
8663473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
8673473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor				ctxt->myDoc, ctxt->node, ret, value);
8683473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    else {
8693473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
8703473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor			        ctxt->myDoc, ctxt->node, ret, val);
8713473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor                xmlFree(val);
8723473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    }
8733473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	} else {
8743473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt, ctxt->myDoc,
8753473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor					       ctxt->node, ret, value);
8763473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	}
8773473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    } else {
8783473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        /*
8793473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 * when validating, the ID registration is done at the attribute
8803473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 * validation level. Otherwise we have to do specific handling here.
8813473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 */
8823473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	if (xmlIsID(ctxt->myDoc, ctxt->node, ret))
8833473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    xmlAddID(&ctxt->vctxt, ctxt->myDoc, value, ret);
8843473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	else if (xmlIsRef(ctxt->myDoc, ctxt->node, ret))
8853473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    xmlAddRef(&ctxt->vctxt, ctxt->myDoc, value, ret);
8863473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
8873473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
8883473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (nval != NULL)
8893473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlFree(nval);
8903473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (name != NULL)
8913473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlFree(name);
8923473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (ns != NULL)
8933473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlFree(ns);
8943473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
8953473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
8963473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
8973473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * startElement:
8983473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
8993473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @fullname:  The element name, including namespace prefix
9003473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @atts:  An array of name/value attributes pairs, NULL terminated
9013473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
9023473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * called when an opening tag has been processed.
9033473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
9043473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid
9053473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorstartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
9063473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
9073473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
9083473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlNodePtr ret;
9093473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlNodePtr parent = ctxt->node;
9103473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlNsPtr ns;
9113473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlChar *name;
9123473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlChar *prefix;
9133473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    const xmlChar *att;
9143473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    const xmlChar *value;
9153473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    int i;
9163473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
9173473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX
9183473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext,
9193473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    "SAX.startElement(%s)\n", fullname);
9203473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
9213473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
9223473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    /*
9233473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     * First check on validity:
9243473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     */
9253473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (ctxt->validate && (ctxt->myDoc->extSubset == NULL) &&
9263473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        ((ctxt->myDoc->intSubset == NULL) ||
9273473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	 ((ctxt->myDoc->intSubset->notations == NULL) &&
9283473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	  (ctxt->myDoc->intSubset->elements == NULL) &&
9293473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	  (ctxt->myDoc->intSubset->attributes == NULL) &&
9303473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	  (ctxt->myDoc->intSubset->entities == NULL)))) {
9313473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	if (ctxt->vctxt.error != NULL) {
9323473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor            ctxt->vctxt.error(ctxt->vctxt.userData,
9333473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	      "Validation failed: no DTD found !\n");
9343473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	}
9353473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ctxt->validate = 0;
9363473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
9373473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
9383473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
9393473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    /*
9403473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     * Split the full name into a namespace prefix and the tag name
9413473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     */
9423473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    name = xmlSplitQName(ctxt, fullname, &prefix);
9433473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
9443473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
9453473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    /*
9463473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     * Note : the namespace resolution is deferred until the end of the
9473473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     *        attributes parsing, since local namespace can be defined as
9483473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     *        an attribute at this level.
9493473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     */
9503473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    ret = xmlNewDocNode(ctxt->myDoc, NULL, name, NULL);
9513473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (ret == NULL) return;
9523473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (ctxt->myDoc->children == NULL) {
9533473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX_TREE
9543473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlGenericError(xmlGenericErrorContext, "Setting %s as root\n", name);
9553473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
9563473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
9573473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    } else if (parent == NULL) {
9583473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        parent = ctxt->myDoc->children;
9593473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
9603473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    ctxt->nodemem = -1;
9613473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
9623473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    /*
9633473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     * We are parsing a new node.
9643473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     */
9653473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX_TREE
9663473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext, "pushing(%s)\n", name);
9673473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
9683473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    nodePush(ctxt, ret);
9693473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
9703473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    /*
9713473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     * Link the child element
9723473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     */
9733473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (parent != NULL) {
9743473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        if (parent->type == XML_ELEMENT_NODE) {
9753473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX_TREE
9763473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    xmlGenericError(xmlGenericErrorContext,
9773473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		    "adding child %s to %s\n", name, parent->name);
9783473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
9793473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    xmlAddChild(parent, ret);
9803473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	} else {
9813473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX_TREE
9823473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    xmlGenericError(xmlGenericErrorContext,
9833473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		    "adding sibling %s to ", name);
9843473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    xmlDebugDumpOneNode(stderr, parent, 0);
9853473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
9863473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    xmlAddSibling(parent, ret);
9873473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	}
9883473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
9893473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
9903473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    /*
9913473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     * process all the attributes whose name start with "xml"
9923473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     */
9933473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (atts != NULL) {
9943473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        i = 0;
9953473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	att = atts[i++];
9963473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	value = atts[i++];
9973473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	if (!ctxt->html) {
9983473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    while ((att != NULL) && (value != NULL)) {
9993473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		if ((att[0] == 'x') && (att[1] == 'm') && (att[2] == 'l'))
10003473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		    attribute(ctxt, att, value);
10013473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
10023473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		att = atts[i++];
10033473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		value = atts[i++];
10043473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    }
10053473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	}
10063473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
10073473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
10083473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    /*
10093473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     * Search the namespace, note that since the attributes have been
10103473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     * processed, the local namespaces are available.
10113473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     */
10123473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    ns = xmlSearchNs(ctxt->myDoc, ret, prefix);
10133473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if ((ns == NULL) && (parent != NULL))
10143473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ns = xmlSearchNs(ctxt->myDoc, parent, prefix);
10153473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if ((prefix != NULL) && (ns == NULL)) {
10163473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ns = xmlNewNs(ret, NULL, prefix);
10173473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	if ((ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
10183473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ctxt->sax->warning(ctxt->userData,
10193473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		 "Namespace prefix %s is not defined\n", prefix);
10203473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
10213473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlSetNs(ret, ns);
10223473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
10233473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    /*
10243473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     * process all the other attributes
10253473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     */
10263473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (atts != NULL) {
10273473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        i = 0;
10283473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	att = atts[i++];
10293473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	value = atts[i++];
10303473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	if (ctxt->html) {
10313473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    while (att != NULL) {
10323473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		attribute(ctxt, att, value);
10333473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		att = atts[i++];
10343473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		value = atts[i++];
10353473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    }
10363473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	} else {
10373473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    while ((att != NULL) && (value != NULL)) {
10383473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		if ((att[0] != 'x') || (att[1] != 'm') || (att[2] != 'l'))
10393473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		    attribute(ctxt, att, value);
10403473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
10413473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		/*
10423473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		 * Next ones
10433473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		 */
10443473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		att = atts[i++];
10453473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		value = atts[i++];
10463473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    }
10473473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	}
10483473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
10493473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
10503473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    /*
10513473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     * If it's the Document root, finish the Dtd validation and
10523473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     * check the document root element for validity
10533473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     */
10543473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if ((ctxt->validate) && (ctxt->vctxt.finishDtd == 0)) {
10553473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ctxt->valid &= xmlValidateDtdFinal(&ctxt->vctxt, ctxt->myDoc);
10563473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ctxt->valid &= xmlValidateRoot(&ctxt->vctxt, ctxt->myDoc);
10573473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ctxt->vctxt.finishDtd = 1;
10583473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
10593473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
10603473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (prefix != NULL)
10613473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlFree(prefix);
10623473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (name != NULL)
10633473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlFree(name);
10643473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
10653473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
10663473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
10673473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
10683473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * endElement:
10693473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
10703473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @name:  The element name
10713473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
10723473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * called when the end of an element has been detected.
10733473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
10743473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid
10753473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorendElement(void *ctx, const xmlChar *name)
10763473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
10773473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
10783473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserNodeInfo node_info;
10793473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlNodePtr cur = ctxt->node;
10803473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
10813473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX
10823473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (name == NULL)
10833473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        xmlGenericError(xmlGenericErrorContext, "SAX.endElement(NULL)\n");
10843473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    else
10853473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlGenericError(xmlGenericErrorContext, "SAX.endElement(%s)\n", name);
10863473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
10873473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
10883473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    /* Capture end position and add node */
10893473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (cur != NULL && ctxt->record_info) {
10903473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor      node_info.end_pos = ctxt->input->cur - ctxt->input->base;
10913473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor      node_info.end_line = ctxt->input->line;
10923473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor      node_info.node = cur;
10933473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor      xmlParserAddNodeInfo(ctxt, &node_info);
10943473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
10953473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    ctxt->nodemem = -1;
10963473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
10973473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (ctxt->validate && ctxt->wellFormed &&
10983473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        ctxt->myDoc && ctxt->myDoc->intSubset)
10993473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        ctxt->valid &= xmlValidateOneElement(&ctxt->vctxt, ctxt->myDoc,
11003473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor					     cur);
11013473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
11023473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
11033473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    /*
11043473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     * end of parsing of this node.
11053473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     */
11063473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX_TREE
11073473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext, "popping(%s)\n", cur->name);
11083473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
11093473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    nodePop(ctxt);
11103473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
11113473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
11123473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
11133473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * reference:
11143473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
11153473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @name:  The entity name
11163473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
11173473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * called when an entity reference is detected.
11183473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
11193473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid
11203473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorreference(void *ctx, const xmlChar *name)
11213473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
11223473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
11233473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlNodePtr ret;
11243473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
11253473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX
11263473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext,
11273473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    "SAX.reference(%s)\n", name);
11283473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
11293473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (name[0] == '#')
11303473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ret = xmlNewCharRef(ctxt->myDoc, name);
11313473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    else
11323473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ret = xmlNewReference(ctxt->myDoc, name);
11333473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX_TREE
11343473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext,
11353473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    "add reference %s to %s \n", name, ctxt->node->name);
11363473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
11373473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlAddChild(ctxt->node, ret);
11383473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
11393473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
11403473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
11413473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * characters:
11423473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
11433473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ch:  a xmlChar string
11443473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @len: the number of xmlChar
11453473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
11463473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * receiving some chars from the parser.
11473473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Question: how much at a time ???
11483473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
11493473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid
11503473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorcharacters(void *ctx, const xmlChar *ch, int len)
11513473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
11523473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
11533473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlNodePtr lastChild;
11543473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
11553473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX
11563473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext,
11573473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    "SAX.characters(%.30s, %d)\n", ch, len);
11583473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
11593473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    /*
11603473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     * Handle the data if any. If there is no child
11613473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     * add it as content, otherwise if the last child is text,
11623473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     * concatenate it, else create a new node of type text.
11633473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     */
11643473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
11653473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (ctxt->node == NULL) {
11663473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX_TREE
11673473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlGenericError(xmlGenericErrorContext,
11683473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		"add chars: ctxt->node == NULL !\n");
11693473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
11703473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        return;
11713473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
11723473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    lastChild = xmlGetLastChild(ctxt->node);
11733473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX_TREE
11743473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext,
11753473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    "add chars to %s \n", ctxt->node->name);
11763473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
11773473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
11783473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    /*
11793473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     * Here we needed an accelerator mechanism in case of very large
11803473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     * elements. Use an attribute in the structure !!!
11813473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     */
11823473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (lastChild == NULL) {
11833473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	/* first node, first time */
11843473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlNodeAddContentLen(ctxt->node, ch, len);
11853473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifndef XML_USE_BUFFER_CONTENT
11863473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	if (ctxt->node->children != NULL) {
11873473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ctxt->nodelen = len;
11883473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ctxt->nodemem = len + 1;
11893473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	}
11903473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
11913473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    } else {
11923473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	if ((xmlNodeIsText(lastChild)) && (ctxt->nodemem != 0)) {
11933473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifndef XML_USE_BUFFER_CONTENT
11943473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    /*
11953473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	     * The whole point of maintaining nodelen and nodemem,
11963473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	     * xmlTextConcat is too costly, i.e. compute lenght,
11973473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	     * reallocate a new buffer, move data, append ch. Here
11983473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	     * We try to minimaze realloc() uses and avoid copying
11993473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	     * and recomputing lenght over and over.
12003473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	     */
12013473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    if (ctxt->nodelen + len >= ctxt->nodemem) {
12023473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		xmlChar *newbuf;
12033473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		int size;
12043473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
12053473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		size = ctxt->nodemem + len;
12063473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		size *= 2;
12073473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor                newbuf = (xmlChar *) xmlRealloc(lastChild->content,size);
12083473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		if (newbuf == NULL) {
12093473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		    if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
12103473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor			ctxt->sax->error(ctxt->userData,
12113473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor			     "SAX.characters(): out of memory\n");
12123473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		    return;
12133473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		}
12143473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		ctxt->nodemem = size;
12153473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		lastChild->content = newbuf;
12163473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    }
12173473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    memcpy(&lastChild->content[ctxt->nodelen], ch, len);
12183473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ctxt->nodelen += len;
12193473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    lastChild->content[ctxt->nodelen] = 0;
12203473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#else
12213473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    xmlTextConcat(lastChild, ch, len);
12223473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
12233473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	} else {
12243473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    /* Mixed content, first time */
12253473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    lastChild = xmlNewTextLen(ch, len);
12263473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    xmlAddChild(ctxt->node, lastChild);
12273473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifndef XML_USE_BUFFER_CONTENT
12283473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    if (ctxt->node->children != NULL) {
12293473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		ctxt->nodelen = len;
12303473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		ctxt->nodemem = len + 1;
12313473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    }
12323473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
12333473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	}
12343473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
12353473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
12363473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
12373473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
12383473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * ignorableWhitespace:
12393473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
12403473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ch:  a xmlChar string
12413473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @len: the number of xmlChar
12423473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
12433473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * receiving some ignorable whitespaces from the parser.
12443473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Question: how much at a time ???
12453473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
12463473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid
12473473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorignorableWhitespace(void *ctx, const xmlChar *ch, int len)
12483473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
12493473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    /* xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx; */
12503473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX
12513473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext,
12523473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    "SAX.ignorableWhitespace(%.30s, %d)\n", ch, len);
12533473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
12543473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
12553473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
12563473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
12573473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * processingInstruction:
12583473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
12593473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @target:  the target name
12603473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @data: the PI data's
12613473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
12623473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * A processing instruction has been parsed.
12633473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
12643473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid
12653473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorprocessingInstruction(void *ctx, const xmlChar *target,
12663473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor                      const xmlChar *data)
12673473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
12683473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
12693473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlNodePtr ret;
12703473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlNodePtr parent = ctxt->node;
12713473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
12723473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX
12733473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext,
12743473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    "SAX.processingInstruction(%s, %s)\n", target, data);
12753473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
12763473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
12773473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    ret = xmlNewPI(target, data);
12783473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (ret == NULL) return;
12793473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    parent = ctxt->node;
12803473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
12813473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (ctxt->inSubset == 1) {
12823473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlAddChild((xmlNodePtr) ctxt->myDoc->intSubset, ret);
12833473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	return;
12843473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    } else if (ctxt->inSubset == 2) {
12853473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlAddChild((xmlNodePtr) ctxt->myDoc->extSubset, ret);
12863473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	return;
12873473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
12883473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if ((ctxt->myDoc->children == NULL) || (parent == NULL)) {
12893473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX_TREE
12903473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    xmlGenericError(xmlGenericErrorContext,
12913473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		    "Setting PI %s as root\n", target);
12923473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
12933473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
12943473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	return;
12953473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
12963473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (parent->type == XML_ELEMENT_NODE) {
12973473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX_TREE
12983473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlGenericError(xmlGenericErrorContext,
12993473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		"adding PI %s child to %s\n", target, parent->name);
13003473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
13013473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlAddChild(parent, ret);
13023473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    } else {
13033473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX_TREE
13043473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlGenericError(xmlGenericErrorContext,
13053473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		"adding PI %s sibling to ", target);
13063473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlDebugDumpOneNode(stderr, parent, 0);
13073473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
13083473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlAddSibling(parent, ret);
13093473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
13103473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
13113473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
13123473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
13133473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * globalNamespace:
13143473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
13153473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @href:  the namespace associated URN
13163473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @prefix: the namespace prefix
13173473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
13183473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * An old global namespace has been parsed.
13193473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
13203473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid
13213473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorglobalNamespace(void *ctx, const xmlChar *href, const xmlChar *prefix)
13223473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
13233473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
13243473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX
13253473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext,
13263473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    "SAX.globalNamespace(%s, %s)\n", href, prefix);
13273473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
13283473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlNewGlobalNs(ctxt->myDoc, href, prefix);
13293473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
13303473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
13313473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
13323473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * setNamespace:
13333473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
13343473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @name:  the namespace prefix
13353473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
13363473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Set the current element namespace.
13373473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
13383473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
13393473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid
13403473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorsetNamespace(void *ctx, const xmlChar *name)
13413473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
13423473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
13433473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlNsPtr ns;
13443473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlNodePtr parent;
13453473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
13463473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX
13473473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext, "SAX.setNamespace(%s)\n", name);
13483473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
13493473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    ns = xmlSearchNs(ctxt->myDoc, ctxt->node, name);
13503473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (ns == NULL) { /* ctxt->node may not have a parent yet ! */
13513473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        if (ctxt->nodeNr >= 2) {
13523473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    parent = ctxt->nodeTab[ctxt->nodeNr - 2];
13533473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    if (parent != NULL)
13543473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		ns = xmlSearchNs(ctxt->myDoc, parent, name);
13553473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	}
13563473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
13573473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlSetNs(ctxt->node, ns);
13583473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
13593473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
13603473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
13613473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * getNamespace:
13623473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
13633473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
13643473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Get the current element namespace.
13653473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
13663473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Returns the xmlNsPtr or NULL if none
13673473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
13683473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
13693473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorxmlNsPtr
13703473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorgetNamespace(void *ctx)
13713473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
13723473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
13733473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlNsPtr ret;
13743473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
13753473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX
13763473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext, "SAX.getNamespace()\n");
13773473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
13783473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    ret = ctxt->node->ns;
13793473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    return(ret);
13803473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
13813473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
13823473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
13833473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * checkNamespace:
13843473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
13853473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @namespace: the namespace to check against
13863473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
13873473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Check that the current element namespace is the same as the
13883473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * one read upon parsing.
13893473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
13903473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Returns 1 if true 0 otherwise
13913473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
13923473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
13933473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorint
13943473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorcheckNamespace(void *ctx, xmlChar *namespace)
13953473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
13963473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
13973473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlNodePtr cur = ctxt->node;
13983473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
13993473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX
14003473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext,
14013473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    "SAX.checkNamespace(%s)\n", namespace);
14023473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
14033473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
14043473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    /*
14053473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     * Check that the Name in the ETag is the same as in the STag.
14063473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor     */
14073473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (namespace == NULL) {
14083473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        if ((cur->ns != NULL) && (cur->ns->prefix != NULL)) {
14093473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
14103473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		ctxt->sax->error(ctxt,
14113473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		 "End tags for %s don't hold the namespace %s\n",
14123473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		                 cur->name, cur->ns->prefix);
14133473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ctxt->wellFormed = 0;
14143473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	}
14153473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    } else {
14163473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        if ((cur->ns == NULL) || (cur->ns->prefix == NULL)) {
14173473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
14183473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		ctxt->sax->error(ctxt,
14193473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		 "End tags %s holds a prefix %s not used by the open tag\n",
14203473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		                 cur->name, namespace);
14213473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ctxt->wellFormed = 0;
14223473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	} else if (!xmlStrEqual(namespace, cur->ns->prefix)) {
14233473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
14243473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		ctxt->sax->error(ctxt,
14253473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    "Start and End tags for %s don't use the same namespaces: %s and %s\n",
14263473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	                         cur->name, cur->ns->prefix, namespace);
14273473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    ctxt->wellFormed = 0;
14283473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	} else
14293473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    return(1);
14303473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
14313473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    return(0);
14323473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
14333473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
14343473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
14353473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * namespaceDecl:
14363473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
14373473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @href:  the namespace associated URN
14383473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @prefix: the namespace prefix
14393473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
14403473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * A namespace has been parsed.
14413473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
14423473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid
14433473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylornamespaceDecl(void *ctx, const xmlChar *href, const xmlChar *prefix)
14443473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
14453473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
14463473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX
14473473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (prefix == NULL)
14483473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlGenericError(xmlGenericErrorContext,
14493473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		"SAX.namespaceDecl(%s, NULL)\n", href);
14503473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    else
14513473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlGenericError(xmlGenericErrorContext,
14523473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		"SAX.namespaceDecl(%s, %s)\n", href, prefix);
14533473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
14543473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlNewNs(ctxt->node, href, prefix);
14553473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
14563473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
14573473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
14583473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * comment:
14593473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
14603473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @value:  the comment content
14613473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
14623473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * A comment has been parsed.
14633473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
14643473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid
14653473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorcomment(void *ctx, const xmlChar *value)
14663473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
14673473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
14683473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlNodePtr ret;
14693473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlNodePtr parent = ctxt->node;
14703473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
14713473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX
14723473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext, "SAX.comment(%s)\n", value);
14733473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
14743473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    ret = xmlNewDocComment(ctxt->myDoc, value);
14753473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (ret == NULL) return;
14763473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
14773473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (ctxt->inSubset == 1) {
14783473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlAddChild((xmlNodePtr) ctxt->myDoc->intSubset, ret);
14793473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	return;
14803473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    } else if (ctxt->inSubset == 2) {
14813473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlAddChild((xmlNodePtr) ctxt->myDoc->extSubset, ret);
14823473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	return;
14833473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
14843473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if ((ctxt->myDoc->children == NULL) || (parent == NULL)) {
14853473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX_TREE
14863473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    xmlGenericError(xmlGenericErrorContext,
14873473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		    "Setting comment as root\n");
14883473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
14893473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
14903473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	return;
14913473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
14923473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (parent->type == XML_ELEMENT_NODE) {
14933473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX_TREE
14943473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlGenericError(xmlGenericErrorContext,
14953473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		"adding comment child to %s\n", parent->name);
14963473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
14973473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlAddChild(parent, ret);
14983473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    } else {
14993473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX_TREE
15003473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlGenericError(xmlGenericErrorContext,
15013473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor		"adding comment sibling to ");
15023473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlDebugDumpOneNode(stderr, parent, 0);
15033473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
15043473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlAddSibling(parent, ret);
15053473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
15063473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
15073473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
15083473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
15093473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * cdataBlock:
15103473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @ctx: the user data (XML parser context)
15113473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @value:  The pcdata content
15123473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * @len:  the block length
15133473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
15143473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * called when a pcdata block has been parsed
15153473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
15163473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid
15173473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorcdataBlock(void *ctx, const xmlChar *value, int len)
15183473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
15193473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
15203473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlNodePtr ret, lastChild;
15213473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
15223473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX
15233473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext,
15243473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    "SAX.pcdata(%.10s, %d)\n", value, len);
15253473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
15263473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    lastChild = xmlGetLastChild(ctxt->node);
15273473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#ifdef DEBUG_SAX_TREE
15283473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlGenericError(xmlGenericErrorContext,
15293473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	    "add chars to %s \n", ctxt->node->name);
15303473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor#endif
15313473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if ((lastChild != NULL) &&
15323473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor        (lastChild->type == XML_CDATA_SECTION_NODE)) {
15333473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlTextConcat(lastChild, value, len);
15343473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    } else {
15353473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	ret = xmlNewCDataBlock(ctxt->myDoc, value, len);
15363473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlAddChild(ctxt->node, ret);
15373473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    }
15383473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
15393473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
15403473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/*
15413473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Default handler for XML, builds the DOM tree
15423473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
15433473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorxmlSAXHandler xmlDefaultSAXHandler = {
15443473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    internalSubset,
15453473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    isStandalone,
15463473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    hasInternalSubset,
15473473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    hasExternalSubset,
15483473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    resolveEntity,
15493473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    getEntity,
15503473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    entityDecl,
15513473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    notationDecl,
15523473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    attributeDecl,
15533473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    elementDecl,
15543473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    unparsedEntityDecl,
15553473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    setDocumentLocator,
15563473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    startDocument,
15573473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    endDocument,
15583473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    startElement,
15593473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    endElement,
15603473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    reference,
15613473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    characters,
15623473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    ignorableWhitespace,
15633473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    processingInstruction,
15643473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    comment,
15653473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserWarning,
15663473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserError,
15673473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserError,
15683473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    getParameterEntity,
15693473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    cdataBlock,
15703473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    externalSubset,
15713473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor};
15723473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
15733473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
15743473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * xmlDefaultSAXHandlerInit:
15753473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
15763473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Initialize the default SAX handler
15773473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
15783473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid
15793473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorxmlDefaultSAXHandlerInit(void)
15803473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
15813473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDefaultSAXHandler.internalSubset = internalSubset;
15823473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDefaultSAXHandler.externalSubset = externalSubset;
15833473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDefaultSAXHandler.isStandalone = isStandalone;
15843473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDefaultSAXHandler.hasInternalSubset = hasInternalSubset;
15853473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDefaultSAXHandler.hasExternalSubset = hasExternalSubset;
15863473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDefaultSAXHandler.resolveEntity = resolveEntity;
15873473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDefaultSAXHandler.getEntity = getEntity;
15883473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDefaultSAXHandler.getParameterEntity = getParameterEntity;
15893473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDefaultSAXHandler.entityDecl = entityDecl;
15903473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDefaultSAXHandler.attributeDecl = attributeDecl;
15913473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDefaultSAXHandler.elementDecl = elementDecl;
15923473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDefaultSAXHandler.notationDecl = notationDecl;
15933473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDefaultSAXHandler.unparsedEntityDecl = unparsedEntityDecl;
15943473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDefaultSAXHandler.setDocumentLocator = setDocumentLocator;
15953473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDefaultSAXHandler.startDocument = startDocument;
15963473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDefaultSAXHandler.endDocument = endDocument;
15973473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDefaultSAXHandler.startElement = startElement;
15983473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDefaultSAXHandler.endElement = endElement;
15993473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDefaultSAXHandler.reference = reference;
16003473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDefaultSAXHandler.characters = characters;
16013473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDefaultSAXHandler.cdataBlock = cdataBlock;
16023473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDefaultSAXHandler.ignorableWhitespace = ignorableWhitespace;
16033473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDefaultSAXHandler.processingInstruction = processingInstruction;
16043473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDefaultSAXHandler.comment = comment;
16053473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    if (xmlGetWarningsDefaultValue == 0)
16063473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlDefaultSAXHandler.warning = NULL;
16073473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    else
16083473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor	xmlDefaultSAXHandler.warning = xmlParserWarning;
16093473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDefaultSAXHandler.error = xmlParserError;
16103473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlDefaultSAXHandler.fatalError = xmlParserError;
16113473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
16123473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
16133473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/*
16143473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Default handler for HTML, builds the DOM tree
16153473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
16163473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorxmlSAXHandler htmlDefaultSAXHandler = {
16173473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    internalSubset,
16183473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    NULL,
16193473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    NULL,
16203473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    NULL,
16213473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    NULL,
16223473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    getEntity,
16233473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    NULL,
16243473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    NULL,
16253473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    NULL,
16263473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    NULL,
16273473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    NULL,
16283473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    setDocumentLocator,
16293473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    startDocument,
16303473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    endDocument,
16313473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    startElement,
16323473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    endElement,
16333473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    NULL,
16343473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    characters,
16353473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    ignorableWhitespace,
16363473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    NULL,
16373473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    comment,
16383473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserWarning,
16393473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserError,
16403473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserError,
16413473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    getParameterEntity,
16423473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    cdataBlock,
16433473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    NULL,
16443473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor};
16453473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
16463473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
16473473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * htmlDefaultSAXHandlerInit:
16483473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
16493473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Initialize the default SAX handler
16503473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
16513473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid
16523473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorhtmlDefaultSAXHandlerInit(void)
16533473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
16543473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    htmlDefaultSAXHandler.internalSubset = internalSubset;
16553473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    htmlDefaultSAXHandler.externalSubset = NULL;
16563473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    htmlDefaultSAXHandler.isStandalone = NULL;
16573473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    htmlDefaultSAXHandler.hasInternalSubset = NULL;
16583473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    htmlDefaultSAXHandler.hasExternalSubset = NULL;
16593473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    htmlDefaultSAXHandler.resolveEntity = NULL;
16603473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    htmlDefaultSAXHandler.getEntity = getEntity;
16613473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    htmlDefaultSAXHandler.getParameterEntity = NULL;
16623473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    htmlDefaultSAXHandler.entityDecl = NULL;
16633473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    htmlDefaultSAXHandler.attributeDecl = NULL;
16643473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    htmlDefaultSAXHandler.elementDecl = NULL;
16653473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    htmlDefaultSAXHandler.notationDecl = NULL;
16663473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    htmlDefaultSAXHandler.unparsedEntityDecl = NULL;
16673473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    htmlDefaultSAXHandler.setDocumentLocator = setDocumentLocator;
16683473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    htmlDefaultSAXHandler.startDocument = startDocument;
16693473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    htmlDefaultSAXHandler.endDocument = endDocument;
16703473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    htmlDefaultSAXHandler.startElement = startElement;
16713473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    htmlDefaultSAXHandler.endElement = endElement;
16723473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    htmlDefaultSAXHandler.reference = NULL;
16733473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    htmlDefaultSAXHandler.characters = characters;
16743473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    htmlDefaultSAXHandler.cdataBlock = cdataBlock;
16753473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    htmlDefaultSAXHandler.ignorableWhitespace = ignorableWhitespace;
16763473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    htmlDefaultSAXHandler.processingInstruction = NULL;
16773473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    htmlDefaultSAXHandler.comment = comment;
16783473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    htmlDefaultSAXHandler.warning = xmlParserWarning;
16793473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    htmlDefaultSAXHandler.error = xmlParserError;
16803473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    htmlDefaultSAXHandler.fatalError = xmlParserError;
16813473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
16823473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
16833473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/*
16843473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Default handler for HTML, builds the DOM tree
16853473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
16863473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorxmlSAXHandler sgmlDefaultSAXHandler = {
16873473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    internalSubset,
16883473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    NULL,
16893473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    NULL,
16903473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    NULL,
16913473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    NULL,
16923473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    getEntity,
16933473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    NULL,
16943473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    NULL,
16953473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    NULL,
16963473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    NULL,
16973473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    NULL,
16983473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    setDocumentLocator,
16993473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    startDocument,
17003473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    endDocument,
17013473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    startElement,
17023473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    endElement,
17033473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    NULL,
17043473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    characters,
17053473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    ignorableWhitespace,
17063473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    NULL,
17073473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    comment,
17083473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserWarning,
17093473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserError,
17103473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    xmlParserError,
17113473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    getParameterEntity,
17123473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    NULL,
17133473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    NULL,
17143473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor};
17153473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor
17163473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor/**
17173473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * sgmlDefaultSAXHandlerInit:
17183473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor *
17193473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor * Initialize the default SAX handler
17203473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor */
17213473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylorvoid
17223473f88a7abdf4e585e267288fb77e898c580d2bOwen TaylorsgmlDefaultSAXHandlerInit(void)
17233473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor{
17243473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    sgmlDefaultSAXHandler.internalSubset = internalSubset;
17253473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    sgmlDefaultSAXHandler.externalSubset = NULL;
17263473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    sgmlDefaultSAXHandler.isStandalone = NULL;
17273473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    sgmlDefaultSAXHandler.hasInternalSubset = NULL;
17283473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    sgmlDefaultSAXHandler.hasExternalSubset = NULL;
17293473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    sgmlDefaultSAXHandler.resolveEntity = NULL;
17303473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    sgmlDefaultSAXHandler.getEntity = getEntity;
17313473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    sgmlDefaultSAXHandler.getParameterEntity = NULL;
17323473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    sgmlDefaultSAXHandler.entityDecl = NULL;
17333473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    sgmlDefaultSAXHandler.attributeDecl = NULL;
17343473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    sgmlDefaultSAXHandler.elementDecl = NULL;
17353473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    sgmlDefaultSAXHandler.notationDecl = NULL;
17363473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    sgmlDefaultSAXHandler.unparsedEntityDecl = NULL;
17373473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    sgmlDefaultSAXHandler.setDocumentLocator = setDocumentLocator;
17383473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    sgmlDefaultSAXHandler.startDocument = startDocument;
17393473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    sgmlDefaultSAXHandler.endDocument = endDocument;
17403473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    sgmlDefaultSAXHandler.startElement = startElement;
17413473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    sgmlDefaultSAXHandler.endElement = endElement;
17423473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    sgmlDefaultSAXHandler.reference = NULL;
17433473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    sgmlDefaultSAXHandler.characters = characters;
17443473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    sgmlDefaultSAXHandler.cdataBlock = NULL;
17453473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    sgmlDefaultSAXHandler.ignorableWhitespace = ignorableWhitespace;
17463473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    sgmlDefaultSAXHandler.processingInstruction = NULL;
17473473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    sgmlDefaultSAXHandler.comment = comment;
17483473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    sgmlDefaultSAXHandler.warning = xmlParserWarning;
17493473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    sgmlDefaultSAXHandler.error = xmlParserError;
17503473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor    sgmlDefaultSAXHandler.fatalError = xmlParserError;
17513473f88a7abdf4e585e267288fb77e898c580d2bOwen Taylor}
1752