/*
* relaxng.c : implementation of the Relax-NG handling and validity checking
*
* See Copyright for the status of this software.
*
* Daniel Veillard <veillard@redhat.com>
*/
/**
* TODO:
* - add support for DTD compatibility spec
* - report better mem allocations pbms at runtime and abort immediately.
*/
#define IN_LIBXML
#include "libxml.h"
#ifdef LIBXML_SCHEMAS_ENABLED
#include <string.h>
#include <stdio.h>
#include <libxml/xmlmemory.h>
#include <libxml/parserInternals.h>
#include <libxml/xmlschemastypes.h>
#include <libxml/xmlautomata.h>
#include <libxml/xmlregexp.h>
#include <libxml/xmlschemastypes.h>
/*
* The Relax-NG namespace
*/
#if 0
#define DEBUG 1
#define DEBUG_GRAMMAR 1
#define DEBUG_CONTENT 1
#define DEBUG_TYPE 1
#define DEBUG_VALID 1
#define DEBUG_INTERLEAVE 1
#define DEBUG_LIST 1
#define DEBUG_INCLUDE 1
#define DEBUG_ERROR 1
#define DEBUG_COMPILE 1
#define DEBUG_PROGRESSIVE 1
#endif
#define TODO \
"Unimplemented block at %s:%d\n", \
typedef enum {
typedef enum {
struct _xmlRelaxNGGrammar {
};
typedef enum {
struct _xmlRelaxNGDefine {
};
/**
* _xmlRelaxNG:
*
* A RelaxNGs definition
*/
struct _xmlRelaxNG {
};
struct _xmlRelaxNGParserCtxt {
const xmlChar *define; /* the current define scope */
int nbInterleaves;
const char *buffer;
int size;
/* the document stack */
/* the include stack */
/* used to compile content models */
};
/**
* xmlRelaxNGInterleaveGroup:
*
* A RelaxNGs partition set associated to lists of definitions
*/
struct _xmlRelaxNGInterleaveGroup {
};
/**
* xmlRelaxNGPartitions:
*
* A RelaxNGs partition associated to an interleave group
*/
struct _xmlRelaxNGPartition {
* right group when possible */
};
/**
* xmlRelaxNGValidState:
*
* A RelaxNGs validation state
*/
struct _xmlRelaxNGValidState {
};
/**
* xmlRelaxNGStates:
*
* A RelaxNGs container for validation state
*/
struct _xmlRelaxNGStates {
};
/**
* xmlRelaxNGValidError:
*
* A RelaxNGs validation error
*/
struct _xmlRelaxNGValidError {
};
/**
* xmlRelaxNGValidCtxt:
*
* A RelaxNGs validation context
*/
struct _xmlRelaxNGValidCtxt {
/*
* Errors accumulated in branches may have to be stacked to be
* provided back when it's sure they affect validation.
*/
int freeStatesNr;
int freeStatesMax;
/*
* This is used for "progressive" validation
*/
* outside the regexp */
};
/**
* xmlRelaxNGInclude:
*
* Structure associated to a RelaxNGs document element
*/
struct _xmlRelaxNGInclude {
};
/**
* xmlRelaxNGDocument:
*
* Structure associated to a RelaxNGs document element
*/
struct _xmlRelaxNGDocument {
};
/************************************************************************
* *
* Some factorized error routines *
* *
************************************************************************/
/**
* xmlRngPErrMemory:
* @ctxt: an Relax-NG parser context
* @extra: extra informations
*
* Handle a redefinition of attribute error
*/
static void
{
else
}
if (extra)
"Memory allocation failed : %s\n", extra);
else
}
/**
* xmlRngVErrMemory:
* @ctxt: a Relax-NG validation context
* @extra: extra informations
*
* Handle a redefinition of attribute error
*/
static void
{
else
}
if (extra)
"Memory allocation failed : %s\n", extra);
else
}
/**
* xmlRngPErr:
* @ctxt: a Relax-NG parser context
* @node: the node raising the error
* @error: the error code
* @msg: message
* @str1: extra info
* @str2: extra info
*
* Handle a Relax NG Parsing error
*/
static void
{
else
}
}
/**
* xmlRngVErr:
* @ctxt: a Relax-NG validation context
* @node: the node raising the error
* @error: the error code
* @msg: message
* @str1: extra info
* @str2: extra info
*
* Handle a Relax NG Validation error
*/
static void
{
else
}
}
/************************************************************************
* *
* Preliminary type checking interfaces *
* *
************************************************************************/
/**
* xmlRelaxNGTypeHave:
* @data: data needed for the library
* @type: the type name
* @value: the value to check
*
* Function provided by a type library to check if a type is exported
*
* Returns 1 if yes, 0 if no and -1 in case of error.
*/
/**
* xmlRelaxNGTypeCheck:
* @data: data needed for the library
* @type: the type name
* @value: the value to check
* @result: place to store the result if needed
*
* Function provided by a type library to check if a value match a type
*
* Returns 1 if yes, 0 if no and -1 in case of error.
*/
/**
* xmlRelaxNGFacetCheck:
* @data: data needed for the library
* @type: the type name
* @facet: the facet name
* @val: the facet value
* @strval: the string value
* @value: the value to check
*
* Function provided by a type library to check a value facet
*
* Returns 1 if yes, 0 if no and -1 in case of error.
*/
/**
* xmlRelaxNGTypeFree:
* @data: data needed for the library
* @result: the value to free
*
* Function provided by a type library to free a returned result
*/
/**
* xmlRelaxNGTypeCompare:
* @data: data needed for the library
* @type: the type name
* @value1: the first value
* @value2: the second value
*
* Function provided by a type library to compare two values accordingly
* to a type.
*
* Returns 1 if yes, 0 if no and -1 in case of error.
*/
void *comp1,
struct _xmlRelaxNGTypeLibrary {
};
/************************************************************************
* *
* Allocation functions *
* *
************************************************************************/
static void xmlRelaxNGFreeDefine(xmlRelaxNGDefinePtr define);
/**
* xmlRelaxNGFreeDocument:
* @docu: a document structure
*
* Deallocate a RelaxNG document structure.
*/
static void
{
return;
}
/**
* xmlRelaxNGFreeDocumentList:
* @docu: a list of document structure
*
* Deallocate a RelaxNG document structures.
*/
static void
{
}
}
/**
* xmlRelaxNGFreeInclude:
* @incl: a include structure
*
* Deallocate a RelaxNG include structure.
*/
static void
{
return;
}
/**
* xmlRelaxNGFreeIncludeList:
* @incl: a include structure list
*
* Deallocate a RelaxNG include structure.
*/
static void
{
}
}
/**
* xmlRelaxNGNewRelaxNG:
* @ctxt: a Relax-NG validation context (optional)
*
* Allocate a new RelaxNG structure.
*
* Returns the newly allocated structure or NULL in case or error
*/
static xmlRelaxNGPtr
{
return (NULL);
}
return (ret);
}
/**
* xmlRelaxNGFreeInnerSchema:
* @schema: a schema structure
*
* Deallocate a RelaxNG schema structure.
*/
static void
{
return;
int i;
}
}
/**
* xmlRelaxNGFree:
* @schema: a schema structure
*
* Deallocate a RelaxNG structure.
*/
void
{
return;
int i;
}
}
/**
* xmlRelaxNGNewGrammar:
* @ctxt: a Relax-NG validation context (optional)
*
* Allocate a new RelaxNG grammar.
*
* Returns the newly allocated structure or NULL in case or error
*/
static xmlRelaxNGGrammarPtr
{
return (NULL);
}
return (ret);
}
/**
* xmlRelaxNGFreeGrammar:
* @grammar: a grammar structure
*
* Deallocate a RelaxNG grammar structure.
*/
static void
{
return;
}
}
}
}
}
/**
* xmlRelaxNGNewDefine:
* @ctxt: a Relax-NG validation context
* @node: the node in the input document.
*
* Allocate a new RelaxNG define.
*
* Returns the newly allocated structure or NULL in case or error
*/
static xmlRelaxNGDefinePtr
{
return (NULL);
}
sizeof
return (NULL);
}
}
return (NULL);
}
return (ret);
}
/**
* xmlRelaxNGFreePartition:
* @partitions: a partition set structure
*
* Deallocate RelaxNG partition set structures.
*/
static void
{
int j;
if (partitions != NULL) {
for (j = 0; j < partitions->nbgroups; j++) {
}
}
}
}
}
}
/**
* xmlRelaxNGFreeDefine:
* @define: a define structure
*
* Deallocate a RelaxNG define structure.
*/
static void
{
if (define == NULL)
return;
}
xmlRegFreeRegexp(define->contModel);
xmlFree(define);
}
/**
* xmlRelaxNGNewStates:
* @ctxt: a Relax-NG validation context
* @size: the default size for the container
*
* Allocate a new RelaxNG validation state container
*
* Returns the newly allocated structure or NULL in case or error
*/
static xmlRelaxNGStatesPtr
{
ctxt->freeStatesNr--;
return (ret);
}
if (size < 16)
size = 16;
(size -
1) *
sizeof(xmlRelaxNGValidStatePtr));
return (NULL);
}
sizeof
return (NULL);
}
return (ret);
}
/**
* xmlRelaxNGAddStateUniq:
* @ctxt: a Relax-NG validation context
* @states: the states container
* @state: the validation state
*
* Add a RelaxNG validation state to the container without checking
* for unicity.
*
* Return 1 in case of success and 0 if this is a duplicate and -1 on error
*/
static int
{
return (-1);
}
int size;
(size) *
sizeof
return (-1);
}
}
return (1);
}
/**
* xmlRelaxNGAddState:
* @ctxt: a Relax-NG validation context
* @states: the states container
* @state: the validation state
*
* Add a RelaxNG validation state to the container
*
* Return 1 in case of success and 0 if this is a duplicate and -1 on error
*/
static int
{
int i;
return (-1);
}
int size;
(size) *
sizeof
return (-1);
}
}
return (0);
}
}
return (1);
}
/**
* xmlRelaxNGFreeStates:
* @ctxt: a Relax-NG validation context
* @states: teh container
*
* Free a RelaxNG validation state container
*/
static void
{
return;
ctxt->freeStatesNr = 0;
}
sizeof
return;
}
}
} else {
}
}
/**
* xmlRelaxNGNewValidState:
* @ctxt: a Relax-NG validation context
* @node: the current node or NULL for the document
*
* Allocate a new RelaxNG validation state
*
* Returns the newly allocated structure or NULL in case or error
*/
static xmlRelaxNGValidStatePtr
{
int nbAttrs = 0;
return (NULL);
} else {
else
nbAttrs++;
}
}
} else {
ret =
xmlMalloc(sizeof(xmlRelaxNGValidState));
return (NULL);
}
}
} else {
}
if (nbAttrs > 0) {
if (nbAttrs < 4)
else
sizeof(xmlAttrPtr));
return (ret);
}
sizeof(xmlAttrPtr));
return (ret);
}
}
} else {
nbAttrs = 0;
}
}
}
return (ret);
}
/**
* xmlRelaxNGCopyValidState:
* @ctxt: a Relax-NG validation context
* @state: a validation state
*
* Copy the validation state
*
* Returns the newly allocated structure or NULL in case or error
*/
static xmlRelaxNGValidStatePtr
{
unsigned int maxAttrs;
return (NULL);
} else {
ret =
xmlMalloc(sizeof(xmlRelaxNGValidState));
return (NULL);
}
}
sizeof(xmlAttrPtr));
return (ret);
}
sizeof(xmlAttrPtr));
return (ret);
}
}
}
return (ret);
}
/**
* xmlRelaxNGEqualValidState:
* @ctxt: a Relax-NG validation context
* @state1: a validation state
* @state2: a validation state
*
* Compare the validation states for equality
*
* Returns 1 if equald, 0 otherwise
*/
static int
{
int i;
return (0);
return (1);
return (0);
return (0);
return (0);
return (0);
return (0);
return (0);
return (0);
}
return (1);
}
/**
* xmlRelaxNGFreeValidState:
* @state: a validation state structure
*
* Deallocate a RelaxNG validation state structure.
*/
static void
{
return;
}
} else {
}
}
/************************************************************************
* *
* Semi internal functions *
* *
************************************************************************/
/**
* xmlRelaxParserSetFlag:
* @ctxt: a RelaxNG parser context
* @flags: a set of flags values
*
* Semi private function used to pass informations to a parser context
* which are a combination of xmlRelaxNGParserFlag .
*
* Returns 0 if success and -1 in case of error
*/
int
{
if (flags & XML_RELAXNGP_FREE_DOC) {
}
if (flags & XML_RELAXNGP_CRNG) {
}
if (flags != 0) return(-1);
return(0);
}
/************************************************************************
* *
* Document functions *
* *
************************************************************************/
/**
* xmlRelaxNGIncludePush:
* @ctxt: the parser context
* @value: the element doc
*
* Pushes a new include on top of the include stack
*
* Returns 0 in case of error, the index in the stack otherwise
*/
static int
{
return (0);
}
}
return (0);
}
}
}
/**
* xmlRelaxNGIncludePop:
* @ctxt: the parser context
*
* Pops the top include from the include stack
*
* Returns the include just removed
*/
static xmlRelaxNGIncludePtr
{
return (NULL);
else
return (ret);
}
/**
* xmlRelaxNGRemoveRedefine:
* @ctxt: the parser context
* @URL: the normalized URL
* @target: the included target
* @name: the define name to eliminate
*
* Applies the elimination algorithm of 4.7
*
* Returns 0 in case of error, 1 in case of success.
*/
static int
{
int found = 0;
#ifdef DEBUG_INCLUDE
"Elimination of <include> start from %s\n", URL);
else
"Elimination of <include> define %s from %s\n",
#endif
found = 1;
found = 1;
}
}
if (xmlStrEqual
#ifdef DEBUG_INCLUDE
#endif
found = 1;
}
#ifdef DEBUG_INCLUDE
#endif
}
}
}
}
return (found);
}
/**
* xmlRelaxNGLoadInclude:
* @ctxt: the parser context
* @URL: the normalized URL
* @node: the include node.
* @ns: the namespace passed from the context.
*
* First lookup if the document is already loaded into the parser context,
* check against recursion. If not found the resource is loaded and
* the content is preprocessed before being returned back to the caller.
*
* Returns the xmlRelaxNGIncludePtr or NULL in case of error
*/
static xmlRelaxNGIncludePtr
{
int i;
#ifdef DEBUG_INCLUDE
"xmlRelaxNGLoadInclude(%s)\n", URL);
#endif
/*
* check against recursion in the stack
*/
"Detected an Include recursion for %s\n", URL,
NULL);
return (NULL);
}
}
/*
* load the document
*/
return (NULL);
}
#ifdef DEBUG_INCLUDE
#endif
/*
* Allocate the document structures and register it first.
*/
return (NULL);
}
/*
* transmit the ns if needed
*/
}
}
}
/*
* push it on the stack
*/
/*
* Some preprocessing of the document content, this include recursing
* in the include stack.
*/
#ifdef DEBUG_INCLUDE
#endif
return (NULL);
}
/*
* Pop up the include from the stack
*/
#ifdef DEBUG_INCLUDE
#endif
/*
* Check that the top element is a grammar
*/
"xmlRelaxNG: included document is empty %s\n", URL,
NULL);
return (NULL);
}
"xmlRelaxNG: included document %s root is not a grammar\n",
return (NULL);
}
/*
* Elimination of redefined rules in the include.
*/
int found = 0;
found =
if (!found) {
"xmlRelaxNG: include %s has a start but not the included grammar\n",
}
"xmlRelaxNG: include %s has define without name\n",
} else {
int found;
if (!found) {
"xmlRelaxNG: include %s has a define %s but not the included grammar\n",
}
}
}
}
return (ret);
}
/**
* xmlRelaxNGValidErrorPush:
* @ctxt: the validation context
* @err: the error code
* @arg1: the first string argument
* @arg2: the second string argument
* @dup: arg need to be duplicated
*
* Pushes a new error on top of the error stack
*
* Returns 0 in case of error, the index in the stack otherwise
*/
static int
{
#ifdef DEBUG_ERROR
#endif
sizeof
return (0);
}
}
sizeof
return (0);
}
}
if (dup) {
} else {
}
} else {
}
}
/**
* xmlRelaxNGValidErrorPop:
* @ctxt: the validation context
*
* Pops the top error from the error stack
*/
static void
{
return;
}
else
}
}
/**
* xmlRelaxNGDocumentPush:
* @ctxt: the parser context
* @value: the element doc
*
* Pushes a new doc on top of the doc stack
*
* Returns 0 in case of error, the index in the stack otherwise
*/
static int
{
return (0);
}
}
return (0);
}
}
}
/**
* xmlRelaxNGDocumentPop:
* @ctxt: the parser context
*
* Pops the top doc from the doc stack
*
* Returns the doc just removed
*/
static xmlRelaxNGDocumentPtr
{
return (NULL);
else
return (ret);
}
/**
* xmlRelaxNGLoadExternalRef:
* @ctxt: the parser context
* @URL: the normalized URL
* @ns: the inherited ns if any
*
* First lookup if the document is already loaded into the parser context,
* check against recursion. If not found the resource is loaded and
* the content is preprocessed before being returned back to the caller.
*
* Returns the xmlRelaxNGDocumentPtr or NULL in case of error
*/
static xmlRelaxNGDocumentPtr
{
int i;
/*
* check against recursion in the stack
*/
"Detected an externalRef recursion for %s\n", URL,
NULL);
return (NULL);
}
}
/*
* load the document
*/
return (NULL);
}
/*
* Allocate the document structures and register it first.
*/
return (NULL);
}
/*
* transmit the ns if needed
*/
}
}
}
/*
* push it on the stack and register it in the hash table
*/
/*
* Some preprocessing of the document content
*/
return (NULL);
}
return (ret);
}
/************************************************************************
* *
* Error functions *
* *
************************************************************************/
static const char *
{
return ("none");
case XML_RELAXNG_EMPTY:
return ("empty");
case XML_RELAXNG_NOT_ALLOWED:
return ("notAllowed");
case XML_RELAXNG_EXCEPT:
return ("except");
case XML_RELAXNG_TEXT:
return ("text");
case XML_RELAXNG_ELEMENT:
return ("element");
case XML_RELAXNG_DATATYPE:
return ("datatype");
case XML_RELAXNG_VALUE:
return ("value");
case XML_RELAXNG_LIST:
return ("list");
case XML_RELAXNG_ATTRIBUTE:
return ("attribute");
case XML_RELAXNG_DEF:
return ("def");
case XML_RELAXNG_REF:
return ("ref");
case XML_RELAXNG_EXTERNALREF:
return ("externalRef");
case XML_RELAXNG_PARENTREF:
return ("parentRef");
case XML_RELAXNG_OPTIONAL:
return ("optional");
case XML_RELAXNG_ZEROORMORE:
return ("zeroOrMore");
case XML_RELAXNG_ONEORMORE:
return ("oneOrMore");
case XML_RELAXNG_CHOICE:
return ("choice");
case XML_RELAXNG_GROUP:
return ("group");
case XML_RELAXNG_INTERLEAVE:
return ("interleave");
case XML_RELAXNG_START:
return ("start");
case XML_RELAXNG_NOOP:
return ("noop");
case XML_RELAXNG_PARAM:
return ("param");
}
return ("unknown");
}
/**
* xmlRelaxNGGetErrorString:
* @err: the error code
* @arg1: the first string argument
* @arg2: the second string argument
*
* computes a formatted error string for the given error code and args
*
* Returns the error string, it must be deallocated by the caller
*/
static xmlChar *
{
msg[0] = 0;
switch (err) {
case XML_RELAXNG_OK:
return (NULL);
case XML_RELAXNG_ERR_MEMORY:
return (xmlCharStrdup("out of memory\n"));
case XML_RELAXNG_ERR_TYPE:
break;
case XML_RELAXNG_ERR_TYPEVAL:
arg2);
break;
case XML_RELAXNG_ERR_DUPID:
break;
case XML_RELAXNG_ERR_TYPECMP:
break;
case XML_RELAXNG_ERR_NOSTATE:
return (xmlCharStrdup("Internal error: no state\n"));
case XML_RELAXNG_ERR_NODEFINE:
return (xmlCharStrdup("Internal error: no define\n"));
case XML_RELAXNG_ERR_INTERNAL:
break;
break;
return (xmlCharStrdup
("Internal: interleave block has no data\n"));
case XML_RELAXNG_ERR_INTERSEQ:
return (xmlCharStrdup("Invalid sequence in interleave\n"));
break;
case XML_RELAXNG_ERR_ELEMNAME:
arg2);
break;
case XML_RELAXNG_ERR_ELEMNONS:
arg1);
break;
"Element %s has wrong namespace: expecting %s\n", arg1,
arg2);
break;
break;
"Did not expect text in element %s content\n", arg1);
break;
arg1);
break;
break;
case XML_RELAXNG_ERR_NOELEM:
arg1);
break;
case XML_RELAXNG_ERR_NOTELEM:
return (xmlCharStrdup("Expecting an element got text\n"));
arg1);
break;
arg1);
break;
break;
break;
case XML_RELAXNG_ERR_LACKDATA:
arg1);
break;
case XML_RELAXNG_ERR_DATAELEM:
arg1);
break;
case XML_RELAXNG_ERR_VALELEM:
arg1);
break;
case XML_RELAXNG_ERR_LISTELEM:
arg1);
break;
case XML_RELAXNG_ERR_DATATYPE:
break;
case XML_RELAXNG_ERR_VALUE:
break;
case XML_RELAXNG_ERR_LIST:
return (xmlCharStrdup("Error validating list\n"));
return (xmlCharStrdup("No top grammar defined\n"));
return (xmlCharStrdup("Extra data in the document\n"));
default:
return (xmlCharStrdup("Unknown error !\n"));
}
if (msg[0] == 0) {
}
}
/**
* xmlRelaxNGShowValidError:
* @ctxt: the validation context
* @err: the error number
* @node: the node
* @child: the node child generating the problem.
* @arg1: the first argument
* @arg2: the second argument
*
* Show a validation error.
*/
static void
{
return;
#ifdef DEBUG_ERROR
#endif
return;
}
/**
* xmlRelaxNGPopErrors:
* @ctxt: the validation context
* @level: the error level in the stack
*
* pop and discard all errors until the given level is reached
*/
static void
{
int i;
#ifdef DEBUG_ERROR
"Pop errors till level %d\n", level);
#endif
}
}
}
/**
* xmlRelaxNGDumpValidError:
* @ctxt: the validation context
*
* Show all validation error over a given index.
*/
static void
{
int i, j, k;
#ifdef DEBUG_ERROR
#endif
if (k < MAX_ERROR) {
for (j = 0; j < i; j++) {
goto skip;
}
}
k++;
}
skip:
}
}
}
/**
* xmlRelaxNGAddValidError:
* @ctxt: the validation context
* @err: the error number
* @arg1: the first argument
* @arg2: the second argument
* @dup: need to dup the args
*
* Register a validation error, either generating it if it's sure
* or stacking it for later handling if unsure.
*/
static void
{
return;
return;
#ifdef DEBUG_ERROR
#endif
/*
* generate the error directly
*/
/*
* Flush first any stacked error which might be the
* real cause of the problem.
*/
} else {
}
}
/*
* Stack the error for later processing if needed
*/
else {
}
}
/************************************************************************
* *
* Type library hooks *
* *
************************************************************************/
/**
* xmlRelaxNGSchemaTypeHave:
* @data: data needed for the library
* @type: the type name
*
* Check if the given type is provided by
* the W3C XMLSchema Datatype library.
*
* Returns 1 if yes, 0 if no and -1 in case of error.
*/
static int
{
return (-1);
return (0);
return (1);
}
/**
* xmlRelaxNGSchemaTypeCheck:
* @data: data needed for the library
* @type: the type name
* @value: the value to check
* @node: the node
*
* Check if the given type and value are validated by
* the W3C XMLSchema Datatype library.
*
* Returns 1 if yes, 0 if no and -1 in case of error.
*/
static int
{
int ret;
return (-1);
return (-1);
return (2);
if (ret == 0)
return (1);
if (ret > 0)
return (0);
return (-1);
}
/**
* xmlRelaxNGSchemaFacetCheck:
* @data: data needed for the library
* @type: the type name
* @facet: the facet name
* @val: the facet value
* @strval: the string value
* @value: the value to check
*
* Function provided by a type library to check a value facet
*
* Returns 1 if yes, 0 if no and -1 in case of error.
*/
static int
void *value)
{
int ret;
return (-1);
return (-1);
facet = xmlSchemaNewFacet();
return (-1);
} else {
return (-1);
}
if (ret != 0) {
return (-1);
}
if (ret != 0)
return (-1);
return (0);
}
/**
* xmlRelaxNGSchemaFreeValue:
* @data: data needed for the library
* @value: the value to free
*
* Function provided by a type library to free a Schemas value
*
* Returns 1 if yes, 0 if no and -1 in case of error.
*/
static void
{
}
/**
* xmlRelaxNGSchemaTypeCompare:
* @data: data needed for the library
* @type: the type name
* @value1: the first value
* @value2: the second value
*
* Compare two values for equality accordingly a type from the W3C XMLSchema
* Datatype library.
*
* Returns 1 if equal, 0 if no and -1 in case of error.
*/
static int
void *comp1,
{
int ret;
return (-1);
return (-1);
if (ret != 0)
return (-1);
return (-1);
} else {
}
if (ret != 0) {
return (-1);
}
return (-1);
}
if (ret == -2)
return (-1);
if (ret == 0)
return (1);
return (0);
}
/**
* xmlRelaxNGDefaultTypeHave:
* @data: data needed for the library
* @type: the type name
*
* Check if the given type is provided by
* the default datatype library.
*
* Returns 1 if yes, 0 if no and -1 in case of error.
*/
static int
{
return (-1);
return (1);
return (1);
return (0);
}
/**
* xmlRelaxNGDefaultTypeCheck:
* @data: data needed for the library
* @type: the type name
* @value: the value to check
* @node: the node
*
* Check if the given type and value are validated by
* the default datatype library.
*
* Returns 1 if yes, 0 if no and -1 in case of error.
*/
static int
void **result ATTRIBUTE_UNUSED,
{
return (-1);
return (1);
return (1);
}
return (0);
}
/**
* xmlRelaxNGDefaultTypeCompare:
* @data: data needed for the library
* @type: the type name
* @value1: the first value
* @value2: the second value
*
* Compare two values accordingly a type from the default
* datatype library.
*
* Returns 1 if yes, 0 if no and -1 in case of error.
*/
static int
void *comp1 ATTRIBUTE_UNUSED,
{
/*
* TODO: trivial optimizations are possible by
* computing at compile-time
*/
ret = -1;
ret = 1;
else
ret = 0;
} else
ret = 1;
}
return (ret);
}
static int xmlRelaxNGTypeInitialized = 0;
/**
* xmlRelaxNGFreeTypeLibrary:
* @lib: the type library structure
* @namespace: the URI bound to the library
*
* Free the structure associated to the type library
*/
static void
{
return;
}
/**
* xmlRelaxNGRegisterTypeLibrary:
* @namespace: the URI bound to the library
* @data: data associated to the library
* @have: the provide function
* @check: the checking function
* @comp: the comparison function
*
* Register a new type library
*
* Returns 0 in case of success and -1 in case of error.
*/
static int
{
int ret;
return (-1);
"Relax-NG types library '%s' already registered\n",
return (-1);
}
lib =
xmlMalloc(sizeof(xmlRelaxNGTypeLibrary));
return (-1);
}
if (ret < 0) {
"Relax-NG types library failed to register '%s'\n",
return (-1);
}
return (0);
}
/**
* xmlRelaxNGInitTypes:
*
* Initilize the default type libraries.
*
* Returns 0 in case of success and -1 in case of error.
*/
int
xmlRelaxNGInitTypes(void)
{
if (xmlRelaxNGTypeInitialized != 0)
return (0);
if (xmlRelaxNGRegisteredTypes == NULL) {
"Failed to allocate sh table for Relax-NG types\n");
return (-1);
}
NULL);
return (0);
}
/**
* xmlRelaxNGCleanupTypes:
*
* Cleanup the default Schemas type library associated to RelaxNG
*/
void
xmlRelaxNGCleanupTypes(void)
{
if (xmlRelaxNGTypeInitialized == 0)
return;
}
/************************************************************************
* *
* Compiling element content into regexp *
* *
* Sometime the element content can be compiled into a pure regexp, *
* This allows a faster execution and streamability at that level *
* *
************************************************************************/
/**
* xmlRelaxNGIsCompileable:
* @define: the definition to check
*
* Check if a definition is nullable.
*
* Returns 1 if yes, 0 if no and -1 in case of error
*/
static int
{
return (-1);
}
return (1);
return (0);
case XML_RELAXNG_NOOP:
break;
case XML_RELAXNG_TEXT:
case XML_RELAXNG_EMPTY:
ret = 1;
break;
case XML_RELAXNG_ELEMENT:
/*
* Check if the element content is compileable
*/
if (ret != 1)
break;
}
/*
* Because the routine is recursive, we must guard against
* discovering both COMPILABLE and NOT_COMPILABLE
*/
if (ret == 0) {
}
#ifdef DEBUG_COMPILE
if (ret == 1) {
"element content for %s is compilable\n",
} else if (ret == 0) {
"element content for %s is not compilable\n",
} else {
"Problem in RelaxNGIsCompileable for element %s\n",
}
#endif
}
/*
* All elements return a compileable status unless they
* are generic like anyName
*/
ret = 0;
else
ret = 1;
return (ret);
case XML_RELAXNG_REF:
case XML_RELAXNG_EXTERNALREF:
case XML_RELAXNG_PARENTREF:
return (1);
} else {
if (ret != 1)
break;
}
}
break;
case XML_RELAXNG_START:
case XML_RELAXNG_OPTIONAL:
case XML_RELAXNG_ZEROORMORE:
case XML_RELAXNG_ONEORMORE:
case XML_RELAXNG_CHOICE:
case XML_RELAXNG_GROUP:
case XML_RELAXNG_DEF:{
if (ret != 1)
break;
}
break;
}
case XML_RELAXNG_EXCEPT:
case XML_RELAXNG_ATTRIBUTE:
case XML_RELAXNG_INTERLEAVE:
case XML_RELAXNG_DATATYPE:
case XML_RELAXNG_LIST:
case XML_RELAXNG_PARAM:
case XML_RELAXNG_VALUE:
case XML_RELAXNG_NOT_ALLOWED:
ret = 0;
break;
}
if (ret == 0)
if (ret == 1)
#ifdef DEBUG_COMPILE
if (ret == 1) {
"RelaxNGIsCompileable %s : true\n",
} else if (ret == 0) {
"RelaxNGIsCompileable %s : false\n",
} else {
"Problem in RelaxNGIsCompileable %s\n",
}
#endif
return (ret);
}
/**
* xmlRelaxNGCompile:
* ctxt: the RelaxNG parser context
* @define: the definition tree to compile
*
* Compile the set of definitions, it works recursively, till the
* element boundaries, where it tries to compile the content if possible
*
* Returns 0 if success and -1 in case of error
*/
static int
{
int ret = 0;
return (-1);
case XML_RELAXNG_START:
return (-1);
}
}
break;
case XML_RELAXNG_ELEMENT:
def);
}
return (-1);
}
/*
* we can only use the automata if it is determinist
*/
}
} else {
/*
* we can't build the content model for this element content
* but it still might be possible to build it for some of its
* children, recurse.
*/
}
break;
case XML_RELAXNG_NOOP:
break;
case XML_RELAXNG_OPTIONAL:{
break;
}
case XML_RELAXNG_ZEROORMORE:{
}
break;
}
case XML_RELAXNG_ONEORMORE:{
}
}
break;
}
case XML_RELAXNG_CHOICE:{
if (ret != 0)
break;
else {
target);
}
}
break;
}
case XML_RELAXNG_REF:
case XML_RELAXNG_EXTERNALREF:
case XML_RELAXNG_PARENTREF:
case XML_RELAXNG_GROUP:
case XML_RELAXNG_DEF:
if (ret != 0)
break;
}
break;
case XML_RELAXNG_TEXT:{
NULL);
break;
}
case XML_RELAXNG_EMPTY:
break;
case XML_RELAXNG_EXCEPT:
case XML_RELAXNG_ATTRIBUTE:
case XML_RELAXNG_INTERLEAVE:
case XML_RELAXNG_NOT_ALLOWED:
case XML_RELAXNG_DATATYPE:
case XML_RELAXNG_LIST:
case XML_RELAXNG_PARAM:
case XML_RELAXNG_VALUE:
/* This should not happen and generate an internal error */
break;
}
return (ret);
}
/**
* xmlRelaxNGTryCompile:
* ctxt: the RelaxNG parser context
* @define: the definition tree to compile
*
* Try to compile the set of definitions, it works recursively,
* possibly ignoring parts which cannot be compiled.
*
* Returns 0 if success and -1 in case of error
*/
static int
{
int ret = 0;
return (-1);
#ifdef DEBUG_PROGRESSIVE
if (ret == 0) {
"compiled the start\n");
else
} else {
"failed to compile the start\n");
else
"failed to compile element %s\n",
}
#endif
return (ret);
}
}
case XML_RELAXNG_NOOP:
break;
case XML_RELAXNG_TEXT:
case XML_RELAXNG_DATATYPE:
case XML_RELAXNG_LIST:
case XML_RELAXNG_PARAM:
case XML_RELAXNG_VALUE:
case XML_RELAXNG_EMPTY:
case XML_RELAXNG_ELEMENT:
ret = 0;
break;
case XML_RELAXNG_OPTIONAL:
case XML_RELAXNG_ZEROORMORE:
case XML_RELAXNG_ONEORMORE:
case XML_RELAXNG_CHOICE:
case XML_RELAXNG_GROUP:
case XML_RELAXNG_DEF:
case XML_RELAXNG_START:
case XML_RELAXNG_REF:
case XML_RELAXNG_EXTERNALREF:
case XML_RELAXNG_PARENTREF:
if (ret != 0)
break;
}
break;
case XML_RELAXNG_EXCEPT:
case XML_RELAXNG_ATTRIBUTE:
case XML_RELAXNG_INTERLEAVE:
case XML_RELAXNG_NOT_ALLOWED:
ret = 0;
break;
}
return (ret);
}
/************************************************************************
* *
* Parsing functions *
* *
************************************************************************/
int group);
def);
xmlRelaxNGDefinePtr define,
/**
* xmlRelaxNGIsNullable:
* @define: the definition to verify
*
* Check if a definition is nullable.
*
* Returns 1 if yes, 0 if no and -1 in case of error
*/
static int
{
int ret;
if (define == NULL)
return (-1);
if (define->dflags & IS_NULLABLE)
return (1);
if (define->dflags & IS_NOT_NULLABLE)
return (0);
switch (define->type) {
case XML_RELAXNG_EMPTY:
case XML_RELAXNG_TEXT:
ret = 1;
break;
case XML_RELAXNG_NOOP:
case XML_RELAXNG_DEF:
case XML_RELAXNG_REF:
case XML_RELAXNG_EXTERNALREF:
case XML_RELAXNG_PARENTREF:
case XML_RELAXNG_ONEORMORE:
break;
case XML_RELAXNG_EXCEPT:
case XML_RELAXNG_NOT_ALLOWED:
case XML_RELAXNG_ELEMENT:
case XML_RELAXNG_DATATYPE:
case XML_RELAXNG_PARAM:
case XML_RELAXNG_VALUE:
case XML_RELAXNG_LIST:
case XML_RELAXNG_ATTRIBUTE:
ret = 0;
break;
case XML_RELAXNG_CHOICE:{
if (ret != 0)
goto done;
}
ret = 0;
break;
}
case XML_RELAXNG_START:
case XML_RELAXNG_INTERLEAVE:
case XML_RELAXNG_GROUP:{
if (ret != 1)
goto done;
}
return (1);
}
default:
return (-1);
}
done:
if (ret == 0)
define->dflags |= IS_NOT_NULLABLE;
if (ret == 1)
define->dflags |= IS_NULLABLE;
return (ret);
}
/**
* xmlRelaxNGIsBlank:
* @str: a string
*
* Check if a string is ignorable c.f. 4.2. Whitespace
*
* Returns 1 if the string is NULL or made of blanks chars, 0 otherwise
*/
static int
{
return (1);
while (*str != 0) {
if (!(IS_BLANK_CH(*str)))
return (0);
str++;
}
return (1);
}
/**
* xmlRelaxNGGetDataTypeLibrary:
* @ctxt: a Relax-NG parser context
* @node: the current data or value element
*
* Applies algorithm from 4.3. datatypeLibrary attribute
*
* Returns the datatypeLibary value or NULL if not found
*/
static xmlChar *
{
if (ret[0] == 0) {
return (NULL);
}
return (ret);
}
return (escape);
}
}
if (ret[0] == 0) {
return (NULL);
}
return (ret);
}
return (escape);
}
}
return (NULL);
}
/**
* xmlRelaxNGParseValue:
* @ctxt: a Relax-NG parser context
* @node: the data node.
*
* parse the content of a RelaxNG value node.
*
* Returns the definition pointer or NULL in case of error
*/
static xmlRelaxNGDefinePtr
{
int success = 0;
return (NULL);
if (xmlValidateNCName(type, 0)) {
}
library =
"Use of unregistered type library '%s'\n", library,
NULL);
} else {
"Internal error with type library '%s': no 'have'\n",
} else {
if (success != 1) {
"Error type '%s' is not exported by type library '%s'\n",
}
}
}
}
"Expecting a single text value for <value>content\n",
success =
if (success != 1) {
"Value '%s' is not acceptable for type '%s'\n",
} else {
}
}
}
return (def);
}
/**
* xmlRelaxNGParseData:
* @ctxt: a Relax-NG parser context
* @node: the data node.
*
* parse the content of a RelaxNG data node.
*
* Returns the definition pointer or NULL in case of error
*/
static xmlRelaxNGDefinePtr
{
int tmp;
NULL);
return (NULL);
}
if (xmlValidateNCName(type, 0)) {
}
library =
return (NULL);
}
"Use of unregistered type library '%s'\n", library,
NULL);
} else {
"Internal error with type library '%s': no 'have'\n",
} else {
if (tmp != 1) {
"Error type '%s' is not exported by type library '%s'\n",
} else
if ((xmlStrEqual
(library,
}
}
}
/*
* Handle optional params
*/
break;
if (xmlStrEqual(library,
"Type library '%s' does not allow type parameters\n",
} else {
}
} else {
}
}
}
}
}
/*
* Handle optional except
*/
return (def);
}
}
} else {
}
}
}
}
/*
* Check there is no unhandled data
*/
"Element data has unexpected content %s\n",
}
return (def);
}
/**
* xmlRelaxNGCompareNameClasses:
* @name: the restriction on the name
* @ns: the restriction on the namespace
*
* Compare the 2 lists of element definitions. The comparison is
* that if both lists do not accept the same QNames, it returns 1
* If the 2 lists can accept the same QName the comparison returns 0
*
* Returns 1 disttinct, 0 if equal
*/
static int
{
return (1);
} else {
}
} else {
}
} else {
}
} else {
ret = 0;
}
} else {
ret = 1;
}
return (0);
return (1);
} else {
}
if (ret == 0)
return (ret);
} else {
}
} else {
}
} else {
}
} else {
ret = 0;
}
} else {
ret = 1;
}
} else {
}
return (ret);
}
/**
* xmlRelaxNGCompareElemDefLists:
* @ctxt: a Relax-NG parser context
*
* Compare the 2 lists of element or attribute definitions. The comparison
* is that if both lists do not accept the same QNames, it returns 1
* If the 2 lists can accept the same QName the comparison returns 0
*
* Returns 1 disttinct, 0 if equal
*/
static int
{
return (1);
return (1);
return (0);
def2++;
}
def1++;
}
return (1);
}
/**
* xmlRelaxNGGenerateAttributes:
* @ctxt: a Relax-NG parser context
* @def: the definition definition
*
* Check if the definition can only generate attributes
*
* Returns 1 if yes, 0 if no and -1 in case of error.
*/
static int
{
/*
* Don't run that check in case of error. Infinite recursion
* becomes possible.
*/
return (-1);
return (0);
}
continue;
}
}
break;
continue;
}
do {
break;
return (1);
break;
}
}
return (1);
}
/**
* xmlRelaxNGGetElements:
* @ctxt: a Relax-NG parser context
* @def: the definition definition
* @eora: gather elements (0) or attributes (1)
*
* Compute the list of top elements a definition can generate
*
* Returns a list of elements or NULL if none was found.
*/
static xmlRelaxNGDefinePtr *
{
int len = 0;
int max = 0;
/*
* Don't run that check in case of error. Infinite recursion
* becomes possible.
*/
return (NULL);
max = 10;
ret = (xmlRelaxNGDefinePtr *)
return (NULL);
}
max *= 2;
return (NULL);
}
}
/*
* Don't go within elements or attributes or string values.
* Just gather the element top list
*/
}
continue;
}
}
break;
continue;
}
do {
break;
return (ret);
break;
}
}
return (ret);
}
/**
* xmlRelaxNGCheckChoiceDeterminism:
* @ctxt: a Relax-NG parser context
* @def: the choice definition
*
* Also used to find indeterministic pattern in choice
*/
static void
{
int is_nullable = 0;
int is_indeterminist = 0;
return;
return;
/*
* Don't run that check in case of error. Infinite recursion
* becomes possible.
*/
return;
nbchild++;
}
sizeof(xmlRelaxNGDefinePtr
*));
return;
}
i = 0;
/*
* a bit strong but safe
*/
if (is_nullable == 0) {
} else {
is_triable = 0;
}
is_triable = 0;
} else if (is_triable == 1) {
int res;
(void *) cur);
if (res != 0)
is_triable = -1;
(void *) cur);
else
(void *) cur);
if (res != 0)
is_triable = -1;
(void *) cur);
else
(void *) cur);
if (res != 0)
is_triable = -1;
} else {
is_triable = -1;
}
tmp++;
}
}
i++;
}
for (i = 0; i < nbchild; i++) {
continue;
for (j = 0; j < i; j++) {
continue;
if (ret == 0) {
is_indeterminist = 1;
}
}
}
for (i = 0; i < nbchild; i++) {
}
if (is_indeterminist) {
}
if (is_triable == 1) {
}
}
/**
* xmlRelaxNGCheckGroupAttrs:
* @ctxt: a Relax-NG parser context
* @def: the group definition
*
* Detects violations of rule 7.3
*/
static void
{
return;
return;
/*
* Don't run that check in case of error. Infinite recursion
* becomes possible.
*/
return;
nbchild++;
}
nbchild++;
}
sizeof(xmlRelaxNGDefinePtr
*));
return;
}
i = 0;
i++;
}
i++;
}
for (i = 0; i < nbchild; i++) {
continue;
for (j = 0; j < i; j++) {
continue;
if (ret == 0) {
}
}
}
for (i = 0; i < nbchild; i++) {
}
}
/**
* xmlRelaxNGComputeInterleaves:
* @def: the interleave definition
* @ctxt: a Relax-NG parser context
* @name: the definition name
*
* A lot of work for preprocessing interleave definitions
* is potentially needed to get a decent execution speed at runtime
* - trying to get a total order on the element nodes generated
* by the interleaves, order the list of interleave definitions
* following that order.
* - if <text/> is used to handle mixed content, it is better to
* flag this in the define and simplify the runtime checking
* algorithm
*/
static void
{
int nbgroups = 0;
int nbchild = 0;
int is_mixed = 0;
/*
* Don't run that check in case of error. Infinite recursion
* becomes possible.
*/
return;
#ifdef DEBUG_INTERLEAVE
"xmlRelaxNGComputeInterleaves(%s)\n", name);
#endif
nbchild++;
}
#ifdef DEBUG_INTERLEAVE
#endif
goto error;
xmlMalloc(sizeof(xmlRelaxNGInterleaveGroup));
goto error;
is_mixed++;
nbgroups++;
}
#ifdef DEBUG_INTERLEAVE
#endif
/*
* Let's check that all rules makes a partitions according to 7.4
*/
xmlMalloc(sizeof(xmlRelaxNGPartition));
if (partitions == NULL)
goto error;
for (i = 0; i < nbgroups; i++) {
for (j = i + 1; j < nbgroups; j++) {
continue;
if (ret == 0) {
"Element or text conflicts in interleave\n",
}
if (ret == 0) {
"Attributes conflicts in interleave\n", NULL,
NULL);
}
}
(void *) (long) (i + 1));
if (res != 0)
is_determinist = -1;
(void *) (long) (i + 1));
else
(void *) (long) (i + 1));
if (res != 0)
is_determinist = -1;
(void *) (long) (i + 1));
else
(void *) (long) (i + 1));
is_determinist = 2;
if (res != 0)
is_determinist = -1;
} else {
is_determinist = -1;
}
tmp++;
}
} else {
is_determinist = 0;
}
}
/*
* and save the partition list back in the def
*/
if (is_mixed != 0)
if (is_determinist == 1)
if (is_determinist == 2)
return;
for (i = 0; i < nbgroups; i++)
}
}
}
/**
* xmlRelaxNGParseInterleave:
* @ctxt: a Relax-NG parser context
* @node: the data node.
*
* parse the content of a RelaxNG interleave node.
*
* Returns the definition pointer or NULL in case of error
*/
static xmlRelaxNGDefinePtr
{
return (NULL);
}
} else {
"Failed to add %s to hash table\n",
}
}
}
} else {
}
} else {
}
}
}
return (def);
}
/**
* xmlRelaxNGParseInclude:
* @ctxt: a Relax-NG parser context
* @node: the include node
*
* Integrate the content of an include node in the current grammar
*
* Returns 0 in case of success or -1 in case of error
*/
static int
{
return (-1);
}
return (-1);
}
return (-1);
}
/*
* Merge the definition from both the include and the internal list
*/
if (tmp != 0)
ret = -1;
}
if (tmp != 0)
ret = -1;
}
return (ret);
}
/**
* xmlRelaxNGParseDefine:
* @ctxt: a Relax-NG parser context
* @node: the define node
*
* parse the content of a RelaxNG define element node.
*
* Returns 0 in case of success or -1 in case of error
*/
static int
{
} else {
if (xmlValidateNCName(name, 0)) {
}
return (-1);
}
} else {
}
ret = -1;
} else {
if (tmp < 0) {
"Internal error on define aggregation of %s\n",
ret = -1;
} else {
}
}
}
}
return (ret);
}
/**
* xmlRelaxNGProcessExternalRef:
* @ctxt: the parser context
* @node: the externlRef node
*
* Process and compile an externlRef node
*
* Returns the xmlRelaxNGDefinePtr or NULL in case of error
*/
static xmlRelaxNGDefinePtr
{
return (NULL);
/*
* Then do the parsing for good
*/
NULL);
return (NULL);
}
/*
* ns transmission rules
*/
break;
}
}
newNs = 1;
}
} else {
}
/*
* Parsing to get a precompiled schemas.
*/
}
/*
* the externalRef may be reused in a different ns context
*/
if (newNs == 1) {
}
}
} else {
}
return (def);
}
/**
* xmlRelaxNGParsePattern:
* @ctxt: a Relax-NG parser context
* @node: the pattern node.
*
* parse the content of a RelaxNG pattern node.
*
* Returns the definition pointer or NULL in case of error or if no
* pattern is generated.
*/
static xmlRelaxNGDefinePtr
{
return (NULL);
}
return (NULL);
}
return (NULL);
}
return (NULL);
} else {
}
return (NULL);
} else {
}
return (NULL);
} else {
}
return (NULL);
} else {
}
return (NULL);
} else {
}
return (NULL);
} else {
NULL);
}
}
}
} else {
int tmp;
if (tmp < 0) {
"Error refs definitions '%s'\n",
} else {
"Error refs definitions\n",
}
} else {
}
}
}
return (NULL);
} else {
}
return (NULL);
"xmlRelaxNGParse: notAllowed element is not empty\n",
}
#ifdef DEBUG_GRAMMAR
"Found <grammar> pattern\n");
#endif
#if 0
}
#endif
}
else
"Use of parentRef without a parent grammar\n", NULL,
NULL);
return (NULL);
}
return (NULL);
} else {
"parentRef name '%s' is not an NCName\n",
}
}
}
int tmp;
tmp =
if (tmp < 0) {
"Internal error parentRef definitions '%s'\n",
} else {
}
}
}
} else {
}
}
return (def);
}
}
} else {
NULL);
}
return (def);
}
/**
* xmlRelaxNGParseAttribute:
* @ctxt: a Relax-NG parser context
* @node: the element node
*
* parse the content of a RelaxNG attribute node.
*
* Returns the definition pointer or NULL in case of error.
*/
static xmlRelaxNGDefinePtr
{
int old_flags;
return (NULL);
"xmlRelaxNGParseattribute: attribute has no children\n",
return (ret);
}
case XML_RELAXNG_EMPTY:
case XML_RELAXNG_NOT_ALLOWED:
case XML_RELAXNG_TEXT:
case XML_RELAXNG_ELEMENT:
case XML_RELAXNG_DATATYPE:
case XML_RELAXNG_VALUE:
case XML_RELAXNG_LIST:
case XML_RELAXNG_REF:
case XML_RELAXNG_PARENTREF:
case XML_RELAXNG_EXTERNALREF:
case XML_RELAXNG_DEF:
case XML_RELAXNG_ONEORMORE:
case XML_RELAXNG_ZEROORMORE:
case XML_RELAXNG_OPTIONAL:
case XML_RELAXNG_CHOICE:
case XML_RELAXNG_GROUP:
case XML_RELAXNG_INTERLEAVE:
case XML_RELAXNG_ATTRIBUTE:
break;
case XML_RELAXNG_START:
case XML_RELAXNG_PARAM:
case XML_RELAXNG_EXCEPT:
"attribute has invalid content\n", NULL,
NULL);
break;
case XML_RELAXNG_NOOP:
"RNG Internal error, noop found in attribute\n",
break;
}
}
}
}
return (ret);
}
/**
* xmlRelaxNGParseExceptNameClass:
* @ctxt: a Relax-NG parser context
* @node: the except node
* @attr: 1 if within an attribute, 0 if within an element
*
* parse the content of a RelaxNG nameClass node.
*
* Returns the definition pointer or NULL in case of error.
*/
static xmlRelaxNGDefinePtr
{
return (NULL);
}
"exceptNameClass allows only a single except node\n",
}
return (NULL);
}
return (NULL);
break;
if (attr)
else
} else {
}
}
}
return (ret);
}
/**
* xmlRelaxNGParseNameClass:
* @ctxt: a Relax-NG parser context
* @node: the nameClass node
* @def: the current definition
*
* parse the content of a RelaxNG nameClass node.
*
* Returns the definition pointer or NULL in case of error.
*/
static xmlRelaxNGDefinePtr
{
return (NULL);
else
}
}
if (xmlValidateNCName(val, 0)) {
"Element %s name '%s' is not an NCName\n",
else
"name '%s' is not an NCName\n",
}
"Attribute with namespace '%s' is not allowed\n",
}
"Attribute with QName 'xmlns' is not allowed\n",
}
}
}
"Attribute with namespace '%s' is not allowed\n",
}
}
return (NULL);
} else {
} else {
}
}
}
}
} else {
"expecting name, anyName, nsName or choice : got %s\n",
return (NULL);
}
} else {
}
}
}
return (ret);
}
/**
* xmlRelaxNGParseElement:
* @ctxt: a Relax-NG parser context
* @node: the element node
*
* parse the content of a RelaxNG element node.
*
* Returns the definition pointer or NULL in case of error.
*/
static xmlRelaxNGDefinePtr
{
return (NULL);
"xmlRelaxNGParseElement: element has no children\n",
return (ret);
}
"xmlRelaxNGParseElement: element has no content\n",
return (ret);
}
case XML_RELAXNG_EMPTY:
case XML_RELAXNG_NOT_ALLOWED:
case XML_RELAXNG_TEXT:
case XML_RELAXNG_ELEMENT:
case XML_RELAXNG_DATATYPE:
case XML_RELAXNG_VALUE:
case XML_RELAXNG_LIST:
case XML_RELAXNG_REF:
case XML_RELAXNG_PARENTREF:
case XML_RELAXNG_EXTERNALREF:
case XML_RELAXNG_DEF:
case XML_RELAXNG_ZEROORMORE:
case XML_RELAXNG_ONEORMORE:
case XML_RELAXNG_OPTIONAL:
case XML_RELAXNG_CHOICE:
case XML_RELAXNG_GROUP:
case XML_RELAXNG_INTERLEAVE:
} else {
} else {
}
}
}
break;
case XML_RELAXNG_ATTRIBUTE:
break;
case XML_RELAXNG_START:
"RNG Internal error, start found in element\n",
break;
case XML_RELAXNG_PARAM:
"RNG Internal error, param found in element\n",
break;
case XML_RELAXNG_EXCEPT:
"RNG Internal error, except found in element\n",
break;
case XML_RELAXNG_NOOP:
"RNG Internal error, noop found in element\n",
break;
}
}
}
return (ret);
}
/**
* xmlRelaxNGParsePatterns:
* @ctxt: a Relax-NG parser context
* @nodes: list of nodes
* @group: use an implicit <group> for elements
*
* parse the content of a RelaxNG start node.
*
* Returns the definition pointer or NULL in case of error.
*/
static xmlRelaxNGDefinePtr
int group)
{
} else {
}
}
} else {
} else {
}
}
}
}
return (def);
}
/**
* xmlRelaxNGParseStart:
* @ctxt: a Relax-NG parser context
* @nodes: start children nodes
*
* parse the content of a RelaxNG start node.
*
* Returns 0 in case of success, -1 in case of error
*/
static int
{
int ret = 0;
return (-1);
}
return (-1);
}
return (-1);
}
} else {
}
} else {
}
return (-1);
}
return (ret);
}
/**
* xmlRelaxNGParseGrammarContent:
* @ctxt: a Relax-NG parser context
* @nodes: grammar children nodes
*
* parse the content of a RelaxNG grammar node.
*
* Returns 0 in case of success, -1 in case of error
*/
static int
{
return (-1);
}
} else {
if (tmp != 0)
ret = -1;
}
if (tmp != 0)
ret = -1;
if (tmp != 0)
ret = -1;
} else {
NULL);
ret = -1;
}
}
return (ret);
}
/**
* xmlRelaxNGCheckReference:
* @ref: the ref
* @ctxt: a Relax-NG parser context
* @name: the name associated to the defines
*
* Applies the 4.17. combine attribute rule for all the define
* element of a given grammar using the same name.
*/
static void
{
"Internal error: no grammar in CheckReference %s\n",
return;
}
"Internal error: reference has content in CheckReference %s\n",
return;
}
}
} else {
"Reference %s has no matching definition\n", name,
NULL);
}
} else {
"Reference %s has no matching definition\n", name,
NULL);
}
}
/**
* xmlRelaxNGCheckCombine:
* @define: the define(s) list
* @ctxt: a Relax-NG parser context
* @name: the name associated to the defines
*
* Applies the 4.17. combine attribute rule for all the define
* element of a given grammar using the same name.
*/
static void
{
int missing = 0;
return;
cur = define;
if (choiceOrInterleave == -1)
choiceOrInterleave = 1;
else if (choiceOrInterleave == 0) {
"Defines for %s use both 'choice' and 'interleave'\n",
}
if (choiceOrInterleave == -1)
choiceOrInterleave = 0;
else if (choiceOrInterleave == 1) {
"Defines for %s use both 'choice' and 'interleave'\n",
}
} else {
"Defines for %s use unknown combine value '%s''\n",
}
} else {
if (missing == 0)
missing = 1;
else {
"Some defines for %s needs the combine attribute\n",
}
}
}
#ifdef DEBUG
"xmlRelaxNGCheckCombine(): merging %s defines: %d\n",
#endif
if (choiceOrInterleave == -1)
choiceOrInterleave = 0;
return;
if (choiceOrInterleave == 0)
else
tmp = define;
/*
* we need first to create a wrapper.
*/
break;
} else {
}
} else {
}
}
}
if (choiceOrInterleave == 0) {
"Failed to create interleaves hash table\n", NULL,
NULL);
} else {
0) {
"Failed to add %s to hash table\n",
}
}
}
}
/**
* xmlRelaxNGCombineStart:
* @ctxt: a Relax-NG parser context
* @grammar: the grammar
*
* Applies the 4.17. combine rule for all the start
* element of a given grammar.
*/
static void
{
int missing = 0;
return;
"Internal error: start element not found\n", NULL,
NULL);
} else {
}
if (choiceOrInterleave == -1)
choiceOrInterleave = 1;
else if (choiceOrInterleave == 0) {
"<start> use both 'choice' and 'interleave'\n",
}
if (choiceOrInterleave == -1)
choiceOrInterleave = 0;
else if (choiceOrInterleave == 1) {
"<start> use both 'choice' and 'interleave'\n",
}
} else {
"<start> uses unknown combine value '%s''\n",
}
} else {
if (missing == 0)
missing = 1;
else {
"Some <start> element miss the combine attribute\n",
}
}
}
#ifdef DEBUG
"xmlRelaxNGCombineStart(): merging <start>: %d\n",
#endif
if (choiceOrInterleave == -1)
choiceOrInterleave = 0;
return;
if (choiceOrInterleave == 0)
else
if (choiceOrInterleave == 0) {
"Failed to create interleaves hash table\n", NULL,
NULL);
} else {
0) {
"Failed to add %s to hash table\n",
}
}
}
}
/**
* xmlRelaxNGCheckCycles:
* @ctxt: a Relax-NG parser context
* @nodes: grammar children nodes
* @depth: the counter
*
* Check for cycles.
*
* Returns 0 if check passed, and -1 in case of error
*/
static int
{
int ret = 0;
"Detected a cycle in %s references\n",
return (-1);
}
} else {
}
}
return (ret);
}
/**
* xmlRelaxNGTryUnlink:
* @ctxt: a Relax-NG parser context
* @cur: the definition to unlink
* @parent: the parent definition
* @prev: the previous sibling definition
*
* Try to unlink a definition. If not possble make it a NOOP
*
* Returns the new prev definition
*/
static xmlRelaxNGDefinePtr
{
} else {
} else {
}
}
return (prev);
}
/**
* xmlRelaxNGSimplify:
* @ctxt: a Relax-NG parser context
* @nodes: grammar children nodes
*
* Check for simplification of empty and notAllowed
*/
static void
{
}
break;
}
} else
break;
}
} else
} else {
/*
* On Elements, try to move attribute only generating rules on
* the attrs rules.
*/
int attronly;
attronly =
if (attronly == 1) {
/*
* migrate cur->content to attrs
*/
} else {
/*
* cur->content can generate elements or text
*/
break;
}
}
if (attronly == 1) {
/*
* migrate tmp to attrs
*/
} else {
}
}
}
/*
* This may result in a simplification
*/
} else {
}
}
}
/*
* the current node may have been transformed back
*/
break;
}
} else
break;
}
} else
} else {
}
}
}
}
/**
* xmlRelaxNGGroupContentType:
* @ct1: the first content type
* @ct2: the second content type
*
* Try to group 2 content types
*
* Returns the content type
*/
static xmlRelaxNGContentType
{
if ((ct1 == XML_RELAXNG_CONTENT_ERROR) ||
(ct2 == XML_RELAXNG_CONTENT_ERROR))
return (XML_RELAXNG_CONTENT_ERROR);
if (ct1 == XML_RELAXNG_CONTENT_EMPTY)
return (ct2);
if (ct2 == XML_RELAXNG_CONTENT_EMPTY)
return (ct1);
if ((ct1 == XML_RELAXNG_CONTENT_COMPLEX) &&
return (XML_RELAXNG_CONTENT_COMPLEX);
return (XML_RELAXNG_CONTENT_ERROR);
}
/**
* xmlRelaxNGMaxContentType:
* @ct1: the first content type
* @ct2: the second content type
*
* Compute the max content-type
*
* Returns the content type
*/
static xmlRelaxNGContentType
{
if ((ct1 == XML_RELAXNG_CONTENT_ERROR) ||
(ct2 == XML_RELAXNG_CONTENT_ERROR))
return (XML_RELAXNG_CONTENT_ERROR);
if ((ct1 == XML_RELAXNG_CONTENT_SIMPLE) ||
return (XML_RELAXNG_CONTENT_SIMPLE);
if ((ct1 == XML_RELAXNG_CONTENT_COMPLEX) ||
return (XML_RELAXNG_CONTENT_COMPLEX);
return (XML_RELAXNG_CONTENT_EMPTY);
}
/**
* xmlRelaxNGCheckRules:
* @ctxt: a Relax-NG parser context
* @cur: the current definition
* @flags: some accumulated flags
* @ptype: the parent type
*
* Check for rules in section 7.1 and 7.2
*
* Returns the content type of @cur
*/
static xmlRelaxNGContentType
{
/*
* This should actually be caught by list//element(ref) at the
* element boundaries, c.f. Bug #159968 local refs are dropped
* in step 4.19.
*/
#if 0
if (flags & XML_RELAXNG_IN_LIST) {
"Found forbidden pattern list//ref\n", NULL,
NULL);
}
#endif
if (flags & XML_RELAXNG_IN_DATAEXCEPT) {
}
} else {
}
/*
* The 7.3 Attribute derivation rule for groups is plugged there
*/
if (flags & XML_RELAXNG_IN_DATAEXCEPT) {
}
if (flags & XML_RELAXNG_IN_LIST) {
"Found forbidden pattern list//element(ref)\n",
}
if (flags & XML_RELAXNG_IN_ATTRIBUTE) {
"Found forbidden pattern attribute//element(ref)\n",
}
if (flags & XML_RELAXNG_IN_ATTRIBUTE) {
"Found forbidden pattern attribute//element(ref)\n",
}
/*
* reset since in the simple form elements are only child
*/
nflags = 0;
ret =
if (ret != XML_RELAXNG_CONTENT_EMPTY) {
"Element %s attributes have a content type error\n",
}
ret =
if (ret == XML_RELAXNG_CONTENT_ERROR) {
"Element %s has a content type error\n",
} else {
}
if (flags & XML_RELAXNG_IN_ATTRIBUTE) {
"Found forbidden pattern attribute//attribute\n",
}
if (flags & XML_RELAXNG_IN_LIST) {
"Found forbidden pattern list//attribute\n",
}
if (flags & XML_RELAXNG_IN_OOMGROUP) {
"Found forbidden pattern oneOrMore//group//attribute\n",
}
if (flags & XML_RELAXNG_IN_OOMINTERLEAVE) {
"Found forbidden pattern oneOrMore//interleave//attribute\n",
}
if (flags & XML_RELAXNG_IN_DATAEXCEPT) {
}
if (flags & XML_RELAXNG_IN_START) {
"Found forbidden pattern start//attribute\n",
}
if ((!(flags & XML_RELAXNG_IN_ONEORMORE))
"Found anyName attribute without oneOrMore ancestor\n",
} else {
"Found nsName attribute without oneOrMore ancestor\n",
}
}
if (flags & XML_RELAXNG_IN_DATAEXCEPT) {
}
if (flags & XML_RELAXNG_IN_START) {
"Found forbidden pattern start//oneOrMore\n",
}
ret =
if (flags & XML_RELAXNG_IN_LIST) {
"Found forbidden pattern list//list\n", NULL,
NULL);
}
if (flags & XML_RELAXNG_IN_DATAEXCEPT) {
}
if (flags & XML_RELAXNG_IN_START) {
"Found forbidden pattern start//list\n", NULL,
NULL);
}
ret =
if (flags & XML_RELAXNG_IN_DATAEXCEPT) {
}
if (flags & XML_RELAXNG_IN_START) {
"Found forbidden pattern start//group\n", NULL,
NULL);
}
if (flags & XML_RELAXNG_IN_ONEORMORE)
else
ret =
/*
* The 7.3 Attribute derivation rule for groups is plugged there
*/
if (flags & XML_RELAXNG_IN_LIST) {
"Found forbidden pattern list//interleave\n",
}
if (flags & XML_RELAXNG_IN_DATAEXCEPT) {
}
if (flags & XML_RELAXNG_IN_START) {
"Found forbidden pattern start//interleave\n",
}
if (flags & XML_RELAXNG_IN_ONEORMORE)
else
ret =
else
ret =
if (flags & XML_RELAXNG_IN_START) {
"Found forbidden pattern start//data\n", NULL,
NULL);
}
if (flags & XML_RELAXNG_IN_START) {
"Found forbidden pattern start//value\n", NULL,
NULL);
}
if (flags & XML_RELAXNG_IN_LIST) {
"Found forbidden pattern list//text\n", NULL,
NULL);
}
if (flags & XML_RELAXNG_IN_DATAEXCEPT) {
}
if (flags & XML_RELAXNG_IN_START) {
"Found forbidden pattern start//text\n", NULL,
NULL);
}
if (flags & XML_RELAXNG_IN_DATAEXCEPT) {
}
if (flags & XML_RELAXNG_IN_START) {
"Found forbidden pattern start//empty\n", NULL,
NULL);
}
ret =
} else {
ret =
}
if (ptype == XML_RELAXNG_GROUP) {
} else if (ptype == XML_RELAXNG_INTERLEAVE) {
if (tmp != XML_RELAXNG_CONTENT_ERROR)
} else if (ptype == XML_RELAXNG_CHOICE) {
} else if (ptype == XML_RELAXNG_LIST) {
} else if (ptype == XML_RELAXNG_EXCEPT) {
if (ret == XML_RELAXNG_CONTENT_ERROR)
else
} else {
}
}
return (val);
}
/**
* xmlRelaxNGParseGrammar:
* @ctxt: a Relax-NG parser context
* @nodes: grammar children nodes
*
* parse a Relax-NG <grammar> node
*
* Returns the internal xmlRelaxNGGrammarPtr built or
* NULL in case of error
*/
static xmlRelaxNGGrammarPtr
{
#ifdef DEBUG_GRAMMAR
#endif
return (NULL);
/*
* Link the new grammar in the tree
*/
} else {
}
}
}
/*
* Apply 4.17 mergingd rules to defines and starts
*/
ctxt);
}
/*
* link together defines and refs in this grammar
*/
ctxt);
}
return (ret);
}
/**
* xmlRelaxNGParseDocument:
* @ctxt: a Relax-NG parser context
* @node: the root node of the RelaxNG schema
*
* parse a Relax-NG definition resource and build an internal
* xmlRelaxNG struture which can be used to validate instances.
*
* Returns the internal XML RelaxNG structure built or
* NULL in case of error
*/
static xmlRelaxNGPtr
{
return (NULL);
return (NULL);
} else {
return (schema);
}
/*
* Link the new grammar in the tree
*/
} else {
}
}
}
}
}
#ifdef DEBUG
"xmlRelaxNGParseDocument() failed\n");
#endif
return (schema);
}
/************************************************************************
* *
* Reading RelaxNGs *
* *
************************************************************************/
/**
* xmlRelaxNGNewParserCtxt:
* @URL: the location of the schema
*
* to contain an XML RelaxNGs file.
*
* Returns the parser context or NULL in case of error
*/
{
return (NULL);
ret =
return (NULL);
}
return (ret);
}
/**
* xmlRelaxNGNewMemParserCtxt:
* @buffer: a pointer to a char array containing the schemas
* @size: the size of the array
*
* Create an XML RelaxNGs parse context for that memory buffer expected
* to contain an XML RelaxNGs file.
*
* Returns the parser context or NULL in case of error
*/
{
return (NULL);
ret =
return (NULL);
}
return (ret);
}
/**
* xmlRelaxNGNewDocParserCtxt:
* @doc: a preparsed document tree
*
* Create an XML RelaxNGs parser context for that document.
* Note: since the process of compiling a RelaxNG schemas modifies the
* document, the @doc parameter is duplicated internally.
*
* Returns the parser context or NULL in case of error
*/
{
return (NULL);
return (NULL);
ret =
return (NULL);
}
return (ret);
}
/**
* xmlRelaxNGFreeParserCtxt:
* @ctxt: the schema parser context
*
* Free the resources associated to the schema parser context
*/
void
{
return;
int i;
}
}
/**
* xmlRelaxNGNormExtSpace:
* @value: a value
*
* Removes the leading and ending spaces of the value
* The string is modified "in situ"
*/
static void
{
return;
while (IS_BLANK_CH(*cur))
cur++;
do {
cur++;
if (*cur == 0)
return;
while (IS_BLANK_CH(*cur))
cur++;
if (*cur == 0) {
*start = 0;
return;
}
} while (1);
} else {
do {
if (*cur == 0) {
*start = 0;
return;
}
/* don't try to normalize the inner spaces */
while (IS_BLANK_CH(*cur))
cur++;
if (*cur == 0) {
*start = 0;
return;
}
} while (1);
}
}
/**
* xmlRelaxNGCleanupAttributes:
* @ctxt: a Relax-NG parser context
* @node: a Relax-NG node
*
* Check all the attributes on the given node
*/
static void
{
"Attribute %s is not allowed on %s\n",
}
"Attribute %s is not allowed on %s\n",
}
"Attribute %s is not allowed on %s\n",
}
"Attribute %s is not allowed on %s\n",
}
if (val[0] != 0) {
"Attribute %s contains invalid URI %s\n",
} else {
"Attribute %s URI %s is not absolute\n",
}
"Attribute %s URI %s has a fragment ID\n",
}
}
}
}
}
}
}
}
/**
* xmlRelaxNGCleanupTree:
* @ctxt: a Relax-NG parser context
* @root: an xmlNodePtr subtree
*
* Cleanup the subtree from unwanted nodes for parsing, resolve
* Include and externalRef lookups.
*/
static void
{
}
/*
* Simplification 4.1. Annotations
*/
"element %s doesn't allow foreign elements\n",
}
goto skip_children;
} else {
break;
}
}
"xmlRelaxNGParse: externalRef has no href attribute\n",
goto skip_children;
}
"Incorrect URI for externalRef %s\n",
goto skip_children;
}
"Fragment forbidden in URI for externalRef %s\n",
goto skip_children;
}
"Failed to compute URL for externalRef %s\n",
goto skip_children;
}
"Failed to load externalRef %s\n", URL,
NULL);
goto skip_children;
}
"xmlRelaxNGParse: include has no href attribute\n",
goto skip_children;
}
"Failed to compute URL for include %s\n",
goto skip_children;
}
break;
}
}
"Failed to load include %s\n", URL,
NULL);
goto skip_children;
}
{
/*
* Simplification 4.8. name attribute of element
* and attribute elements
*/
text =
name);
} else {
}
}
"Failed to create a name %s element\n",
}
/* xmlUnsetProp(cur, BAD_CAST "ns"); */
}
BAD_CAST "attribute")) {
}
}
/*
* Simplification 4.8. name attribute of element
* and attribute elements
*/
break;
}
}
} else {
}
}
/*
* Simplification: 4.10. QNames
*/
"xmlRelaxNGParse: no namespace for prefix %s\n",
} else {
}
}
}
}
/*
* 4.16
*/
}
}
/*
* 4.16
*/
goto skip_children;
goto skip_children;
}
/*
* 4.16
*/
}
}
/*
* Thisd is not an else since "include" is transformed
* into a div
*/
/*
* implements rule 4.11
*/
}
}
}
/*
* Since we are about to delete cur, if it's nsDef is non-NULL we
* need to preserve it (it contains the ns definitions for the
* children we just moved). We'll just stick it on to the end
* of cur->parent's list, since it's never going to be re-serialized
* (bug 143738).
*/
}
goto skip_children;
}
}
}
/*
* Simplification 4.2 whitespaces
*/
if (IS_BLANK_NODE(cur)) {
&&
} else {
goto skip_children;
}
}
} else {
goto skip_children;
}
/*
* Skip to next node
*/
continue;
}
}
continue;
}
do {
break;
break;
}
break;
}
}
}
}
/**
* xmlRelaxNGCleanupDoc:
* @ctxt: a Relax-NG parser context
* @doc: an xmldocPtr document pointer
*
* Cleanup the document from unwanted nodes for parsing, resolve
* Include and externalRef lookups.
*
* Returns the cleaned up document or NULL in case of error
*/
static xmlDocPtr
{
/*
* Extract the root
*/
return (NULL);
}
return (doc);
}
/**
* xmlRelaxNGParse:
* @ctxt: a Relax-NG parser context
*
* parse a schema definition resource and build an internal
* XML Shema struture which can be used to validate instances.
*
* Returns the internal XML RelaxNG structure built from the resource or
* NULL in case of error
*/
{
return (NULL);
/*
*/
NULL);
return (NULL);
}
"xmlRelaxNGParse: could not parse schemas\n", NULL,
NULL);
return (NULL);
}
} else {
return (NULL);
}
/*
* Some preprocessing of the document content
*/
return (NULL);
}
/*
* Then do the parsing for good
*/
XML_RNGP_EMPTY, "xmlRelaxNGParse: %s is empty\n",
return (NULL);
}
return (NULL);
}
/*
*/
/*
* try to preprocess interleaves
*/
}
/*
* if there was a parsing error return NULL
*/
return (NULL);
}
/*
* try to compile (parts of) the schemas
*/
}
}
}
/*
* Transfer the pointer for cleanup at the schema level.
*/
return (ret);
}
/**
* xmlRelaxNGSetParserErrors:
* @ctxt: a Relax-NG validation context
* @err: the error callback
* @warn: the warning callback
* @ctx: contextual data for the callbacks
*
* Set the callback functions used to handle errors for a validation context
*/
void
{
return;
}
/**
* xmlRelaxNGGetParserErrors:
* @ctxt: a Relax-NG validation context
* @err: the error callback result
* @warn: the warning callback result
* @ctx: contextual data for the callbacks result
*
* Get the callback information used to handle errors for a validation context
*
* Returns -1 in case of failure, 0 otherwise.
*/
int
{
return (-1);
return (0);
}
/**
* xmlRelaxNGSetParserStructuredErrors:
* @ctxt: a Relax-NG parser context
* @serror: the error callback
* @ctx: contextual data for the callbacks
*
* Set the callback functions used to handle errors for a parsing context
*/
void
void *ctx)
{
return;
}
#ifdef LIBXML_OUTPUT_ENABLED
/************************************************************************
* *
* Dump back a compiled form *
* *
************************************************************************/
xmlRelaxNGDefinePtr define);
/**
* xmlRelaxNGDumpDefines:
* @output: the file output
* @defines: a list of define structures
*
* Dump a RelaxNG structure back
*/
static void
{
}
}
/**
* xmlRelaxNGDumpDefine:
* @output: the file output
* @define: a define structure
*
* Dump a RelaxNG structure back
*/
static void
{
if (define == NULL)
return;
switch (define->type) {
case XML_RELAXNG_EMPTY:
break;
case XML_RELAXNG_NOT_ALLOWED:
break;
case XML_RELAXNG_TEXT:
break;
case XML_RELAXNG_ELEMENT:
}
break;
case XML_RELAXNG_LIST:
break;
case XML_RELAXNG_ONEORMORE:
break;
case XML_RELAXNG_ZEROORMORE:
break;
case XML_RELAXNG_CHOICE:
break;
case XML_RELAXNG_GROUP:
break;
case XML_RELAXNG_INTERLEAVE:
break;
case XML_RELAXNG_OPTIONAL:
break;
case XML_RELAXNG_ATTRIBUTE:
break;
case XML_RELAXNG_DEF:
break;
case XML_RELAXNG_REF:
break;
case XML_RELAXNG_PARENTREF:
break;
case XML_RELAXNG_EXTERNALREF:
break;
case XML_RELAXNG_DATATYPE:
case XML_RELAXNG_VALUE:
TODO break;
case XML_RELAXNG_START:
case XML_RELAXNG_EXCEPT:
case XML_RELAXNG_PARAM:
TODO break;
case XML_RELAXNG_NOOP:
break;
}
}
/**
* xmlRelaxNGDumpGrammar:
* @output: the file output
* @grammar: a grammar structure
* @top: is this a top grammar
*
* Dump a RelaxNG structure back
*/
static void
{
return;
if (top)
break;
break;
break;
default:
}
} else {
}
/* TODO ? Dump the defines ? */
}
/**
* xmlRelaxNGDump:
* @output: the file output
* @schema: a schema structure
*
* Dump a RelaxNG structure back
*/
void
{
return;
return;
}
} else {
}
return;
}
}
/**
* xmlRelaxNGDumpTree:
* @output: the file output
* @schema: a schema structure
*
* Dump the transformed RelaxNG tree.
*/
void
{
return;
return;
}
} else {
}
}
#endif /* LIBXML_OUTPUT_ENABLED */
/************************************************************************
* *
* Validation of compiled content *
* *
************************************************************************/
xmlRelaxNGDefinePtr define);
/**
* xmlRelaxNGValidateCompiledCallback:
* @exec: the regular expression instance
* @token: the token which matched
* @transdata: callback data, the define for the subelement if available
@ @inputdata: callback data, the Relax NG validation context
*
* Handle the callback and if needed validate the element children.
*/
static void
{
int ret;
#ifdef DEBUG_COMPILE
"Compiled callback for: '%s'\n", token);
#endif
return;
}
if (define == NULL) {
if (token[0] == '#')
return;
return;
}
return;
} else if (define->type != XML_RELAXNG_ELEMENT) {
return;
}
if (ret != 0)
}
/**
* xmlRelaxNGValidateCompiledContent:
* @ctxt: the RelaxNG validation context
* @regexp: the regular expression as compiled
* @content: list of children to test against the regexp
*
* Validate the content model of an element or start using the regexp
*
* Returns 0 in case of success, -1 in case of error.
*/
static int
{
int ret = 0;
int oldperr;
return (-1);
case XML_TEXT_NODE:
case XML_CDATA_SECTION_NODE:
if (xmlIsBlankNode(cur))
break;
if (ret < 0) {
}
break;
case XML_ELEMENT_NODE:
} else {
}
if (ret < 0) {
}
break;
default:
break;
}
if (ret < 0)
break;
/*
* Switch to next element
*/
}
if (ret == 1) {
ret = 0;
} else if (ret == 0) {
/*
* TODO: get some of the names needed to exit the current state of exec
*/
ret = -1;
} else {
ret = -1;
}
/*
* There might be content model errors outside of the pure
* regexp validation, e.g. for attribute values.
*/
}
return (ret);
}
/************************************************************************
* *
* Progressive validation of when possible *
* *
************************************************************************/
int dolog);
/**
* xmlRelaxNGElemPush:
* @ctxt: the validation context
* @exec: the regexp runtime for the new content model
*
* Push a new regexp for the current node content model on the stack
*
* Returns 0 in case of success and -1 in case of error.
*/
static int
{
sizeof
return (-1);
}
}
sizeof
return (-1);
}
}
return (0);
}
/**
* xmlRelaxNGElemPop:
* @ctxt: the validation context
*
* Pop the regexp of the current node content model from the stack
*
* Returns the exec or NULL if empty
*/
static xmlRegExecCtxtPtr
{
return (NULL);
else
return (ret);
}
/**
* xmlRelaxNGValidateProgressiveCallback:
* @exec: the regular expression instance
* @token: the token which matched
* @transdata: callback data, the define for the subelement if available
@ @inputdata: callback data, the Relax NG validation context
*
* Handle the callback and if needed validate the element children.
*/
static void
{
#ifdef DEBUG_PROGRESSIVE
"Progressive callback for: '%s'\n", token);
#endif
return;
}
if (define == NULL) {
if (token[0] == '#')
return;
return;
}
return;
} else if (define->type != XML_RELAXNG_ELEMENT) {
return;
}
return;
}
/*
* this node cannot be validated in a streamable fashion
*/
#ifdef DEBUG_PROGRESSIVE
"Element '%s' validation is not streamable\n",
token);
#endif
return;
}
return;
}
/*
* Validate the attributes part of the content.
*/
return;
}
if (ret != 0) {
}
}
if (ret != 0) {
}
if (xmlRelaxNGValidateElementEnd(ctxt, 0) == 0) {
tmp = 0;
break;
}
}
if (tmp != 0) {
/*
* validation error, log the message for the "best" one
*/
}
}
}
}
}
}
/**
* xmlRelaxNGValidatePushElement:
* @ctxt: the validation context
* @doc: a document instance
* @elem: an element instance
*
* Push a new element start on the RelaxNG validation stack.
*
* returns 1 if no validation problem was found or 0 if validating the
* element requires a full node, and -1 in case of error.
*/
int
{
return (-1);
#ifdef DEBUG_PROGRESSIVE
#endif
xmlRelaxNGDefinePtr define;
return (-1);
}
return (-1);
}
return (0);
}
ctxt);
return (-1);
}
}
ret =
ctxt);
} else {
}
if (ret < 0) {
} else {
ret = 0;
ret = -1;
else
ret = 1;
}
#ifdef DEBUG_PROGRESSIVE
if (ret < 0)
#endif
return (ret);
}
/**
* xmlRelaxNGValidatePushCData:
* @ctxt: the RelaxNG 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 -1 otherwise
*/
int
{
return (-1);
#ifdef DEBUG_PROGRESSIVE
#endif
while (*data != 0) {
if (!IS_BLANK_CH(*data))
break;
data++;
}
if (*data == 0)
return (1);
if (ret < 0) {
#ifdef DEBUG_PROGRESSIVE
#endif
return (-1);
}
return (1);
}
/**
* xmlRelaxNGValidatePopElement:
* @ctxt: the RelaxNG validation context
* @doc: a document instance
* @elem: an element instance
*
* Pop the element end from the RelaxNG validation stack.
*
* returns 1 if no validation problem was found or 0 otherwise
*/
int
{
int ret;
return (-1);
#ifdef DEBUG_PROGRESSIVE
#endif
/*
* verify that we reached a terminal state of the content model.
*/
if (ret == 0) {
/*
* TODO: get some of the names needed to exit the current state of exec
*/
ret = -1;
} else if (ret < 0) {
ret = -1;
} else {
ret = 1;
}
#ifdef DEBUG_PROGRESSIVE
if (ret < 0)
#endif
return (ret);
}
/**
* xmlRelaxNGValidateFullElement:
* @ctxt: the validation context
* @doc: a document instance
* @elem: an element instance
*
* Validate a full subtree when xmlRelaxNGValidatePushElement() returned
* 0 and the content of the node has been expanded.
*
* returns 1 if no validation problem was found or -1 in case of error.
*/
int
{
int ret;
return (-1);
#ifdef DEBUG_PROGRESSIVE
#endif
return (-1);
}
ret = -1;
else
ret = 1;
#ifdef DEBUG_PROGRESSIVE
if (ret < 0)
#endif
return (ret);
}
/************************************************************************
* *
* Generic interpreted validation implementation *
* *
************************************************************************/
xmlRelaxNGDefinePtr define);
/**
* xmlRelaxNGSkipIgnored:
* @ctxt: a schema validation context
* @node: the top node.
*
* Skip ignorable nodes in that context
*
* Returns the new sibling or NULL in case of error.
*/
static xmlNodePtr
{
/*
* TODO complete and handle entities
*/
(IS_BLANK_NODE(node)))))) {
}
return (node);
}
/**
* xmlRelaxNGNormalize:
* @ctxt: a schema validation context
* @str: the string to normalize
*
* Implements the normalizeWhiteSpace( s ) function from
* section 6.2.9 of the spec
*
* Returns the new string or NULL in case of error.
*/
static xmlChar *
{
int len;
return (NULL);
while (*tmp != 0)
tmp++;
return (NULL);
}
p = ret;
while (IS_BLANK_CH(*str))
str++;
while (*str != 0) {
if (IS_BLANK_CH(*str)) {
while (IS_BLANK_CH(*str))
str++;
if (*str == 0)
break;
*p++ = ' ';
} else
*p++ = *str++;
}
*p = 0;
return (ret);
}
/**
* xmlRelaxNGValidateDatatype:
* @ctxt: a Relax-NG validation context
* @value: the string value
* @type: the datatype definition
* @node: the node
*
* Validate the given value against the dataype
*
* Returns 0 if the validation succeeded or an error code.
*/
static int
{
return (-1);
}
ret =
} else {
}
} else
ret = -1;
if (ret < 0) {
return (-1);
} else if (ret == 1) {
ret = 0;
} else if (ret == 2) {
} else {
ret = -1;
}
if (tmp != 0)
ret = -1;
}
}
}
return (ret);
}
/**
* xmlRelaxNGNextValue:
* @ctxt: a Relax-NG validation context
*
* Skip to the next value when validating within a list
*
* Returns 0 if the operation succeeded or an error code.
*/
static int
{
return (0);
}
while (*cur != 0)
cur++;
cur++;
else
return (0);
}
/**
* xmlRelaxNGValidateValueList:
* @ctxt: a Relax-NG validation context
* @defines: the list of definitions to verify
*
* Validate the given set of definitions for the current value
*
* Returns 0 if the validation succeeded or an error code.
*/
static int
{
int ret = 0;
if (ret != 0)
break;
}
return (ret);
}
/**
* xmlRelaxNGValidateValue:
* @ctxt: a Relax-NG validation context
* @define: the definition to verify
*
* Validate the given definition for the current value
*
* Returns 0 if the validation succeeded or an error code.
*/
static int
xmlRelaxNGDefinePtr define)
{
switch (define->type) {
case XML_RELAXNG_EMPTY:{
int idx = 0;
idx++;
ret = -1;
}
break;
}
case XML_RELAXNG_TEXT:
break;
case XML_RELAXNG_VALUE:{
(void *) define->attrs,
} else
ret = -1;
if (ret < 0) {
define->name);
return (-1);
} else if (ret == 1) {
ret = 0;
} else {
ret = -1;
}
} else {
/*
* TODO: trivial optimizations are possible by
* computing at compile-time
*/
ret = -1;
}
}
if (ret == 0)
break;
}
case XML_RELAXNG_DATATYPE:{
if (ret == 0)
break;
}
case XML_RELAXNG_CHOICE:{
if (ret == 0) {
break;
}
}
if (ret != 0) {
} else {
xmlRelaxNGPopErrors(ctxt, 0);
}
break;
}
case XML_RELAXNG_LIST:{
#ifdef DEBUG_LIST
int nb_values = 0;
#endif
}
return (-1);
}
while (*cur != 0) {
if (IS_BLANK_CH(*cur)) {
*cur = 0;
cur++;
#ifdef DEBUG_LIST
nb_values++;
#endif
while (IS_BLANK_CH(*cur))
*cur++ = 0;
} else
cur++;
}
#ifdef DEBUG_LIST
"list value: '%s' found %d items\n",
nb_values = 0;
#endif
cur++;
if (ret != 0) {
#ifdef DEBUG_LIST
"Failed to validate value: '%s' with %d rule\n",
#endif
break;
}
#ifdef DEBUG_LIST
nb_values++;
#endif
}
ret = -1;
}
break;
}
case XML_RELAXNG_ONEORMORE:
if (ret != 0) {
break;
}
/* no break on purpose */
case XML_RELAXNG_ZEROORMORE:{
ret =
if (ret != 0) {
ret = 0;
break;
}
}
xmlRelaxNGPopErrors(ctxt, 0);
break;
}
case XML_RELAXNG_EXCEPT:{
if (ret == 0) {
ret = -1;
break;
} else
ret = 0;
}
break;
}
case XML_RELAXNG_DEF:
case XML_RELAXNG_GROUP:{
if (ret != 0) {
ret = -1;
break;
} else
ret = 0;
}
break;
}
case XML_RELAXNG_REF:
case XML_RELAXNG_PARENTREF:
break;
default:
}
return (ret);
}
/**
* xmlRelaxNGValidateValueContent:
* @ctxt: a Relax-NG validation context
* @defines: the list of definitions to verify
*
* Validate the given definitions for the current value
*
* Returns 0 if the validation succeeded or an error code.
*/
static int
{
int ret = 0;
if (ret != 0)
break;
}
return (ret);
}
/**
* xmlRelaxNGAttributeMatch:
* @ctxt: a Relax-NG validation context
* @define: the definition to check
* @prop: the attribute
*
* Check if the attribute matches the definition nameClass
*
* Returns 1 if the attribute matches, 0 if no, or -1 in case of error
*/
static int
{
int ret;
return (0);
}
if (define->ns[0] == 0) {
return (0);
} else {
return (0);
}
}
return (1);
define = define->nameClass;
if (define->type == XML_RELAXNG_EXCEPT) {
if (ret == 1)
return (0);
if (ret < 0)
return (ret);
}
} else {
TODO}
return (1);
}
/**
* xmlRelaxNGValidateAttribute:
* @ctxt: a Relax-NG validation context
* @define: the definition to verify
*
* Validate the given attribute definition for that node
*
* Returns 0 if the validation succeeded or an error code.
*/
static int
xmlRelaxNGDefinePtr define)
{
int ret = 0, i;
return (-1);
break;
}
}
}
if (ret == 0) {
/*
* flag the attribute as processed
*/
}
} else {
ret = -1;
}
#ifdef DEBUG
"xmlRelaxNGValidateAttribute(%s): %d\n",
#endif
} else {
break;
}
}
if (ret == 0) {
/*
* flag the attribute as processed
*/
}
} else {
ret = -1;
}
#ifdef DEBUG
"xmlRelaxNGValidateAttribute(nsName ns = %s): %d\n",
} else {
"xmlRelaxNGValidateAttribute(anyName): %d\n",
ret);
}
#endif
}
return (ret);
}
/**
* xmlRelaxNGValidateAttributeList:
* @ctxt: a Relax-NG validation context
* @define: the list of definition to verify
*
* Validate the given node against the list of attribute definitions
*
* Returns 0 if the validation succeeded or an error code.
*/
static int
{
int needmore = 0;
ret = -1;
} else
needmore = 1;
}
if (!needmore)
return (ret);
if (res < 0)
ret = -1;
} else {
return (-1);
}
break;
}
}
return (ret);
}
/**
* xmlRelaxNGNodeMatchesList:
* @node: the node
* @list: a NULL terminated array of definitions
*
* Check if a node can be matched by one of the definitions
*
* Returns 1 if matches 0 otherwise
*/
static int
{
int i = 0, tmp;
return (0);
if (tmp == 1)
return (1);
return (1);
}
}
return (0);
}
/**
* xmlRelaxNGValidateInterleave:
* @ctxt: a Relax-NG validation context
* @define: the definition to verify
*
* Validate an interleave definition for a node.
*
* Returns 0 if the validation succeeded or an error code.
*/
static int
xmlRelaxNGDefinePtr define)
{
int oldflags;
} else {
return (-1);
}
/*
* Optimizations for MIXED
*/
if (nbgroups == 2) {
/*
* this is a pure <mixed> case
*/
rule);
else
partitions->groups[0]->
rule);
if (ret == 0) {
seq);
}
return (ret);
}
}
/*
* Build arrays to store the first and last node of the chain
* pertaining to each group
*/
return (-1);
}
return (-1);
}
/*
* Walk the sequence of children finding the right group and
* sorting them in sequences.
*/
NULL);
BAD_CAST "#any",
} else
tmp =
NULL);
tmp =
NULL);
}
i = nbgroups;
} else {
i = ((long) tmp) - 1;
i = nbgroups;
}
}
} else {
for (i = 0; i < nbgroups; i++) {
continue;
break;
}
}
/*
* We break as soon as an element not matched is found
*/
if (i >= nbgroups) {
break;
}
} else {
}
else
}
if (ret != 0) {
ret = -1;
goto done;
}
for (i = 0; i < nbgroups; i++) {
}
if (ret != 0)
break;
ret = -1;
goto done;
}
int j;
int found = 0;
/*
* PBM: what happen if there is attributes checks in the interleaves
*/
if (found == 0) {
best = j;
}
found = 1;
/* try to keep the latest one to mach old heuristic */
best = j;
}
if (lowattr == 0)
break;
} else if (found == 0) {
if (lowattr == -1) {
best = j;
} else
/* try to keep the latest one to mach old heuristic */
best = j;
}
}
}
/*
* BIG PBM: here we pick only one restarting point :-(
*/
if (best != -1) {
} else {
oldstate =
}
}
}
if (found == 0) {
ret = -1;
goto done;
}
} else {
ret = -1;
break;
}
}
}
if (ret != 0) {
ret = -1;
goto done;
}
done:
/*
* builds the next links chain from the prev one
*/
break;
}
if (ret == 0) {
}
return (ret);
}
/**
* xmlRelaxNGValidateDefinitionList:
* @ctxt: a Relax-NG validation context
* @define: the list of definition to verify
*
* Validate the given node content against the (list) of definitions
*
* Returns 0 if the validation succeeded or an error code.
*/
static int
{
BAD_CAST "NULL definition list");
return (-1);
}
if (res < 0)
ret = -1;
} else {
return (-1);
}
break;
}
return (ret);
}
/**
* xmlRelaxNGElementMatch:
* @ctxt: a Relax-NG validation context
* @define: the definition to check
* @elem: the element
*
* Check if the element matches the definition nameClass
*
* Returns 1 if the element matches, 0 if no, or -1 in case of error
*/
static int
{
return (0);
}
}
return (0);
return (0);
}
return (0);
return (0);
}
return (1);
define = define->nameClass;
if (define->type == XML_RELAXNG_EXCEPT) {
}
if (ret == 1) {
return (0);
}
if (ret < 0) {
return (ret);
}
}
ret = 1;
}
} else if (define->type == XML_RELAXNG_CHOICE) {
}
if (ret == 1) {
return (1);
}
if (ret < 0) {
return (ret);
}
}
if (ret != 0) {
} else {
xmlRelaxNGPopErrors(ctxt, 0);
}
}
ret = 0;
}
} else {
}
return (ret);
}
/**
* xmlRelaxNGBestState:
* @ctxt: a Relax-NG validation context
*
* Find the "best" state in the ctxt->states list of states to report
* errors about. I.e. a state with no element left in the child list
* or the one with the less attributes left.
* This is called only if a falidation error was detected
*
* Returns the index of the "best" state or -1 in case of error
*/
static int
{
int i, tmp;
return (-1);
continue;
value = 100000;
best = i;
}
} else {
best = i;
}
}
}
return (best);
}
/**
* xmlRelaxNGLogBestError:
* @ctxt: a Relax-NG validation context
*
* Find the "best" state in the ctxt->states list of states to report
* errors about and log it.
*/
static void
{
int best;
return;
}
}
/**
* xmlRelaxNGValidateElementEnd:
* @ctxt: a Relax-NG validation context
* @dolog: indicate that error logging should be done
*
* Validate the end of the element, implements check that
* there is nothing left not consumed in the element content
* or in the attribute list.
*
* Returns 0 if the validation succeeded or an error code.
*/
static int
{
int i;
if (dolog) {
}
return (-1);
}
}
if (dolog) {
}
return (-1 - i);
}
}
return (0);
}
/**
* xmlRelaxNGValidateState:
* @ctxt: a Relax-NG validation context
* @define: the definition to verify
*
* Validate the current state against the definition
*
* Returns 0 if the validation succeeded or an error code.
*/
static int
xmlRelaxNGDefinePtr define)
{
if (define == NULL) {
return (-1);
}
} else {
}
#ifdef DEBUG
"Start validating %s ", xmlRelaxNGDefName(define));
else
#endif
switch (define->type) {
case XML_RELAXNG_EMPTY:
ret = 0;
break;
case XML_RELAXNG_NOT_ALLOWED:
ret = -1;
break;
case XML_RELAXNG_TEXT:
break;
case XML_RELAXNG_ELEMENT:
ret = -1;
break;
}
ret = -1;
break;
}
/*
* This node was already validated successfully against
* this definition.
*/
||
}
break;
}
if (ret <= 0) {
ret = -1;
break;
}
ret = 0;
}
}
ret = -1;
break;
}
if (tmp != 0) {
ret = -1;
}
}
define->contModel,
#ifdef DEBUG_COMPILE
"Validating content of '%s' : %d\n",
#endif
if (tmp != 0)
ret = -1;
tmp = -1;
if (xmlRelaxNGValidateElementEnd(ctxt, 0) == 0) {
tmp = 0;
break;
}
}
if (tmp != 0) {
/*
* validation error, log the message for the "best" one
*/
}
tabState[i]);
}
ret = -1;
} else {
if (ret == 0)
}
} else {
define->
content);
if (tmp != 0) {
ret = -1;
} else {
}
}
}
tmp = -1;
if (xmlRelaxNGValidateElementEnd(ctxt, 0) == 0) {
tmp = 0;
break;
}
}
if (tmp != 0) {
/*
* validation error, log the message for the "best" one
*/
}
tabState[i]);
}
ret = -1;
} else {
if (ret == 0)
}
}
if (ret == 0) {
}
if (ret != 0) {
ret = 0;
#if 0
} else {
ret = -2;
#endif
}
} else {
}
#ifdef DEBUG
"xmlRelaxNGValidateDefinition(): validated %s : %d",
else
#endif
break;
case XML_RELAXNG_OPTIONAL:{
ret =
define->content);
if (ret != 0) {
ret = 0;
break;
}
} else {
ret = -1;
break;
}
}
ret = 0;
break;
}
case XML_RELAXNG_ONEORMORE:
if (ret != 0) {
break;
}
/* no break on purpose */
case XML_RELAXNG_ZEROORMORE:{
int progress;
int base, j;
ret = -1;
break;
}
/*
* All the input states are also exit states
*/
ctxt->
state));
} else {
ctxt->
states->
[j]));
}
}
do {
progress = 0;
define->
content);
if (ret == 0) {
if (tmp == 1)
progress = 1;
j++) {
tmp =
ctxt->
states->
[j]);
if (tmp == 1)
progress = 1;
}
}
} else {
}
}
}
} else {
define->
content);
if (ret != 0) {
} else {
if (tmp == 1)
progress = 1;
ctxt->
states->
tabState[j]);
if (tmp == 1)
progress = 1;
}
} else {
}
}
}
}
if (progress) {
/*
* Collect all the new nodes added at that step
* and make them the new node set
*/
res->
[base]);
} else {
progress = 0;
break;
}
}
(ctxt,
}
}
} while (progress == 1);
}
#if 0
/*
* errors may have to be propagated back...
*/
#endif
ret = 0;
break;
}
case XML_RELAXNG_CHOICE:{
/*
* node == NULL can't be optimized since IS_TRIABLE
* doesn't account for choice which may lead to
* only attributes.
*/
(xmlHashTablePtr) define->data;
/*
* Something we can optimize cleanly there is only one
* possble branch out !
*/
list =
list =
} else
list =
list =
NULL);
}
ret = -1;
break;
}
if (ret == 0) {
}
break;
}
if (ret == 0) {
}
tabState[i]);
}
}
} else {
}
}
ret = 0;
} else {
}
if (ret != 0) {
}
} else {
}
break;
}
case XML_RELAXNG_DEF:
case XML_RELAXNG_GROUP:
break;
case XML_RELAXNG_INTERLEAVE:
break;
case XML_RELAXNG_ATTRIBUTE:
break;
case XML_RELAXNG_START:
case XML_RELAXNG_NOOP:
case XML_RELAXNG_REF:
case XML_RELAXNG_EXTERNALREF:
case XML_RELAXNG_PARENTREF:
break;
case XML_RELAXNG_DATATYPE:{
ret = -1;
break;
}
/* TODO: handle entities ... */
}
if (ret == -1) {
break;
}
ret = -1;
break;
}
}
if (ret == -1) {
} else if (ret == 0) {
}
break;
}
case XML_RELAXNG_VALUE:{
ret = -1;
break;
}
/* TODO: handle entities ... */
}
if (ret == -1) {
break;
}
ret = -1;
break;
}
}
if (ret == -1) {
} else if (ret == 0) {
}
break;
}
case XML_RELAXNG_LIST:{
int len;
/*
* Make sure it's only text nodes
*/
ret = -1;
break;
}
/* TODO: handle entities ... */
}
if (ret == -1) {
break;
}
ret = -1;
break;
}
}
if (ret == -1) {
}
break;
}
case XML_RELAXNG_EXCEPT:
case XML_RELAXNG_PARAM:
break;
}
#ifdef DEBUG
"Validating %s ", xmlRelaxNGDefName(define));
if (ret == 0)
else
#endif
return (ret);
}
/**
* xmlRelaxNGValidateDefinition:
* @ctxt: a Relax-NG validation context
* @define: the definition to verify
*
* Validate the current node lists against the definition
*
* Returns 0 if the validation succeeded or an error code.
*/
static int
xmlRelaxNGDefinePtr define)
{
/*
* We should NOT have both ctxt->state and ctxt->states
*/
}
}
}
}
return (ret);
}
j = 0;
/*
* We should NOT have both ctxt->state and ctxt->states
*/
}
if (ret == 0) {
/* add the state to the container */
} else {
/* add the state directly in states */
}
} else {
/* make it the new container and copy other results */
for (k = 0; k < j; k++)
} else {
/* add all the new results to res and reff the container */
}
}
} else {
}
}
}
ret = 0;
} else if (j > 1) {
ret = 0;
} else if (j == 1) {
ret = 0;
} else {
ret = -1;
}
}
}
return (ret);
}
/**
* xmlRelaxNGValidateDocument:
* @ctxt: a Relax-NG validation context
* @doc: the document
*
* Validate the given document
*
* Returns 0 if the validation succeeded or an error code.
*/
static int
{
int ret;
return (-1);
return (-1);
}
if (ret != -1) {
ret = -1;
}
}
int i;
tmp = 0;
}
if (tmp == -1) {
if (ret != -1) {
ret = -1;
}
}
}
}
if (ret != 0)
#ifdef DEBUG
"%d Extra error messages left on stack !\n",
}
#endif
#ifdef LIBXML_VALID_ENABLED
ret = -1;
}
#endif /* LIBXML_VALID_ENABLED */
ret = -1;
return (ret);
}
/************************************************************************
* *
* Validation interfaces *
* *
************************************************************************/
/**
* xmlRelaxNGNewValidCtxt:
* @schema: a precompiled XML RelaxNGs
*
* Create an XML RelaxNGs validation context based on the given schema
*
* Returns the validation context or NULL in case of error
*/
{
return (NULL);
}
return (ret);
}
/**
* xmlRelaxNGFreeValidCtxt:
* @ctxt: the schema validation context
*
* Free the resources associated to the schema validation context
*/
void
{
int k;
return;
}
}
for (k = 0; k < ctxt->freeStatesNr; k++) {
}
}
}
}
}
/**
* xmlRelaxNGSetValidErrors:
* @ctxt: a Relax-NG validation context
* @err: the error function
* @warn: the warning function
* @ctx: the functions context
*
* Set the error and warning callback informations
*/
void
{
return;
}
/**
* xmlRelaxNGSetValidStructuredErrors:
* @ctxt: a Relax-NG validation context
* @serror: the structured error function
* @ctx: the functions context
*
* Set the structured error callback
*/
void
{
return;
}
/**
* xmlRelaxNGGetValidErrors:
* @ctxt: a Relax-NG validation context
* @err: the error function result
* @warn: the warning function result
* @ctx: the functions context result
*
* Get the error and warning callback informations
*
* Returns -1 in case of error and 0 otherwise
*/
int
{
return (-1);
return (0);
}
/**
* xmlRelaxNGValidateDoc:
* @ctxt: a Relax-NG validation context
* @doc: a parsed document tree
*
* Validate a document tree in memory.
*
* Returns 0 if the document is valid, a positive error code
* number otherwise and -1 in case of internal or API error.
*/
int
{
int ret;
return (-1);
/*
* TODO: build error codes
*/
if (ret == -1)
return (1);
return (ret);
}
#define bottom_relaxng
#include "elfgcchack.h"
#endif /* LIBXML_SCHEMAS_ENABLED */