38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * valid.c : part of the code use to do the DTD handling and the validity
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * See Copyright for the status of this software.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * daniel@veillard.com
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncstatic xmlElementPtr xmlGetDtdElementDesc2(xmlDtdPtr dtd, const xmlChar *name,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync/* #define DEBUG_VALID_ALGO */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync/* #define DEBUG_REGEXP_ALGO */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Unimplemented block at %s:%d\n", \
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync/************************************************************************
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Error handling routines *
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ************************************************************************/
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlVErrMemory:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: an XML validation parser context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @extra: extra informations
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Handle an out of memory error
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlVErrMemory(xmlValidCtxtPtr ctxt, const char *extra)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Use the special values to detect if it is part of a parsing
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync long delta = (char *) ctxt - (char *) ctxt->userData;
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Memory allocation failed\n");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlErrValid:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: an XML validation parser context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @error: the error number
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @extra: extra informations
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Handle a validation error
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlErrValid(xmlValidCtxtPtr ctxt, xmlParserErrors error,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Use the special values to detect if it is part of a parsing
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync long delta = (char *) ctxt - (char *) ctxt->userData;
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlErrValidNode:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: an XML validation parser context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @node: the node raising the error
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @error: the error number
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @str1: extra informations
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @str2: extra informations
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @str3: extra informations
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Handle a validation error, provide contextual informations
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Use the special values to detect if it is part of a parsing
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync long delta = (char *) ctxt - (char *) ctxt->userData;
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync __xmlRaiseError(schannel, channel, data, pctxt, node, XML_FROM_VALID, error,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync (const char *) str1,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync (const char *) str1,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#endif /* LIBXML_VALID_ENABLED or LIBXML_SCHEMAS_ENABLED */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlErrValidNodeNr:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: an XML validation parser context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @node: the node raising the error
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @error: the error number
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @str1: extra informations
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @int2: extra informations
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @str3: extra informations
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Handle a validation error, provide contextual informations
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Use the special values to detect if it is part of a parsing
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync long delta = (char *) ctxt - (char *) ctxt->userData;
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync __xmlRaiseError(schannel, channel, data, pctxt, node, XML_FROM_VALID, error,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync (const char *) str1,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync (const char *) str3,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlErrValidWarning:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: an XML validation parser context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @node: the node raising the error
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @error: the error number
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @str1: extra information
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @str2: extra information
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @str3: extra information
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Handle a validation error, provide contextual information
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Use the special values to detect if it is part of a parsing
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync long delta = (char *) ctxt - (char *) ctxt->userData;
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync __xmlRaiseError(schannel, channel, data, pctxt, node, XML_FROM_VALID, error,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync (const char *) str1,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync (const char *) str1,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * If regexp are enabled we can do continuous validation without the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * need of a tree to validate the content model. this is done in each
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * callbacks.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Each xmlValidState represent the validation state associated to the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * set of nodes currently open from the document root to the current element.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlElementPtr elemDecl; /* pointer to the content model */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncvstateVPush(xmlValidCtxtPtr ctxt, xmlElementPtr elemDecl, xmlNodePtr node) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((ctxt->vstateMax == 0) || (ctxt->vstateTab == NULL)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ctxt->vstateTab = (xmlValidState *) xmlMalloc(ctxt->vstateMax *
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync tmp = (xmlValidState *) xmlRealloc(ctxt->vstateTab,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ctxt->vstateTab[ctxt->vstateNr].elemDecl = elemDecl;
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((elemDecl != NULL) && (elemDecl->etype == XML_ELEMENT_TYPE_ELEMENT)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlRegNewExecCtxt(elemDecl->contModel, NULL, NULL);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Failed to build content model regexp for %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync elemDecl = ctxt->vstateTab[ctxt->vstateNr].elemDecl;
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((elemDecl != NULL) && (elemDecl->etype == XML_ELEMENT_TYPE_ELEMENT)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlRegFreeExecCtxt(ctxt->vstateTab[ctxt->vstateNr].exec);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ctxt->vstate = &ctxt->vstateTab[ctxt->vstateNr - 1];
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#else /* not LIBXML_REGEXP_ENABLED */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * If regexp are not enabled, it uses a home made algorithm less
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * complex and easier to
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * debug/maintain than a generic NFA -> DFA state based algo. The
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * only restriction is on the deepness of the tree limited by the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * size of the occurs bitfield
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * this is the content of a saved state for rollbacks
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlElementContentPtr cont; /* pointer to the content model subtree */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlNodePtr node; /* pointer to the current node in the list */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync long occurs;/* bitfield for multiple occurrences */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync unsigned char depth; /* current depth in the overall tree */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#define MAX_DEPTH ((sizeof(_xmlValidState.occurs)) * 8)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#define OCCURRENCE (ctxt->vstate->occurs & (1 << DEPTH))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#define PARENT_OCCURRENCE (ctxt->vstate->occurs & ((1 << DEPTH) - 1))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#define SET_OCCURRENCE ctxt->vstate->occurs |= (1 << DEPTH)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#define RESET_OCCURRENCE ctxt->vstate->occurs &= ((1 << DEPTH) - 1)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncvstateVPush(xmlValidCtxtPtr ctxt, xmlElementContentPtr cont,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync unsigned char state) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync tmp = (xmlValidState *) xmlRealloc(ctxt->vstateTab,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Don't push on the stack a state already here
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((i >= 0) && (ctxt->vstateTab[i].cont == cont) &&
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ctxt->vstate->cont = ctxt->vstateTab[ctxt->vstateNr].cont;
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ctxt->vstate->node = ctxt->vstateTab[ctxt->vstateNr].node;
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ctxt->vstate->depth = ctxt->vstateTab[ctxt->vstateNr].depth;
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ctxt->vstate->occurs = ctxt->vstateTab[ctxt->vstateNr].occurs;
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ctxt->vstate->state = ctxt->vstateTab[ctxt->vstateNr].state;
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#endif /* LIBXML_REGEXP_ENABLED */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return (0);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return (0);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlGenericError(xmlGenericErrorContext, "%s ", cur->name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlGenericError(xmlGenericErrorContext, "&%s; ", cur->name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlGenericError(xmlGenericErrorContext, "pi(%s) ", cur->name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlGenericError(xmlGenericErrorContext, "comment ");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlGenericError(xmlGenericErrorContext, "?attr? ");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlGenericError(xmlGenericErrorContext, "?doctype? ");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlGenericError(xmlGenericErrorContext, "?frag? ");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlGenericError(xmlGenericErrorContext, "?nota? ");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlGenericError(xmlGenericErrorContext, "?html? ");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlGenericError(xmlGenericErrorContext, "?docb? ");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlGenericError(xmlGenericErrorContext, "?edecl? ");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlGenericError(xmlGenericErrorContext, "?adecl? ");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlGenericError(xmlGenericErrorContext, "?entdecl? ");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlGenericError(xmlGenericErrorContext, "?nsdecl? ");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlGenericError(xmlGenericErrorContext, "incstart ");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlGenericError(xmlGenericErrorContext, "incend ");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidDebug(xmlNodePtr cur, xmlElementContentPtr cont) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlGenericError(xmlGenericErrorContext, "valid: ");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlGenericError(xmlGenericErrorContext, "against ");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlGenericError(xmlGenericErrorContext, "%s\n", expr);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlGenericError(xmlGenericErrorContext, "pcdata,");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlGenericError(xmlGenericErrorContext, ",%d,%X,%d)",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlGenericError(xmlGenericErrorContext, "state: ");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlGenericError(xmlGenericErrorContext, " stack: %d ",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync for (i = 0, j = ctxt->vstateNr - 1;(i < 3) && (j > 0);i++,j--)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#define DEBUG_VALID_STATE(n,c) xmlValidDebug(n,c);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#define DEBUG_VALID_STATE(n,c) xmlValidStateDebug(ctxt);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlGenericError(xmlGenericErrorContext, "%s\n", m);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync/* TODO: use hash table for accesses to elem and attribute definitions */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlAttributePtr xmlScanAttributeDecl(xmlDtdPtr dtd, const xmlChar *elem);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync/************************************************************************
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Content model validation based on the regexps *
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ************************************************************************/
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidBuildAContentModel:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @content: the content model
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the schema parser context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @name: the element name whose content is being built
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Generate the automata sequence needed for that type
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns 1 if successful or 0 in case of error.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidBuildAContentModel(xmlElementContentPtr content,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, NULL, XML_ERR_INTERNAL_ERROR,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Found NULL content in content model of %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, NULL, XML_ERR_INTERNAL_ERROR,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Found PCDATA in content model of %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync fullname = xmlBuildQName(content->name, content->prefix, fn, 50);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlAutomataNewEpsilon(ctxt->am, oldstate, ctxt->state);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((fullname != fn) && (fullname != content->name))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Simply iterate over the content
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ctxt->state = xmlAutomataNewEpsilon(ctxt->am, oldstate, NULL);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlValidBuildAContentModel(content->c1, ctxt, name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync } while ((content->type == XML_ELEMENT_CONTENT_SEQ) &&
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ctxt->state = xmlAutomataNewEpsilon(ctxt->am, oldend, NULL);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlAutomataNewEpsilon(ctxt->am, oldstate, ctxt->state);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlAutomataNewEpsilon(ctxt->am, oldstate, ctxt->state);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * iterate over the subtypes and remerge the end with an
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * epsilon transition
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlValidBuildAContentModel(content->c1, ctxt, name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlAutomataNewEpsilon(ctxt->am, ctxt->state, oldend);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync } while ((content->type == XML_ELEMENT_CONTENT_OR) &&
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlAutomataNewEpsilon(ctxt->am, ctxt->state, oldend);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ctxt->state = xmlAutomataNewEpsilon(ctxt->am, oldend, NULL);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlAutomataNewEpsilon(ctxt->am, oldstate, ctxt->state);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlAutomataNewEpsilon(ctxt->am, oldstate, ctxt->state);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "ContentModel broken for element %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync (const char *) name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidBuildContentModel:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: a validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @elem: an element declaration node
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * (Re)Build the automata associated to the content model of this
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns 1 in case of success, 0 in case of error
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidBuildContentModel(xmlValidCtxtPtr ctxt, xmlElementPtr elem) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* TODO: should we rebuild in this case ? */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Cannot create automata for element %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlValidBuildAContentModel(elem->content, ctxt, elem->name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (xmlRegexpIsDeterminist(elem->contModel) != 1) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlSnprintfElementContent(expr, 5000, elem->content, 1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Content model of %s is not determinist: %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#endif /* LIBXML_REGEXP_ENABLED */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync/****************************************************************
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Util functions for data allocation/deallocation *
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ****************************************************************/
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlNewValidCtxt:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Allocate a validation context structure.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns NULL if not, otherwise the new validation context structure
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((ret = xmlMalloc(sizeof (xmlValidCtxt))) == NULL) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlFreeValidCtxt:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @cur: the validation context to free
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Free a validation context structure.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#endif /* LIBXML_VALID_ENABLED */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlNewDocElementContent:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: the document
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @name: the subelement name or NULL
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @type: the type of element content decl
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Allocate an element content structure for the document.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns NULL if not, otherwise the new element content structure
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlNewDocElementContent(xmlDocPtr doc, const xmlChar *name,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "xmlNewElementContent : name == NULL !\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "xmlNewElementContent : name != NULL !\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Internal: ELEMENT content corrupted invalid type\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret = (xmlElementContentPtr) xmlMalloc(sizeof(xmlElementContent));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlNewElementContent:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @name: the subelement name or NULL
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @type: the type of element content decl
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Allocate an element content structure.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Deprecated in favor of xmlNewDocElementContent
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns NULL if not, otherwise the new element content structure
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlNewElementContent(const xmlChar *name, xmlElementContentType type) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlCopyDocElementContent:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: the document owning the element declaration
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @cur: An element content pointer.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Build a copy of an element content description.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the new xmlElementContentPtr or NULL in case of error.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlCopyDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret = (xmlElementContentPtr) xmlMalloc(sizeof(xmlElementContent));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret->prefix = xmlDictLookup(dict, cur->prefix, -1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync tmp = (xmlElementContentPtr) xmlMalloc(sizeof(xmlElementContent));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync tmp->prefix = xmlDictLookup(dict, cur->prefix, -1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlCopyElementContent:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @cur: An element content pointer.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Build a copy of an element content description.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Deprecated, use xmlCopyDocElementContent instead
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the new xmlElementContentPtr or NULL in case of error.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlFreeDocElementContent:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: the document owning the element declaration
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @cur: the element content tree to free
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Free an element content structure. The whole subtree is removed.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlFreeDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Internal: ELEMENT content corrupted invalid type\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (cur->c1 != NULL) xmlFreeDocElementContent(doc, cur->c1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((cur->name != NULL) && (!xmlDictOwns(dict, cur->name)))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((cur->prefix != NULL) && (!xmlDictOwns(dict, cur->prefix)))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (cur->name != NULL) xmlFree((xmlChar *) cur->name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (cur->prefix != NULL) xmlFree((xmlChar *) cur->prefix);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlFreeElementContent:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @cur: the element content tree to free
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Free an element content structure. The whole subtree is removed.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Deprecated, use xmlFreeDocElementContent instead
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlDumpElementContent:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @buf: An XML buffer
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @content: An element table
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @glob: 1 if one must print the englobing parenthesis, 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * This will dump the content of the element table as an XML DTD definition
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlDumpElementContent(xmlBufferPtr buf, xmlElementContentPtr content, int glob) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((content->c1->type == XML_ELEMENT_CONTENT_OR) ||
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((content->c2->type == XML_ELEMENT_CONTENT_OR) ||
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((content->c1->type == XML_ELEMENT_CONTENT_OR) ||
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((content->c2->type == XML_ELEMENT_CONTENT_SEQ) ||
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Internal: ELEMENT content corrupted invalid type\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlSprintfElementContent:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @buf: an output buffer
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @content: An element table
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @englob: 1 if one must print the englobing parenthesis, 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Deprecated, unsafe, use xmlSnprintfElementContent
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlSprintfElementContent(char *buf ATTRIBUTE_UNUSED,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#endif /* LIBXML_OUTPUT_ENABLED */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlSnprintfElementContent:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @buf: an output buffer
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @size: the buffer size
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @content: An element table
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @englob: 1 if one must print the englobing parenthesis, 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * This will dump the content of the element content definition
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Intended just for the debug routine
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlSnprintfElementContent(char *buf, int size, xmlElementContentPtr content, int englob) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (size - len < xmlStrlen(content->prefix) + 10) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((content->c1->type == XML_ELEMENT_CONTENT_OR) ||
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlSnprintfElementContent(buf, size, content->c1, 1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlSnprintfElementContent(buf, size, content->c1, 0);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (((content->c2->type == XML_ELEMENT_CONTENT_OR) ||
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync (content->c2->ocur != XML_ELEMENT_CONTENT_ONCE)) &&
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync (content->c2->type != XML_ELEMENT_CONTENT_ELEMENT))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlSnprintfElementContent(buf, size, content->c2, 1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlSnprintfElementContent(buf, size, content->c2, 0);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((content->c1->type == XML_ELEMENT_CONTENT_OR) ||
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlSnprintfElementContent(buf, size, content->c1, 1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlSnprintfElementContent(buf, size, content->c1, 0);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (((content->c2->type == XML_ELEMENT_CONTENT_SEQ) ||
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync (content->c2->ocur != XML_ELEMENT_CONTENT_ONCE)) &&
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync (content->c2->type != XML_ELEMENT_CONTENT_ELEMENT))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlSnprintfElementContent(buf, size, content->c2, 1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlSnprintfElementContent(buf, size, content->c2, 0);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync/****************************************************************
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Registration of DTD declarations *
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ****************************************************************/
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlFreeElement:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @elem: An element
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Deallocate the memory used by an element definition
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlFreeDocElementContent(elem->doc, elem->content);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlAddElementDecl:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @dtd: pointer to the DTD
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @name: the entity name
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @type: the element type
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @content: the element content tree or NULL
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Register a new element declaration
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns NULL if not, otherwise the entity
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "xmlAddElementDecl: content != NULL for EMPTY\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "xmlAddElementDecl: content != NULL for ANY\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "xmlAddElementDecl: content == NULL for MIXED\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "xmlAddElementDecl: content == NULL for ELEMENT\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Internal: ELEMENT decl corrupted invalid type\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * check if name is a QName
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Create the Element table if needed.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "xmlAddElementDecl: Table creation failed!\n");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * lookup old attributes inserted on an undefined element in the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * internal subset.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((dtd->doc != NULL) && (dtd->doc->intSubset != NULL)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret = xmlHashLookup2(dtd->doc->intSubset->elements, name, ns);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((ret != NULL) && (ret->etype == XML_ELEMENT_TYPE_UNDEFINED)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlHashRemoveEntry2(dtd->doc->intSubset->elements, name, ns, NULL);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * The element may already be present if one of its attribute
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * was registered first
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * The element is already defined in this DTD.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, (xmlNodePtr) dtd, XML_DTD_ELEM_REDEFINED,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Redefinition of element %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#endif /* LIBXML_VALID_ENABLED */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret = (xmlElementPtr) xmlMalloc(sizeof(xmlElement));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * fill the structure.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Validity Check:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Insertion must not fail
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * The element is already defined in this DTD.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, (xmlNodePtr) dtd, XML_DTD_ELEM_REDEFINED,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Redefinition of element %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#endif /* LIBXML_VALID_ENABLED */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * For new element, may have attributes from earlier
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * definition in internal subset
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Finish to fill the structure.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Avoid a stupid copy when called by the parser
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * and flag it by setting a special parent value
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * so the parser doesn't unallocate it.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret->content = xmlCopyDocElementContent(dtd->doc, content);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Link it to the DTD
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlFreeElementTable:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @table: An element table
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Deallocate the memory used by an element hash table.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlHashFree(table, (xmlHashDeallocator) xmlFreeElement);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlCopyElement:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @elem: An element
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Build a copy of an element.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the new xmlElementPtr or NULL in case of error.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync cur = (xmlElementPtr) xmlMalloc(sizeof(xmlElement));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync cur->content = xmlCopyElementContent(elem->content);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* TODO : rebuild the attribute list on the copy */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlCopyElementTable:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @table: An element table
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Build a copy of an element table.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the new xmlElementTablePtr or NULL in case of error.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#endif /* LIBXML_TREE_ENABLED */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlDumpElementDecl:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @buf: the XML buffer output
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @elem: An element table
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * This will dump the content of the element declaration as an XML
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * DTD definition
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlDumpElementDecl(xmlBufferPtr buf, xmlElementPtr elem) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Internal: ELEMENT struct corrupted invalid type\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlDumpElementDeclScan:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @elem: An element table
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @buf: the XML buffer output
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * This routine is used by the hash scan function. It just reverses
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * the arguments.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlDumpElementDeclScan(xmlElementPtr elem, xmlBufferPtr buf) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlDumpElementTable:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @buf: the XML buffer output
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @table: An element table
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * This will dump the content of the element table as an XML DTD definition
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlDumpElementTable(xmlBufferPtr buf, xmlElementTablePtr table) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlHashScan(table, (xmlHashScanner) xmlDumpElementDeclScan, buf);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#endif /* LIBXML_OUTPUT_ENABLED */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlCreateEnumeration:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @name: the enumeration name or NULL
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * create and initialize an enumeration attribute node.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the xmlEnumerationPtr just created or NULL in case
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * of error.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret = (xmlEnumerationPtr) xmlMalloc(sizeof(xmlEnumeration));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlFreeEnumeration:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @cur: the tree to free.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * free an enumeration attribute node (recursive).
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (cur->next != NULL) xmlFreeEnumeration(cur->next);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (cur->name != NULL) xmlFree((xmlChar *) cur->name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlCopyEnumeration:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @cur: the tree to copy.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Copy an enumeration attribute node (recursive).
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the xmlEnumerationPtr just created or NULL in case
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * of error.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (cur->next != NULL) ret->next = xmlCopyEnumeration(cur->next);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#endif /* LIBXML_TREE_ENABLED */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlDumpEnumeration:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @buf: the XML buffer output
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @enum: An enumeration
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * This will dump the content of the enumeration
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlDumpEnumeration(xmlBufferPtr buf, xmlEnumerationPtr cur) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#endif /* LIBXML_OUTPUT_ENABLED */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlScanAttributeDeclCallback:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @attr: the attribute decl
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @list: the list to update
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Callback called by xmlScanAttributeDecl when a new attribute
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * has to be entered in the list.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlScanAttributeDeclCallback(xmlAttributePtr attr, xmlAttributePtr *list,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlScanAttributeDecl:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @dtd: pointer to the DTD
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @elem: the element name
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * When inserting a new element scan the DtD for existing attributes
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * for that element and initialize the Attribute chain
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the pointer to the first attribute decl in the chain,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * possibly NULL.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlScanAttributeDecl(xmlDtdPtr dtd, const xmlChar *elem) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* WRONG !!! */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync (xmlHashScanner) xmlScanAttributeDeclCallback, &ret);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlScanIDAttributeDecl:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @elem: the element name
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @err: whether to raise errors here
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Verify that the element don't have too many ID attributes
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * declared.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the number of ID attributes found.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlScanIDAttributeDecl(xmlValidCtxtPtr ctxt, xmlElementPtr elem, int err) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_MULTIPLE_ID,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Element %s has too many ID attributes defined : %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#endif /* LIBXML_VALID_ENABLED */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlFreeAttribute:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @elem: An attribute
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Deallocate the memory used by an attribute definition
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((attr->elem != NULL) && (!xmlDictOwns(dict, attr->elem)))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((attr->name != NULL) && (!xmlDictOwns(dict, attr->name)))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((attr->prefix != NULL) && (!xmlDictOwns(dict, attr->prefix)))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlAddAttributeDecl:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @dtd: pointer to the DTD
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @elem: the element name
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @name: the attribute name
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ns: the attribute namespace prefix
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @type: the attribute type
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @def: the attribute default type
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @defaultValue: the attribute default value
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @tree: if it's an enumeration, the associated list
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Register a new attribute declaration
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Note that @tree becomes the ownership of the DTD
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns NULL if not new, otherwise the attribute decl
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync const xmlChar *defaultValue, xmlEnumerationPtr tree) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Check the type and possibly the default value.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Internal: ATTRIBUTE struct corrupted invalid type\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync (!xmlValidateAttributeValue(type, defaultValue))) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, (xmlNodePtr) dtd, XML_DTD_ATTRIBUTE_DEFAULT,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Attribute %s of %s: invalid default value\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#endif /* LIBXML_VALID_ENABLED */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Check first that an attribute defined in the external subset wasn't
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * already defined in the internal subset
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((dtd->doc != NULL) && (dtd->doc->extSubset == dtd) &&
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret = xmlHashLookup3(dtd->doc->intSubset->attributes, name, ns, elem);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Create the Attribute table if needed.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "xmlAddAttributeDecl: Table creation failed!\n");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret = (xmlAttributePtr) xmlMalloc(sizeof(xmlAttribute));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * fill the structure.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * doc must be set before possible error causes call
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * to xmlFreeAttribute (because it's used to check on
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * dict use)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret->defaultValue = xmlDictLookup(dict, defaultValue, -1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Validity Check:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Search the DTD for previous declarations of the ATTLIST
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (xmlHashAddEntry3(table, ret->name, ret->prefix, ret->elem, ret) < 0) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * The attribute is already defined in this DTD.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidWarning(ctxt, (xmlNodePtr) dtd, XML_DTD_ATTRIBUTE_REDEFINED,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Attribute %s of element %s: already defined\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#endif /* LIBXML_VALID_ENABLED */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Validity Check:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Multiple ID per element
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, (xmlNodePtr) dtd, XML_DTD_MULTIPLE_ID,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Element %s has too may ID attributes defined : %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#endif /* LIBXML_VALID_ENABLED */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Insert namespace default def first they need to be
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * processed first.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Link it to the DTD
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlFreeAttributeTable:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @table: An attribute table
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Deallocate the memory used by an entities hash table.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlHashFree(table, (xmlHashDeallocator) xmlFreeAttribute);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlCopyAttribute:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @attr: An attribute
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Build a copy of an attribute.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the new xmlAttributePtr or NULL in case of error.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync cur = (xmlAttributePtr) xmlMalloc(sizeof(xmlAttribute));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlCopyAttributeTable:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @table: An attribute table
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Build a copy of an attribute table.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the new xmlAttributeTablePtr or NULL in case of error.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#endif /* LIBXML_TREE_ENABLED */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlDumpAttributeDecl:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @buf: the XML buffer output
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @attr: An attribute declaration
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * This will dump the content of the attribute declaration as an XML
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * DTD definition
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlDumpAttributeDecl(xmlBufferPtr buf, xmlAttributePtr attr) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Internal: ATTRIBUTE struct corrupted invalid type\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Internal: ATTRIBUTE struct corrupted invalid def\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlBufferWriteQuotedString(buf, attr->defaultValue);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlDumpAttributeDeclScan:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @attr: An attribute declaration
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @buf: the XML buffer output
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * This is used with the hash scan function - just reverses arguments
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlDumpAttributeDeclScan(xmlAttributePtr attr, xmlBufferPtr buf) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlDumpAttributeTable:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @buf: the XML buffer output
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @table: An attribute table
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * This will dump the content of the attribute table as an XML DTD definition
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlDumpAttributeTable(xmlBufferPtr buf, xmlAttributeTablePtr table) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlHashScan(table, (xmlHashScanner) xmlDumpAttributeDeclScan, buf);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#endif /* LIBXML_OUTPUT_ENABLED */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync/************************************************************************
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * NOTATIONs *
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ************************************************************************/
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlFreeNotation:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @not: A notation
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Deallocate the memory used by an notation definition
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlAddNotationDecl:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @dtd: pointer to the DTD
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @name: the entity name
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @PublicID: the public identifier or NULL
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @SystemID: the system identifier or NULL
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Register a new notation declaration
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns NULL if not, otherwise the entity
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlAddNotationDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync const xmlChar *PublicID, const xmlChar *SystemID) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Create the Notation table if needed.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync dtd->notations = table = xmlHashCreateDict(0, dict);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "xmlAddNotationDecl: Table creation failed!\n");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret = (xmlNotationPtr) xmlMalloc(sizeof(xmlNotation));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * fill the structure.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Validity Check:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Check the DTD for previous declarations of the ATTLIST
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "xmlAddNotationDecl: %s already defined\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync (const char *) name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#endif /* LIBXML_VALID_ENABLED */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlFreeNotationTable:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @table: An notation table
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Deallocate the memory used by an entities hash table.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlHashFree(table, (xmlHashDeallocator) xmlFreeNotation);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlCopyNotation:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @nota: A notation
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Build a copy of a notation.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the new xmlNotationPtr or NULL in case of error.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync cur = (xmlNotationPtr) xmlMalloc(sizeof(xmlNotation));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlCopyNotationTable:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @table: A notation table
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Build a copy of a notation table.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns the new xmlNotationTablePtr or NULL in case of error.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#endif /* LIBXML_TREE_ENABLED */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlDumpNotationDecl:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @buf: the XML buffer output
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @nota: A notation declaration
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * This will dump the content the notation declaration as an XML DTD definition
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlDumpNotationDecl(xmlBufferPtr buf, xmlNotationPtr nota) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlDumpNotationDeclScan:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @nota: A notation declaration
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @buf: the XML buffer output
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * This is called with the hash scan function, and just reverses args
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlDumpNotationDeclScan(xmlNotationPtr nota, xmlBufferPtr buf) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlDumpNotationTable:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @buf: the XML buffer output
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @table: A notation table
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * This will dump the content of the notation table as an XML DTD definition
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlDumpNotationTable(xmlBufferPtr buf, xmlNotationTablePtr table) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlHashScan(table, (xmlHashScanner) xmlDumpNotationDeclScan, buf);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#endif /* LIBXML_OUTPUT_ENABLED */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync/************************************************************************
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ************************************************************************/
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * DICT_FREE:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @str: a string
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Free a string if it is not owned by the "dict" dictionnary in the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * current scope
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync (xmlDictOwns(dict, (const xmlChar *)(str)) == 0))) \
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlFreeID:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @not: A id
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Deallocate the memory used by an id definition
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlAddID:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: pointer to the document
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @value: the value name
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @attr: the attribute holding the ID
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Register a new id declaration
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns NULL if not, otherwise the new xmlIDPtr
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlAddID(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Create the ID table if needed.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync doc->ids = table = xmlHashCreateDict(0, doc->dict);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "xmlAddID: Table creation failed!\n");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * fill the structure.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Operating in streaming mode, attr is gonna disapear
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret->name = xmlDictLookup(doc->dict, attr->name, -1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * The id is already defined in this DTD.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, attr->parent, XML_DTD_ID_REDEFINED,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "ID %s already defined\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#endif /* LIBXML_VALID_ENABLED */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlFreeIDTable:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @table: An id table
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Deallocate the memory used by an ID hash table.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlHashFree(table, (xmlHashDeallocator) xmlFreeID);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: the document
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @elem: the element carrying the attribute
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @attr: the attribute
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Determine whether an attribute is of type ID. In case we have DTD(s)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * then this is done if DTD loading has been requested. In the case
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * of HTML documents parsed with the HTML parser, then ID detection is
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * done systematically.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns 0 or 1 depending on the lookup result
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlIsID(xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((attr == NULL) || (attr->name == NULL)) return(0);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((attr->ns != NULL) && (attr->ns->prefix != NULL) &&
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((doc->intSubset == NULL) && (doc->extSubset == NULL)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ((elem == NULL) || (xmlStrEqual(elem->name, BAD_CAST "a")))))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync fullelemname = (elem->ns != NULL && elem->ns->prefix != NULL) ?
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlBuildQName(elem->name, elem->ns->prefix, felem, 50) :
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync fullattrname = (attr->ns != NULL && attr->ns->prefix != NULL) ?
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlBuildQName(attr->name, attr->ns->prefix, fattr, 50) :
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (fullelemname != NULL && fullattrname != NULL) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync attrDecl = xmlGetDtdAttrDesc(doc->intSubset, fullelemname,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((attrDecl == NULL) && (doc->extSubset != NULL))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync attrDecl = xmlGetDtdAttrDesc(doc->extSubset, fullelemname,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((fullattrname != fattr) && (fullattrname != attr->name))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((fullelemname != felem) && (fullelemname != elem->name))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((attrDecl != NULL) && (attrDecl->atype == XML_ATTRIBUTE_ID))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlRemoveID:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: the document
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @attr: the attribute
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Remove the given attribute from the ID table maintained internally.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns -1 if the lookup failed and 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlHashRemoveEntry(table, ID, (xmlHashDeallocator) xmlFreeID);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlGetID:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: pointer to the document
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ID: the ID value
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Search the attribute declaring the given ID
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns NULL if not found, otherwise the xmlAttrPtr defining the ID
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * We are operating on a stream, return a well known reference
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * since the attribute node doesn't exist anymore
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync/************************************************************************
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ************************************************************************/
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlFreeRef:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @lk: A list link
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Deallocate the memory used by a ref definition
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlFreeRefList:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @list_ref: A list of references.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Deallocate the memory used by a list of references
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlWalkRemoveRef:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @data: Contents of current link
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @user: Value supplied by the user
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns 0 to abort the walk or 1 to continue
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlWalkRemoveRef(const void *data, const void *user)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (attr0 == attr1) { /* Matched: remove and terminate walk */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlDummyCompare
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @data0: Value supplied by the user
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @data1: Value supplied by the user
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Do nothing, return 0. Used to create unordered lists.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return (0);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlAddRef:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: pointer to the document
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @value: the value name
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @attr: the attribute holding the Ref
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Register a new ref declaration
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns NULL if not, otherwise the new xmlRefPtr
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlAddRef(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Create the Ref table if needed.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync doc->refs = table = xmlHashCreateDict(0, doc->dict);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "xmlAddRef: Table creation failed!\n");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * fill the structure.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Operating in streaming mode, attr is gonna disapear
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* To add a reference :-
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * References are maintained as a list of references,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Lookup the entry, if no entry create new nodelist
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Add the owning node to the NodeList
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Return the ref
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (NULL == (ref_list = xmlHashLookup(table, value))) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (NULL == (ref_list = xmlListCreate(xmlFreeRef, xmlDummyCompare))) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "xmlAddRef: Reference list creation failed!\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "xmlAddRef: Reference list insertion failed!\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "xmlAddRef: Reference list insertion failed!\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlFreeRefTable:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @table: An ref table
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Deallocate the memory used by an Ref hash table.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlHashFree(table, (xmlHashDeallocator) xmlFreeRefList);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlIsRef:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: the document
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @elem: the element carrying the attribute
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @attr: the attribute
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Determine whether an attribute is of type Ref. In case we have DTD(s)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * then this is simple, otherwise we use an heuristic: name Ref (upper
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * or lowercase).
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns 0 or 1 depending on the lookup result
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlIsRef(xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((doc->intSubset == NULL) && (doc->extSubset == NULL)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* TODO @@@ */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync attrDecl = xmlGetDtdAttrDesc(doc->intSubset, elem->name, attr->name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((attrDecl == NULL) && (doc->extSubset != NULL))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlRemoveRef:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: the document
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @attr: the attribute
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Remove the given attribute from the Ref table maintained internally.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns -1 if the lookup failed and 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return (-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* At this point, ref_list refers to a list of references which
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * have the same key as the supplied attr. Our list of references
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * is ordered by reference address and we don't have that information
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * here to use when removing. We'll have to walk the list and
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * check for a matching attribute, when we find one stop the walk
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * and remove the entry.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * The list is ordered by reference, so that means we don't have the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * key. Passing the list and the reference to the walker means we
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * will have enough data to be able to remove the entry.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Remove the supplied attr from our list */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /*If the list is empty then remove the list entry in the hash */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlHashUpdateEntry(table, ID, NULL, (xmlHashDeallocator)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlGetRefs:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: pointer to the document
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ID: the ID value
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Find the set of references for the supplied ID.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns NULL if not found, otherwise node set for the ID.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync/************************************************************************
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Routines for validity checking *
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ************************************************************************/
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlGetDtdElementDesc:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @dtd: a pointer to the DtD to search
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @name: the element name
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Search the DTD for the description of this element
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns the xmlElementPtr if found or NULL
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlGetDtdElementDesc(xmlDtdPtr dtd, const xmlChar *name) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlGetDtdElementDesc2:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @dtd: a pointer to the DtD to search
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @name: the element name
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @create: create an empty description if not found
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Search the DTD for the description of this element
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns the xmlElementPtr if found or NULL
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlGetDtdElementDesc2(xmlDtdPtr dtd, const xmlChar *name, int create) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Create the Element table if needed.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlVErrMemory(NULL, "element table allocation failed");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync cur = (xmlElementPtr) xmlMalloc(sizeof(xmlElement));
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * fill the structure.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlGetDtdQElementDesc:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @dtd: a pointer to the DtD to search
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @name: the element name
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @prefix: the element namespace prefix
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Search the DTD for the description of this element
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns the xmlElementPtr if found or NULL
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlGetDtdQElementDesc(xmlDtdPtr dtd, const xmlChar *name,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlGetDtdAttrDesc:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @dtd: a pointer to the DtD to search
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @elem: the element name
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @name: the attribute name
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Search the DTD for the description of this attribute on
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * this element.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns the xmlAttributePtr if found or NULL
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlGetDtdAttrDesc(xmlDtdPtr dtd, const xmlChar *elem, const xmlChar *name) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlGetDtdQAttrDesc:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @dtd: a pointer to the DtD to search
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @elem: the element name
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @name: the attribute name
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @prefix: the attribute namespace prefix
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Search the DTD for the description of this qualified attribute on
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * this element.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns the xmlAttributePtr if found or NULL
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlGetDtdQAttrDesc(xmlDtdPtr dtd, const xmlChar *elem, const xmlChar *name,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlGetDtdNotationDesc:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @dtd: a pointer to the DtD to search
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @name: the notation name
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Search the DTD for the description of this notation
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns the xmlNotationPtr if found or NULL
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlGetDtdNotationDesc(xmlDtdPtr dtd, const xmlChar *name) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidateNotationUse:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: the document
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @notationName: the notation name to check
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Validate that the given name match a notation declaration.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - [ VC: Notation Declared ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns 1 if valid or 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidateNotationUse(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((doc == NULL) || (doc->intSubset == NULL)) return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync notaDecl = xmlGetDtdNotationDesc(doc->intSubset, notationName);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((notaDecl == NULL) && (doc->extSubset != NULL))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync notaDecl = xmlGetDtdNotationDesc(doc->extSubset, notationName);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, (xmlNodePtr) doc, XML_DTD_UNKNOWN_NOTATION,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "NOTATION %s is not declared\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#endif /* LIBXML_VALID_ENABLED or LIBXML_SCHEMAS_ENABLED */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlIsMixedElement:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: the document
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @name: the element name
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Search in the DtDs whether an element accept Mixed content (or ANY)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * basically if it is supposed to accept text childs
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns 0 if no, 1 if yes, and -1 if no element description is available
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlIsMixedElement(xmlDocPtr doc, const xmlChar *name) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((doc == NULL) || (doc->intSubset == NULL)) return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync elemDecl = xmlGetDtdElementDesc(doc->intSubset, name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((elemDecl == NULL) && (doc->extSubset != NULL))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync elemDecl = xmlGetDtdElementDesc(doc->extSubset, name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * return 1 for EMPTY since we want VC error to pop up
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * on <empty> </empty> for example
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidateNameValue:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @value: an Name value
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Validate that the given value match Name production
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns 1 if valid or 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (val != 0) return(0);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidateNamesValue:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @value: an Names value
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Validate that the given value match Names production
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns 1 if valid or 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Should not test IS_BLANK(val) here -- see erratum E20*/
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (val != 0) return(0);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidateNmtokenValue:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @value: an Nmtoken value
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Validate that the given value match Nmtoken production
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * [ VC: Name Token ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns 1 if valid or 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (val != 0) return(0);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidateNmtokensValue:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @value: an Nmtokens value
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Validate that the given value match Nmtokens production
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * [ VC: Name Token ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns 1 if valid or 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Should not test IS_BLANK(val) here -- see erratum E20*/
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (val != 0) return(0);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidateNotationDecl:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: a document instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @nota: a notation definition
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Try to validate a single notation definition
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * basically it does the following checks as described by the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * XML-1.0 recommendation:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - it seems that no validity constraint exists on notation declarations
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * But this function get called anyway ...
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns 1 if valid or 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidateNotationDecl(xmlValidCtxtPtr ctxt ATTRIBUTE_UNUSED, xmlDocPtr doc ATTRIBUTE_UNUSED,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidateAttributeValue:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @type: an attribute type
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @value: an attribute value
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Validate that the given attribute value match the proper production
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * [ VC: ID ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Values of type ID must match the Name production....
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * [ VC: IDREF ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Values of type IDREF must match the Name production, and values
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * of type IDREFS must match Names ...
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * [ VC: Entity Name ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Values of type ENTITY must match the Name production, values
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * of type ENTITIES must match Names ...
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * [ VC: Name Token ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Values of type NMTOKEN must match the Nmtoken production; values
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * of type NMTOKENS must match Nmtokens.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns 1 if valid or 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidateAttributeValue(xmlAttributeType type, const xmlChar *value) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidateAttributeValue2:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: the document
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @name: the attribute name (used for error reporting only)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @type: the attribute type
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @value: the attribute value
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Validate that the given attribute value match a given type.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * This typically cannot be done before having finished parsing
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * the subsets.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * [ VC: IDREF ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Values of type IDREF must match one of the declared IDs
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Values of type IDREFS must match a sequence of the declared IDs
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * each Name must match the value of an ID attribute on some element
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * in the XML document; i.e. IDREF values must match the value of
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * some ID attribute
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * [ VC: Entity Name ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Values of type ENTITY must match one declared entity
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Values of type ENTITIES must match a sequence of declared entities
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * [ VC: Notation Attributes ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * all notation names in the declaration must be declared.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns 1 if valid or 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidateAttributeValue2(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync const xmlChar *name, xmlAttributeType type, const xmlChar *value) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* yeah it's a bit messy... */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "ENTITY attribute %s reference an unknown entity \"%s\"\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync } else if (ent->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "ENTITY attribute %s reference an entity \"%s\" of wrong type\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync while (*cur != 0) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "ENTITIES attribute %s reference an unknown entity \"%s\"\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync } else if (ent->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "ENTITIES attribute %s reference an entity \"%s\" of wrong type\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync nota = xmlGetDtdNotationDesc(doc->intSubset, value);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync nota = xmlGetDtdNotationDesc(doc->extSubset, value);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "NOTATION attribute %s reference an unknown notation \"%s\"\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidCtxtNormalizeAttributeValue:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: the document
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @elem: the parent
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @name: the attribute name
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @value: the attribute value
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context or NULL
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Does the validation related extra step of the normalization of attribute
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * If the declared value is not CDATA, then the XML processor must further
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * process the normalized attribute value by discarding any leading and
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * trailing space (#x20) characters, and by replacing sequences of space
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * (#x20) characters by single space (#x20) character.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Also check VC: Standalone Document Declaration in P32, and update
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * ctxt->valid accordingly
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns a new normalized string if normalization is needed, NULL otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * the caller must free the returned value.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlNodePtr elem, const xmlChar *name, const xmlChar *value) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((elem->ns != NULL) && (elem->ns->prefix != NULL)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync fullname = xmlBuildQName(elem->name, elem->ns->prefix, fn, 50);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync attrDecl = xmlGetDtdAttrDesc(doc->intSubset, fullname, name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((attrDecl == NULL) && (doc->extSubset != NULL)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync attrDecl = xmlGetDtdAttrDesc(doc->extSubset, fullname, name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((attrDecl == NULL) && (doc->intSubset != NULL))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync attrDecl = xmlGetDtdAttrDesc(doc->intSubset, elem->name, name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((attrDecl == NULL) && (doc->extSubset != NULL)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync attrDecl = xmlGetDtdAttrDesc(doc->extSubset, elem->name, name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync while (*src != 0) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((doc->standalone) && (extsubset == 1) && (!xmlStrEqual(value, ret))) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_DTD_NOT_STANDALONE,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync"standalone: %s on %s value had to be normalized based on external subset declaration\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidNormalizeAttributeValue:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: the document
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @elem: the parent
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @name: the attribute name
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @value: the attribute value
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Does the validation related extra step of the normalization of attribute
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * If the declared value is not CDATA, then the XML processor must further
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * process the normalized attribute value by discarding any leading and
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * trailing space (#x20) characters, and by replacing sequences of space
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * (#x20) characters by single space (#x20) character.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns a new normalized string if normalization is needed, NULL otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * the caller must free the returned value.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidNormalizeAttributeValue(xmlDocPtr doc, xmlNodePtr elem,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((elem->ns != NULL) && (elem->ns->prefix != NULL)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync fullname = xmlBuildQName(elem->name, elem->ns->prefix, fn, 50);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync attrDecl = xmlGetDtdAttrDesc(doc->intSubset, fullname, name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((attrDecl == NULL) && (doc->extSubset != NULL))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync attrDecl = xmlGetDtdAttrDesc(doc->extSubset, fullname, name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync attrDecl = xmlGetDtdAttrDesc(doc->intSubset, elem->name, name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((attrDecl == NULL) && (doc->extSubset != NULL))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync attrDecl = xmlGetDtdAttrDesc(doc->extSubset, elem->name, name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync while (*src != 0) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidateAttributeIdCallback(xmlAttributePtr attr, int *count,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidateAttributeDecl:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: a document instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @attr: an attribute definition
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Try to validate a single attribute definition
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * basically it does the following checks as described by the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * XML-1.0 recommendation:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - [ VC: Attribute Default Legal ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - [ VC: Enumeration ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - [ VC: ID Attribute Default ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * The ID/IDREF uniqueness and matching are done separately
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns 1 if valid or 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidateAttributeDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Attribute Default Legal */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Enumeration */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync val = xmlValidateAttributeValue(attr->atype, attr->defaultValue);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (val == 0) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, (xmlNodePtr) attr, XML_DTD_ATTRIBUTE_DEFAULT,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Syntax of default value for attribute %s of %s is not valid\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* ID Attribute Default */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, (xmlNodePtr) attr, XML_DTD_ID_FIXED,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "ID attribute %s of %s is not valid must be #IMPLIED or #REQUIRED\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* One ID per Element Type */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* the trick is that we parse DtD as their own internal subset */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlElementPtr elem = xmlGetDtdElementDesc(doc->intSubset,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * The attribute may be declared in the internal subset and the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * element in the external subset.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync table = (xmlAttributeTablePtr) doc->intSubset->attributes;
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlHashScan3(table, NULL, NULL, attr->elem, (xmlHashScanner)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNodeNr(ctxt, (xmlNodePtr) attr, XML_DTD_ID_SUBSET,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Element %s has %d ID attribute defined in the internal subset : %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync elem = xmlGetDtdElementDesc(doc->extSubset, attr->elem);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNodeNr(ctxt, (xmlNodePtr) attr, XML_DTD_ID_SUBSET,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Element %s has %d ID attribute defined in the external subset : %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, (xmlNodePtr) attr, XML_DTD_ID_SUBSET,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync"Element %s has ID attributes defined in the internal and external subset : %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Validity Constraint: Enumeration */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((attr->defaultValue != NULL) && (attr->tree != NULL)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (xmlStrEqual(tree->name, attr->defaultValue)) break;
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, (xmlNodePtr) attr, XML_DTD_ATTRIBUTE_VALUE,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync"Default value \"%s\" for attribute %s of %s is not among the enumerated set\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidateElementDecl:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: a document instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @elem: an element definition
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Try to validate a single element definition
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * basically it does the following checks as described by the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * XML-1.0 recommendation:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - [ VC: One ID per Element Type ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - [ VC: No Duplicate Types ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - [ VC: Unique Element Type Declaration ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns 1 if valid or 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidateElementDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Build the regexp associated to the content model */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* No Duplicate Types */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (cur->c1->type == XML_ELEMENT_CONTENT_ELEMENT) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_CONTENT_ERROR,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Definition of %s has duplicate references of %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_CONTENT_ERROR,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Definition of %s has duplicate references of %s:%s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (next->c1->type != XML_ELEMENT_CONTENT_ELEMENT) break;
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_CONTENT_ERROR,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Definition of %s has duplicate references to %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_CONTENT_ERROR,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Definition of %s has duplicate references to %s:%s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* VC: Unique Element Type Declaration */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync tst = xmlGetDtdElementDesc(doc->intSubset, elem->name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_ELEM_REDEFINED,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Redefinition of element %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync tst = xmlGetDtdElementDesc(doc->extSubset, elem->name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_ELEM_REDEFINED,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Redefinition of element %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* One ID per Element Type
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * already done when registering the attribute
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (xmlScanIDAttributeDecl(ctxt, elem) > 1) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidateOneAttribute:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: a document instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @elem: an element instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @attr: an attribute instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @value: the attribute value (without entities processing)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Try to validate a single attribute for an element
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * basically it does the following checks as described by the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * XML-1.0 recommendation:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - [ VC: Attribute Value Type ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - [ VC: Fixed Attribute Default ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - [ VC: Entity Name ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - [ VC: Name Token ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - [ VC: ID ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - [ VC: IDREF ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - [ VC: Entity Name ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - [ VC: Notation Attributes ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * The ID/IDREF uniqueness and matching are done separately
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns 1 if valid or 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidateOneAttribute(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlNodePtr elem, xmlAttrPtr attr, const xmlChar *value)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((elem == NULL) || (elem->name == NULL)) return(0);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((attr == NULL) || (attr->name == NULL)) return(0);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((elem->ns != NULL) && (elem->ns->prefix != NULL)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync fullname = xmlBuildQName(elem->name, elem->ns->prefix, fn, 50);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync attrDecl = xmlGetDtdQAttrDesc(doc->intSubset, fullname,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((attrDecl == NULL) && (doc->extSubset != NULL))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync attrDecl = xmlGetDtdQAttrDesc(doc->extSubset, fullname,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync attrDecl = xmlGetDtdAttrDesc(doc->intSubset, fullname, attr->name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((attrDecl == NULL) && (doc->extSubset != NULL))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync attrDecl = xmlGetDtdQAttrDesc(doc->intSubset, elem->name,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((attrDecl == NULL) && (doc->extSubset != NULL))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync attrDecl = xmlGetDtdQAttrDesc(doc->extSubset, elem->name,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((attrDecl == NULL) && (doc->extSubset != NULL))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Validity Constraint: Attribute Value Type */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_DTD_UNKNOWN_ATTRIBUTE,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "No declaration for attribute %s of element %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync val = xmlValidateAttributeValue(attrDecl->atype, value);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (val == 0) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_DTD_ATTRIBUTE_VALUE,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Syntax of value for attribute %s of %s is not valid\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Validity constraint: Fixed Attribute Default */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_DTD_ATTRIBUTE_DEFAULT,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Value for attribute %s of %s is different from default \"%s\"\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Validity Constraint: ID uniqueness */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Validity Constraint: Notation Attributes */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* First check that the given NOTATION was declared */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync nota = xmlGetDtdNotationDesc(doc->intSubset, value);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync nota = xmlGetDtdNotationDesc(doc->extSubset, value);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_DTD_UNKNOWN_NOTATION,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Value \"%s\" for attribute %s of %s is not a declared Notation\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Second, verify that it's among the list */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_DTD_NOTATION_VALUE,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync"Value \"%s\" for attribute %s of %s is not among the enumerated notations\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Validity Constraint: Enumeration */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (attrDecl->atype == XML_ATTRIBUTE_ENUMERATION) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_DTD_ATTRIBUTE_VALUE,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Value \"%s\" for attribute %s of %s is not among the enumerated set\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Fixed Attribute Default */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_DTD_ATTRIBUTE_VALUE,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Value for attribute %s of %s must be \"%s\"\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Extra check for the attribute value */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret &= xmlValidateAttributeValue2(ctxt, doc, attr->name,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidateOneNamespace:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: a document instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @elem: an element instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @prefix: the namespace prefix
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ns: an namespace declaration instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @value: the attribute value (without entities processing)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Try to validate a single namespace declaration for an element
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * basically it does the following checks as described by the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * XML-1.0 recommendation:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - [ VC: Attribute Value Type ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - [ VC: Fixed Attribute Default ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - [ VC: Entity Name ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - [ VC: Name Token ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - [ VC: ID ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - [ VC: IDREF ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - [ VC: Entity Name ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - [ VC: Notation Attributes ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * The ID/IDREF uniqueness and matching are done separately
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns 1 if valid or 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidateOneNamespace(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlNodePtr elem, const xmlChar *prefix, xmlNsPtr ns, const xmlChar *value) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* xmlElementPtr elemDecl; */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((elem == NULL) || (elem->name == NULL)) return(0);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync fullname = xmlBuildQName(elem->name, prefix, fn, 50);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync attrDecl = xmlGetDtdQAttrDesc(doc->intSubset, fullname,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((attrDecl == NULL) && (doc->extSubset != NULL))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync attrDecl = xmlGetDtdQAttrDesc(doc->extSubset, fullname,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync attrDecl = xmlGetDtdAttrDesc(doc->intSubset, fullname,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((attrDecl == NULL) && (doc->extSubset != NULL))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync attrDecl = xmlGetDtdAttrDesc(doc->extSubset, fullname,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync attrDecl = xmlGetDtdQAttrDesc(doc->intSubset, elem->name,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((attrDecl == NULL) && (doc->extSubset != NULL))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync attrDecl = xmlGetDtdQAttrDesc(doc->extSubset, elem->name,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((attrDecl == NULL) && (doc->extSubset != NULL))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Validity Constraint: Attribute Value Type */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_DTD_UNKNOWN_ATTRIBUTE,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "No declaration for attribute xmlns:%s of element %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_DTD_UNKNOWN_ATTRIBUTE,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "No declaration for attribute xmlns of element %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync val = xmlValidateAttributeValue(attrDecl->atype, value);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (val == 0) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_DTD_INVALID_DEFAULT,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Syntax of value for attribute xmlns:%s of %s is not valid\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_DTD_INVALID_DEFAULT,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Syntax of value for attribute xmlns of %s is not valid\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Validity constraint: Fixed Attribute Default */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_DTD_ATTRIBUTE_DEFAULT,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Value for attribute xmlns:%s of %s is different from default \"%s\"\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_DTD_ATTRIBUTE_DEFAULT,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Value for attribute xmlns of %s is different from default \"%s\"\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Validity Constraint: ID uniqueness */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (xmlAddID(ctxt, doc, value, (xmlAttrPtr) ns) == NULL)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (xmlAddRef(ctxt, doc, value, (xmlAttrPtr) ns) == NULL)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Validity Constraint: Notation Attributes */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* First check that the given NOTATION was declared */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync nota = xmlGetDtdNotationDesc(doc->intSubset, value);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync nota = xmlGetDtdNotationDesc(doc->extSubset, value);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_DTD_UNKNOWN_NOTATION,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Value \"%s\" for attribute xmlns:%s of %s is not a declared Notation\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_DTD_UNKNOWN_NOTATION,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Value \"%s\" for attribute xmlns of %s is not a declared Notation\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Second, verify that it's among the list */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_DTD_NOTATION_VALUE,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync"Value \"%s\" for attribute xmlns:%s of %s is not among the enumerated notations\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_DTD_NOTATION_VALUE,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync"Value \"%s\" for attribute xmlns of %s is not among the enumerated notations\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Validity Constraint: Enumeration */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (attrDecl->atype == XML_ATTRIBUTE_ENUMERATION) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_DTD_ATTRIBUTE_VALUE,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync"Value \"%s\" for attribute xmlns:%s of %s is not among the enumerated set\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_DTD_ATTRIBUTE_VALUE,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync"Value \"%s\" for attribute xmlns of %s is not among the enumerated set\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Fixed Attribute Default */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_DTD_ELEM_NAMESPACE,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Value for attribute xmlns:%s of %s must be \"%s\"\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_DTD_ELEM_NAMESPACE,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Value for attribute xmlns of %s must be \"%s\"\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Extra check for the attribute value */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret &= xmlValidateAttributeValue2(ctxt, doc, ns->prefix,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret &= xmlValidateAttributeValue2(ctxt, doc, BAD_CAST "xmlns",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidateSkipIgnorable:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @child: the child list
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Skip ignorable elements w.r.t. the validation process
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns the first element to consider for validation of the content model
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* These things are ignored (skipped) during validation. */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* keep current node */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidateElementType:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Try to validate the content model of an element internal function
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns 1 if valid or 0 ,-1 in case of error, -2 if an entity
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * reference is found and -3 if the validation succeeded but
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * the content model is not determinist.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((NODE != NULL) && (NODE->type == XML_ENTITY_REF_NODE))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-2);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * We arrive here when more states need to be examined
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * We just recovered from a rollback generated by a possible
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * epsilon transition, go directly to the analysis phase
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * we may have to save a backup state here. This is the equivalent
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * of handling epsilon transition in NFAs.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ((CONT->ocur == XML_ELEMENT_CONTENT_PLUS) && (OCCURRENCE)))) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (vstateVPush(ctxt, CONT, NODE, DEPTH, OCCURS, ROLLBACK_PARENT) < 0)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Check first if the content matches
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * go to next element in the content model
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * skipping ignorable elems
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-2);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((NODE->ns == NULL) || (NODE->ns->prefix == NULL)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * go to next element in the content model
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * skipping ignorable elems
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-2);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Small optimization.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (CONT->c1->type == XML_ELEMENT_CONTENT_ELEMENT) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((NODE->ns == NULL) || (NODE->ns->prefix == NULL)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret = xmlStrEqual(NODE->ns->prefix, CONT->c1->prefix);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (ret == 0) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * save the second branch 'or' branch
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (vstateVPush(ctxt, CONT->c2, NODE, (unsigned char)(DEPTH + 1),
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Small optimization.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((CONT->c1->type == XML_ELEMENT_CONTENT_ELEMENT) &&
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((NODE->ns == NULL) || (NODE->ns->prefix == NULL)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret = xmlStrEqual(NODE->ns->prefix, CONT->c1->prefix);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (ret == 0) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * At this point handle going up in the tree
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * First do the analysis depending on the occurrence model at
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * this level.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (ret == 0) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync DEBUG_VALID_MSG("Plus branch succeeded, continuing");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync DEBUG_VALID_MSG("Mult branch succeeded, continuing");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* SET_OCCURRENCE; */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Then act accordingly at the parent level
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (ret == 0) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync DEBUG_VALID_MSG("Failed, remaining input, rollback");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (ret == 0) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlSnprintfElements:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @buf: an output buffer
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @size: the size of the buffer
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @content: An element
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @glob: 1 if one must print the englobing parenthesis, 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * This will dump the list of elements to the buffer
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Intended just for the debug routine
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlSnprintfElements(char *buf, int size, xmlNodePtr node, int glob) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((cur->ns != NULL) && (cur->ns->prefix != NULL)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (size - len < xmlStrlen(cur->ns->prefix) + 10) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidateElementContent:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @child: the child list
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @elemDecl: pointer to the element declaration
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @warn: emit the error message
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @parent: the parent element (for error reporting)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Try to validate the content model of an element
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns 1 if valid or 0 if not and -1 in case of error
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidateElementContent(xmlValidCtxtPtr ctxt, xmlNodePtr child,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlElementPtr elemDecl, int warn, xmlNodePtr parent) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Build the regexp associated to the content model */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (!xmlRegexpIsDeterminist(elemDecl->contModel)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync exec = xmlRegNewExecCtxt(elemDecl->contModel, NULL, NULL);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Push the current node to be able to roll back
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * and process within the entity
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((cur->ns != NULL) && (cur->ns->prefix != NULL)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Switch to next element
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#else /* LIBXML_REGEXP_ENABLED */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Allocate the stack
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * The first entry in the stack is reserved to the current state
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidWarning(ctxt, child, XML_DTD_CONTENT_NOT_DETERMINIST,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Content model for Element %s is ambiguous\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * An entities reference appeared at this level.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Buid a minimal representation of this node content
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * sufficient to run the validation process on it
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync DEBUG_VALID_MSG("Found an entity reference, linearizing");
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Push the current node to be able to roll back
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * and process within the entity
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* no break on purpose */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* no break on purpose */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Allocate a new node and minimally fills in
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * what's required
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * E59 spaces in CDATA does not match the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * nonterminal S
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Switch to next element
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Relaunch the validation
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#endif /* LIBXML_REGEXP_ENABLED */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlSnprintfElementContent(&expr[0], 5000, cont, 1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#endif /* LIBXML_REGEXP_ENABLED */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, parent, XML_DTD_CONTENT_MODEL,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Element %s content does not follow the DTD, expecting %s, got %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, parent, XML_DTD_CONTENT_MODEL,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Element content does not follow the DTD, expecting %s, got %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, parent, XML_DTD_CONTENT_MODEL,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Element %s content does not follow the DTD\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, parent, XML_DTD_CONTENT_MODEL,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Element content does not follow the DTD\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Deallocate the copy if done, and free up the validation stack
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidateCdataElement:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: a document instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @elem: an element instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Check that an element follows #CDATA
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns 1 if valid or 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidateOneCdataElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((ctxt == NULL) || (doc == NULL) || (elem == NULL))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Push the current node to be able to roll back
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * and process within the entity
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Switch to next element
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidateCheckMixed:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @cont: the mixed content model
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @qname: the qualified name as appearing in the serialization
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Check if the given node is part of the content model.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns 1 if yes, 0 if no, -1 in case of error
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((cont->prefix == NULL) && (xmlStrEqual(cont->name, qname)))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync } else if ((cont->type == XML_ELEMENT_CONTENT_OR) &&
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync } else if ((cont->type != XML_ELEMENT_CONTENT_OR) ||
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Internal: MIXED struct corrupted\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync } else if ((cont->type == XML_ELEMENT_CONTENT_OR) &&
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync (xmlStrncmp(cont->c1->prefix, qname, plen) == 0) &&
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync } else if ((cont->type != XML_ELEMENT_CONTENT_OR) ||
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Internal: MIXED struct corrupted\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidGetElemDecl:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: a document instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @elem: an element instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @extsubset: pointer, (out) indicate if the declaration was found
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * in the external subset.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Finds a declaration associated to an element in the document.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns the pointer to the declaration or NULL if not found.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidGetElemDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Fetch the declaration for the qualified name
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((elem->ns != NULL) && (elem->ns->prefix != NULL))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((elemDecl == NULL) && (doc->extSubset != NULL)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Fetch the declaration for the non qualified name
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * This is "non-strict" validation should be done on the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * full QName but in that case being flexible makes sense.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync elemDecl = xmlGetDtdElementDesc(doc->intSubset, elem->name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((elemDecl == NULL) && (doc->extSubset != NULL)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync elemDecl = xmlGetDtdElementDesc(doc->extSubset, elem->name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "No declaration for element %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidatePushElement:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: a document instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @elem: an element instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @qname: the qualified name as appearing in the serialization
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Push a new element start on the validation stack.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns 1 if no validation problem was found or 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidatePushElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync/* printf("PushElem %s\n", qname); */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((ctxt->vstateNr > 0) && (ctxt->vstate != NULL)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Check the new element agaisnt the content model of the new elem.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Element %s was declared EMPTY this one has content\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* I don't think anything is required then */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* simple case of declared as #PCDATA */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Element %s was declared #PCDATA but contains non text nodes\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret = xmlValidateCheckMixed(ctxt, elemDecl->content,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Element %s is not declared in %s list of possible children\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * VC: Standalone Document Declaration
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - element types with element content, if white space
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * occurs directly within any instance of those types.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret = xmlRegExecPushString(state->exec, qname, NULL);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Element %s content does not follow the DTD, Misplaced %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync eDecl = xmlValidGetElemDecl(ctxt, doc, elem, &extsubset);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidatePushCData:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @data: some character data read
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @len: the lenght of the data
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * check the CData parsed for validation in the current stack
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns 1 if no validation problem was found or 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidatePushCData(xmlValidCtxtPtr ctxt, const xmlChar *data, int len) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync/* printf("CDATA %s %d\n", data, len); */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((ctxt->vstateNr > 0) && (ctxt->vstate != NULL)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Check the new element agaisnt the content model of the new elem.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Element %s was declared EMPTY this one has content\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync for (i = 0;i < len;i++) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Element %s content does not follow the DTD, Text not allowed\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * VC: Standalone Document Declaration
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * element types with element content, if white space
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * occurs directly within any instance of those types.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidatePopElement:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: a document instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @elem: an element instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @qname: the qualified name as appearing in the serialization
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Pop the element end from the validation stack.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns 1 if no validation problem was found or 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidatePopElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc ATTRIBUTE_UNUSED,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync/* printf("PopElem %s\n", qname); */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((ctxt->vstateNr > 0) && (ctxt->vstate != NULL)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Check the new element agaisnt the content model of the new elem.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret = xmlRegExecPushString(state->exec, NULL, NULL);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (ret == 0) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Element %s content does not follow the DTD, Expecting more child\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * previous validation errors should not generate
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * a new one here
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#endif /* LIBXML_REGEXP_ENABLED */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidateOneElement:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: a document instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @elem: an element instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Try to validate a single element and it's attributes,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * basically it does the following checks as described by the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * XML-1.0 recommendation:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - [ VC: Element Valid ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - [ VC: Required Attribute ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Then call xmlValidateOneAttribute() for each attribute present.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * The ID/IDREF checkings are done separately
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns 1 if valid or 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidateOneElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_ERR_INTERNAL_ERROR,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Attribute element not expected\n", NULL, NULL ,NULL);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_ERR_INTERNAL_ERROR,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Text element has children !\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_ERR_INTERNAL_ERROR,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Text element has namespace !\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_ERR_INTERNAL_ERROR,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Text element has no content !\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_ERR_INTERNAL_ERROR,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Entity element not expected\n", NULL, NULL ,NULL);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_ERR_INTERNAL_ERROR,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Notation element not expected\n", NULL, NULL ,NULL);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_ERR_INTERNAL_ERROR,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Document element not expected\n", NULL, NULL ,NULL);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_ERR_INTERNAL_ERROR,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_ERR_INTERNAL_ERROR,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Fetch the declaration
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync elemDecl = xmlValidGetElemDecl(ctxt, doc, elem, &extsubset);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * If vstateNr is not zero that means continuous validation is
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * activated, do not try to check the content model at that level.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Check that the element content matches the definition */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "No declaration for element %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Element %s was declared EMPTY this one has content\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* I don't think anything is required then */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* simple case of declared as #PCDATA */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync (elemDecl->content->type == XML_ELEMENT_CONTENT_PCDATA)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Element %s was declared #PCDATA but contains non text nodes\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* Hum, this start to get messy */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((child->ns != NULL) && (child->ns->prefix != NULL)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync fullname = xmlBuildQName(child->name, child->ns->prefix,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync } else if ((cont->type == XML_ELEMENT_CONTENT_OR) &&
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync } else if ((cont->type != XML_ELEMENT_CONTENT_OR) ||
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Internal: MIXED struct corrupted\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync } else if ((cont->type == XML_ELEMENT_CONTENT_OR) &&
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync } else if ((cont->type != XML_ELEMENT_CONTENT_OR) ||
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Internal: MIXED struct corrupted\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Element %s is not declared in %s list of possible children\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * VC: Standalone Document Declaration
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - element types with element content, if white space
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * occurs directly within any instance of those types.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (*content == 0) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync"standalone: %s declared in the external subset contains white spaces nodes\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync tmp = xmlValidateElementContent(ctxt, child, elemDecl, 1, elem);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync } /* not continuous */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync /* [ VC: Required Attribute ] */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync } else if (xmlStrEqual(attr->prefix, BAD_CAST "xmlns")) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * qualified names handling is problematic, having a
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * different prefix should be possible but DTDs don't
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * allow to define the URI instead of the prefix :-(
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * We should allow applications to define namespaces
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * for their application even if the DTD doesn't
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * carry one, otherwise, basically we would always
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_DTD_MISSING_ATTRIBUTE,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Element %s does not carry attribute %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_DTD_MISSING_ATTRIBUTE,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Element %s does not carry attribute %s:%s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync } else if (qualified == 0) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Element %s required attribute %s:%s has no prefix\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidWarning(ctxt, elem, XML_DTD_DIFFERENT_PREFIX,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Element %s required attribute %s:%s has different prefix\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Special tests checking #FIXED namespace declarations
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * have the right value since this is not done as an
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * attribute checking
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Element %s namespace name for default namespace does not match the DTD\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync } else if (xmlStrEqual(attr->prefix, BAD_CAST "xmlns")) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, elem, XML_DTD_ELEM_NAMESPACE,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Element %s namespace name for %s does not match the DTD\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidateRoot:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: a document instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Try to validate a the root element
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * basically it does the following check as described by the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * XML-1.0 recommendation:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - [ VC: Root Element Type ]
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * it doesn't try to recurse or apply other check to the element
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns 1 if valid or 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidateRoot(xmlValidCtxtPtr ctxt, xmlDocPtr doc) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * When doing post validation against a separate DTD, those may
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * no internal subset has been generated
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Check first the document root against the NQName
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (!xmlStrEqual(doc->intSubset->name, root->name)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((root->ns != NULL) && (root->ns->prefix != NULL)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync fullname = xmlBuildQName(root->name, root->ns->prefix, fn, 50);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((xmlStrEqual(doc->intSubset->name, BAD_CAST "HTML")) &&
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "root and DTD name do not match '%s' and '%s'\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidateElement:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: a document instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @elem: an element instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Try to validate the subtree under an element
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns 1 if valid or 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidateElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * XInclude elements were added after parsing in the infoset,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * they don't really mean anything validation wise.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Entities references have to be handled separately
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync value = xmlNodeListGetString(doc, attr->children, 0);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret &= xmlValidateOneAttribute(ctxt, doc, elem, attr, value);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret &= xmlValidateOneNamespace(ctxt, doc, elem, NULL,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidateRef:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ref: A reference to be validated
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: Validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @name: Name of ID we are searching for
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync while (*cur != 0) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "attribute %s line %d references an unknown ID \"%s\"\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, attr->parent, XML_DTD_UNKNOWN_ID,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "IDREF attribute %s references an unknown ID \"%s\"\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync while (*cur != 0) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, attr->parent, XML_DTD_UNKNOWN_ID,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "IDREFS attribute %s references an unknown ID \"%s\"\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlWalkValidateList:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @data: Contents of current link
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @user: Value supplied by the user
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Returns 0 to abort the walk or 1 to continue
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlWalkValidateList(const void *data, const void *user)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlValidateMemoPtr memo = (xmlValidateMemoPtr)user;
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlValidateRef((xmlRefPtr)data, memo->ctxt, memo->name);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidateCheckRefCallback:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ref_list: List of references
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: Validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @name: Name of ID we are searching for
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidateCheckRefCallback(xmlListPtr ref_list, xmlValidCtxtPtr ctxt,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidateDocumentFinal:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: a document instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Does the final step for the document validation once all the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * incremental validation steps have been completed
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * basically it does the following checks described by the XML Rec
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Check all the IDREF/IDREFS attributes definition for validity
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns 1 if valid or 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidateDocumentFinal(xmlValidCtxtPtr ctxt, xmlDocPtr doc) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Check all the NOTATION/NOTATIONS attributes
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Check all the ENTITY/ENTITIES attributes definition for validity
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Check all the IDREF/IDREFS attributes definition for validity
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlHashScan(table, (xmlHashScanner) xmlValidateCheckRefCallback, ctxt);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidateDtd:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: a document instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @dtd: a dtd instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Try to validate the document against the dtd instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Basically it does check all the definitions in the DtD.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Note the the internal subset (if present) is de-coupled
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * (i.e. not used), which could give problems if ID or IDREF
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * is present.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns 1 if valid or 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidateDtd(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlDtdPtr dtd) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (ret == 0) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidateNotationCallback(xmlEntityPtr cur, xmlValidCtxtPtr ctxt,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (cur->etype == XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret = xmlValidateNotationUse(ctxt, cur->doc, notation);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidateAttributeCallback(xmlAttributePtr cur, xmlValidCtxtPtr ctxt,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ret = xmlValidateAttributeValue2(ctxt, ctxt->doc, cur->name,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "xmlValidateAttributeCallback(%s): internal error\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync elem = xmlGetDtdElementDesc(doc->intSubset, cur->elem);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync elem = xmlGetDtdElementDesc(doc->extSubset, cur->elem);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync elem = xmlGetDtdElementDesc((xmlDtdPtr) cur->parent, cur->elem);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "attribute %s: could not find decl for element %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlErrValidNode(ctxt, NULL, XML_DTD_EMPTY_NOTATION,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "NOTATION attribute %s declared for EMPTY element %s\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidateDtdFinal:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: a document instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Does the final step for the dtds validation once all the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * subsets have been parsed
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * basically it does the following checks described by the XML Rec
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - check that ENTITY and ENTITIES type attributes default or
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * possible values matches one of the defined entities.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * - check that NOTATION type attributes default or
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * possible values matches one of the defined notations.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns 1 if valid or 0 if invalid and -1 if not well-formed
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidateDtdFinal(xmlValidCtxtPtr ctxt, xmlDocPtr doc) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((doc->intSubset == NULL) && (doc->extSubset == NULL))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlHashScan(table, (xmlHashScanner) xmlValidateAttributeCallback, ctxt);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlHashScan(entities, (xmlHashScanner) xmlValidateNotationCallback,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlHashScan(table, (xmlHashScanner) xmlValidateAttributeCallback, ctxt);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlHashScan(entities, (xmlHashScanner) xmlValidateNotationCallback,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidateDocument:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctxt: the validation context
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @doc: a document instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Try to validate the document instance
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * basically it does the all the checks described by the XML Rec
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * i.e. validates the internal and external subset (if present)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * and validate the document tree.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns 1 if valid or 0 otherwise
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidateDocument(xmlValidCtxtPtr ctxt, xmlDocPtr doc) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((doc->intSubset == NULL) && (doc->extSubset == NULL)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((doc->intSubset != NULL) && ((doc->intSubset->SystemID != NULL) ||
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync (doc->intSubset->ExternalID != NULL)) && (doc->extSubset == NULL)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Could not build URI for external subset \"%s\"\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync doc->extSubset = xmlParseDTD(doc->intSubset->ExternalID,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Could not load the external subset \"%s\"\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync "Could not load the external subset \"%s\"\n",
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync/************************************************************************
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Routines for dynamic validation editing *
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync ************************************************************************/
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidGetPotentialChildren:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @ctree: an element content tree
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @names: an array to store the list of child names
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @len: a pointer to the number of element in the list
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @max: the size of the array
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Build/extend a list of potential children allowed by the content tree
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns the number of element in the list, or -1 in case of error.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidGetPotentialChildren(xmlElementContent *ctree,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((ctree == NULL) || (names == NULL) || (len == NULL))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync for (i = 0; i < *len;i++)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (xmlStrEqual(BAD_CAST "#PCDATA", names[i])) return(*len);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync for (i = 0; i < *len;i++)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (xmlStrEqual(ctree->name, names[i])) return(*len);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlValidGetPotentialChildren(ctree->c1, names, len, max);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlValidGetPotentialChildren(ctree->c2, names, len, max);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlValidGetPotentialChildren(ctree->c1, names, len, max);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync xmlValidGetPotentialChildren(ctree->c2, names, len, max);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Dummy function to suppress messages while we try out valid elements
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncstatic void XMLCDECL xmlNoValidityErr(void *ctx ATTRIBUTE_UNUSED,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * xmlValidGetValidElements:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @prev: an element to insert after
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @next: an element to insert next
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @names: an array to store the list of child names
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @max: the size of the array
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * This function returns the list of authorized children to insert
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * within an existing tree while respecting the validity constraints
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * forced by the Dtd. The insertion point is defined using @prev and
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * @next in the following ways:
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * to insert before 'node': xmlValidGetValidElements(node->prev, node, ...
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * to insert next 'node': xmlValidGetValidElements(node, node->next, ...
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * to replace 'node': xmlValidGetValidElements(node->prev, node->next, ...
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * to prepend a child to 'node': xmlValidGetValidElements(NULL, node->childs,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * to append a child to 'node': xmlValidGetValidElements(node->last, NULL, ...
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * pointers to the element names are inserted at the beginning of the array
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * and do not need to be freed.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * returns the number of element in the list, or -1 in case of error. If
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * the function returns the value @max the caller is invited to grow the
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * receiving array and retry.
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsyncxmlValidGetValidElements(xmlNode *prev, xmlNode *next, const xmlChar **names,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync return(-1);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync vctxt.error = xmlNoValidityErr; /* this suppresses err/warn output */
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Retrieves the parent element declaration
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync element_desc = xmlGetDtdElementDesc(parent->doc->intSubset,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if ((element_desc == NULL) && (parent->doc->extSubset != NULL))
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync element_desc = xmlGetDtdElementDesc(parent->doc->extSubset,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Do a backup of the current tree structure
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Creates a dummy node and insert it into the tree
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync test_node = xmlNewDocNode (ref_node->doc, NULL, BAD_CAST "<!dummy?>", NULL);
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Insert each potential child node and check if the parent is
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * still valid
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync nb_elements = xmlValidGetPotentialChildren(element_desc->content,
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync for (i = 0;i < nb_elements;i++) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync if (xmlValidateOneElement(&vctxt, parent->doc, parent)) {
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync for (j = 0; j < nb_valid_elements;j++)
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Restore the tree structure
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync * Free up the dummy node
38ae7e4efe803ea78b6499cd05a394db32623e41vboxsync#endif /* LIBXML_VALID_ENABLED */