valid.c revision 38ae7e4efe803ea78b6499cd05a394db32623e41
/*
* valid.c : part of the code use to do the DTD handling and the validity
* checking
*
* See Copyright for the status of this software.
*
* daniel@veillard.com
*/
#define IN_LIBXML
#include "libxml.h"
#include <string.h>
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#include <libxml/xmlmemory.h>
#include <libxml/parserInternals.h>
#include <libxml/xmlerror.h>
int create);
/* #define DEBUG_VALID_ALGO */
/* #define DEBUG_REGEXP_ALGO */
#define TODO \
"Unimplemented block at %s:%d\n", \
/************************************************************************
* *
* Error handling routines *
* *
************************************************************************/
/**
* xmlVErrMemory:
* @ctxt: an XML validation parser context
* @extra: extra informations
*
* Handle an out of memory error
*/
static void
{
/* Use the special values to detect if it is part of a parsing
context */
}
}
if (extra)
"Memory allocation failed : %s\n", extra);
else
"Memory allocation failed\n");
}
/**
* xmlErrValid:
* @ctxt: an XML validation parser context
* @error: the error number
* @extra: extra informations
*
* Handle a validation error
*/
static void
{
/* Use the special values to detect if it is part of a parsing
context */
}
}
if (extra)
else
msg);
}
#if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
/**
* xmlErrValidNode:
* @ctxt: an XML validation parser context
* @node: the node raising the error
* @error: the error number
* @str1: extra informations
* @str2: extra informations
* @str3: extra informations
*
* Handle a validation error, provide contextual informations
*/
static void
{
/* Use the special values to detect if it is part of a parsing
context */
}
}
XML_ERR_ERROR, NULL, 0,
(const char *) str1,
(const char *) str1,
}
#endif /* LIBXML_VALID_ENABLED or LIBXML_SCHEMAS_ENABLED */
#ifdef LIBXML_VALID_ENABLED
/**
* xmlErrValidNodeNr:
* @ctxt: an XML validation parser context
* @node: the node raising the error
* @error: the error number
* @str1: extra informations
* @int2: extra informations
* @str3: extra informations
*
* Handle a validation error, provide contextual informations
*/
static void
{
/* Use the special values to detect if it is part of a parsing
context */
}
}
XML_ERR_ERROR, NULL, 0,
(const char *) str1,
(const char *) str3,
}
/**
* xmlErrValidWarning:
* @ctxt: an XML validation parser context
* @node: the node raising the error
* @error: the error number
* @str1: extra information
* @str2: extra information
* @str3: extra information
*
* Handle a validation error, provide contextual information
*/
static void
{
/* Use the special values to detect if it is part of a parsing
context */
}
}
XML_ERR_WARNING, NULL, 0,
(const char *) str1,
(const char *) str1,
}
#ifdef LIBXML_REGEXP_ENABLED
/*
* If regexp are enabled we can do continuous validation without the
* need of a tree to validate the content model. this is done in each
* callbacks.
* Each xmlValidState represent the validation state associated to the
* set of nodes currently open from the document root to the current element.
*/
typedef struct _xmlValidState {
static int
return(-1);
}
}
return(-1);
}
}
} else {
"Failed to build content model regexp for %s\n",
}
}
}
static int
}
else
}
#else /* not LIBXML_REGEXP_ENABLED */
/*
* If regexp are not enabled, it uses a home made algorithm less
* complex and easier to
* only restriction is on the deepness of the tree limited by the
* size of the occurs bitfield
*
* this is the content of a saved state for rollbacks
*/
#define ROLLBACK_OR 0
#define ROLLBACK_PARENT 1
typedef struct _xmlValidState {
long occurs;/* bitfield for multiple occurrences */
unsigned char depth; /* current depth in the overall tree */
unsigned char state; /* ROLLBACK_XXX */
#define MAX_RECURSE 25000
static int
unsigned char state) {
return(-1);
}
return(-1);
}
}
return(-1);
}
}
/*
* Don't push on the stack a state already here
*/
}
static int
}
#endif /* LIBXML_REGEXP_ENABLED */
static int
{
return (0);
}
}
return (0);
}
}
}
static xmlNodePtr
{
return (NULL);
else
return (ret);
}
#ifdef DEBUG_VALID_ALGO
static void
return;
}
case XML_ELEMENT_NODE:
break;
case XML_TEXT_NODE:
break;
case XML_CDATA_SECTION_NODE:
break;
case XML_ENTITY_REF_NODE:
break;
case XML_PI_NODE:
break;
case XML_COMMENT_NODE:
break;
case XML_ATTRIBUTE_NODE:
break;
case XML_ENTITY_NODE:
break;
case XML_DOCUMENT_NODE:
break;
case XML_DOCUMENT_TYPE_NODE:
break;
case XML_DOCUMENT_FRAG_NODE:
break;
case XML_NOTATION_NODE:
break;
case XML_HTML_DOCUMENT_NODE:
break;
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
break;
#endif
case XML_DTD_NODE:
break;
case XML_ELEMENT_DECL:
break;
case XML_ATTRIBUTE_DECL:
break;
case XML_ENTITY_DECL:
break;
case XML_NAMESPACE_DECL:
break;
case XML_XINCLUDE_START:
break;
case XML_XINCLUDE_END:
break;
}
}
static void
}
}
static void
char expr[5000];
expr[0] = 0;
}
static void
else
break;
break;
case XML_ELEMENT_CONTENT_SEQ:
break;
case XML_ELEMENT_CONTENT_OR:
break;
}
}
static void
int i, j;
}
/*****
#define DEBUG_VALID_STATE(n,c) xmlValidDebug(n,c);
*****/
#define DEBUG_VALID_MSG(m) \
#else
#define DEBUG_VALID_STATE(n,c)
#define DEBUG_VALID_MSG(m)
#endif
/* TODO: use hash table for accesses to elem and attribute definitions */
#define CHECK_DTD \
#ifdef LIBXML_REGEXP_ENABLED
/************************************************************************
* *
* Content model validation based on the regexps *
* *
************************************************************************/
/**
* xmlValidBuildAContentModel:
* @content: the content model
* @ctxt: the schema parser context
* @name: the element name whose content is being built
*
* Generate the automata sequence needed for that type
*
* Returns 1 if successful or 0 in case of error.
*/
static int
"Found NULL content in content model of %s\n",
return(0);
}
"Found PCDATA in content model of %s\n",
return(0);
break;
case XML_ELEMENT_CONTENT_ELEMENT: {
return(0);
}
case XML_ELEMENT_CONTENT_ONCE:
break;
case XML_ELEMENT_CONTENT_OPT:
break;
case XML_ELEMENT_CONTENT_PLUS:
break;
case XML_ELEMENT_CONTENT_MULT:
break;
}
break;
}
case XML_ELEMENT_CONTENT_SEQ: {
/*
* Simply iterate over the content
*/
if (ocur != XML_ELEMENT_CONTENT_ONCE) {
}
do {
switch (ocur) {
case XML_ELEMENT_CONTENT_ONCE:
break;
case XML_ELEMENT_CONTENT_OPT:
break;
case XML_ELEMENT_CONTENT_MULT:
break;
case XML_ELEMENT_CONTENT_PLUS:
break;
}
break;
}
case XML_ELEMENT_CONTENT_OR: {
if ((ocur == XML_ELEMENT_CONTENT_PLUS) ||
(ocur == XML_ELEMENT_CONTENT_MULT)) {
}
/*
* iterate over the subtypes and remerge the end with an
* epsilon transition
*/
do {
switch (ocur) {
case XML_ELEMENT_CONTENT_ONCE:
break;
case XML_ELEMENT_CONTENT_OPT:
break;
case XML_ELEMENT_CONTENT_MULT:
break;
case XML_ELEMENT_CONTENT_PLUS:
break;
}
break;
}
default:
"ContentModel broken for element %s\n",
(const char *) name);
return(0);
}
return(1);
}
/**
* xmlValidBuildContentModel:
* @ctxt: a validation context
* @elem: an element declaration node
*
* (Re)Build the automata associated to the content model of this
* element
*
* Returns 1 in case of success, 0 in case of error
*/
int
return(0);
return(0);
return(1);
/* TODO: should we rebuild in this case ? */
return(0);
}
return(1);
}
"Cannot create automata for element %s\n",
return(0);
}
char expr[5000];
expr[0] = 0;
"Content model of %s is not determinist: %s\n",
#ifdef DEBUG_REGEXP_ALGO
#endif
return(0);
}
return(1);
}
#endif /* LIBXML_REGEXP_ENABLED */
/****************************************************************
* *
* Util functions for data allocation/deallocation *
* *
****************************************************************/
/**
* xmlNewValidCtxt:
*
* Allocate a validation context structure.
*
* Returns NULL if not, otherwise the new validation context structure
*/
xmlValidCtxtPtr xmlNewValidCtxt(void) {
return (NULL);
}
return (ret);
}
/**
* xmlFreeValidCtxt:
* @cur: the validation context to free
*
* Free a validation context structure.
*/
void
}
#endif /* LIBXML_VALID_ENABLED */
/**
* xmlNewDocElementContent:
* @doc: the document
* @name: the subelement name or NULL
* @type: the type of element content decl
*
* Allocate an element content structure for the document.
*
* Returns NULL if not, otherwise the new element content structure
*/
switch(type) {
"xmlNewElementContent : name == NULL !\n",
NULL);
}
break;
case XML_ELEMENT_CONTENT_SEQ:
case XML_ELEMENT_CONTENT_OR:
"xmlNewElementContent : name != NULL !\n",
NULL);
}
break;
default:
"Internal: ELEMENT content corrupted invalid type\n",
NULL);
return(NULL);
}
return(NULL);
}
int l;
else
} else {
} else {
}
}
}
return(ret);
}
/**
* xmlNewElementContent:
* @name: the subelement name or NULL
* @type: the type of element content decl
*
* Allocate an element content structure.
* Deprecated in favor of xmlNewDocElementContent
*
* Returns NULL if not, otherwise the new element content structure
*/
}
/**
* xmlCopyDocElementContent:
* @doc: the document owning the element declaration
* @cur: An element content pointer.
*
* Build a copy of an element content description.
*
* Returns the new xmlElementContentPtr or NULL in case of error.
*/
return(NULL);
}
if (dict)
else
}
if (dict)
else
}
return(ret);
}
if (dict)
else
}
if (dict)
else
}
}
}
return(ret);
}
/**
* xmlCopyElementContent:
* @cur: An element content pointer.
*
* Build a copy of an element content description.
* Deprecated, use xmlCopyDocElementContent instead
*
* Returns the new xmlElementContentPtr or NULL in case of error.
*/
}
/**
* xmlFreeDocElementContent:
* @doc: the document owning the element declaration
* @cur: the element content tree to free
*
* Free an element content structure. The whole subtree is removed.
*/
void
case XML_ELEMENT_CONTENT_SEQ:
case XML_ELEMENT_CONTENT_OR:
break;
default:
"Internal: ELEMENT content corrupted invalid type\n",
NULL);
return;
}
if (dict) {
} else {
}
}
}
/**
* xmlFreeElementContent:
* @cur: the element content tree to free
*
* Free an element content structure. The whole subtree is removed.
* Deprecated, use xmlFreeDocElementContent instead
*/
void
}
#ifdef LIBXML_OUTPUT_ENABLED
/**
* xmlDumpElementContent:
* @buf: An XML buffer
* @content: An element table
* @glob: 1 if one must print the englobing parenthesis, 0 otherwise
*
* This will dump the content of the element table as an XML DTD definition
*/
static void
break;
}
break;
case XML_ELEMENT_CONTENT_SEQ:
else
else
break;
case XML_ELEMENT_CONTENT_OR:
else
else
break;
default:
"Internal: ELEMENT content corrupted invalid type\n",
NULL);
}
if (glob)
case XML_ELEMENT_CONTENT_ONCE:
break;
case XML_ELEMENT_CONTENT_OPT:
break;
case XML_ELEMENT_CONTENT_MULT:
break;
case XML_ELEMENT_CONTENT_PLUS:
break;
}
}
/**
* xmlSprintfElementContent:
* @buf: an output buffer
* @content: An element table
* @englob: 1 if one must print the englobing parenthesis, 0 otherwise
*
* Deprecated, unsafe, use xmlSnprintfElementContent
*/
void
int englob ATTRIBUTE_UNUSED) {
}
#endif /* LIBXML_OUTPUT_ENABLED */
/**
* xmlSnprintfElementContent:
* @buf: an output buffer
* @size: the buffer size
* @content: An element table
* @englob: 1 if one must print the englobing parenthesis, 0 otherwise
*
* This will dump the content of the element content definition
* Intended just for the debug routine
*/
void
int len;
return;
}
break;
return;
}
}
return;
}
break;
case XML_ELEMENT_CONTENT_SEQ:
else
return;
}
else
break;
case XML_ELEMENT_CONTENT_OR:
else
return;
}
else
break;
}
if (englob)
case XML_ELEMENT_CONTENT_ONCE:
break;
case XML_ELEMENT_CONTENT_OPT:
break;
case XML_ELEMENT_CONTENT_MULT:
break;
case XML_ELEMENT_CONTENT_PLUS:
break;
}
}
/****************************************************************
* *
* Registration of DTD declarations *
* *
****************************************************************/
/**
* xmlFreeElement:
* @elem: An element
*
* Deallocate the memory used by an element definition
*/
static void
#ifdef LIBXML_REGEXP_ENABLED
#endif
}
/**
* xmlAddElementDecl:
* @ctxt: the validation context
* @dtd: pointer to the DTD
* @name: the entity name
* @type: the element type
* @content: the element content tree or NULL
*
* Register a new element declaration
*
* Returns NULL if not, otherwise the entity
*/
return(NULL);
}
return(NULL);
}
switch (type) {
case XML_ELEMENT_TYPE_EMPTY:
"xmlAddElementDecl: content != NULL for EMPTY\n",
NULL);
return(NULL);
}
break;
case XML_ELEMENT_TYPE_ANY:
"xmlAddElementDecl: content != NULL for ANY\n",
NULL);
return(NULL);
}
break;
case XML_ELEMENT_TYPE_MIXED:
"xmlAddElementDecl: content == NULL for MIXED\n",
NULL);
return(NULL);
}
break;
case XML_ELEMENT_TYPE_ELEMENT:
"xmlAddElementDecl: content == NULL for ELEMENT\n",
NULL);
return(NULL);
}
break;
default:
"Internal: ELEMENT decl corrupted invalid type\n",
NULL);
return(NULL);
}
/*
* check if name is a QName
*/
/*
* Create the Element table if needed.
*/
}
"xmlAddElementDecl: Table creation failed!\n");
return(NULL);
}
/*
* lookup old attributes inserted on an undefined element in the
* internal subset.
*/
}
}
/*
* The element may already be present if one of its attribute
* was registered first
*/
#ifdef LIBXML_VALID_ENABLED
/*
* The element is already defined in this DTD.
*/
"Redefinition of element %s\n",
#endif /* LIBXML_VALID_ENABLED */
return(NULL);
}
}
} else {
return(NULL);
}
/*
* fill the structure.
*/
return(NULL);
}
/*
* Validity Check:
* Insertion must not fail
*/
#ifdef LIBXML_VALID_ENABLED
/*
* The element is already defined in this DTD.
*/
"Redefinition of element %s\n",
#endif /* LIBXML_VALID_ENABLED */
return(NULL);
}
/*
* For new element, may have attributes from earlier
* definition in internal subset
*/
}
/*
* Finish to fill the structure.
*/
/*
* Avoid a stupid copy when called by the parser
* and flag it by setting a special parent value
* so the parser doesn't unallocate it.
*/
} else {
}
/*
* Link it to the DTD
*/
} else {
}
return(ret);
}
/**
* xmlFreeElementTable:
* @table: An element table
*
* Deallocate the memory used by an element hash table.
*/
void
}
#ifdef LIBXML_TREE_ENABLED
/**
* xmlCopyElement:
* @elem: An element
*
* Build a copy of an element.
*
* Returns the new xmlElementPtr or NULL in case of error.
*/
static xmlElementPtr
return(NULL);
}
else
else
/* TODO : rebuild the attribute list on the copy */
return(cur);
}
/**
* xmlCopyElementTable:
* @table: An element table
*
* Build a copy of an element table.
*
* Returns the new xmlElementTablePtr or NULL in case of error.
*/
}
#endif /* LIBXML_TREE_ENABLED */
#ifdef LIBXML_OUTPUT_ENABLED
/**
* xmlDumpElementDecl:
* @buf: the XML buffer output
* @elem: An element table
*
* This will dump the content of the element declaration as an XML
* DTD definition
*/
void
return;
case XML_ELEMENT_TYPE_EMPTY:
}
break;
case XML_ELEMENT_TYPE_ANY:
}
break;
case XML_ELEMENT_TYPE_MIXED:
}
break;
case XML_ELEMENT_TYPE_ELEMENT:
}
break;
default:
"Internal: ELEMENT struct corrupted invalid type\n",
NULL);
}
}
/**
* xmlDumpElementDeclScan:
* @elem: An element table
* @buf: the XML buffer output
*
* This routine is used by the hash scan function. It just reverses
* the arguments.
*/
static void
}
/**
* xmlDumpElementTable:
* @buf: the XML buffer output
* @table: An element table
*
* This will dump the content of the element table as an XML DTD definition
*/
void
return;
}
#endif /* LIBXML_OUTPUT_ENABLED */
/**
* xmlCreateEnumeration:
* @name: the enumeration name or NULL
*
* create and initialize an enumeration attribute node.
*
* Returns the xmlEnumerationPtr just created or NULL in case
* of error.
*/
return(NULL);
}
return(ret);
}
/**
* xmlFreeEnumeration:
* @cur: the tree to free.
*
* free an enumeration attribute node (recursive).
*/
void
}
#ifdef LIBXML_TREE_ENABLED
/**
* xmlCopyEnumeration:
* @cur: the tree to copy.
*
* Copy an enumeration attribute node (recursive).
*
* Returns the xmlEnumerationPtr just created or NULL in case
* of error.
*/
return(ret);
}
#endif /* LIBXML_TREE_ENABLED */
#ifdef LIBXML_OUTPUT_ENABLED
/**
* xmlDumpEnumeration:
* @buf: the XML buffer output
* @enum: An enumeration
*
* This will dump the content of the enumeration
*/
static void
return;
else {
}
}
#endif /* LIBXML_OUTPUT_ENABLED */
#ifdef LIBXML_VALID_ENABLED
/**
* xmlScanAttributeDeclCallback:
* @attr: the attribute decl
* @list: the list to update
*
* Callback called by xmlScanAttributeDecl when a new attribute
* has to be entered in the list.
*/
static void
}
/**
* xmlScanAttributeDecl:
* @dtd: pointer to the DTD
* @elem: the element name
*
* When inserting a new element scan the DtD for existing attributes
* for that element and initialize the Attribute chain
*
* Returns the pointer to the first attribute decl in the chain,
* possibly NULL.
*/
return(NULL);
}
return(NULL);
}
return(NULL);
/* WRONG !!! */
return(ret);
}
/**
* xmlScanIDAttributeDecl:
* @ctxt: the validation context
* @elem: the element name
* @err: whether to raise errors here
*
* Verify that the element don't have too many ID attributes
* declared.
*
* Returns the number of ID attributes found.
*/
static int
int ret = 0;
ret ++;
"Element %s has too many ID attributes defined : %s\n",
}
}
return(ret);
}
#endif /* LIBXML_VALID_ENABLED */
/**
* xmlFreeAttribute:
* @elem: An attribute
*
* Deallocate the memory used by an attribute definition
*/
static void
else
if (dict) {
} else {
}
}
/**
* xmlAddAttributeDecl:
* @ctxt: the validation context
* @dtd: pointer to the DTD
* @elem: the element name
* @name: the attribute name
* @ns: the attribute namespace prefix
* @type: the attribute type
* @def: the attribute default type
* @defaultValue: the attribute default value
* @tree: if it's an enumeration, the associated list
*
* Register a new attribute declaration
* Note that @tree becomes the ownership of the DTD
*
* Returns NULL if not new, otherwise the attribute decl
*/
return(NULL);
}
return(NULL);
}
return(NULL);
}
#ifdef LIBXML_VALID_ENABLED
/*
* Check the type and possibly the default value.
*/
switch (type) {
case XML_ATTRIBUTE_CDATA:
break;
case XML_ATTRIBUTE_ID:
break;
case XML_ATTRIBUTE_IDREF:
break;
case XML_ATTRIBUTE_IDREFS:
break;
case XML_ATTRIBUTE_ENTITY:
break;
case XML_ATTRIBUTE_ENTITIES:
break;
case XML_ATTRIBUTE_NMTOKEN:
break;
case XML_ATTRIBUTE_NMTOKENS:
break;
break;
case XML_ATTRIBUTE_NOTATION:
break;
default:
"Internal: ATTRIBUTE struct corrupted invalid type\n",
NULL);
return(NULL);
}
if ((defaultValue != NULL) &&
"Attribute %s of %s: invalid default value\n",
defaultValue = NULL;
}
#endif /* LIBXML_VALID_ENABLED */
/*
* Check first that an attribute defined in the external subset wasn't
* already defined in the internal subset
*/
return(NULL);
}
/*
* Create the Attribute table if needed.
*/
}
"xmlAddAttributeDecl: Table creation failed!\n");
return(NULL);
}
return(NULL);
}
/*
* fill the structure.
*/
/*
* doc must be set before possible error causes call
* to xmlFreeAttribute (because it's used to check on
* dict use)
*/
if (dict) {
} else {
}
if (defaultValue != NULL) {
if (dict)
else
}
/*
* Validity Check:
* Search the DTD for previous declarations of the ATTLIST
*/
#ifdef LIBXML_VALID_ENABLED
/*
* The attribute is already defined in this DTD.
*/
"Attribute %s of element %s: already defined\n",
#endif /* LIBXML_VALID_ENABLED */
return(NULL);
}
/*
* Validity Check:
* Multiple ID per element
*/
#ifdef LIBXML_VALID_ENABLED
if ((type == XML_ATTRIBUTE_ID) &&
"Element %s has too may ID attributes defined : %s\n",
}
#endif /* LIBXML_VALID_ENABLED */
/*
* Insert namespace default def first they need to be
* processed first.
*/
} else {
break;
}
} else {
}
}
}
/*
* Link it to the DTD
*/
} else {
}
return(ret);
}
/**
* xmlFreeAttributeTable:
* @table: An attribute table
*
* Deallocate the memory used by an entities hash table.
*/
void
}
#ifdef LIBXML_TREE_ENABLED
/**
* xmlCopyAttribute:
* @attr: An attribute
*
* Build a copy of an attribute.
*
* Returns the new xmlAttributePtr or NULL in case of error.
*/
static xmlAttributePtr
return(NULL);
}
return(cur);
}
/**
* xmlCopyAttributeTable:
* @table: An attribute table
*
* Build a copy of an attribute table.
*
* Returns the new xmlAttributeTablePtr or NULL in case of error.
*/
}
#endif /* LIBXML_TREE_ENABLED */
#ifdef LIBXML_OUTPUT_ENABLED
/**
* xmlDumpAttributeDecl:
* @buf: the XML buffer output
* @attr: An attribute declaration
*
* This will dump the content of the attribute declaration as an XML
* DTD definition
*/
void
return;
}
case XML_ATTRIBUTE_CDATA:
break;
case XML_ATTRIBUTE_ID:
break;
case XML_ATTRIBUTE_IDREF:
break;
case XML_ATTRIBUTE_IDREFS:
break;
case XML_ATTRIBUTE_ENTITY:
break;
case XML_ATTRIBUTE_ENTITIES:
break;
case XML_ATTRIBUTE_NMTOKEN:
break;
case XML_ATTRIBUTE_NMTOKENS:
break;
break;
case XML_ATTRIBUTE_NOTATION:
break;
default:
"Internal: ATTRIBUTE struct corrupted invalid type\n",
NULL);
}
case XML_ATTRIBUTE_NONE:
break;
case XML_ATTRIBUTE_REQUIRED:
break;
case XML_ATTRIBUTE_IMPLIED:
break;
case XML_ATTRIBUTE_FIXED:
break;
default:
"Internal: ATTRIBUTE struct corrupted invalid def\n",
NULL);
}
}
}
/**
* xmlDumpAttributeDeclScan:
* @attr: An attribute declaration
* @buf: the XML buffer output
*
* This is used with the hash scan function - just reverses arguments
*/
static void
}
/**
* xmlDumpAttributeTable:
* @buf: the XML buffer output
* @table: An attribute table
*
* This will dump the content of the attribute table as an XML DTD definition
*/
void
return;
}
#endif /* LIBXML_OUTPUT_ENABLED */
/************************************************************************
* *
* NOTATIONs *
* *
************************************************************************/
/**
* xmlFreeNotation:
* @not: A notation
*
* Deallocate the memory used by an notation definition
*/
static void
}
/**
* xmlAddNotationDecl:
* @dtd: pointer to the DTD
* @ctxt: the validation context
* @name: the entity name
* @PublicID: the public identifier or NULL
* @SystemID: the system identifier or NULL
*
* Register a new notation declaration
*
* Returns NULL if not, otherwise the entity
*/
return(NULL);
}
return(NULL);
}
return(NULL);
}
/*
* Create the Notation table if needed.
*/
}
"xmlAddNotationDecl: Table creation failed!\n");
return(NULL);
}
return(NULL);
}
/*
* fill the structure.
*/
/*
* Validity Check:
* Check the DTD for previous declarations of the ATTLIST
*/
#ifdef LIBXML_VALID_ENABLED
"xmlAddNotationDecl: %s already defined\n",
(const char *) name);
#endif /* LIBXML_VALID_ENABLED */
return(NULL);
}
return(ret);
}
/**
* xmlFreeNotationTable:
* @table: An notation table
*
* Deallocate the memory used by an entities hash table.
*/
void
}
#ifdef LIBXML_TREE_ENABLED
/**
* xmlCopyNotation:
* @nota: A notation
*
* Build a copy of a notation.
*
* Returns the new xmlNotationPtr or NULL in case of error.
*/
static xmlNotationPtr
return(NULL);
}
else
else
else
return(cur);
}
/**
* xmlCopyNotationTable:
* @table: A notation table
*
* Build a copy of a notation table.
*
* Returns the new xmlNotationTablePtr or NULL in case of error.
*/
}
#endif /* LIBXML_TREE_ENABLED */
#ifdef LIBXML_OUTPUT_ENABLED
/**
* xmlDumpNotationDecl:
* @buf: the XML buffer output
* @nota: A notation declaration
*
* This will dump the content the notation declaration as an XML DTD definition
*/
void
return;
}
} else {
}
}
/**
* xmlDumpNotationDeclScan:
* @nota: A notation declaration
* @buf: the XML buffer output
*
* This is called with the hash scan function, and just reverses args
*/
static void
}
/**
* xmlDumpNotationTable:
* @buf: the XML buffer output
* @table: A notation table
*
* This will dump the content of the notation table as an XML DTD definition
*/
void
return;
}
#endif /* LIBXML_OUTPUT_ENABLED */
/************************************************************************
* *
* IDs *
* *
************************************************************************/
/**
* DICT_FREE:
* @str: a string
*
* Free a string if it is not owned by the "dict" dictionnary in the
* current scope
*/
/**
* xmlFreeID:
* @not: A id
*
* Deallocate the memory used by an id definition
*/
static void
}
/**
* xmlAddID:
* @ctxt: the validation context
* @doc: pointer to the document
* @value: the value name
* @attr: the attribute holding the ID
*
* Register a new id declaration
*
* Returns NULL if not, otherwise the new xmlIDPtr
*/
xmlAttrPtr attr) {
return(NULL);
}
return(NULL);
}
return(NULL);
}
/*
* Create the ID table if needed.
*/
}
"xmlAddID: Table creation failed!\n");
return(NULL);
}
return(NULL);
}
/*
* fill the structure.
*/
/*
* Operating in streaming mode, attr is gonna disapear
*/
else
} else {
}
#ifdef LIBXML_VALID_ENABLED
/*
* The id is already defined in this DTD.
*/
"ID %s already defined\n",
}
#endif /* LIBXML_VALID_ENABLED */
return(NULL);
}
return(ret);
}
/**
* xmlFreeIDTable:
* @table: An id table
*
* Deallocate the memory used by an ID hash table.
*/
void
}
/**
* xmlIsID:
* @doc: the document
* @elem: the element carrying the attribute
* @attr: the attribute
*
* Determine whether an attribute is of type ID. In case we have DTD(s)
* then this is done if DTD loading has been requested. In the case
* of HTML documents parsed with the HTML parser, then ID detection is
* done systematically.
*
* Returns 0 or 1 depending on the lookup result
*/
int
return(1);
return(0);
return(1);
return(0);
return(0);
} else {
}
return(1);
}
return(0);
}
/**
* xmlRemoveID:
* @doc: the document
* @attr: the attribute
*
* Remove the given attribute from the ID table maintained internally.
*
* Returns -1 if the lookup failed and 0 otherwise
*/
int
return(-1);
return(-1);
return(-1);
return(-1);
}
return(0);
}
/**
* xmlGetID:
* @doc: pointer to the document
* @ID: the ID value
*
* Search the attribute declaring the given ID
*
* Returns NULL if not found, otherwise the xmlAttrPtr defining the ID
*/
return(NULL);
}
return(NULL);
}
return(NULL);
return(NULL);
/*
* We are operating on a stream, return a well known reference
* since the attribute node doesn't exist anymore
*/
return((xmlAttrPtr) doc);
}
}
/************************************************************************
* *
* Refs *
* *
************************************************************************/
typedef struct xmlRemoveMemo_t
{
xmlListPtr l;
typedef xmlRemoveMemo *xmlRemoveMemoPtr;
typedef struct xmlValidateMemo_t
{
typedef xmlValidateMemo *xmlValidateMemoPtr;
/**
* xmlFreeRef:
* @lk: A list link
*
* Deallocate the memory used by a ref definition
*/
static void
}
/**
* xmlFreeRefList:
* @list_ref: A list of references.
*
* Deallocate the memory used by a list of references
*/
static void
}
/**
* xmlWalkRemoveRef:
* @data: Contents of current link
* @user: Value supplied by the user
*
* Returns 0 to abort the walk or 1 to continue
*/
static int
{
return 0;
}
return 1;
}
/**
* xmlDummyCompare
* @data0: Value supplied by the user
* @data1: Value supplied by the user
*
* Do nothing, return 0. Used to create unordered lists.
*/
static int
const void *data1 ATTRIBUTE_UNUSED)
{
return (0);
}
/**
* xmlAddRef:
* @ctxt: the validation context
* @doc: pointer to the document
* @value: the value name
* @attr: the attribute holding the Ref
*
* Register a new ref declaration
*
* Returns NULL if not, otherwise the new xmlRefPtr
*/
xmlAttrPtr attr) {
return(NULL);
}
return(NULL);
}
return(NULL);
}
/*
* Create the Ref table if needed.
*/
}
"xmlAddRef: Table creation failed!\n");
return(NULL);
}
return(NULL);
}
/*
* fill the structure.
*/
/*
* Operating in streaming mode, attr is gonna disapear
*/
} else {
}
/* To add a reference :-
* References are maintained as a list of references,
* Lookup the entry, if no entry create new nodelist
* Add the owning node to the NodeList
* Return the ref
*/
"xmlAddRef: Reference list creation failed!\n",
NULL);
goto failed;
}
"xmlAddRef: Reference list insertion failed!\n",
NULL);
goto failed;
}
}
"xmlAddRef: Reference list insertion failed!\n",
NULL);
goto failed;
}
return(ret);
}
return(NULL);
}
/**
* xmlFreeRefTable:
* @table: An ref table
*
* Deallocate the memory used by an Ref hash table.
*/
void
}
/**
* xmlIsRef:
* @doc: the document
* @elem: the element carrying the attribute
* @attr: the attribute
*
* Determine whether an attribute is of type Ref. In case we have DTD(s)
* then this is simple, otherwise we use an heuristic: name Ref (upper
* or lowercase).
*
* Returns 0 or 1 depending on the lookup result
*/
int
return(0);
}
return(0);
/* TODO @@@ */
return(0);
} else {
return(1);
}
return(0);
}
/**
* xmlRemoveRef:
* @doc: the document
* @attr: the attribute
*
* Remove the given attribute from the Ref table maintained internally.
*
* Returns -1 if the lookup failed and 0 otherwise
*/
int
return(-1);
return(-1);
return(-1);
return (-1);
}
/* At this point, ref_list refers to a list of references which
* have the same key as the supplied attr. Our list of references
* is ordered by reference address and we don't have that information
* here to use when removing. We'll have to walk the list and
* check for a matching attribute, when we find one stop the walk
* and remove the entry.
* The list is ordered by reference, so that means we don't have the
* key. Passing the list and the reference to the walker means we
* will have enough data to be able to remove the entry.
*/
/* Remove the supplied attr from our list */
/*If the list is empty then remove the list entry in the hash */
if (xmlListEmpty(ref_list))
return(0);
}
/**
* xmlGetRefs:
* @doc: pointer to the document
* @ID: the ID value
*
* Find the set of references for the supplied ID.
*
* Returns NULL if not found, otherwise node set for the ID.
*/
return(NULL);
}
return(NULL);
}
return(NULL);
}
/************************************************************************
* *
* Routines for validity checking *
* *
************************************************************************/
/**
* xmlGetDtdElementDesc:
* @dtd: a pointer to the DtD to search
* @name: the element name
*
* Search the DTD for the description of this element
*
* returns the xmlElementPtr if found or NULL
*/
return(NULL);
return(cur);
}
/**
* xmlGetDtdElementDesc2:
* @dtd: a pointer to the DtD to search
* @name: the element name
* @create: create an empty description if not found
*
* Search the DTD for the description of this element
*
* returns the xmlElementPtr if found or NULL
*/
static xmlElementPtr
if (!create)
return(NULL);
/*
* Create the Element table if needed.
*/
}
return(NULL);
}
}
return(NULL);
}
/*
* fill the structure.
*/
}
return(cur);
}
/**
* xmlGetDtdQElementDesc:
* @dtd: a pointer to the DtD to search
* @name: the element name
* @prefix: the element namespace prefix
*
* Search the DTD for the description of this element
*
* returns the xmlElementPtr if found or NULL
*/
}
/**
* xmlGetDtdAttrDesc:
* @dtd: a pointer to the DtD to search
* @elem: the element name
* @name: the attribute name
*
* Search the DTD for the description of this attribute on
* this element.
*
* returns the xmlAttributePtr if found or NULL
*/
return(NULL);
} else
return(cur);
}
/**
* xmlGetDtdQAttrDesc:
* @dtd: a pointer to the DtD to search
* @elem: the element name
* @name: the attribute name
* @prefix: the attribute namespace prefix
*
* Search the DTD for the description of this qualified attribute on
* this element.
*
* returns the xmlAttributePtr if found or NULL
*/
}
/**
* xmlGetDtdNotationDesc:
* @dtd: a pointer to the DtD to search
* @name: the notation name
*
* Search the DTD for the description of this notation
*
* returns the xmlNotationPtr if found or NULL
*/
}
#if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
/**
* xmlValidateNotationUse:
* @ctxt: the validation context
* @doc: the document
* @notationName: the notation name to check
*
* Validate that the given name match a notation declaration.
* - [ VC: Notation Declared ]
*
* returns 1 if valid or 0 otherwise
*/
int
const xmlChar *notationName) {
"NOTATION %s is not declared\n",
return(0);
}
return(1);
}
#endif /* LIBXML_VALID_ENABLED or LIBXML_SCHEMAS_ENABLED */
/**
* xmlIsMixedElement:
* @doc: the document
* @name: the element name
*
* Search in the DtDs whether an element accept Mixed content (or ANY)
* basically if it is supposed to accept text childs
*
* returns 0 if no, 1 if yes, and -1 if no element description is available
*/
int
return(-1);
case XML_ELEMENT_TYPE_ELEMENT:
return(0);
case XML_ELEMENT_TYPE_EMPTY:
/*
* return 1 for EMPTY since we want VC error to pop up
* on <empty> </empty> for example
*/
case XML_ELEMENT_TYPE_ANY:
case XML_ELEMENT_TYPE_MIXED:
return(1);
}
return(1);
}
#ifdef LIBXML_VALID_ENABLED
/**
* xmlValidateNameValue:
* @value: an Name value
*
* Validate that the given value match Name production
*
* returns 1 if valid or 0 otherwise
*/
int
(val != ':')) {
return(0);
}
(IS_COMBINING(val)) ||
(IS_EXTENDER(val))) {
}
if (val != 0) return(0);
return(1);
}
/**
* xmlValidateNamesValue:
* @value: an Names value
*
* Validate that the given value match Names production
*
* returns 1 if valid or 0 otherwise
*/
int
(val != ':')) {
return(0);
}
(IS_COMBINING(val)) ||
(IS_EXTENDER(val))) {
}
/* Should not test IS_BLANK(val) here -- see erratum E20*/
while (val == 0x20) {
while (val == 0x20) {
}
(val != ':')) {
return(0);
}
(IS_COMBINING(val)) ||
(IS_EXTENDER(val))) {
}
}
if (val != 0) return(0);
return(1);
}
/**
* xmlValidateNmtokenValue:
* @value: an Nmtoken value
*
* Validate that the given value match Nmtoken production
*
* [ VC: Name Token ]
*
* returns 1 if valid or 0 otherwise
*/
int
(!IS_COMBINING(val)) &&
(!IS_EXTENDER(val)))
return(0);
(IS_COMBINING(val)) ||
(IS_EXTENDER(val))) {
}
if (val != 0) return(0);
return(1);
}
/**
* xmlValidateNmtokensValue:
* @value: an Nmtokens value
*
* Validate that the given value match Nmtokens production
*
* [ VC: Name Token ]
*
* returns 1 if valid or 0 otherwise
*/
int
}
(!IS_COMBINING(val)) &&
(!IS_EXTENDER(val)))
return(0);
(IS_COMBINING(val)) ||
(IS_EXTENDER(val))) {
}
/* Should not test IS_BLANK(val) here -- see erratum E20*/
while (val == 0x20) {
while (val == 0x20) {
}
if (val == 0) return(1);
(!IS_COMBINING(val)) &&
(!IS_EXTENDER(val)))
return(0);
(IS_COMBINING(val)) ||
(IS_EXTENDER(val))) {
}
}
if (val != 0) return(0);
return(1);
}
/**
* xmlValidateNotationDecl:
* @ctxt: the validation context
* @doc: a document instance
* @nota: a notation definition
*
* Try to validate a single notation definition
* basically it does the following checks as described by the
* XML-1.0 recommendation:
* - it seems that no validity constraint exists on notation declarations
* But this function get called anyway ...
*
* returns 1 if valid or 0 otherwise
*/
int
int ret = 1;
return(ret);
}
/**
* xmlValidateAttributeValue:
* @type: an attribute type
* @value: an attribute value
*
* Validate that the given attribute value match the proper production
*
* [ VC: ID ]
* Values of type ID must match the Name production....
*
* [ VC: IDREF ]
* Values of type IDREF must match the Name production, and values
* of type IDREFS must match Names ...
*
* [ VC: Entity Name ]
* Values of type ENTITY must match the Name production, values
* of type ENTITIES must match Names ...
*
* [ VC: Name Token ]
* Values of type NMTOKEN must match the Nmtoken production; values
* of type NMTOKENS must match Nmtokens.
*
* returns 1 if valid or 0 otherwise
*/
int
switch (type) {
case XML_ATTRIBUTE_ENTITIES:
case XML_ATTRIBUTE_IDREFS:
return(xmlValidateNamesValue(value));
case XML_ATTRIBUTE_ENTITY:
case XML_ATTRIBUTE_IDREF:
case XML_ATTRIBUTE_ID:
case XML_ATTRIBUTE_NOTATION:
return(xmlValidateNameValue(value));
case XML_ATTRIBUTE_NMTOKENS:
return(xmlValidateNmtokensValue(value));
case XML_ATTRIBUTE_NMTOKEN:
return(xmlValidateNmtokenValue(value));
case XML_ATTRIBUTE_CDATA:
break;
}
return(1);
}
/**
* xmlValidateAttributeValue2:
* @ctxt: the validation context
* @doc: the document
* @name: the attribute name (used for error reporting only)
* @type: the attribute type
* @value: the attribute value
*
* Validate that the given attribute value match a given type.
* This typically cannot be done before having finished parsing
* the subsets.
*
* [ VC: IDREF ]
* Values of type IDREF must match one of the declared IDs
* Values of type IDREFS must match a sequence of the declared IDs
* each Name must match the value of an ID attribute on some element
* in the XML document; i.e. IDREF values must match the value of
* some ID attribute
*
* [ VC: Entity Name ]
* Values of type ENTITY must match one declared entity
* Values of type ENTITIES must match a sequence of declared entities
*
* [ VC: Notation Attributes ]
* all notation names in the declaration must be declared.
*
* returns 1 if valid or 0 otherwise
*/
static int
int ret = 1;
switch (type) {
case XML_ATTRIBUTE_IDREFS:
case XML_ATTRIBUTE_IDREF:
case XML_ATTRIBUTE_ID:
case XML_ATTRIBUTE_NMTOKENS:
case XML_ATTRIBUTE_NMTOKEN:
case XML_ATTRIBUTE_CDATA:
break;
case XML_ATTRIBUTE_ENTITY: {
/* yeah it's a bit messy... */
doc->standalone = 0;
}
"ENTITY attribute %s reference an unknown entity \"%s\"\n",
ret = 0;
"ENTITY attribute %s reference an entity \"%s\" of wrong type\n",
ret = 0;
}
break;
}
case XML_ATTRIBUTE_ENTITIES: {
return(0);
while (*cur != 0) {
*cur = 0;
"ENTITIES attribute %s reference an unknown entity \"%s\"\n",
ret = 0;
"ENTITIES attribute %s reference an entity \"%s\" of wrong type\n",
ret = 0;
}
if (save == 0)
break;
}
break;
}
case XML_ATTRIBUTE_NOTATION: {
"NOTATION attribute %s reference an unknown notation \"%s\"\n",
ret = 0;
}
break;
}
}
return(ret);
}
/**
* xmlValidCtxtNormalizeAttributeValue:
* @ctxt: the validation context
* @doc: the document
* @elem: the parent
* @name: the attribute name
* @value: the attribute value
* @ctxt: the validation context or NULL
*
* Does the validation related extra step of the normalization of attribute
* values:
*
* If the declared value is not CDATA, then the XML processor must further
* process the normalized attribute value by discarding any leading and
* trailing space (#x20) characters, and by replacing sequences of space
* (#x20) characters by single space (#x20) character.
*
* Also check VC: Standalone Document Declaration in P32, and update
* ctxt->valid accordingly
*
* returns a new normalized string if normalization is needed, NULL otherwise
* the caller must free the returned value.
*/
xmlChar *
int extsubset = 0;
return(NULL);
extsubset = 1;
}
}
extsubset = 1;
}
return(NULL);
return(NULL);
return(NULL);
while (*src != 0) {
if (*src == 0x20) {
if (*src != 0)
*dst++ = 0x20;
} else {
}
}
*dst = 0;
"standalone: %s on %s value had to be normalized based on external subset declaration\n",
}
return(ret);
}
/**
* xmlValidNormalizeAttributeValue:
* @doc: the document
* @elem: the parent
* @name: the attribute name
* @value: the attribute value
*
* Does the validation related extra step of the normalization of attribute
* values:
*
* If the declared value is not CDATA, then the XML processor must further
* process the normalized attribute value by discarding any leading and
* trailing space (#x20) characters, and by replacing sequences of space
* (#x20) characters by single space (#x20) character.
*
* Returns a new normalized string if normalization is needed, NULL otherwise
* the caller must free the returned value.
*/
xmlChar *
return(NULL);
}
return(NULL);
return(NULL);
return(NULL);
while (*src != 0) {
if (*src == 0x20) {
if (*src != 0)
*dst++ = 0x20;
} else {
}
}
*dst = 0;
return(ret);
}
static void
}
/**
* xmlValidateAttributeDecl:
* @ctxt: the validation context
* @doc: a document instance
* @attr: an attribute definition
*
* Try to validate a single attribute definition
* basically it does the following checks as described by the
* XML-1.0 recommendation:
* - [ VC: Attribute Default Legal ]
* - [ VC: Enumeration ]
* - [ VC: ID Attribute Default ]
*
*
* returns 1 if valid or 0 otherwise
*/
int
int ret = 1;
int val;
/* Attribute Default Legal */
/* Enumeration */
if (val == 0) {
"Syntax of default value for attribute %s of %s is not valid\n",
}
}
/* ID Attribute Default */
"ID attribute %s of %s is not valid must be #IMPLIED or #REQUIRED\n",
ret = 0;
}
/* One ID per Element Type */
int nbId;
/* the trick is that we parse DtD as their own internal subset */
} else {
/*
* The attribute may be declared in the internal subset and the
* element in the external subset.
*/
nbId = 0;
}
}
if (nbId > 1) {
"Element %s has %d ID attribute defined in the internal subset : %s\n",
int extId = 0;
}
if (extId > 1) {
"Element %s has %d ID attribute defined in the external subset : %s\n",
"Element %s has ID attributes defined in the internal and external subset : %s\n",
}
}
}
/* Validity Constraint: Enumeration */
}
"Default value \"%s\" for attribute %s of %s is not among the enumerated set\n",
ret = 0;
}
}
return(ret);
}
/**
* xmlValidateElementDecl:
* @ctxt: the validation context
* @doc: a document instance
* @elem: an element definition
*
* Try to validate a single element definition
* basically it does the following checks as described by the
* XML-1.0 recommendation:
* - [ VC: One ID per Element Type ]
* - [ VC: No Duplicate Types ]
* - [ VC: Unique Element Type Declaration ]
*
* returns 1 if valid or 0 otherwise
*/
int
int ret = 1;
#if 0
#ifdef LIBXML_REGEXP_ENABLED
/* Build the regexp associated to the content model */
#endif
#endif
/* No Duplicate Types */
"Definition of %s has duplicate references of %s\n",
} else {
"Definition of %s has duplicate references of %s:%s\n",
}
ret = 0;
}
break;
}
"Definition of %s has duplicate references to %s\n",
} else {
"Definition of %s has duplicate references to %s:%s\n",
}
ret = 0;
}
}
}
}
}
/* VC: Unique Element Type Declaration */
"Redefinition of element %s\n",
ret = 0;
}
"Redefinition of element %s\n",
ret = 0;
}
/* One ID per Element Type
* already done when registering the attribute
if (xmlScanIDAttributeDecl(ctxt, elem) > 1) {
ret = 0;
} */
return(ret);
}
/**
* xmlValidateOneAttribute:
* @ctxt: the validation context
* @doc: a document instance
* @elem: an element instance
* @attr: an attribute instance
* @value: the attribute value (without entities processing)
*
* Try to validate a single attribute for an element
* basically it does the following checks as described by the
* XML-1.0 recommendation:
* - [ VC: Attribute Value Type ]
* - [ VC: Fixed Attribute Default ]
* - [ VC: Entity Name ]
* - [ VC: Name Token ]
* - [ VC: ID ]
* - [ VC: IDREF ]
* - [ VC: Entity Name ]
* - [ VC: Notation Attributes ]
*
*
* returns 1 if valid or 0 otherwise
*/
int
{
int val;
int ret = 1;
return(0);
} else {
}
}
} else {
}
}
/* Validity Constraint: Attribute Value Type */
"No declaration for attribute %s of element %s\n",
return(0);
}
if (val == 0) {
"Syntax of value for attribute %s of %s is not valid\n",
ret = 0;
}
/* Validity constraint: Fixed Attribute Default */
"Value for attribute %s of %s is different from default \"%s\"\n",
ret = 0;
}
}
/* Validity Constraint: ID uniqueness */
ret = 0;
}
ret = 0;
}
/* Validity Constraint: Notation Attributes */
/* First check that the given NOTATION was declared */
"Value \"%s\" for attribute %s of %s is not a declared Notation\n",
ret = 0;
}
/* Second, verify that it's among the list */
}
"Value \"%s\" for attribute %s of %s is not among the enumerated notations\n",
ret = 0;
}
}
/* Validity Constraint: Enumeration */
}
"Value \"%s\" for attribute %s of %s is not among the enumerated set\n",
ret = 0;
}
}
/* Fixed Attribute Default */
"Value for attribute %s of %s must be \"%s\"\n",
ret = 0;
}
/* Extra check for the attribute value */
return(ret);
}
/**
* xmlValidateOneNamespace:
* @ctxt: the validation context
* @doc: a document instance
* @elem: an element instance
* @prefix: the namespace prefix
* @ns: an namespace declaration instance
* @value: the attribute value (without entities processing)
*
* Try to validate a single namespace declaration for an element
* basically it does the following checks as described by the
* XML-1.0 recommendation:
* - [ VC: Attribute Value Type ]
* - [ VC: Fixed Attribute Default ]
* - [ VC: Entity Name ]
* - [ VC: Name Token ]
* - [ VC: ID ]
* - [ VC: IDREF ]
* - [ VC: Entity Name ]
* - [ VC: Notation Attributes ]
*
*
* returns 1 if valid or 0 otherwise
*/
int
/* xmlElementPtr elemDecl; */
int val;
int ret = 1;
return(0);
}
} else {
BAD_CAST "xmlns");
BAD_CAST "xmlns");
}
}
} else {
}
}
/* Validity Constraint: Attribute Value Type */
"No declaration for attribute xmlns:%s of element %s\n",
} else {
"No declaration for attribute xmlns of element %s\n",
}
return(0);
}
if (val == 0) {
"Syntax of value for attribute xmlns:%s of %s is not valid\n",
} else {
"Syntax of value for attribute xmlns of %s is not valid\n",
}
ret = 0;
}
/* Validity constraint: Fixed Attribute Default */
"Value for attribute xmlns:%s of %s is different from default \"%s\"\n",
} else {
"Value for attribute xmlns of %s is different from default \"%s\"\n",
}
ret = 0;
}
}
/* Validity Constraint: ID uniqueness */
ret = 0;
}
ret = 0;
}
/* Validity Constraint: Notation Attributes */
/* First check that the given NOTATION was declared */
"Value \"%s\" for attribute xmlns:%s of %s is not a declared Notation\n",
} else {
"Value \"%s\" for attribute xmlns of %s is not a declared Notation\n",
}
ret = 0;
}
/* Second, verify that it's among the list */
}
"Value \"%s\" for attribute xmlns:%s of %s is not among the enumerated notations\n",
} else {
"Value \"%s\" for attribute xmlns of %s is not among the enumerated notations\n",
}
ret = 0;
}
}
/* Validity Constraint: Enumeration */
}
"Value \"%s\" for attribute xmlns:%s of %s is not among the enumerated set\n",
} else {
"Value \"%s\" for attribute xmlns of %s is not among the enumerated set\n",
}
ret = 0;
}
}
/* Fixed Attribute Default */
"Value for attribute xmlns:%s of %s must be \"%s\"\n",
} else {
"Value for attribute xmlns of %s must be \"%s\"\n",
}
ret = 0;
}
/* Extra check for the attribute value */
} else {
}
return(ret);
}
#ifndef LIBXML_REGEXP_ENABLED
/**
* xmlValidateSkipIgnorable:
* @ctxt: the validation context
* @child: the child list
*
* Skip ignorable elements w.r.t. the validation process
*
* returns the first element to consider for validation of the content model
*/
static xmlNodePtr
/* These things are ignored (skipped) during validation. */
case XML_PI_NODE:
case XML_COMMENT_NODE:
case XML_XINCLUDE_START:
case XML_XINCLUDE_END:
break;
case XML_TEXT_NODE:
if (xmlIsBlankNode(child))
else
return(child);
break;
/* keep current node */
default:
return(child);
}
}
return(child);
}
/**
* xmlValidateElementType:
* @ctxt: the validation context
*
* Try to validate the content model of an element internal function
*
* returns 1 if valid or 0 ,-1 in case of error, -2 if an entity
* reference is found and -3 if the validation succeeded but
* the content model is not determinist.
*/
static int
int ret = -1;
int determinist = 1;
return(1);
return(1);
}
return(-2);
/*
* We arrive here when more states need to be examined
*/
cont:
/*
* We just recovered from a rollback generated by a possible
* epsilon transition, go directly to the analysis phase
*/
if (STATE == ROLLBACK_PARENT) {
DEBUG_VALID_MSG("restored parent branch");
ret = 1;
goto analyze;
}
/*
* we may have to save a backup state here. This is the equivalent
* of handling epsilon transition in NFAs.
*/
DEBUG_VALID_MSG("saving parent branch");
return(0);
}
/*
* Check first if the content matches
*/
DEBUG_VALID_MSG("pcdata failed no node");
ret = 0;
break;
}
DEBUG_VALID_MSG("pcdata found, skip to next");
/*
* go to next element in the content model
* skipping ignorable elems
*/
do {
return(-2);
ret = 1;
break;
} else {
DEBUG_VALID_MSG("pcdata failed");
ret = 0;
break;
}
break;
DEBUG_VALID_MSG("element failed no node");
ret = 0;
break;
}
if (ret == 1) {
ret = 0;
} else {
}
}
if (ret == 1) {
DEBUG_VALID_MSG("element found, skip to next");
/*
* go to next element in the content model
* skipping ignorable elems
*/
do {
return(-2);
} else {
DEBUG_VALID_MSG("element failed");
ret = 0;
break;
}
break;
case XML_ELEMENT_CONTENT_OR:
/*
* Small optimization.
*/
DEPTH++;
goto cont;
}
ret = 0;
} else {
}
if (ret == 0) {
DEPTH++;
goto cont;
}
}
/*
* save the second branch 'or' branch
*/
DEBUG_VALID_MSG("saving 'or' branch");
OCCURS, ROLLBACK_OR) < 0)
return(-1);
DEPTH++;
goto cont;
case XML_ELEMENT_CONTENT_SEQ:
/*
* Small optimization.
*/
DEPTH++;
goto cont;
}
ret = 0;
} else {
}
if (ret == 0) {
DEPTH++;
goto cont;
}
}
DEPTH++;
goto cont;
}
/*
* At this point handle going up in the tree
*/
if (ret == -1) {
DEBUG_VALID_MSG("error found returning");
return(ret);
}
/*
* First do the analysis depending on the occurrence model at
* this level.
*/
if (ret == 0) {
case XML_ELEMENT_CONTENT_ONCE:
DEBUG_VALID_MSG("Once branch failed, rollback");
if (vstateVPop(ctxt) < 0 ) {
DEBUG_VALID_MSG("exhaustion, failed");
return(0);
}
determinist = -3;
goto cont;
case XML_ELEMENT_CONTENT_PLUS:
if (OCCURRENCE == 0) {
DEBUG_VALID_MSG("Plus branch failed, rollback");
if (vstateVPop(ctxt) < 0 ) {
DEBUG_VALID_MSG("exhaustion, failed");
return(0);
}
determinist = -3;
goto cont;
}
DEBUG_VALID_MSG("Plus branch found");
ret = 1;
break;
case XML_ELEMENT_CONTENT_MULT:
#ifdef DEBUG_VALID_ALGO
if (OCCURRENCE == 0) {
DEBUG_VALID_MSG("Mult branch failed");
} else {
DEBUG_VALID_MSG("Mult branch found");
}
#endif
ret = 1;
break;
case XML_ELEMENT_CONTENT_OPT:
DEBUG_VALID_MSG("Option branch failed");
ret = 1;
break;
}
} else {
case XML_ELEMENT_CONTENT_OPT:
DEBUG_VALID_MSG("Option branch succeeded");
ret = 1;
break;
case XML_ELEMENT_CONTENT_ONCE:
DEBUG_VALID_MSG("Once branch succeeded");
ret = 1;
break;
case XML_ELEMENT_CONTENT_PLUS:
if (STATE == ROLLBACK_PARENT) {
DEBUG_VALID_MSG("Plus branch rollback");
ret = 1;
break;
}
DEBUG_VALID_MSG("Plus branch exhausted");
ret = 1;
break;
}
DEBUG_VALID_MSG("Plus branch succeeded, continuing");
goto cont;
case XML_ELEMENT_CONTENT_MULT:
if (STATE == ROLLBACK_PARENT) {
DEBUG_VALID_MSG("Mult branch rollback");
ret = 1;
break;
}
DEBUG_VALID_MSG("Mult branch exhausted");
ret = 1;
break;
}
DEBUG_VALID_MSG("Mult branch succeeded, continuing");
/* SET_OCCURRENCE; */
goto cont;
}
}
STATE = 0;
/*
* Then act accordingly at the parent level
*/
break;
DEBUG_VALID_MSG("Error: parent pcdata");
return(-1);
DEBUG_VALID_MSG("Error: parent element");
return(-1);
case XML_ELEMENT_CONTENT_OR:
if (ret == 1) {
DEBUG_VALID_MSG("Or succeeded");
DEPTH--;
} else {
DEBUG_VALID_MSG("Or failed");
DEPTH--;
}
break;
case XML_ELEMENT_CONTENT_SEQ:
if (ret == 0) {
DEBUG_VALID_MSG("Sequence failed");
DEPTH--;
DEBUG_VALID_MSG("Sequence testing 2nd branch");
goto cont;
} else {
DEBUG_VALID_MSG("Sequence succeeded");
DEPTH--;
}
}
}
DEBUG_VALID_MSG("Failed, remaining input, rollback");
if (vstateVPop(ctxt) < 0 ) {
DEBUG_VALID_MSG("exhaustion, failed");
return(0);
}
determinist = -3;
goto cont;
}
if (ret == 0) {
DEBUG_VALID_MSG("Failure, rollback");
if (vstateVPop(ctxt) < 0 ) {
DEBUG_VALID_MSG("exhaustion, failed");
return(0);
}
determinist = -3;
goto cont;
}
return(determinist);
}
#endif
/**
* xmlSnprintfElements:
* @buf: an output buffer
* @size: the size of the buffer
* @content: An element
* @glob: 1 if one must print the englobing parenthesis, 0 otherwise
*
* This will dump the list of elements to the buffer
* Intended just for the debug routine
*/
static void
int len;
return;
}
case XML_ELEMENT_NODE:
return;
}
}
return;
}
break;
case XML_TEXT_NODE:
if (xmlIsBlankNode(cur))
break;
case XML_CDATA_SECTION_NODE:
case XML_ENTITY_REF_NODE:
break;
case XML_ATTRIBUTE_NODE:
case XML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
case XML_HTML_DOCUMENT_NODE:
case XML_DOCUMENT_TYPE_NODE:
case XML_DOCUMENT_FRAG_NODE:
case XML_NOTATION_NODE:
case XML_NAMESPACE_DECL:
break;
case XML_ENTITY_NODE:
case XML_PI_NODE:
case XML_DTD_NODE:
case XML_COMMENT_NODE:
case XML_ELEMENT_DECL:
case XML_ATTRIBUTE_DECL:
case XML_ENTITY_DECL:
case XML_XINCLUDE_START:
case XML_XINCLUDE_END:
break;
}
}
}
/**
* xmlValidateElementContent:
* @ctxt: the validation context
* @child: the child list
* @elemDecl: pointer to the element declaration
* @warn: emit the error message
* @parent: the parent element (for error reporting)
*
* Try to validate the content model of an element
*
* returns 1 if valid or 0 if not and -1 in case of error
*/
static int
int ret = 1;
#ifndef LIBXML_REGEXP_ENABLED
#endif
return(-1);
#ifdef LIBXML_REGEXP_ENABLED
/* Build the regexp associated to the content model */
return(-1);
} else {
return(-1);
}
case XML_ENTITY_REF_NODE:
/*
* Push the current node to be able to roll back
* and process within the entity
*/
continue;
}
break;
case XML_TEXT_NODE:
if (xmlIsBlankNode(cur))
break;
ret = 0;
goto fail;
case XML_CDATA_SECTION_NODE:
/* TODO */
ret = 0;
goto fail;
case XML_ELEMENT_NODE:
ret = -1;
goto fail;
}
} else {
}
break;
default:
break;
}
/*
* Switch to next element
*/
break;
}
}
fail:
}
}
#else /* LIBXML_REGEXP_ENABLED */
/*
* Allocate the stack
*/
return(-1);
}
/*
* The first entry in the stack is reserved to the current state
*/
DEPTH = 0;
OCCURS = 0;
STATE = 0;
"Content model for Element %s is ambiguous\n",
} else if (ret == -2) {
/*
* An entities reference appeared at this level.
* Buid a minimal representation of this node content
* sufficient to run the validation process on it
*/
DEBUG_VALID_MSG("Found an entity reference, linearizing");
case XML_ENTITY_REF_NODE:
/*
* Push the current node to be able to roll back
* and process within the entity
*/
continue;
}
break;
case XML_TEXT_NODE:
if (xmlIsBlankNode(cur))
break;
/* no break on purpose */
case XML_CDATA_SECTION_NODE:
/* no break on purpose */
case XML_ELEMENT_NODE:
/*
* Allocate a new node and minimally fills in
* what's required
*/
ret = -1;
goto done;
}
else {
}
/*
* E59 spaces in CDATA does not match the
* nonterminal S
*/
}
break;
default:
break;
}
/*
* Switch to next element
*/
break;
}
}
/*
* Relaunch the validation
*/
DEPTH = 0;
OCCURS = 0;
STATE = 0;
}
#endif /* LIBXML_REGEXP_ENABLED */
char expr[5000];
char list[5000];
expr[0] = 0;
list[0] = 0;
#ifndef LIBXML_REGEXP_ENABLED
else
#endif /* LIBXML_REGEXP_ENABLED */
"Element %s content does not follow the DTD, expecting %s, got %s\n",
} else {
"Element content does not follow the DTD, expecting %s, got %s\n",
}
} else {
"Element %s content does not follow the DTD\n",
} else {
"Element content does not follow the DTD\n",
}
}
ret = 0;
}
if (ret == -3)
ret = 1;
#ifndef LIBXML_REGEXP_ENABLED
done:
/*
* Deallocate the copy if done, and free up the validation stack
*/
}
}
#endif
}
return(ret);
}
/**
* xmlValidateCdataElement:
* @ctxt: the validation context
* @doc: a document instance
* @elem: an element instance
*
* Check that an element follows #CDATA
*
* returns 1 if valid or 0 otherwise
*/
static int
xmlNodePtr elem) {
int ret = 1;
return(0);
case XML_ENTITY_REF_NODE:
/*
* Push the current node to be able to roll back
* and process within the entity
*/
continue;
}
break;
case XML_COMMENT_NODE:
case XML_PI_NODE:
case XML_TEXT_NODE:
case XML_CDATA_SECTION_NODE:
break;
default:
ret = 0;
goto done;
}
/*
* Switch to next element
*/
break;
}
}
done:
}
return(ret);
}
/**
* xmlValidateCheckMixed:
* @ctxt: the validation context
* @cont: the mixed content model
* @qname: the qualified name as appearing in the serialization
*
* Check if the given node is part of the content model.
*
* Returns 1 if yes, 0 if no, -1 in case of error
*/
static int
int plen;
return(1);
return(1);
"Internal: MIXED struct corrupted\n",
NULL);
break;
}
}
} else {
return(1);
return(1);
"Internal: MIXED struct corrupted\n",
NULL);
break;
}
}
}
return(0);
}
/**
* xmlValidGetElemDecl:
* @ctxt: the validation context
* @doc: a document instance
* @elem: an element instance
* @extsubset: pointer, (out) indicate if the declaration was found
* in the external subset.
*
* Finds a declaration associated to an element in the document.
*
* returns the pointer to the declaration or NULL if not found.
*/
static xmlElementPtr
return(NULL);
*extsubset = 0;
/*
* Fetch the declaration for the qualified name
*/
*extsubset = 1;
}
}
/*
* Fetch the declaration for the non qualified name
* This is "non-strict" validation should be done on the
* full QName but in that case being flexible makes sense.
*/
*extsubset = 1;
}
}
"No declaration for element %s\n",
}
return(elemDecl);
}
#ifdef LIBXML_REGEXP_ENABLED
/**
* xmlValidatePushElement:
* @ctxt: the validation context
* @doc: a document instance
* @elem: an element instance
* @qname: the qualified name as appearing in the serialization
*
* Push a new element start on the validation stack.
*
* returns 1 if no validation problem was found or 0 otherwise
*/
int
int ret = 1;
int extsubset = 0;
return(0);
/* printf("PushElem %s\n", qname); */
/*
* Check the new element agaisnt the content model of the new elem.
*/
ret = 0;
break;
case XML_ELEMENT_TYPE_EMPTY:
"Element %s was declared EMPTY this one has content\n",
ret = 0;
break;
case XML_ELEMENT_TYPE_ANY:
/* I don't think anything is required then */
break;
case XML_ELEMENT_TYPE_MIXED:
/* simple case of declared as #PCDATA */
"Element %s was declared #PCDATA but contains non text nodes\n",
ret = 0;
} else {
qname);
if (ret != 1) {
"Element %s is not declared in %s list of possible children\n",
}
}
break;
case XML_ELEMENT_TYPE_ELEMENT:
/*
* TODO:
* VC: Standalone Document Declaration
* - element types with element content, if white space
* occurs directly within any instance of those types.
*/
if (ret < 0) {
"Element %s content does not follow the DTD, Misplaced %s\n",
ret = 0;
} else {
ret = 1;
}
}
break;
}
}
}
return(ret);
}
/**
* xmlValidatePushCData:
* @ctxt: the validation context
* @data: some character data read
* @len: the lenght of the data
*
* check the CData parsed for validation in the current stack
*
* returns 1 if no validation problem was found or 0 otherwise
*/
int
int ret = 1;
/* printf("CDATA %s %d\n", data, len); */
return(0);
if (len <= 0)
return(ret);
/*
* Check the new element agaisnt the content model of the new elem.
*/
ret = 0;
break;
case XML_ELEMENT_TYPE_EMPTY:
"Element %s was declared EMPTY this one has content\n",
ret = 0;
break;
case XML_ELEMENT_TYPE_ANY:
break;
case XML_ELEMENT_TYPE_MIXED:
break;
case XML_ELEMENT_TYPE_ELEMENT:
if (len > 0) {
int i;
for (i = 0;i < len;i++) {
if (!IS_BLANK_CH(data[i])) {
"Element %s content does not follow the DTD, Text not allowed\n",
ret = 0;
goto done;
}
}
/*
* TODO:
* VC: Standalone Document Declaration
* element types with element content, if white space
* occurs directly within any instance of those types.
*/
}
break;
}
}
}
done:
return(ret);
}
/**
* xmlValidatePopElement:
* @ctxt: the validation context
* @doc: a document instance
* @elem: an element instance
* @qname: the qualified name as appearing in the serialization
*
* Pop the element end from the validation stack.
*
* returns 1 if no validation problem was found or 0 otherwise
*/
int
int ret = 1;
return(0);
/* printf("PopElem %s\n", qname); */
/*
* Check the new element agaisnt the content model of the new elem.
*/
if (ret == 0) {
"Element %s content does not follow the DTD, Expecting more child\n",
} else {
/*
* previous validation errors should not generate
* a new one here
*/
ret = 1;
}
}
}
}
}
return(ret);
}
#endif /* LIBXML_REGEXP_ENABLED */
/**
* xmlValidateOneElement:
* @ctxt: the validation context
* @doc: a document instance
* @elem: an element instance
*
* Try to validate a single element and it's attributes,
* basically it does the following checks as described by the
* XML-1.0 recommendation:
* - [ VC: Element Valid ]
* - [ VC: Required Attribute ]
* Then call xmlValidateOneAttribute() for each attribute present.
*
*
* returns 1 if valid or 0 otherwise
*/
int
xmlNodePtr elem) {
int extsubset = 0;
case XML_ATTRIBUTE_NODE:
return(0);
case XML_TEXT_NODE:
"Text element has children !\n",
return(0);
}
"Text element has namespace !\n",
return(0);
}
"Text element has no content !\n",
return(0);
}
return(1);
case XML_XINCLUDE_START:
case XML_XINCLUDE_END:
return(1);
case XML_CDATA_SECTION_NODE:
case XML_ENTITY_REF_NODE:
case XML_PI_NODE:
case XML_COMMENT_NODE:
return(1);
case XML_ENTITY_NODE:
return(0);
case XML_NOTATION_NODE:
return(0);
case XML_DOCUMENT_NODE:
case XML_DOCUMENT_TYPE_NODE:
case XML_DOCUMENT_FRAG_NODE:
return(0);
case XML_HTML_DOCUMENT_NODE:
return(0);
case XML_ELEMENT_NODE:
break;
default:
return(0);
}
/*
* Fetch the declaration
*/
return(0);
/*
* If vstateNr is not zero that means continuous validation is
* activated, do not try to check the content model at that level.
*/
/* Check that the element content matches the definition */
"No declaration for element %s\n",
return(0);
case XML_ELEMENT_TYPE_EMPTY:
"Element %s was declared EMPTY this one has content\n",
ret = 0;
}
break;
case XML_ELEMENT_TYPE_ANY:
/* I don't think anything is required then */
break;
case XML_ELEMENT_TYPE_MIXED:
/* simple case of declared as #PCDATA */
if (!ret) {
"Element %s was declared #PCDATA but contains non text nodes\n",
}
break;
}
/* Hum, this start to get messy */
fn, 50);
return(0);
break;
break;
"Internal: MIXED struct corrupted\n",
NULL);
break;
}
}
goto child_ok;
}
"Internal: MIXED struct corrupted\n",
NULL);
break;
}
}
"Element %s is not declared in %s list of possible children\n",
ret = 0;
}
}
}
break;
case XML_ELEMENT_TYPE_ELEMENT:
/*
* VC: Standalone Document Declaration
* - element types with element content, if white space
* occurs directly within any instance of those types.
*/
while (IS_BLANK_CH(*content))
content++;
if (*content == 0) {
"standalone: %s declared in the external subset contains white spaces nodes\n",
ret = 0;
break;
}
}
}
}
if (tmp <= 0)
break;
}
} /* not continuous */
/* [ VC: Required Attribute ] */
int qualified = -1;
goto found;
}
goto found;
}
} else {
/*
* qualified names handling is problematic, having a
* different prefix should be possible but DTDs don't
* allow to define the URI instead of the prefix :-(
*/
if (qualified < 0)
qualified = 0;
if (qualified < 1)
qualified = 1;
} else
goto found;
} else {
/*
* We should allow applications to define namespaces
* for their application even if the DTD doesn't
* carry one, otherwise, basically we would always
* break.
*/
goto found;
}
}
}
}
if (qualified == -1) {
"Element %s does not carry attribute %s\n",
ret = 0;
} else {
"Element %s does not carry attribute %s:%s\n",
ret = 0;
}
} else if (qualified == 0) {
"Element %s required attribute %s:%s has no prefix\n",
} else if (qualified == 1) {
"Element %s required attribute %s:%s has different prefix\n",
}
/*
* Special tests checking #FIXED namespace declarations
* have the right value since this is not done as an
* attribute checking
*/
"Element %s namespace name for default namespace does not match the DTD\n",
ret = 0;
}
goto found;
}
}
"Element %s namespace name for %s does not match the DTD\n",
ret = 0;
}
goto found;
}
}
}
}
}
return(ret);
}
/**
* xmlValidateRoot:
* @ctxt: the validation context
* @doc: a document instance
*
* Try to validate a the root element
* basically it does the following check as described by the
* XML-1.0 recommendation:
* - [ VC: Root Element Type ]
* it doesn't try to recurse or apply other check to the element
*
* returns 1 if valid or 0 otherwise
*/
int
int ret;
"no root element\n", NULL);
return(0);
}
/*
* When doing post validation against a separate DTD, those may
* no internal subset has been generated
*/
/*
* Check first the document root against the NQName
*/
return(0);
}
if (ret == 1)
goto name_ok;
}
goto name_ok;
"root and DTD name do not match '%s' and '%s'\n",
return(0);
}
}
return(1);
}
/**
* xmlValidateElement:
* @ctxt: the validation context
* @doc: a document instance
* @elem: an element instance
*
* Try to validate the subtree under an element
*
* returns 1 if valid or 0 otherwise
*/
int
int ret = 1;
/*
* XInclude elements were added after parsing in the infoset,
* they don't really mean anything validation wise.
*/
return(1);
/*
* Entities references have to be handled separately
*/
return(1);
}
}
else
}
}
}
return(ret);
}
/**
* xmlValidateRef:
* @ref: A reference to be validated
* @ctxt: Validation context
* @name: Name of ID we are searching for
*
*/
static void
return;
return;
return;
}
while (*cur != 0) {
*cur = 0;
"attribute %s line %d references an unknown ID \"%s\"\n",
}
if (save == 0)
break;
}
"IDREF attribute %s references an unknown ID \"%s\"\n",
}
return;
}
while (*cur != 0) {
*cur = 0;
"IDREFS attribute %s references an unknown ID \"%s\"\n",
}
if (save == 0)
break;
}
}
}
/**
* xmlWalkValidateList:
* @data: Contents of current link
* @user: Value supplied by the user
*
* Returns 0 to abort the walk or 1 to continue
*/
static int
{
return 1;
}
/**
* xmlValidateCheckRefCallback:
* @ref_list: List of references
* @ctxt: Validation context
* @name: Name of ID we are searching for
*
*/
static void
return;
}
/**
* xmlValidateDocumentFinal:
* @ctxt: the validation context
* @doc: a document instance
*
* Does the final step for the document validation once all the
* incremental validation steps have been completed
*
* basically it does the following checks described by the XML Rec
*
*
* returns 1 if valid or 0 otherwise
*/
int
return(0);
"xmlValidateDocumentFinal: doc == NULL\n", NULL);
return(0);
}
/*
*/
/*
*/
/*
*/
}
/**
* xmlValidateDtd:
* @ctxt: the validation context
* @doc: a document instance
* @dtd: a dtd instance
*
* Try to validate the document against the dtd instance
*
* Basically it does check all the definitions in the DtD.
* Note the the internal subset (if present) is de-coupled
* (i.e. not used), which could give problems if ID or IDREF
* is present.
*
* returns 1 if valid or 0 otherwise
*/
int
int ret;
if (ret == 0) {
return(ret);
}
}
}
return(ret);
}
static void
return;
int ret;
if (ret != 1) {
}
}
}
}
static void
int ret;
return;
case XML_ATTRIBUTE_CDATA:
case XML_ATTRIBUTE_ID:
case XML_ATTRIBUTE_IDREF :
case XML_ATTRIBUTE_IDREFS:
case XML_ATTRIBUTE_NMTOKEN:
case XML_ATTRIBUTE_NMTOKENS:
break;
case XML_ATTRIBUTE_ENTITY:
case XML_ATTRIBUTE_ENTITIES:
case XML_ATTRIBUTE_NOTATION:
}
}
}
}
"xmlValidateAttributeCallback(%s): internal error\n",
return;
}
"attribute %s: could not find decl for element %s\n",
return;
}
"NOTATION attribute %s declared for EMPTY element %s\n",
}
}
}
/**
* xmlValidateDtdFinal:
* @ctxt: the validation context
* @doc: a document instance
*
* Does the final step for the dtds validation once all the
* subsets have been parsed
*
* basically it does the following checks described by the XML Rec
* - check that ENTITY and ENTITIES type attributes default or
* possible values matches one of the defined entities.
* - check that NOTATION type attributes default or
* possible values matches one of the defined notations.
*
* returns 1 if valid or 0 if invalid and -1 if not well-formed
*/
int
return(0);
}
ctxt);
}
}
ctxt);
}
}
/**
* xmlValidateDocument:
* @ctxt: the validation context
* @doc: a document instance
*
* Try to validate the document instance
*
* basically it does the all the checks described by the XML Rec
* i.e. validates the internal and external subset (if present)
* and validate the document tree.
*
* returns 1 if valid or 0 otherwise
*/
int
int ret;
return(0);
"no DTD found!\n", NULL);
return(0);
}
"Could not build URI for external subset \"%s\"\n",
return 0;
}
} else
"Could not load the external subset \"%s\"\n",
} else {
"Could not load the external subset \"%s\"\n",
}
return(0);
}
}
}
}
return(ret);
}
/************************************************************************
* *
* Routines for dynamic validation editing *
* *
************************************************************************/
/**
* xmlValidGetPotentialChildren:
* @ctree: an element content tree
* @names: an array to store the list of child names
* @len: a pointer to the number of element in the list
* @max: the size of the array
*
*
* returns the number of element in the list, or -1 in case of error.
*/
int
int i;
return(-1);
for (i = 0; i < *len;i++)
break;
for (i = 0; i < *len;i++)
break;
case XML_ELEMENT_CONTENT_SEQ:
break;
case XML_ELEMENT_CONTENT_OR:
break;
}
return(*len);
}
/*
* Dummy function to suppress messages while we try out valid elements
*/
const char *msg ATTRIBUTE_UNUSED, ...) {
return;
}
/**
* xmlValidGetValidElements:
* @prev: an element to insert after
* @next: an element to insert next
* @names: an array to store the list of child names
* @max: the size of the array
*
* This function returns the list of authorized children to insert
* within an existing tree while respecting the validity constraints
* forced by the Dtd. The insertion point is defined using @prev and
* @next in the following ways:
* to insert before 'node': xmlValidGetValidElements(node->prev, node, ...
* to insert next 'node': xmlValidGetValidElements(node, node->next, ...
* to replace 'node': xmlValidGetValidElements(node->prev, node->next, ...
* to prepend a child to 'node': xmlValidGetValidElements(NULL, node->childs,
* to append a child to 'node': xmlValidGetValidElements(node->last, NULL, ...
*
* pointers to the element names are inserted at the beginning of the array
* and do not need to be freed.
*
* returns the number of element in the list, or -1 in case of error. If
* the function returns the value @max the caller is invited to grow the
* receiving array and retry.
*/
int
int max) {
int nb_valid_elements = 0;
int nb_elements = 0, i;
return(-1);
if (max <= 0) return(-1);
nb_valid_elements = 0;
/*
* Retrieves the parent element declaration
*/
/*
* Do a backup of the current tree structure
*/
/*
* Creates a dummy node and insert it into the tree
*/
/*
* Insert each potential child node and check if the parent is
* still valid
*/
for (i = 0;i < nb_elements;i++) {
int j;
for (j = 0; j < nb_valid_elements;j++)
if (nb_valid_elements >= max) break;
}
}
/*
* Restore the tree structure
*/
/*
* Free up the dummy node
*/
return(nb_valid_elements);
}
#endif /* LIBXML_VALID_ENABLED */
#define bottom_valid
#include "elfgcchack.h"