xmlschemas.c revision 1f978fcb45a94792ad69b8928ce672591462b905
/*
* schemas.c : implementation of the XML Schema handling and
* schema validity checking
*
* See Copyright for the status of this software.
*
* Daniel Veillard <veillard@redhat.com>
*/
/*
* TODO:
* - when types are redefined in includes, check that all
* types in the redef list are equal
* -> need a type equality operation.
* - if we don't intend to use the schema for schemas, we
* need to validate all schema attributes (ref, type, name)
* against their types.
* - Eliminate item creation for: ??
*
* URGENT TODO:
* - For xsi-driven schema acquisition, augment the IDCs after every
* acquisition episode (xmlSchemaAugmentIDC).
*
* NOTES:
* - Elimated item creation for: <restriction>, <extension>,
* <simpleContent>, <complexContent>, <list>, <union>
*
* PROBLEMS:
* IDC XPath expression and chameleon includes: the targetNamespace is changed, so
* XPath will have trouble to resolve to this namespace, since not known.
*
*
* CONSTRAINTS:
*
* Schema Component Constraint:
* All Group Limited (cos-all-limited)
* Status: complete
* (1.2)
* In xmlSchemaGroupDefReferenceTermFixup() and
* (2)
* In xmlSchemaParseModelGroup()
* TODO: Actually this should go to component-level checks,
* but is done here due to performance. Move it to an other layer
* is schema construction via an API is implemented.
*/
#define IN_LIBXML
#include "libxml.h"
#ifdef LIBXML_SCHEMAS_ENABLED
#include <string.h>
#include <libxml/xmlmemory.h>
#include <libxml/parserInternals.h>
#include <libxml/xmlschemas.h>
#include <libxml/schemasInternals.h>
#include <libxml/xmlschemastypes.h>
#include <libxml/xmlautomata.h>
#include <libxml/xmlregexp.h>
#include <libxml/encoding.h>
#ifdef LIBXML_PATTERN_ENABLED
#endif
#ifdef LIBXML_READER_ENABLED
#include <libxml/xmlreader.h>
#endif
/* #define DEBUG 1 */
/* #define DEBUG_CONTENT 1 */
/* #define DEBUG_TYPE 1 */
/* #define DEBUG_CONTENT_REGEXP 1 */
/* #define DEBUG_AUTOMATA 1 */
/* #define DEBUG_IDC */
/* #define DEBUG_IDC_NODE_TABLE */
/* #define WXS_ELEM_DECL_CONS_ENABLED */
#ifdef DEBUG_IDC
#ifndef DEBUG_IDC_NODE_TABLE
#define DEBUG_IDC_NODE_TABLE
#endif
#endif
/* #define ENABLE_PARTICLE_RESTRICTION 1 */
#define ENABLE_REDEFINE
/* #define ENABLE_NAMED_LOCALS */
/* #define ENABLE_IDC_NODE_TABLES_TEST */
#define DUMP_CONTENT_MODEL
#ifdef LIBXML_READER_ENABLED
/* #define XML_SCHEMA_READER_ENABLED */
#endif
#define TODO \
"Unimplemented block at %s:%d\n", \
/*
* The XML Schemas namespaces
*/
/*
* Come casting macros.
*/
#define ACTXT_CAST (xmlSchemaAbstractCtxtPtr)
#define PCTXT_CAST (xmlSchemaParserCtxtPtr)
#define VCTXT_CAST (xmlSchemaValidCtxtPtr)
#define WXS_BASIC_CAST (xmlSchemaBasicItemPtr)
#define WXS_TREE_CAST (xmlSchemaTreeItemPtr)
#define WXS_PTC_CAST (xmlSchemaParticlePtr)
#define WXS_TYPE_CAST (xmlSchemaTypePtr)
#define WXS_ELEM_CAST (xmlSchemaElementPtr)
#define WXS_ATTR_CAST (xmlSchemaAttributePtr)
#define WXS_ATTR_USE_CAST (xmlSchemaAttributeUsePtr)
#define WXS_MODEL_GROUP_CAST (xmlSchemaModelGroupPtr)
#define WXS_IDC_CAST (xmlSchemaIDCPtr)
#define WXS_QNAME_CAST (xmlSchemaQNameRefPtr)
#define WXS_LIST_CAST (xmlSchemaItemListPtr)
/*
* Macros to query common properties of components.
*/
/*
* Macros for element declarations.
*/
#define WXS_ELEM_TYPEDEF(e) (e)->subtypes
/*
* Macros for attribute declarations.
*/
#define WXS_ATTR_TYPEDEF(a) (a)->subtypes
/*
* Macros for attribute uses.
*/
/*
* Macros for attribute groups.
*/
#define WXS_ATTR_GROUP_HAS_REFS(ag) ((WXS_ATTR_GROUP_CAST (ag))->flags & XML_SCHEMAS_ATTRGROUP_HAS_REFS)
#define WXS_ATTR_GROUP_EXPANDED(ag) ((WXS_ATTR_GROUP_CAST (ag))->flags & XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED)
/*
* Macros for particles.
*/
#define WXS_PARTICLE(p) WXS_PTC_CAST (p)
/*
* Macros for model groups definitions.
*/
/*
* Macros for model groups.
*/
#define WXS_IS_MODEL_GROUP(i) \
(((i)->type == XML_SCHEMA_TYPE_SEQUENCE) || \
((i)->type == XML_SCHEMA_TYPE_CHOICE) || \
((i)->type == XML_SCHEMA_TYPE_ALL))
/*
* Macros for schema buckets.
*/
#define WXS_IS_BUCKET_INCREDEF(t) (((t) == XML_SCHEMA_SCHEMA_INCLUDE) || \
((t) == XML_SCHEMA_SCHEMA_REDEFINE))
#define WXS_IS_BUCKET_IMPMAIN(t) (((t) == XML_SCHEMA_SCHEMA_MAIN) || \
((t) == XML_SCHEMA_SCHEMA_IMPORT))
#define WXS_IMPBUCKET(b) ((xmlSchemaImportPtr) (b))
#define WXS_INCBUCKET(b) ((xmlSchemaIncludePtr) (b))
/*
*/
#define WXS_IS_ANYTYPE(i) \
(( (i)->type == XML_SCHEMA_TYPE_BASIC) && \
#define WXS_IS_COMPLEX(i) \
(((i)->type == XML_SCHEMA_TYPE_COMPLEX) || \
((i)->builtInType == XML_SCHEMAS_ANYTYPE))
#define WXS_IS_SIMPLE(item) \
#define WXS_IS_ANY_SIMPLE_TYPE(i) \
(((i)->type == XML_SCHEMA_TYPE_BASIC) && \
((i)->builtInType == XML_SCHEMAS_ANYSIMPLETYPE))
#define WXS_IS_RESTRICTION(t) \
#define WXS_IS_EXTENSION(t) \
#define WXS_IS_TYPE_NOT_FIXED(i) \
(((i)->type != XML_SCHEMA_TYPE_BASIC) && \
(((i)->flags & XML_SCHEMAS_TYPE_INTERNAL_RESOLVED) == 0))
#define WXS_IS_TYPE_NOT_FIXED_1(item) \
/*
* Macros for exclusively for complex types.
*/
#define WXS_HAS_COMPLEX_CONTENT(item) \
#define WXS_HAS_SIMPLE_CONTENT(item) \
#define WXS_HAS_MIXED_CONTENT(item) \
#define WXS_EMPTIABLE(t) \
#define WXS_TYPE_CONTENTTYPE(t) (t)->subtypes
/*
* Macros for exclusively for simple types.
*/
#define WXS_LIST_ITEMTYPE(t) (t)->subtypes
/*
* Misc parser context macros.
*/
#define WXS_HAS_BUCKETS(ctx) \
/*
* xmlSchemaItemList macros.
*/
/*
* Misc macros.
*/
/*
* use pointer comparison for those values.
* REMOVED: (xmlStrEqual((v1), (v2)))
*/
/*
* Some flags used for various schema constraints.
*/
#define SUBSET_RESTRICTION 1<<0
typedef struct _xmlSchemaNodeInfo xmlSchemaNodeInfo;
typedef xmlSchemaNodeInfo *xmlSchemaNodeInfoPtr;
typedef struct _xmlSchemaItemList xmlSchemaItemList;
typedef xmlSchemaItemList *xmlSchemaItemListPtr;
struct _xmlSchemaItemList {
void **items; /* used for dynamic addition of schemata */
int nbItems; /* used for dynamic addition of schemata */
int sizeItems; /* used for dynamic addition of schemata */
};
#define XML_SCHEMA_CTXT_PARSER 1
#define XML_SCHEMA_CTXT_VALIDATOR 2
typedef struct _xmlSchemaAbstractCtxt xmlSchemaAbstractCtxt;
struct _xmlSchemaAbstractCtxt {
int type; /* E.g. XML_SCHEMA_CTXT_VALIDATOR */
};
typedef struct _xmlSchemaBucket xmlSchemaBucket;
typedef xmlSchemaBucket *xmlSchemaBucketPtr;
#define XML_SCHEMA_SCHEMA_MAIN 0
#define XML_SCHEMA_SCHEMA_IMPORT 1
#define XML_SCHEMA_SCHEMA_INCLUDE 2
#define XML_SCHEMA_SCHEMA_REDEFINE 3
/**
* xmlSchemaSchemaRelation:
*
* Used to create a graph of schema relationships.
*/
typedef struct _xmlSchemaSchemaRelation xmlSchemaSchemaRelation;
struct _xmlSchemaSchemaRelation {
int type; /* E.g. XML_SCHEMA_SCHEMA_IMPORT */
const xmlChar *importNamespace;
};
#define XML_SCHEMA_BUCKET_MARKED 1<<0
struct _xmlSchemaBucket {
int type;
int flags;
const xmlChar *schemaLocation;
const xmlChar *origTargetNamespace;
const xmlChar *targetNamespace;
int located;
int parsed;
int imported;
int preserveDoc;
};
/**
* xmlSchemaImport:
* (extends xmlSchemaBucket)
*
* Reflects a schema. Holds some information
* about the schema and its toplevel components. Duplicate
* toplevel components are not checked at this level.
*/
typedef struct _xmlSchemaImport xmlSchemaImport;
typedef xmlSchemaImport *xmlSchemaImportPtr;
struct _xmlSchemaImport {
int type; /* Main OR import OR include. */
int flags;
/* For chameleon includes, @origTargetNamespace will be NULL */
const xmlChar *origTargetNamespace;
/*
* For chameleon includes, @targetNamespace will be the
* targetNamespace of the including schema.
*/
const xmlChar *targetNamespace;
int located;
int parsed;
int imported;
int preserveDoc;
/* The imported schema. */
};
/*
* (extends xmlSchemaBucket)
*/
typedef struct _xmlSchemaInclude xmlSchemaInclude;
typedef xmlSchemaInclude *xmlSchemaIncludePtr;
struct _xmlSchemaInclude {
int type;
int flags;
const xmlChar *schemaLocation;
const xmlChar *origTargetNamespace;
const xmlChar *targetNamespace;
int located;
int parsed;
int imported;
int preserveDoc;
/* The owning main or import schema bucket. */
};
/**
* xmlSchemaBasicItem:
*
* The abstract base type for schema components.
*/
typedef struct _xmlSchemaBasicItem xmlSchemaBasicItem;
typedef xmlSchemaBasicItem *xmlSchemaBasicItemPtr;
struct _xmlSchemaBasicItem {
};
/**
* xmlSchemaAnnotItem:
*
* The abstract base type for annotated schema components.
* (Extends xmlSchemaBasicItem)
*/
typedef struct _xmlSchemaAnnotItem xmlSchemaAnnotItem;
typedef xmlSchemaAnnotItem *xmlSchemaAnnotItemPtr;
struct _xmlSchemaAnnotItem {
};
/**
* xmlSchemaTreeItem:
*
* The abstract base type for tree-like structured schema components.
* (Extends xmlSchemaAnnotItem)
*/
typedef struct _xmlSchemaTreeItem xmlSchemaTreeItem;
typedef xmlSchemaTreeItem *xmlSchemaTreeItemPtr;
struct _xmlSchemaTreeItem {
};
#define XML_SCHEMA_ATTR_USE_FIXED 1<<0
/**
* xmlSchemaAttributeUsePtr:
*
* The abstract base type for tree-like structured schema components.
* (Extends xmlSchemaTreeItem)
*/
typedef struct _xmlSchemaAttributeUse xmlSchemaAttributeUse;
struct _xmlSchemaAttributeUse {
/*
* The attr. decl. OR a QName-ref. to an attr. decl. OR
* a QName-ref. to an attribute group definition.
*/
int flags;
int occurs; /* required, optional */
};
/**
* xmlSchemaAttributeUseProhibPtr:
*
* A helper component to reflect attribute prohibitions.
* (Extends xmlSchemaBasicItem)
*/
typedef struct _xmlSchemaAttributeUseProhib xmlSchemaAttributeUseProhib;
struct _xmlSchemaAttributeUseProhib {
const xmlChar *targetNamespace;
int isRef;
};
/**
* xmlSchemaRedef:
*/
typedef struct _xmlSchemaRedef xmlSchemaRedef;
typedef xmlSchemaRedef *xmlSchemaRedefPtr;
struct _xmlSchemaRedef {
to-be-redefined comp. */
};
/**
* xmlSchemaConstructionCtxt:
*/
typedef struct _xmlSchemaConstructionCtxt xmlSchemaConstructionCtxt;
struct _xmlSchemaConstructionCtxt {
/* xmlSchemaItemListPtr relations; */ /* List of schema relations. */
need to be fixed. */
};
#define XML_SCHEMAS_PARSE_ERROR 1
#define SCHEMAS_PARSE_OPTIONS XML_PARSE_NOENT
struct _xmlSchemaParserCtxt {
int type;
void *errCtxt; /* user specific error context */
int err;
int nberrors;
int ownsConstructor; /* TODO: Move this to parser *flags*. */
/* xmlSchemaPtr topschema; */
/* xmlHashTablePtr namespaces; */
int counter;
int preserve; /* Whether the doc should be freed */
const char *buffer;
int size;
/*
* Used to build complex element content models
*/
int options;
int isS4S;
int isRedefine;
int xsiAssemble;
int stop; /* If the parser should stop; i.e. a critical error. */
const xmlChar *targetNamespace;
int redefCounter; /* Used for redefinitions. */
};
/**
* xmlSchemaQNameRef:
*
* A component reference item (not a schema component)
* (Extends xmlSchemaBasicItem)
*/
typedef struct _xmlSchemaQNameRef xmlSchemaQNameRef;
typedef xmlSchemaQNameRef *xmlSchemaQNameRefPtr;
struct _xmlSchemaQNameRef {
const xmlChar *targetNamespace;
};
/**
* xmlSchemaParticle:
*
* A particle component.
* (Extends xmlSchemaTreeItem)
*/
typedef struct _xmlSchemaParticle xmlSchemaParticle;
typedef xmlSchemaParticle *xmlSchemaParticlePtr;
struct _xmlSchemaParticle {
a group definition, a XML_SCHEMA_EXTRA_QNAMEREF (if a reference),
etc.) */
int minOccurs;
int maxOccurs;
};
/**
* xmlSchemaModelGroup:
*
* A model group component.
* (Extends xmlSchemaTreeItem)
*/
typedef struct _xmlSchemaModelGroup xmlSchemaModelGroup;
typedef xmlSchemaModelGroup *xmlSchemaModelGroupPtr;
struct _xmlSchemaModelGroup {
};
#define XML_SCHEMA_MODEL_GROUP_DEF_MARKED 1<<0
/**
* xmlSchemaModelGroupDef:
*
* A model group definition component.
* (Extends xmlSchemaTreeItem)
*/
typedef struct _xmlSchemaModelGroupDef xmlSchemaModelGroupDef;
struct _xmlSchemaModelGroupDef {
const xmlChar *targetNamespace;
int flags;
};
typedef struct _xmlSchemaIDC xmlSchemaIDC;
typedef xmlSchemaIDC *xmlSchemaIDCPtr;
/**
* xmlSchemaIDCSelect:
*
* The identity-constraint "field" and "selector" item, holding the
* XPath expression.
*/
typedef struct _xmlSchemaIDCSelect xmlSchemaIDCSelect;
typedef xmlSchemaIDCSelect *xmlSchemaIDCSelectPtr;
struct _xmlSchemaIDCSelect {
int index; /* an index position if significant for IDC key-sequences */
void *xpathComp; /* the compiled XPath expression */
};
/**
* xmlSchemaIDC:
*
* The identity-constraint definition component.
* (Extends xmlSchemaAnnotItem)
*/
struct _xmlSchemaIDC {
const xmlChar *targetNamespace;
int nbFields;
};
/**
* xmlSchemaIDCAug:
*
* The augmented IDC information used for validation.
*/
typedef struct _xmlSchemaIDCAug xmlSchemaIDCAug;
typedef xmlSchemaIDCAug *xmlSchemaIDCAugPtr;
struct _xmlSchemaIDCAug {
int keyrefDepth; /* the lowest tree level to which IDC
tables need to be bubbled upwards */
};
/**
* xmlSchemaPSVIIDCKeySequence:
*
* The key sequence of a node table item.
*/
typedef struct _xmlSchemaPSVIIDCKey xmlSchemaPSVIIDCKey;
typedef xmlSchemaPSVIIDCKey *xmlSchemaPSVIIDCKeyPtr;
struct _xmlSchemaPSVIIDCKey {
};
/**
* xmlSchemaPSVIIDCNode:
*
* The node table item of a node table.
*/
typedef struct _xmlSchemaPSVIIDCNode xmlSchemaPSVIIDCNode;
typedef xmlSchemaPSVIIDCNode *xmlSchemaPSVIIDCNodePtr;
struct _xmlSchemaPSVIIDCNode {
int nodeLine;
int nodeQNameID;
};
/**
* xmlSchemaPSVIIDCBinding:
*
* The identity-constraint binding item of the [identity-constraint table].
*/
typedef struct _xmlSchemaPSVIIDCBinding xmlSchemaPSVIIDCBinding;
struct _xmlSchemaPSVIIDCBinding {
int nbNodes; /* number of entries in the node table */
int sizeNodes; /* size of the node table */
};
#define XPATH_STATE_OBJ_TYPE_IDC_SELECTOR 1
#define XPATH_STATE_OBJ_TYPE_IDC_FIELD 2
#define XPATH_STATE_OBJ_MATCHES -2
#define XPATH_STATE_OBJ_BLOCKED -3
typedef struct _xmlSchemaIDCMatcher xmlSchemaIDCMatcher;
typedef xmlSchemaIDCMatcher *xmlSchemaIDCMatcherPtr;
/**
* xmlSchemaIDCStateObj:
*
* The state object used to evaluate XPath expressions.
*/
typedef struct _xmlSchemaIDCStateObj xmlSchemaIDCStateObj;
typedef xmlSchemaIDCStateObj *xmlSchemaIDCStateObjPtr;
struct _xmlSchemaIDCStateObj {
int type;
int depth; /* depth of creation */
int *history; /* list of (depth, state-id) tuples */
int nbHistory;
int sizeHistory;
matcher */
void *xpathCtxt;
};
#define IDC_MATCHER 0
/**
* xmlSchemaIDCMatcher:
*
* Used to evaluate IDC selectors (and fields).
*/
struct _xmlSchemaIDCMatcher {
int type;
int depth; /* the tree depth at creation time */
int idcType;
elements */
int sizeKeySeqs;
(xmlSchemaPSVIIDCNodePtr) entries */
};
/*
* Element info flags.
*/
#define XML_SCHEMA_NODE_INFO_FLAG_OWNED_NAMES 1<<0
/**
* xmlSchemaNodeInfo:
*
* Holds information of an element node.
*/
struct _xmlSchemaNodeInfo {
int nodeType;
int nodeLine;
int flags; /* combination of node info flags */
int valNeeded;
int normVal;
int depth;
for the scope element*/
element */
int nbNsBindings;
int sizeNsBindings;
int hasKeyrefs;
int appliedXPath; /* Indicates that an XPath has been applied. */
};
#define XML_SCHEMAS_ATTR_UNKNOWN 1
#define XML_SCHEMAS_ATTR_ASSESSED 2
#define XML_SCHEMAS_ATTR_PROHIBITED 3
#define XML_SCHEMAS_ATTR_ERR_MISSING 4
#define XML_SCHEMAS_ATTR_INVALID_VALUE 5
#define XML_SCHEMAS_ATTR_ERR_NO_TYPE 6
#define XML_SCHEMAS_ATTR_ERR_FIXED_VALUE 7
#define XML_SCHEMAS_ATTR_DEFAULT 8
#define XML_SCHEMAS_ATTR_VALIDATE_VALUE 9
#define XML_SCHEMAS_ATTR_ERR_WILD_STRICT_NO_DECL 10
#define XML_SCHEMAS_ATTR_HAS_ATTR_USE 11
#define XML_SCHEMAS_ATTR_HAS_ATTR_DECL 12
#define XML_SCHEMAS_ATTR_WILD_SKIP 13
#define XML_SCHEMAS_ATTR_WILD_LAX_NO_DECL 14
#define XML_SCHEMAS_ATTR_ERR_WILD_DUPLICATE_ID 15
#define XML_SCHEMAS_ATTR_ERR_WILD_AND_USE_ID 16
#define XML_SCHEMAS_ATTR_META 17
/*
* @metaType values of xmlSchemaAttrInfo.
*/
#define XML_SCHEMA_ATTR_INFO_META_XSI_TYPE 1
#define XML_SCHEMA_ATTR_INFO_META_XSI_NIL 2
#define XML_SCHEMA_ATTR_INFO_META_XSI_SCHEMA_LOC 3
#define XML_SCHEMA_ATTR_INFO_META_XMLNS 5
typedef struct _xmlSchemaAttrInfo xmlSchemaAttrInfo;
typedef xmlSchemaAttrInfo *xmlSchemaAttrInfoPtr;
struct _xmlSchemaAttrInfo {
int nodeType;
int nodeLine;
int flags; /* combination of node info flags */
int state;
int metaType;
};
#define XML_SCHEMA_VALID_CTXT_FLAG_STREAM 1
/**
* xmlSchemaValidCtxt:
*
* A Schemas validation context
*/
struct _xmlSchemaValidCtxt {
int type;
void *errCtxt; /* user specific data block */
void *user_data; /* TODO: What is this for? */
int err;
int nberrors;
/* xmlSchemaTypePtr type; */
int valueWS;
int options;
int xsiAssemble;
int depth;
int sizeElemInfos;
int nbIdcNodes;
int sizeIdcNodes;
int nbIdcKeys;
int sizeIdcKeys;
int flags;
#ifdef LIBXML_READER_ENABLED
#endif
int nbAttrInfos;
int sizeAttrInfos;
int skipDepth;
int hasKeyrefs;
int createIDCNodeTables;
};
/**
* xmlSchemaSubstGroup:
*
*
*/
typedef struct _xmlSchemaSubstGroup xmlSchemaSubstGroup;
typedef xmlSchemaSubstGroup *xmlSchemaSubstGroupPtr;
struct _xmlSchemaSubstGroup {
};
/************************************************************************
* *
* Some predeclarations *
* *
************************************************************************/
static int
static const xmlChar *
static int
static int
static void
static xmlSchemaWhitespaceValueType
static xmlSchemaTreeItemPtr
int withParticle);
static const xmlChar *
static xmlSchemaTypeLinkPtr
static void
const char *funcName,
const char *message);
static int
int subset);
static void
static void
static xmlSchemaQNameRefPtr
/************************************************************************
* *
* Helper functions *
* *
************************************************************************/
/**
* xmlSchemaItemTypeToStr:
* @type: the type of the schema item
*
* Returns the component name of a schema item.
*/
static const xmlChar *
{
switch (type) {
case XML_SCHEMA_TYPE_BASIC:
return(BAD_CAST "simple type definition");
case XML_SCHEMA_TYPE_SIMPLE:
return(BAD_CAST "simple type definition");
case XML_SCHEMA_TYPE_COMPLEX:
return(BAD_CAST "complex type definition");
case XML_SCHEMA_TYPE_ELEMENT:
return(BAD_CAST "element declaration");
return(BAD_CAST "attribute use");
return(BAD_CAST "attribute declaration");
case XML_SCHEMA_TYPE_GROUP:
return(BAD_CAST "model group definition");
return(BAD_CAST "attribute group definition");
case XML_SCHEMA_TYPE_NOTATION:
return(BAD_CAST "notation declaration");
case XML_SCHEMA_TYPE_SEQUENCE:
return(BAD_CAST "model group (sequence)");
case XML_SCHEMA_TYPE_CHOICE:
return(BAD_CAST "model group (choice)");
case XML_SCHEMA_TYPE_ALL:
return(BAD_CAST "model group (all)");
case XML_SCHEMA_TYPE_PARTICLE:
return(BAD_CAST "particle");
return(BAD_CAST "unique identity-constraint");
/* return(BAD_CAST "IDC (unique)"); */
case XML_SCHEMA_TYPE_IDC_KEY:
return(BAD_CAST "key identity-constraint");
/* return(BAD_CAST "IDC (key)"); */
return(BAD_CAST "keyref identity-constraint");
/* return(BAD_CAST "IDC (keyref)"); */
case XML_SCHEMA_TYPE_ANY:
return(BAD_CAST "wildcard (any)");
return(BAD_CAST "[helper component] QName reference");
return(BAD_CAST "[helper component] attribute use prohibition");
default:
return(BAD_CAST "Not a schema component");
}
}
/**
* xmlSchemaGetComponentTypeStr:
* @type: the type of the schema item
*
* Returns the component name of a schema item.
*/
static const xmlChar *
{
case XML_SCHEMA_TYPE_BASIC:
return(BAD_CAST "complex type definition");
else
return(BAD_CAST "simple type definition");
default:
}
}
/**
* xmlSchemaGetComponentNode:
* @item: a schema component
*
* Returns node associated with the schema component.
* NOTE that such a node need not be available; plus, a component's
* node need not to reflect the component directly, since there is no
* one-to-one relationship between the XML Schema representation and
* the component representation.
*/
static xmlNodePtr
{
case XML_SCHEMA_TYPE_ELEMENT:
case XML_SCHEMA_TYPE_COMPLEX:
case XML_SCHEMA_TYPE_SIMPLE:
case XML_SCHEMA_TYPE_ANY:
case XML_SCHEMA_TYPE_PARTICLE:
case XML_SCHEMA_TYPE_SEQUENCE:
case XML_SCHEMA_TYPE_CHOICE:
case XML_SCHEMA_TYPE_ALL:
case XML_SCHEMA_TYPE_GROUP:
case XML_SCHEMA_TYPE_IDC_KEY:
/* TODO: What to do with NOTATIONs?
case XML_SCHEMA_TYPE_NOTATION:
return (((xmlSchemaNotationPtr) item)->node);
*/
default:
return (NULL);
}
}
#if 0
/**
* xmlSchemaGetNextComponent:
* @item: a schema component
*
* Returns the next sibling of the schema component.
*/
static xmlSchemaBasicItemPtr
{
case XML_SCHEMA_TYPE_ELEMENT:
case XML_SCHEMA_TYPE_COMPLEX:
case XML_SCHEMA_TYPE_SIMPLE:
case XML_SCHEMA_TYPE_ANY:
return (NULL);
case XML_SCHEMA_TYPE_PARTICLE:
case XML_SCHEMA_TYPE_SEQUENCE:
case XML_SCHEMA_TYPE_CHOICE:
case XML_SCHEMA_TYPE_ALL:
return (NULL);
case XML_SCHEMA_TYPE_GROUP:
return (NULL);
case XML_SCHEMA_TYPE_IDC_KEY:
default:
return (NULL);
}
}
#endif
/**
* xmlSchemaFormatQName:
* @buf: the string buffer
* @namespaceName: the namespace name
* @localName: the local name
*
* Returns the given QName in the format "{namespaceName}localName" or
* just "localName" if @namespaceName is NULL.
*
* Returns the localName if @namespaceName is NULL, a formatted
* string otherwise.
*/
static const xmlChar*
const xmlChar *namespaceName,
{
if (namespaceName != NULL) {
}
if (namespaceName == NULL)
return(localName);
} else {
}
}
static const xmlChar*
{
else
}
static const xmlChar *
{
case XML_SCHEMA_TYPE_ELEMENT:
case XML_SCHEMA_TYPE_BASIC:
case XML_SCHEMA_TYPE_SIMPLE:
case XML_SCHEMA_TYPE_COMPLEX:
case XML_SCHEMA_TYPE_GROUP:
case XML_SCHEMA_TYPE_IDC_KEY:
return(xmlSchemaGetComponentName(
} else
return(NULL);
case XML_SCHEMA_TYPE_NOTATION:
default:
/*
* Other components cannot have names.
*/
break;
}
return (NULL);
}
/*
static const xmlChar *
xmlSchemaGetQNameRefName(void *ref)
{
return(((xmlSchemaQNameRefPtr) ref)->name);
}
static const xmlChar *
xmlSchemaGetQNameRefTargetNs(void *ref)
{
return(((xmlSchemaQNameRefPtr) ref)->targetNamespace);
}
*/
static const xmlChar *
{
case XML_SCHEMA_TYPE_ELEMENT:
case XML_SCHEMA_TYPE_BASIC:
return (BAD_CAST "http://www.w3.org/2001/XMLSchema");
case XML_SCHEMA_TYPE_SIMPLE:
case XML_SCHEMA_TYPE_COMPLEX:
case XML_SCHEMA_TYPE_GROUP:
case XML_SCHEMA_TYPE_IDC_KEY:
return(xmlSchemaGetComponentTargetNs(
}
/* TODO: Will returning NULL break something? */
break;
case XML_SCHEMA_TYPE_NOTATION:
default:
/*
* Other components cannot have names.
*/
break;
}
return (NULL);
}
static const xmlChar*
void *item)
{
return (xmlSchemaFormatQName(buf,
}
static const xmlChar*
{
return(*buf);
}
static const xmlChar*
{
}
/**
* xmlSchemaWildcardPCToString:
* @pc: the type of processContents
*
* Returns a string representation of the type of
* processContents.
*/
static const xmlChar *
{
switch (pc) {
case XML_SCHEMAS_ANY_SKIP:
return (BAD_CAST "skip");
case XML_SCHEMAS_ANY_LAX:
return (BAD_CAST "lax");
case XML_SCHEMAS_ANY_STRICT:
return (BAD_CAST "strict");
default:
return (BAD_CAST "invalid process contents");
}
}
/**
* xmlSchemaGetCanonValueWhtspExt:
* @val: the precomputed value
* @retValue: the returned value
* @ws: the whitespace type of the value
*
* Get a the cononical representation of the value.
* The caller has to free the returned retValue.
*
* Returns 0 if the value could be built and -1 in case of
* API errors or if the value type is not supported yet.
*/
static int
{
int list;
return (-1);
do {
switch (valType) {
case XML_SCHEMAS_STRING:
case XML_SCHEMAS_NORMSTRING:
if (ws == XML_SCHEMA_WHITESPACE_COLLAPSE)
else if (ws == XML_SCHEMA_WHITESPACE_REPLACE)
}
break;
default:
goto internal_error;
}
}
if (! list)
} else
/* List. */
}
return (0);
return (-1);
}
/**
* xmlSchemaFormatItemForReport:
* @buf: the string buffer
* @itemDes: the designation of the item
* @itemName: the name of the item
* @item: the item as an object
* @itemNode: the node of the item
* @local: the local name
* @parsing: if the function is used during the parse
*
* Returns a representation of the given item used
* for error reports.
*
* The following order is used to build the resulting
* designation if the arguments are not NULL:
* 1a. If itemDes not NULL -> itemDes
* 1b. If (itemDes not NULL) and (itemName not NULL)
* -> itemDes + itemName
* 2. If the preceding was NULL and (item not NULL) -> item
* 3. If the preceding was NULL and (itemNode not NULL) -> itemNode
*
* If the itemNode is an attribute node, the name of the attribute
* will be appended to the result.
*
* Returns the formatted string and sets @buf to the resulting value.
*/
static xmlChar*
{
int named = 1;
}
case XML_SCHEMA_TYPE_BASIC: {
if (WXS_IS_ATOMIC(type))
else if (WXS_IS_LIST(type))
else if (WXS_IS_UNION(type))
else
}
break;
case XML_SCHEMA_TYPE_SIMPLE: {
} else {
}
if (WXS_IS_ATOMIC(type))
else if (WXS_IS_LIST(type))
else if (WXS_IS_UNION(type))
else
}
}
break;
case XML_SCHEMA_TYPE_COMPLEX: {
else
}
}
break;
case XML_SCHEMA_TYPE_ATTRIBUTE_USE: {
} else {
}
}
break;
case XML_SCHEMA_TYPE_ATTRIBUTE: {
}
break;
break;
case XML_SCHEMA_TYPE_ELEMENT: {
}
break;
case XML_SCHEMA_TYPE_IDC_KEY:
else
break;
case XML_SCHEMA_TYPE_ANY:
break;
case XML_SCHEMA_FACET_PATTERN:
case XML_SCHEMA_FACET_LENGTH:
break;
case XML_SCHEMA_TYPE_GROUP: {
}
break;
case XML_SCHEMA_TYPE_SEQUENCE:
case XML_SCHEMA_TYPE_CHOICE:
case XML_SCHEMA_TYPE_ALL:
case XML_SCHEMA_TYPE_PARTICLE:
break;
case XML_SCHEMA_TYPE_NOTATION: {
}
default:
named = 0;
}
} else
named = 0;
else
} else
}
} else
}
return (*buf);
}
/**
* xmlSchemaFormatFacetEnumSet:
* @buf: the string buffer
* @type: the type holding the enumeration facets
*
* Builds a string consisting of all enumeration elements.
*
* Returns a string of all enumeration elements.
*/
static const xmlChar *
{
do {
/*
* Use the whitespace type of the base type.
*/
continue;
found = 1;
if (res == -1) {
"xmlSchemaFormatFacetEnumSet",
"compute the canonical lexical representation");
return (NULL);
}
else
}
}
/*
* The enumeration facet of a type restricts the enumeration
* facet of the ancestor type; i.e., such restricted enumerations
* do not belong to the set of the given type. Thus we break
* on the first found enumeration.
*/
if (found)
break;
}
/************************************************************************
* *
* Error functions *
* *
************************************************************************/
#if 0
static void
xmlSchemaErrMemory(const char *msg)
{
msg);
}
#endif
static void
xmlSchemaPSimpleErr(const char *msg)
{
msg);
}
/**
* xmlSchemaPErrMemory:
* @node: a context node
* @extra: extra informations
*
* Handle an out of memory condition
*/
static void
{
extra);
}
/**
* xmlSchemaPErr:
* @ctxt: the parsing context
* @node: the context node
* @error: the error code
* @msg: the error message
* @str1: extra data
* @str2: extra data
*
* Handle a parser error
*/
static void
{
}
}
/**
* xmlSchemaPErr2:
* @ctxt: the parsing context
* @node: the context node
* @node: the current child
* @error: the error code
* @msg: the error message
* @str1: extra data
* @str2: extra data
*
* Handle a parser error
*/
static void
{
else
}
/**
* xmlSchemaPErrExt:
* @ctxt: the parsing context
* @node: the context node
* @error: the error code
* @strData1: extra data
* @strData2: extra data
* @strData3: extra data
* @msg: the message
* @str1: extra parameter for the message display
* @str2: extra parameter for the message display
* @str3: extra parameter for the message display
* @str4: extra parameter for the message display
* @str5: extra parameter for the message display
*
* Handle a parser error
*/
static void
{
}
}
/************************************************************************
* *
* Allround error functions *
* *
************************************************************************/
/**
* xmlSchemaVTypeErrMemory:
* @node: a context node
* @extra: extra informations
*
* Handle an out of memory condition
*/
static void
{
}
extra);
}
static void
{
}
#define WXS_ERROR_TYPE_ERROR 1
#define WXS_ERROR_TYPE_WARNING 2
/**
* xmlSchemaErr3:
* @ctxt: the validation context
* @node: the context node
* @error: the error code
* @msg: the error message
* @str1: extra data
* @str2: extra data
* @str3: extra data
*
* Handle a validation error
*/
static void
{
if (errorLevel != XML_ERR_WARNING) {
} else {
}
/*
* Error node. If we specify a line number, then
* do not channel any node to the error function.
*/
if (line == 0) {
}
/*
* Get filename and line if no node-tree.
*/
}
} else {
/*
* Override the given node's (if any) position
* and channel only the given line number.
*/
/*
* Get filename.
*/
}
if (errorLevel != XML_ERR_WARNING) {
} else {
}
errorLevel, NULL, 0,
} else {
}
}
}
/**
* xmlSchemaErr3:
* @ctxt: the validation context
* @node: the context node
* @error: the error code
* @msg: the error message
* @str1: extra data
* @str2: extra data
* @str3: extra data
*
* Handle a validation error
*/
static void
{
}
static void
{
}
static void
{
}
static xmlChar *
{
{
/*
* Don't try to format other nodes than element and
* attribute nodes.
* Play save and return an empty string.
*/
return(*msg);
}
/*
* Work on tree nodes.
*/
else
} else {
}
else
/*
* Work on node infos.
*/
} else {
}
/*
* Hmm, no node while parsing?
* Return an empty string, in case NULL will break something.
*/
} else {
return (NULL);
}
/*
* VAL TODO: The output of the given schema component is currently
* disabled.
*/
#if 0
}
#endif
return (*msg);
}
static void
const char *funcName,
const char *message,
{
return;
}
static void
const char *funcName,
const char *message)
{
}
#if 0
static void
const char *funcName,
const char *message,
{
}
#endif
static void
const char *message,
{
} else
}
static void
const char *message,
{
}
static void
const char *message,
{
/* URGENT TODO: Set the error code to something sane. */
}
static void
const char *message,
{
}
static int
{
return (-1);
}
static int
{
case XML_SCHEMA_TYPE_COMPLEX:
case XML_SCHEMA_TYPE_SIMPLE:
return(1);
break;
case XML_SCHEMA_TYPE_GROUP:
return (1);
case XML_SCHEMA_TYPE_ELEMENT:
return(1);
break;
return(1);
break;
/* Note that attribute groups are always global. */
default:
return(1);
}
return (0);
}
static void
int displayValue)
{
else
"value of ");
if (! xmlSchemaIsGlobalItem(type))
else
if (WXS_IS_ATOMIC(type))
else if (WXS_IS_LIST(type))
else if (WXS_IS_UNION(type))
if (xmlSchemaIsGlobalItem(type)) {
if (type->builtInType != 0) {
} else
}
else
}
static const xmlChar *
{
else
return (NULL);
}
static void
{
NULL);
}
static void
const char *message,
int nbval,
int nbneg,
{
int i;
/*
* Note that is does not make sense to report that we have a
* wildcard here, since the wildcard might be unfolded into
* multiple transitions.
*/
} else
continue;
cur += 4;
}
/*
* Get the local name.
*/
if (*end == '*') {
end++;
} else {
end++;
}
if (*end != 0) {
end++;
/*
* Skip "*|*" if they come with negated expressions, since
* they represent the same negated wildcard.
*/
/*
* Get the namespace name.
*/
if (*end == '*') {
} else {
while (*end != 0)
end++;
if (i >= nbval)
else
}
} else {
continue;
}
}
}
} else
}
static void
unsigned long length,
const char *message,
{
if (error == XML_SCHEMAV_CVC_ENUMERATION_VALID) {
/*
* If enumerations are validated, one must not expect the
* facet to be given.
*/
} else
/*
* Use a default message.
*/
if ((facetType == XML_SCHEMA_FACET_LENGTH) ||
(facetType == XML_SCHEMA_FACET_MINLENGTH) ||
(facetType == XML_SCHEMA_FACET_MAXLENGTH)) {
/* FIXME, TODO: What is the max expected string length of the
* this value?
*/
if (nodeType == XML_ATTRIBUTE_NODE)
else
if (facetType == XML_SCHEMA_FACET_LENGTH)
BAD_CAST "this differs from the allowed length of '%s'.\n");
else if (facetType == XML_SCHEMA_FACET_MAXLENGTH)
BAD_CAST "this exceeds the allowed maximum length of '%s'.\n");
else if (facetType == XML_SCHEMA_FACET_MINLENGTH)
BAD_CAST "this underruns the allowed minimum length of '%s'.\n");
if (nodeType == XML_ATTRIBUTE_NODE)
else
} else if (facetType == XML_SCHEMA_FACET_ENUMERATION) {
"of the set {%s}.\n");
} else if (facetType == XML_SCHEMA_FACET_PATTERN) {
"by the pattern '%s'.\n");
} else if (facetType == XML_SCHEMA_FACET_MININCLUSIVE) {
"minimum value allowed ('%s').\n");
} else if (facetType == XML_SCHEMA_FACET_MAXINCLUSIVE) {
"maximum value allowed ('%s').\n");
} else if (facetType == XML_SCHEMA_FACET_MINEXCLUSIVE) {
"'%s'.\n");
} else if (facetType == XML_SCHEMA_FACET_MAXEXCLUSIVE) {
"'%s'.\n");
} else if (facetType == XML_SCHEMA_FACET_TOTALDIGITS) {
"digits than are allowed ('%s').\n");
} else if (facetType == XML_SCHEMA_FACET_FRACTIONDIGITS) {
"digits than are allowed ('%s').\n");
} else if (nodeType == XML_ATTRIBUTE_NODE) {
} else {
}
} else {
}
}
/**
* xmlSchemaPMissingAttrErr:
* @ctxt: the schema validation context
* @ownerDes: the designation of the owner
* @ownerName: the name of the owner
* @ownerItem: the owner as a schema object
* @ownerElem: the owner as an element node
* @node: the parent element node of the missing attribute node
* @type: the corresponding type of the attribute node
*
* Reports an illegal attribute.
*/
static void
const char *name,
const char *message)
{
else
"%s: The attribute '%s' is required but missing.\n",
}
/**
* xmlSchemaPResCompAttrErr:
* @ctxt: the schema validation context
* @error: the error code
* @ownerDes: the designation of the owner
* @ownerItem: the owner as a schema object
* @ownerElem: the owner as an element node
* @name: the name of the attribute holding the QName
* @refName: the referenced local name
* @refURI: the referenced namespace URI
* @message: optional message
*
* Used to report QName attribute values that failed to resolve
* to schema components.
*/
static void
const char *name,
const char *refTypeStr)
{
if (refTypeStr == NULL)
"%s, attribute '%s': The QName value '%s' does not resolve to a(n) "
}
/**
* xmlSchemaPCustomAttrErr:
* @ctxt: the schema parser context
* @error: the error code
* @ownerDes: the designation of the owner
* @ownerItem: the owner as a schema object
* @attr: the illegal attribute node
*
* Reports an illegal attribute during the parse.
*/
static void
const char *msg)
{
} else
"%s, attribute '%s': %s.\n",
} else {
"%s, attribute '%s': %s.\n",
}
}
/**
* xmlSchemaPIllegalAttrErr:
* @ctxt: the schema parser context
* @error: the error code
* @ownerDes: the designation of the attribute's owner
* @ownerItem: the attribute's owner item
* @attr: the illegal attribute node
*
* Reports an illegal attribute during the parse.
*/
static void
{
}
/**
* xmlSchemaPCustomErr:
* @ctxt: the schema parser context
* @error: the error code
* @itemDes: the designation of the schema item
* @item: the schema item
* @itemElem: the node of the schema item
* @message: the error message
* @str1: an optional param for the error message
* @str2: an optional param for the error message
* @str3: an optional param for the error message
*
* Reports an error during parsing.
*/
static void
const char *message,
{
}
/**
* xmlSchemaPCustomErr:
* @ctxt: the schema parser context
* @error: the error code
* @itemDes: the designation of the schema item
* @item: the schema item
* @itemElem: the node of the schema item
* @message: the error message
* @str1: the optional param for the error message
*
* Reports an error during parsing.
*/
static void
const char *message,
{
}
/**
* xmlSchemaPAttrUseErr:
* @ctxt: the schema parser context
* @error: the error code
* @itemDes: the designation of the schema type
* @item: the schema type
* @itemElem: the node of the schema type
* @attr: the invalid schema attribute
* @message: the error message
* @str1: the optional param for the error message
*
* Reports an attribute use error during parsing.
*/
static void
const xmlSchemaAttributeUsePtr attruse,
const char *message,
{
}
/**
* xmlSchemaPIllegalFacetAtomicErr:
* @ctxt: the schema parser context
* @error: the error code
* @type: the schema type
* @baseType: the base type of type
* @facet: the illegal facet
*
* Reports an illegal facet for atomic simple types.
*/
static void
{
"%s: The facet '%s' is not allowed on types derived from the "
"type %s.\n",
}
/**
* xmlSchemaPIllegalFacetListUnionErr:
* @ctxt: the schema parser context
* @error: the error code
* @itemDes: the designation of the schema item involved
* @item: the schema item involved
* @facet: the illegal facet
*
* Reports an illegal facet for <list> and <union>.
*/
static void
{
"%s: The facet '%s' is not allowed.\n",
}
/**
* xmlSchemaPMutualExclAttrErr:
* @ctxt: the schema validation context
* @error: the error code
* @elemDes: the designation of the parent element node
* @attr: the bad attribute node
* @type: the corresponding type of the attribute node
*
* Reports an illegal attribute.
*/
static void
const char *name1,
const char *name2)
{
"%s: The attributes '%s' and '%s' are mutually exclusive.\n",
}
/**
* xmlSchemaPSimpleTypeErr:
* @ctxt: the schema validation context
* @error: the error code
* @type: the type specifier
* @ownerDes: the designation of the owner
* @ownerItem: the schema object if existent
* @node: the validated node
* @value: the validated value
*
* Reports a simple type validation error.
* TODO: Should this report the value of an element as well?
*/
static void
const char *expected,
const char *message,
{
/*
* Use default messages.
*/
else
"valid value of ");
if (! xmlSchemaIsGlobalItem(type))
else
if (WXS_IS_ATOMIC(type))
else if (WXS_IS_LIST(type))
else if (WXS_IS_UNION(type))
if (xmlSchemaIsGlobalItem(type)) {
if (type->builtInType != 0) {
} else
}
} else {
else
"valid.");
}
if (expected) {
} else
else
} else {
}
/* Cleanup. */
}
/**
* xmlSchemaPContentErr:
* @ctxt: the schema parser context
* @error: the error code
* @onwerDes: the designation of the holder of the content
* @ownerItem: the owner item of the holder of the content
* @ownerElem: the node of the holder of the content
* @child: the invalid child node
* @message: the optional error message
* @content: the optional string describing the correct content
*
* Reports an error concerning the content of a schema element.
*/
static void
const char *message,
const char *content)
{
"%s: %s.\n",
else {
"%s: The content is not valid. Expected is %s.\n",
} else {
"%s: The content is not valid.\n",
}
}
}
/************************************************************************
* *
* Streamable error functions *
* *
************************************************************************/
/************************************************************************
* *
* Validation helper functions *
* *
************************************************************************/
/************************************************************************
* *
* Allocation functions *
* *
************************************************************************/
/**
* xmlSchemaNewSchemaForParserCtxt:
* @ctxt: a schema validation context
*
* Allocate a new Schema structure.
*
* Returns the newly allocated structure or NULL in case or error
*/
static xmlSchemaPtr
{
return (NULL);
}
return (ret);
}
/**
* xmlSchemaNewFacet:
*
* Allocate a new Facet structure.
*
* Returns the newly allocated structure or NULL in case or error
*/
xmlSchemaNewFacet(void)
{
return (NULL);
}
return (ret);
}
/**
* xmlSchemaNewAnnot:
* @ctxt: a schema validation context
* @node: a node
*
* Allocate a new annotation structure.
*
* Returns the newly allocated structure or NULL in case or error
*/
static xmlSchemaAnnotPtr
{
return (NULL);
}
return (ret);
}
static xmlSchemaItemListPtr
xmlSchemaItemListCreate(void)
{
"allocating an item list structure", NULL);
return (NULL);
}
return (ret);
}
static void
{
}
}
static int
{
20 * sizeof(void *));
return(-1);
}
return(-1);
}
}
return(0);
}
static int
int initialSize,
void *item)
{
if (initialSize <= 0)
initialSize = 1;
initialSize * sizeof(void *));
return(-1);
}
return(-1);
}
}
return(0);
}
static int
{
20 * sizeof(void *));
return(-1);
}
return(-1);
}
}
/*
*/
} else {
int i;
}
return(0);
}
#if 0 /* enable if ever needed */
static int
int initialSize,
void *item,
int idx)
{
if (initialSize <= 0)
initialSize = 1;
initialSize * sizeof(void *));
return(-1);
}
return(-1);
}
}
/*
*/
} else {
int i;
}
return(0);
}
#endif
static int
{
int i;
xmlSchemaPSimpleErr("Internal error: xmlSchemaItemListRemove, "
"index error.\n");
return(-1);
}
/* TODO: Really free the list? */
} else {
}
return(0);
}
/**
* xmlSchemaItemListFree:
* @annot: a schema type structure
*
* Deallocate a annotation structure
*/
static void
{
return;
}
static void
{
return;
}
}
do {
}
}
}
}
static xmlSchemaBucketPtr
{
int size;
PERROR_INT("xmlSchemaBucketCreate",
"no main schema on constructor");
return(NULL);
}
/* Create the schema bucket. */
if (WXS_IS_BUCKET_INCREDEF(type))
size = sizeof(xmlSchemaInclude);
else
size = sizeof(xmlSchemaImport);
return(NULL);
}
return(NULL);
}
return(NULL);
}
/*
* The following will assure that only the first bucket is marked as
* XML_SCHEMA_SCHEMA_MAIN and it points to the *main* schema.
* For each following import buckets an xmlSchema will be created.
* An xmlSchema will be created for every distinct targetNamespace.
* We assign the targetNamespace to the schemata here.
*/
if (! WXS_HAS_BUCKETS(pctxt)) {
if (WXS_IS_BUCKET_INCREDEF(type)) {
PERROR_INT("xmlSchemaBucketCreate",
"first bucket but it's an include or redefine");
return(NULL);
}
/* Force the type to be XML_SCHEMA_SCHEMA_MAIN. */
/* Point to the *main* schema. */
/*
* Ensure that the main schema gets a targetNamespace.
*/
} else {
if (type == XML_SCHEMA_SCHEMA_MAIN) {
PERROR_INT("xmlSchemaBucketCreate",
"main bucket but it's not the first one");
return(NULL);
} else if (type == XML_SCHEMA_SCHEMA_IMPORT) {
/*
* Create a schema for imports and assign the
* targetNamespace.
*/
return(NULL);
}
}
}
if (WXS_IS_BUCKET_IMPMAIN(type)) {
int res;
/*
* Imports go into the "schemasImports" slot of the main *schema*.
* Note that we create an import entry for the main schema as well; i.e.,
* even if there's only one schema, we'll get an import.
*/
return(NULL);
}
}
if (targetNamespace == NULL)
else
if (res != 0) {
PERROR_INT("xmlSchemaBucketCreate",
"failed to add the schema bucket to the hash");
return(NULL);
}
} else {
/* Set the @ownerImport of an include bucket. */
else
/* Includes got into the "includes" slot of the *main* schema. */
return(NULL);
}
}
}
/*
* Add to list of all buckets; this is used for lookup
* during schema construction time only.
*/
return(NULL);
return(ret);
}
static int
{
*list = xmlSchemaItemListCreate();
return(-1);
}
return(0);
}
/**
* xmlSchemaFreeAnnot:
* @annot: a schema type structure
*
* Deallocate a annotation structure
*/
static void
{
return;
} else {
do {
}
}
/**
* xmlSchemaFreeNotation:
* @schema: a schema notation structure
*
* Deallocate a Schema Notation structure.
*/
static void
{
return;
}
/**
* xmlSchemaFreeAttribute:
* @attr: an attribute declaration
*
* Deallocates an attribute declaration structure.
*/
static void
{
return;
}
/**
* xmlSchemaFreeAttributeUse:
* @use: an attribute use
*
* Deallocates an attribute use structure.
*/
static void
{
return;
}
/**
* xmlSchemaFreeAttributeUseProhib:
* @prohib: an attribute use prohibition
*
* Deallocates an attribute use structure.
*/
static void
{
return;
}
/**
* xmlSchemaFreeWildcardNsSet:
* set: a schema wildcard namespace
*
* Deallocates a list of wildcard constraint structures.
*/
static void
{
}
}
/**
* xmlSchemaFreeWildcard:
* @wildcard: a wildcard structure
*
* Deallocates a wildcard structure.
*/
void
{
return;
}
/**
* xmlSchemaFreeAttributeGroup:
* @schema: a schema attribute group structure
*
* Deallocate a Schema Attribute Group structure.
*/
static void
{
return;
}
/**
* xmlSchemaFreeQNameRef:
* @item: a QName reference structure
*
* Deallocatea a QName reference structure.
*/
static void
{
}
/**
* xmlSchemaFreeTypeLinkList:
* @alink: a type link
*
* Deallocate a list of types.
*/
static void
{
}
}
static void
{
}
}
/**
* xmlSchemaFreeIDC:
* @idc: a identity-constraint definition
*
* Deallocates an identity-constraint definition.
*/
static void
{
return;
/* Selector */
}
/* Fields */
do {
}
}
/**
* xmlSchemaFreeElement:
* @schema: a schema element structure
*
* Deallocate a Schema Element structure.
*/
static void
{
return;
}
/**
* xmlSchemaFreeFacet:
* @facet: a schema facet structure
*
* Deallocate a Schema Facet structure.
*/
void
{
return;
}
/**
* xmlSchemaFreeType:
* @type: a schema type structure
*
* Deallocate a Schema Type structure.
*/
void
{
return;
}
}
do {
}
}
/**
* xmlSchemaFreeModelGroupDef:
* @item: a schema model group definition
*
* Deallocates a schema model group definition.
*/
static void
{
}
/**
* xmlSchemaFreeModelGroup:
* @item: a schema model group
*
* Deallocates a schema model group structure.
*/
static void
{
}
static void
{
return;
{
int i;
continue;
case XML_SCHEMA_TYPE_SIMPLE:
case XML_SCHEMA_TYPE_COMPLEX:
break;
break;
break;
break;
case XML_SCHEMA_TYPE_ELEMENT:
break;
case XML_SCHEMA_TYPE_PARTICLE:
break;
case XML_SCHEMA_TYPE_SEQUENCE:
case XML_SCHEMA_TYPE_CHOICE:
case XML_SCHEMA_TYPE_ALL:
break;
break;
case XML_SCHEMA_TYPE_GROUP:
break;
case XML_SCHEMA_TYPE_ANY:
break;
case XML_SCHEMA_TYPE_IDC_KEY:
break;
case XML_SCHEMA_TYPE_NOTATION:
break;
break;
default: {
/* TODO: This should never be hit. */
"Internal error: xmlSchemaComponentListFree, "
"unexpected component type '%s'\n",
}
break;
}
}
}
}
/**
* xmlSchemaFree:
* @schema: a schema structure
*
* Deallocate a Schema structure.
*/
void
{
return;
/* @volatiles is not used anymore :-/ */
/*
* Note that those slots are not responsible for freeing
* schema components anymore; this will now be done by
* the schema buckets.
*/
int i;
}
}
/* Never free the doc here, since this will be done by the buckets. */
}
/************************************************************************
* *
* Debug functions *
* *
************************************************************************/
#ifdef LIBXML_OUTPUT_ENABLED
static void
/**
* xmlSchemaElementDump:
* @elem: an element
* @output: the file output
*
* Dump the element
*/
static void
{
return;
#if 0
else
}
#endif
/*
* Misc other properties.
*/
}
/*
*/
/*
* Type.
*/
else
/*
* Dump local types.
*/
}
/*
* Substitution group.
*/
else
}
}
/**
* xmlSchemaAnnotDump:
* @output: the file output
* @annot: a annotation
*
* Dump the annotation
*/
static void
{
return;
} else
}
/**
* xmlSchemaContentModelDump:
* @particle: the schema particle
* @output: the file output
* @depth: the depth used for intentation
*
* Dump a SchemaType structure
*/
static void
{
char shift[100];
int i;
return;
for (i = 0;((i < depth) && (i < 25));i++)
return;
}
} else {
case XML_SCHEMA_TYPE_ELEMENT:
break;
case XML_SCHEMA_TYPE_SEQUENCE:
break;
case XML_SCHEMA_TYPE_CHOICE:
break;
case XML_SCHEMA_TYPE_ALL:
break;
case XML_SCHEMA_TYPE_ANY:
break;
default:
return;
}
}
if (term &&
}
}
/**
* xmlSchemaAttrUsesDump:
* @uses: attribute uses list
* @output: the file output
*
* Dumps a list of attribute use components.
*/
static void
{
int i;
return;
} else {
}
}
}
/**
* xmlSchemaTypeDump:
* @output: the file output
* @type: a type structure
*
* Dump a SchemaType structure
*/
static void
{
return;
}
else
case XML_SCHEMA_TYPE_BASIC:
break;
case XML_SCHEMA_TYPE_SIMPLE:
break;
case XML_SCHEMA_TYPE_COMPLEX:
break;
case XML_SCHEMA_TYPE_SEQUENCE:
break;
case XML_SCHEMA_TYPE_CHOICE:
break;
case XML_SCHEMA_TYPE_ALL:
break;
case XML_SCHEMA_TYPE_UR:
break;
break;
break;
default:
break;
}
switch (type->contentType) {
break;
case XML_SCHEMA_CONTENT_EMPTY:
break;
break;
case XML_SCHEMA_CONTENT_MIXED:
break;
/* not used. */
break;
case XML_SCHEMA_CONTENT_BASIC:
break;
break;
case XML_SCHEMA_CONTENT_ANY:
break;
}
else
}
#ifdef DUMP_CONTENT_MODEL
output, 1);
}
#endif
}
/**
* xmlSchemaDump:
* @output: the file output
* @schema: a schema structure
*
* Dump a Schema structure.
*/
void
{
return;
return;
}
else
else
output);
}
#ifdef DEBUG_IDC_NODE_TABLE
/**
* xmlSchemaDebugDumpIDCTable:
* @vctxt: the WXS validation context
*
* Displays the current IDC table for debug purposes.
*/
static void
const xmlChar *namespaceName,
{
int i, j, res;
return;
do {
if (res >= 0)
else
if (res == 0)
else
}
}
if (res >= 0)
else
if (res == 0)
else
}
}
}
}
#endif /* DEBUG_IDC */
#endif /* LIBXML_OUTPUT_ENABLED */
/************************************************************************
* *
* Utilities *
* *
************************************************************************/
/**
* xmlSchemaGetPropNode:
* @node: the element node
* @name: the name of the attribute
*
* Seeks an attribute with a name of @name in
* no namespace.
*
* Returns the attribute or NULL if not present.
*/
static xmlAttrPtr
{
return(NULL);
return(prop);
}
return (NULL);
}
/**
* xmlSchemaGetPropNodeNs:
* @node: the element node
* @uri: the uri
* @name: the name of the attribute
*
* Seeks an attribute with a local name of @name and
* a namespace URI of @uri.
*
* Returns the attribute or NULL if not present.
*/
static xmlAttrPtr
{
return(NULL);
return(prop);
}
return (NULL);
}
static const xmlChar *
{
return(ret);
}
static const xmlChar *
{
}
/**
* xmlSchemaGetProp:
* @ctxt: the parser context
* @node: the node
* @name: the property name
*
* Read a attribute value and internalize the string
*
* Returns the string or NULL if not present.
*/
static const xmlChar *
const char *name)
{
return(NULL);
return(ret);
}
/************************************************************************
* *
* Parsing functions *
* *
************************************************************************/
#define WXS_FIND_GLOBAL_ITEM(slot) \
} \
else \
goto exit; \
}
/**
* xmlSchemaGetElem:
* @schema: the schema context
* @name: the element name
* @ns: the element namespace
*
* Lookup a global element declaration in the schema.
*
* Returns the element declaration or NULL if not found.
*/
static xmlSchemaElementPtr
{
return(NULL);
}
exit:
#ifdef DEBUG
else
nsName);
}
#endif
return (ret);
}
/**
* xmlSchemaGetType:
* @schema: the main schema
* @name: the type's name
* nsName: the type's namespace
*
* Lookup a type in the schemas or the predefined types
*
* Returns the group definition or NULL if not found.
*/
static xmlSchemaTypePtr
{
return (NULL);
/* First try the built-in types. */
goto exit;
/*
* Note that we try the parsed schemas as well here
* since one might have parsed the S4S, which contain more
* than the built-in types.
* TODO: Can we optimize this?
*/
}
}
exit:
#ifdef DEBUG
else
nsName);
}
#endif
return (ret);
}
/**
* xmlSchemaGetAttributeDecl:
* @schema: the context of the schema
* @name: the name of the attribute
* @ns: the target namespace of the attribute
*
* Lookup a an attribute in the schema or imported schemas
*
* Returns the attribute declaration or NULL if not found.
*/
static xmlSchemaAttributePtr
{
return (NULL);
}
exit:
#ifdef DEBUG
else
nsName);
}
#endif
return (ret);
}
/**
* xmlSchemaGetAttributeGroup:
* @schema: the context of the schema
* @name: the name of the attribute group
* @ns: the target namespace of the attribute group
*
* Lookup a an attribute group in the schema or imported schemas
*
* Returns the attribute group definition or NULL if not found.
*/
static xmlSchemaAttributeGroupPtr
{
return (NULL);
}
exit:
/* TODO:
if ((ret != NULL) && (ret->redef != NULL)) {
* Return the last redefinition. *
ret = ret->redef;
}
*/
#ifdef DEBUG
else
nsName);
}
#endif
return (ret);
}
/**
* xmlSchemaGetGroup:
* @schema: the context of the schema
* @name: the name of the group
* @ns: the target namespace of the group
*
* Lookup a group in the schema or imported schemas
*
* Returns the group definition or NULL if not found.
*/
static xmlSchemaModelGroupDefPtr
{
return (NULL);
}
exit:
#ifdef DEBUG
else
nsName);
}
#endif
return (ret);
}
static xmlSchemaNotationPtr
{
return (NULL);
}
exit:
return (ret);
}
static xmlSchemaIDCPtr
{
return (NULL);
}
exit:
return (ret);
}
/**
* xmlSchemaGetNamedComponent:
* @schema: the schema
* @name: the name of the group
* @ns: the target namespace of the group
*
* Lookup a group in the schema or imported schemas
*
* Returns the group definition or NULL if not found.
*/
static xmlSchemaBasicItemPtr
{
switch (itemType) {
case XML_SCHEMA_TYPE_GROUP:
case XML_SCHEMA_TYPE_ELEMENT:
default:
return (NULL);
}
}
/************************************************************************
* *
* Parsing functions *
* *
************************************************************************/
#define IS_BLANK_NODE(n) \
/**
* xmlSchemaIsBlank:
* @str: a string
* @len: the length of the string or -1
*
* Check if a string is ignorable
*
* Returns 1 if the string is NULL or made of blanks chars, 0 otherwise
*/
static int
{
return (1);
if (len < 0) {
while (*str != 0) {
if (!(IS_BLANK_CH(*str)))
return (0);
str++;
}
if (!(IS_BLANK_CH(*str)))
return (0);
str++;
len--;
}
return (1);
}
#define WXS_COMP_NAME(c, t) ((t) (c))->name
#define WXS_COMP_TNS(c, t) ((t) (c))->targetNamespace
/*
* xmlSchemaFindRedefCompInGraph:
* ATTENTION TODO: This uses pointer comp. for strings.
*/
static xmlSchemaBasicItemPtr
{
int i;
return(NULL);
goto subschemas;
/*
* Search in global components.
*/
switch (type) {
case XML_SCHEMA_TYPE_COMPLEX:
case XML_SCHEMA_TYPE_SIMPLE:
nsName))
{
return(ret);
}
break;
case XML_SCHEMA_TYPE_GROUP:
if ((WXS_COMP_NAME(ret,
xmlSchemaModelGroupDefPtr) == name) &&
{
return(ret);
}
break;
if ((WXS_COMP_NAME(ret,
xmlSchemaAttributeGroupPtr) == name) &&
{
return(ret);
}
break;
default:
/* Should not be hit. */
return(NULL);
}
}
}
/*
*/
/*
* TODO: Marking the bucket will not avoid multiple searches
* in the same schema, but avoids at least circularity.
*/
do {
return(ret);
}
}
return(NULL);
}
/**
* xmlSchemaAddNotation:
* @ctxt: a schema parser context
* @schema: the schema being built
* @name: the item name
*
* Add an XML schema annotation declaration
* *WARNING* this interface is highly subject to change
*
* Returns the new struture or NULL in case of error
*/
static xmlSchemaNotationPtr
{
return (NULL);
return (NULL);
}
/* TODO: do we need the node to be set?
* ret->node = node;*/
return (ret);
}
/**
* xmlSchemaAddAttribute:
* @ctxt: a schema parser context
* @schema: the schema being built
* @name: the item name
* @namespace: the namespace
*
* Add an XML schema Attrribute declaration
* *WARNING* this interface is highly subject to change
*
* Returns the new struture or NULL in case of error
*/
static xmlSchemaAttributePtr
{
return (NULL);
return (NULL);
}
if (topLevel)
else
return (ret);
}
/**
* xmlSchemaAddAttributeUse:
* @ctxt: a schema parser context
* @schema: the schema being built
* @name: the item name
* @namespace: the namespace
*
* Add an XML schema Attrribute declaration
* *WARNING* this interface is highly subject to change
*
* Returns the new struture or NULL in case of error
*/
static xmlSchemaAttributeUsePtr
{
return (NULL);
return (NULL);
}
return (ret);
}
/*
* xmlSchemaAddRedef:
*
* Adds a redefinition information. This is used at a later stage to:
* resolve references to the redefined components and to check constraints.
*/
static xmlSchemaRedefPtr
void *item,
const xmlChar *refTargetNs)
{
ret = (xmlSchemaRedefPtr)
xmlMalloc(sizeof(xmlSchemaRedef));
"allocating redefinition info", NULL);
return (NULL);
}
else
return (ret);
}
/**
* xmlSchemaAddAttributeGroupDefinition:
* @ctxt: a schema parser context
* @schema: the schema being built
* @name: the item name
* @nsName: the target namespace
* @node: the corresponding node
*
* Add an XML schema Attrribute Group definition.
*
* Returns the new struture or NULL in case of error
*/
static xmlSchemaAttributeGroupPtr
{
return (NULL);
xmlMalloc(sizeof(xmlSchemaAttributeGroup));
return (NULL);
}
/* TODO: Remove the flag. */
if (pctxt->isRedefine) {
return(NULL);
}
pctxt->redefCounter = 0;
}
return (ret);
}
/**
* xmlSchemaAddElement:
* @ctxt: a schema parser context
* @schema: the schema being built
* @name: the type name
* @namespace: the type namespace
*
* Add an XML schema Element declaration
* *WARNING* this interface is highly subject to change
*
* Returns the new struture or NULL in case of error
*/
static xmlSchemaElementPtr
{
return (NULL);
return (NULL);
}
if (topLevel)
else
return (ret);
}
/**
* xmlSchemaAddType:
* @ctxt: a schema parser context
* @schema: the schema being built
* @name: the item name
* @namespace: the namespace
*
* Add an XML schema item
* *WARNING* this interface is highly subject to change
*
* Returns the new struture or NULL in case of error
*/
static xmlSchemaTypePtr
{
return (NULL);
return (NULL);
}
if (topLevel) {
if (ctxt->isRedefine) {
return(NULL);
}
ctxt->redefCounter = 0;
}
} else
return (ret);
}
static xmlSchemaQNameRefPtr
{
xmlMalloc(sizeof(xmlSchemaQNameRef));
"allocating QName reference item", NULL);
return (NULL);
}
/*
* Store the reference item in the schema.
*/
return (ret);
}
{
xmlMalloc(sizeof(xmlSchemaAttributeUseProhib));
"allocating attribute use prohibition", NULL);
return (NULL);
}
return (ret);
}
/**
* xmlSchemaAddModelGroup:
* @ctxt: a schema parser context
* @schema: the schema being built
* @type: the "compositor" type of the model group
* @node: the node in the schema doc
*
* Adds a schema model group
* *WARNING* this interface is highly subject to change
*
* Returns the new struture or NULL in case of error
*/
static xmlSchemaModelGroupPtr
{
return (NULL);
xmlMalloc(sizeof(xmlSchemaModelGroup));
NULL);
return (NULL);
}
if ((type == XML_SCHEMA_TYPE_SEQUENCE) ||
(type == XML_SCHEMA_TYPE_CHOICE))
return (ret);
}
/**
* xmlSchemaAddParticle:
* @ctxt: a schema parser context
* @schema: the schema being built
* @node: the corresponding node in the schema doc
* @min: the minOccurs
* @max: the maxOccurs
*
* Adds an XML schema particle component.
* *WARNING* this interface is highly subject to change
*
* Returns the new struture or NULL in case of error
*/
static xmlSchemaParticlePtr
{
return (NULL);
#ifdef DEBUG
#ifndef VBOX
#endif /* !VBOX */
#endif
xmlMalloc(sizeof(xmlSchemaParticle));
NULL);
return (NULL);
}
/*
* Note that addition to pending components will be done locally
* to the specific parsing function, since the most particles
* need not to be fixed up (i.e. the reference to be resolved).
* REMOVED: WXS_ADD_PENDING(ctxt, ret);
*/
return (ret);
}
/**
* xmlSchemaAddModelGroupDefinition:
* @ctxt: a schema validation context
* @schema: the schema being built
* @name: the group name
*
* Add an XML schema Group definition
*
* Returns the new struture or NULL in case of error
*/
static xmlSchemaModelGroupDefPtr
{
return (NULL);
xmlMalloc(sizeof(xmlSchemaModelGroupDef));
return (NULL);
}
if (ctxt->isRedefine) {
return(NULL);
}
ctxt->redefCounter = 0;
}
return (ret);
}
/**
* xmlSchemaNewWildcardNs:
* @ctxt: a schema validation context
*
* Creates a new wildcard namespace constraint.
*
* Returns the new struture or NULL in case of error
*/
static xmlSchemaWildcardNsPtr
{
xmlMalloc(sizeof(xmlSchemaWildcardNs));
return (NULL);
}
return (ret);
}
static xmlSchemaIDCPtr
{
return (NULL);
"allocating an identity-constraint definition", NULL);
return (NULL);
}
/* The target namespace of the parent element declaration. */
/*
* Only keyrefs need to be fixup up.
*/
if (category == XML_SCHEMA_TYPE_IDC_KEYREF)
return (ret);
}
/**
* xmlSchemaAddWildcard:
* @ctxt: a schema validation context
* @schema: a schema
*
* Adds a wildcard.
* It corresponds to a xsd:anyAttribute and xsd:any.
*
* Returns the new struture or NULL in case of error
*/
static xmlSchemaWildcardPtr
{
return (NULL);
return (NULL);
}
return (ret);
}
static void
{
return;
}
static xmlSchemaSubstGroupPtr
{
/* Init subst group hash. */
return(NULL);
}
/* Create a new substitution group. */
"allocating a substitution group container", NULL);
return(NULL);
}
/* Create list of members. */
return(NULL);
}
/* Add subst group to hash. */
PERROR_INT("xmlSchemaSubstGroupAdd",
"failed to add a new substitution container");
return(NULL);
}
return(ret);
}
static xmlSchemaSubstGroupPtr
{
return(NULL);
}
/**
* xmlSchemaAddElementSubstitutionMember:
* @pctxt: a schema parser context
* @head: the head of the substitution group
* @member: the new member of the substitution group
*
* Allocate a new annotation structure.
*
* Returns the newly allocated structure or NULL in case or error
*/
static int
{
return (-1);
if (substGroup == NULL)
if (substGroup == NULL)
return(-1);
return(-1);
return(0);
}
/************************************************************************
* *
* Utilities for parsing *
* *
************************************************************************/
/**
* xmlSchemaPValAttrNodeQNameValue:
* @ctxt: a schema parser context
* @schema: the schema context
* @ownerDes: the designation of the parent element
* @ownerItem: the parent as a schema object
* @value: the QName value
* @local: the resulting local part if found, the attribute value otherwise
* @uri: the resulting namespace URI if found
*
* Extracts the local name and the URI of a QName value and validates it.
* This one is intended to be used on attribute values that
* should resolve to schema components.
*
* Returns 0, in case the QName is valid, a positive error code
* if not valid and -1 if an internal error occurs.
*/
static int
{
if (ret > 0) {
} else if (ret < 0)
return (-1);
if (ns)
/* TODO: move XML_SCHEMAS_INCLUDING_CONVERT_NS to the
* parser context. */
/*
* This one takes care of included schemas with no
* target namespace.
*/
}
return (0);
}
/*
* At this point xmlSplitQName3 has to return a local name.
*/
"The value '%s' of simple type 'xs:QName' has no "
} else {
}
return (0);
}
/**
* xmlSchemaPValAttrNodeQName:
* @ctxt: a schema parser context
* @schema: the schema context
* @ownerDes: the designation of the owner element
* @ownerItem: the owner as a schema object
* @attr: the attribute node
* @local: the resulting local part if found, the attribute value otherwise
* @uri: the resulting namespace URI if found
*
* Extracts and validates the QName of an attribute value.
* This one is intended to be used on attribute values that
* should resolve to schema components.
*
* Returns 0, in case the QName is valid, a positive error code
* if not valid and -1 if an internal error occurs.
*/
static int
{
}
/**
* xmlSchemaPValAttrQName:
* @ctxt: a schema parser context
* @schema: the schema context
* @ownerDes: the designation of the parent element
* @ownerItem: the owner as a schema object
* @ownerElem: the parent node of the attribute
* @name: the name of the attribute
* @local: the resulting local part if found, the attribute value otherwise
* @uri: the resulting namespace URI if found
*
* Extracts and validates the QName of an attribute value.
*
* Returns 0, in case the QName is valid, a positive error code
* if not valid and -1 if an internal error occurs.
*/
static int
const char *name,
{
return (0);
}
}
/**
* xmlSchemaPValAttrID:
* @ctxt: a schema parser context
* @schema: the schema context
* @ownerDes: the designation of the parent element
* @ownerItem: the owner as a schema object
* @ownerElem: the parent node of the attribute
* @name: the name of the attribute
*
* Extracts and validates the ID of an attribute value.
*
* Returns 0, in case the ID is valid, a positive error code
* if not valid and -1 if an internal error occurs.
*/
static int
{
int ret;
return(0);
if (ret == 0) {
/*
* NOTE: the IDness might have already be declared in the DTD
*/
/*
* TODO: Use xmlSchemaStrip here; it's not exported at this
* moment.
*/
}
} else
}
} else if (ret > 0) {
"not a valid 'xs:NCName'",
}
return (ret);
}
static int
{
return(0);
}
/**
* xmlGetMaxOccurs:
* @ctxt: a schema validation context
* @node: a subtree containing XML Schema informations
*
* Get the maxOccurs property
*
* Returns the default if not found, or the value
*/
static int
{
int ret = 0;
return (def);
/* XML_SCHEMAP_INVALID_MINOCCURS, */
return (def);
} else
return (UNBOUNDED); /* encoding it with -1 might be another option */
}
while (IS_BLANK_CH(*cur))
cur++;
if (*cur == 0) {
/* XML_SCHEMAP_INVALID_MINOCCURS, */
return (def);
}
cur++;
}
while (IS_BLANK_CH(*cur))
cur++;
/*
* TODO: Restrict the maximal value to Integer.
*/
/* XML_SCHEMAP_INVALID_MINOCCURS, */
return (def);
}
return (ret);
}
/**
* xmlGetMinOccurs:
* @ctxt: a schema validation context
* @node: a subtree containing XML Schema informations
*
* Get the minOccurs property
*
* Returns the default if not found, or the value
*/
static int
{
int ret = 0;
return (def);
while (IS_BLANK_CH(*cur))
cur++;
if (*cur == 0) {
/* XML_SCHEMAP_INVALID_MINOCCURS, */
return (def);
}
cur++;
}
while (IS_BLANK_CH(*cur))
cur++;
/*
* TODO: Restrict the maximal value to Integer.
*/
/* XML_SCHEMAP_INVALID_MINOCCURS, */
return (def);
}
return (ret);
}
/**
* xmlSchemaPGetBoolNodeValue:
* @ctxt: a schema validation context
* @ownerDes: owner designation
* @ownerItem: the owner as a schema item
* @node: the node holding the value
*
* Converts a boolean string value into 1 or 0.
*
* Returns 0 or 1.
*/
static int
{
int res = 0;
/*
* 3.2.2.1 Lexical representation
* An instance of a datatype that is defined as �boolean�
* can have the following legal literals {true, false, 1, 0}.
*/
res = 1;
res = 0;
res = 1;
res = 0;
else {
}
return (res);
}
/**
* xmlGetBooleanProp:
* @ctxt: a schema validation context
* @node: a subtree containing XML Schema informations
* @name: the attribute name
* @def: the default value
*
* Evaluate if a boolean property is set
*
* Returns the default if not found, 0 if found to be false,
* 1 if found to be true
*/
static int
{
return (def);
/*
* 3.2.2.1 Lexical representation
* An instance of a datatype that is defined as �boolean�
* can have the following legal literals {true, false, 1, 0}.
*/
def = 1;
def = 0;
def = 1;
def = 0;
else {
NULL,
}
return (def);
}
/************************************************************************
* *
* Shema extraction from an Infoset *
* *
************************************************************************/
int topLevel);
ctxt,
int topLevel);
ctxt,
static xmlSchemaBasicItemPtr
int parentType);
static xmlSchemaWildcardPtr
/**
* xmlSchemaPValAttrNodeValue:
*
* @ctxt: a schema parser context
* @ownerDes: the designation of the parent element
* @ownerItem: the schema object owner if existent
* @attr: the schema attribute node being validated
* @value: the value
* @type: the built-in type to be validated against
*
* Validates a value against the given built-in type.
* This one is intended to be used internally for validation
* of schema attribute values during parsing of the schema.
*
* Returns 0 if the value is valid, a positive error code
* number otherwise and -1 in case of an internal or API error.
*/
static int
{
int ret = 0;
/*
* NOTE: Should we move this to xmlschematypes.c? Hmm, but this
* one is really meant to be used internally, so better not.
*/
return (-1);
PERROR_INT("xmlSchemaPValAttrNodeValue",
"the given type is not a built-in type");
return (-1);
}
switch (type->builtInType) {
case XML_SCHEMAS_NCNAME:
case XML_SCHEMAS_QNAME:
case XML_SCHEMAS_ANYURI:
case XML_SCHEMAS_TOKEN:
case XML_SCHEMAS_LANGUAGE:
(xmlNodePtr) attr);
break;
default: {
PERROR_INT("xmlSchemaPValAttrNodeValue",
"validation using the given type is not supported while "
"parsing a schema");
return (-1);
}
}
/*
* TODO: Should we use the S4S error codes instead?
*/
if (ret < 0) {
PERROR_INT("xmlSchemaPValAttrNodeValue",
"failed to validate a schema attribute value");
return (-1);
} else if (ret > 0) {
if (WXS_IS_LIST(type))
else
}
return (ret);
}
/**
* xmlSchemaPValAttrNode:
*
* @ctxt: a schema parser context
* @ownerDes: the designation of the parent element
* @ownerItem: the schema object owner if existent
* @attr: the schema attribute node being validated
* @type: the built-in type to be validated against
* @value: the resulting value if any
*
* Extracts and validates a value against the given built-in type.
* This one is intended to be used internally for validation
* of schema attribute values during parsing of the schema.
*
* Returns 0 if the value is valid, a positive error code
* number otherwise and -1 in case of an internal or API error.
*/
static int
{
return (-1);
}
/**
* xmlSchemaPValAttr:
*
* @ctxt: a schema parser context
* @node: the element node of the attribute
* @ownerDes: the designation of the parent element
* @ownerItem: the schema object owner if existent
* @ownerElem: the owner element node
* @name: the name of the schema attribute node
* @type: the built-in type to be validated against
* @value: the resulting value if any
*
* Extracts and validates a value against the given built-in type.
* This one is intended to be used internally for validation
* of schema attribute values during parsing of the schema.
*
* Returns 0 if the value is valid, a positive error code
* number otherwise and -1 in case of an internal or API error.
*/
static int
const char *name,
{
return (-1);
}
"Internal error: xmlSchemaPValAttr, the given "
"type '%s' is not a built-in type.\n",
return (-1);
}
return (0);
}
}
static int
const xmlChar *namespaceName)
{
/* TODO: Pointer comparison instead? */
return (0);
return (0);
/*
* Check if the referenced namespace was <import>ed.
*/
do {
return (0);
}
/*
* No matching <import>ed namespace found.
*/
{
if (namespaceName == NULL)
"References from this schema to components in no "
"namespace are not allowed, since not indicated by an "
else
"References from this schema to components in the "
"namespace '%s' are not allowed, since not indicated by an "
}
return (XML_SCHEMAP_SRC_RESOLVE);
}
/**
* xmlSchemaParseLocalAttributes:
* @ctxt: a schema validation context
* @schema: the schema being built
* @node: a subtree containing XML Schema informations
* @type: the hosting type where the attributes will be anchored
*
* Parses attribute uses and attribute declarations and
* attribute group references.
*/
static int
int parentType, int *hasRefs)
{
void *item;
*list, parentType);
} else {
*hasRefs = 1;
}
/* TODO: Customize grow factor. */
*list = xmlSchemaItemListCreate();
return(-1);
}
return(-1);
}
}
return (0);
}
/**
* xmlSchemaParseAnnotation:
* @ctxt: a schema validation context
* @schema: the schema being built
* @node: a subtree containing XML Schema informations
*
* parse a XML schema Attrribute declaration
* *WARNING* this interface is highly subject to change
*
* Returns -1 in case of error, 0 if the declaration is improper and
* 1 in case of success.
*/
static xmlSchemaAnnotPtr
{
int barked = 0;
/*
* INFO: S4S completed.
*/
/*
* id = ID
* {any attributes with non-schema namespace . . .}>
* Content: (appinfo | documentation)*
*/
return (NULL);
if (needed)
else
}
}
/*
* And now for the children...
*/
/* TODO: make available the content of "appinfo". */
/*
* source = anyURI
* {any attributes with non-schema namespace . . .}>
* Content: ({any})*
*/
}
}
/* TODO: make available the content of "documentation". */
/*
* source = anyURI
* {any attributes with non-schema namespace . . .}>
* Content: ({any})*
*/
}
} else {
}
}
}
/*
* Attribute "xml:lang".
*/
} else {
if (!barked)
barked = 1;
}
}
return (ret);
}
/**
* xmlSchemaParseFacet:
* @ctxt: a schema validation context
* @schema: the schema being built
* @node: a subtree containing XML Schema informations
*
* parse a XML schema Facet declaration
* *WARNING* this interface is highly subject to change
*
* Returns the new type structure or NULL in case of error
*/
static xmlSchemaFacetPtr
{
return (NULL);
facet = xmlSchemaNewFacet();
return (NULL);
}
return (NULL);
}
} else {
return (NULL);
}
}
}
}
"Facet %s has unexpected child content\n",
}
return (facet);
}
/**
* xmlSchemaParseWildcardNs:
* @ctxt: a schema parser context
* @wildc: the wildcard, already created
* @node: a subtree containing XML Schema informations
*
* Parses the attribute "processContents" and "namespace"
* of a xsd:anyAttribute and xsd:any.
* *WARNING* this interface is highly subject to change
*
* Returns 0 if everything goes fine, a positive error code
* if something is not valid and -1 if an internal error occurs.
*/
static int
{
int ret = 0;
} else {
}
/*
* Build the namespace constraints.
*/
return (-1);
}
} else {
do {
while (IS_BLANK_CH(*cur))
cur++;
end++;
break;
NULL,
"((##any | ##other) | List of (xs:anyURI | "
"(##targetNamespace | ##local)))",
} else {
dictnsItem = NULL;
} else {
/*
* Validate the item (anyURI).
*/
}
/*
* Avoid dublicate namespaces.
*/
break;
}
return (-1);
}
else
}
}
} while (*cur != 0);
}
return (ret);
}
static int
int minOccurs,
int maxOccurs) {
return (0);
/*
* TODO: Maybe we should better not create the particle,
* content model.
*/
/*
* 3.9.6 Schema Component Constraint: Particle Correct
*
*/
if (maxOccurs < 1) {
/*
* 2.2 {max occurs} must be greater than or equal to 1.
*/
"The value must be greater than or equal to 1");
return (XML_SCHEMAP_P_PROPS_CORRECT_2_2);
/*
* 2.1 {min occurs} must not be greater than {max occurs}.
*/
"The value must not be greater than the value of 'maxOccurs'");
return (XML_SCHEMAP_P_PROPS_CORRECT_2_1);
}
}
return (0);
}
/**
* xmlSchemaParseAny:
* @ctxt: a schema validation context
* @schema: the schema being built
* @node: a subtree containing XML Schema informations
*
* Parsea a XML schema <any> element. A particle and wildcard
* will be created (except if minOccurs==maxOccurs==0, in this case
* nothing will be created).
* *WARNING* this interface is highly subject to change
*
* Returns the particle or NULL in case of error or if minOccurs==maxOccurs==0
*/
static xmlSchemaParticlePtr
{
return (NULL);
/*
* Check for illegal attributes.
*/
}
}
}
/*
*/
"(xs:nonNegativeInteger | unbounded)");
"xs:nonNegativeInteger");
/*
* Create & parse the wildcard.
*/
return (NULL);
/*
* And now for the children...
*/
}
NULL, "(annotation?)");
}
/*
* No component if minOccurs==maxOccurs==0.
*/
/* Don't free the wildcard, since it's already on the list. */
return (NULL);
}
/*
* Create the particle.
*/
return (NULL);
return (particle);
}
/**
* xmlSchemaParseNotation:
* @ctxt: a schema validation context
* @schema: the schema being built
* @node: a subtree containing XML Schema informations
*
* parse a XML schema Notation declaration
*
* Returns the new structure or NULL in case of error
*/
static xmlSchemaNotationPtr
{
return (NULL);
return (NULL);
}
return (NULL);
}
NULL, "(annotation?)");
}
return (ret);
}
/**
* xmlSchemaParseAnyAttribute:
* @ctxt: a schema validation context
* @schema: the schema being built
* @node: a subtree containing XML Schema informations
*
* parse a XML schema AnyAttrribute declaration
* *WARNING* this interface is highly subject to change
*
* Returns a wildcard or NULL.
*/
static xmlSchemaWildcardPtr
{
return (NULL);
node);
return (NULL);
}
/*
* Check for illegal attributes.
*/
}
}
}
/*
* Parse the namespace list.
*/
return (NULL);
/*
* And now for the children...
*/
}
NULL, "(annotation?)");
}
return (ret);
}
/**
* xmlSchemaParseAttribute:
* @ctxt: a schema validation context
* @schema: the schema being built
* @node: a subtree containing XML Schema informations
*
* parse a XML schema Attrribute declaration
* *WARNING* this interface is highly subject to change
*
* Returns the attribute declaration.
*/
static xmlSchemaBasicItemPtr
int parentType)
{
#define WXS_ATTR_DEF_VAL_DEFAULT 1
#define WXS_ATTR_DEF_VAL_FIXED 2
/*
* 3.2.3 Constraints on XML Representations of Attribute Declarations
*/
return (NULL);
return (NULL);
}
return(NULL);
isRef = 1;
}
/*
* Check for illegal attributes.
*/
if (isRef) {
goto attr_next;
goto attr_next;
}
} else {
goto attr_next;
goto attr_next;
goto attr_next;
/*
* Evaluate the target namespace
*/
hasForm = 1;
(xmlNodePtr) attr);
{
NULL, "(qualified | unqualified)",
}
goto attr_next;
}
}
/* TODO: Maybe we need to normalize the value beforehand. */
else {
NULL, "(optional | prohibited | required)",
}
goto attr_next;
/*
* 3.2.3 : 1
* default and fixed must not both be present.
*/
if (defValue) {
} else {
}
goto attr_next;
/*
* 3.2.3 : 1
* default and fixed must not both be present.
*/
if (defValue) {
} else {
}
goto attr_next;
}
goto attr_next;
}
/*
* 3.2.3 : 2
* If default and use are both present, use must have
* the actual value optional.
*/
if ((defValueType == WXS_ATTR_DEF_VAL_DEFAULT) &&
(occurs != XML_SCHEMAS_ATTR_USE_OPTIONAL)) {
"(optional | prohibited | required)", NULL,
"The value of the attribute 'use' must be 'optional' "
"if the attribute 'default' is present",
}
/*
* We want correct attributes.
*/
return(NULL);
if (! isRef) {
/* TODO: move XML_SCHEMAS_QUALIF_ATTR to the parser. */
/*
* 3.2.6 Schema Component Constraint: xsi: Not Allowed
* TODO: Move this to the component layer.
*/
"The target namespace must not match '%s'",
}
return (NULL);
}
return (NULL);
}
/*
* 3.2.6 Schema Component Constraint: xmlns Not Allowed
* TODO: Move this to the component layer.
*/
"The value of the attribute must not match 'xmlns'",
return (NULL);
}
goto check_children;
/*
* Create the attribute use component.
*/
return(NULL);
/*
* Create the attribute declaration.
*/
return (NULL);
}
/*
* Value constraint.
*/
if (defValueType == WXS_ATTR_DEF_VAL_FIXED)
}
} else if (occurs != XML_SCHEMAS_ATTR_USE_PROHIBITED) {
/*
* Create the attribute use component.
*/
return(NULL);
/*
* We need to resolve the reference at later stage.
*/
/*
* Create a QName reference to the attribute declaration.
*/
return(NULL);
/*
* Assign the reference. This will be substituted for the
* referenced attribute declaration when the QName is resolved.
*/
/*
* Value constraint.
*/
if (defValueType == WXS_ATTR_DEF_VAL_FIXED)
}
/*
* And now for the children...
*/
if (occurs == XML_SCHEMAS_ATTR_USE_PROHIBITED) {
}
"(annotation?)");
}
/*
* Check for pointlessness of attribute prohibitions.
*/
if (parentType == XML_SCHEMA_TYPE_ATTRIBUTEGROUP) {
"Skipping attribute use prohibition, since it is "
"pointless inside an <attributeGroup>",
return(NULL);
} else if (parentType == XML_SCHEMA_TYPE_EXTENSION) {
"Skipping attribute use prohibition, since it is "
"pointless when extending a type",
return(NULL);
}
if (! isRef) {
}
/*
* Check for duplicate attribute prohibitions.
*/
if (uses) {
int i;
{
"Skipping duplicate attribute use prohibition '%s'",
return(NULL);
}
}
}
/*
* Create the attribute prohibition helper component.
*/
return(NULL);
if (isRef) {
/*
* We need at least to resolve to the attribute declaration.
*/
}
return(WXS_BASIC_CAST prohib);
} else {
/*
* TODO: Should this go into the attr decl?
*/
}
if (isRef) {
/*
* 3.2.3 : 3.2
* If ref is present, then all of <simpleType>,
* form and type must be absent.
*/
"(annotation?)");
else
"(annotation?)");
}
} else {
/*
* 3.2.3 : 4
* type and <simpleType> must not both be present.
*/
"The attribute 'type' and the <simpleType> child "
"are mutually exclusive", NULL);
} else
}
"(annotation?, simpleType?)");
}
}
return (WXS_BASIC_CAST use);
}
static xmlSchemaAttributePtr
{
/*
* Note that the w3c spec assumes the schema to be validated with schema
* for schemas beforehand.
*
* 3.2.3 Constraints on XML Representations of Attribute Declarations
*/
return (NULL);
/*
* 3.2.3 : 3.1
* One of ref or name must be present, but not both
*/
return (NULL);
}
return (NULL);
}
/*
* 3.2.6 Schema Component Constraint: xmlns Not Allowed
* TODO: Move this to the component layer.
*/
"The value of the attribute must not match 'xmlns'",
return (NULL);
}
/*
* 3.2.6 Schema Component Constraint: xsi: Not Allowed
* TODO: Move this to the component layer.
* Or better leave it here and add it to the component layer
* if we have a schema construction API.
*/
"The target namespace must not match '%s'",
}
return (NULL);
/*
* Check for illegal attributes.
*/
{
}
}
}
/*
* Attribute "fixed".
*/
/*
* Attribute "default".
*/
/*
* 3.2.3 : 1
* default and fixed must not both be present.
*/
} else
}
/*
* And now for the children...
*/
}
/*
* 3.2.3 : 4
* type and <simpleType> must not both be present.
*/
"The attribute 'type' and the <simpleType> child "
"are mutually exclusive", NULL);
} else
}
"(annotation?, simpleType?)");
return (ret);
}
/**
* xmlSchemaParseAttributeGroupRef:
* @ctxt: a schema validation context
* @schema: the schema being built
* @node: a subtree containing XML Schema informations
*
* Parse an attribute group definition reference.
* Note that a reference to an attribute group does not
* correspond to any component at all.
* *WARNING* this interface is highly subject to change
*
* Returns the attribute group or NULL in case of error.
*/
static xmlSchemaQNameRefPtr
{
return (NULL);
return (NULL);
}
return(NULL);
/*
* Check for illegal attributes.
*/
{
}
}
}
/* Attribute ID */
/*
* And now for the children...
*/
/*
* TODO: We do not have a place to store the annotation, do we?
*/
}
"(annotation?)");
}
/*
* Handle attribute group redefinitions.
*/
{
/*
* SPEC src-redefine:
* (7.1) "If it has an <attributeGroup> among its contents
* the �actual value� of whose ref [attribute] is the same
* as the �actual value� of its own name attribute plus
* target namespace, then it must have exactly one such group."
*/
if (pctxt->redefCounter != 0) {
"The redefining attribute group definition "
"'%s' must not contain more than one "
"reference to the redefined definition",
return(NULL);
}
pctxt->redefCounter++;
/*
* URGENT TODO: How to ensure that the reference will not be
* handled by the normal component resolution mechanism?
*/
return(NULL);
} else {
/*
* Create a QName-reference helper component. We will substitute this
* component for the attribute uses of the referenced attribute group
* definition.
*/
return(NULL);
/* Add to pending items, to be able to resolve the reference. */
}
return (ret);
}
/**
* xmlSchemaParseAttributeGroupDefinition:
* @pctxt: a schema validation context
* @schema: the schema being built
* @node: a subtree containing XML Schema informations
*
* parse a XML schema Attribute Group declaration
* *WARNING* this interface is highly subject to change
*
* Returns the attribute group definition or NULL in case of error.
*/
static xmlSchemaAttributeGroupPtr
{
int hasRefs = 0;
return (NULL);
return (NULL);
}
/*
* The name is crucial, exit if invalid.
*/
return (NULL);
}
return (NULL);
/*
* Check for illegal attributes.
*/
{
}
}
}
/* Attribute ID */
/*
* And now for the children...
*/
}
/*
*/
return(NULL);
if (hasRefs)
/*
* Parse the attribute wildcard.
*/
}
"(annotation?, ((attribute | attributeGroup)*, anyAttribute?))");
}
return (ret);
}
/**
* xmlSchemaPValAttrFormDefault:
* @value: the value
* @flags: the flags to be modified
* @flagQualified: the specific flag for "qualified"
*
* Returns 0 if the value is valid, 1 otherwise.
*/
static int
int *flags,
int flagQualified)
{
if ((*flags & flagQualified) == 0)
*flags |= flagQualified;
return (1);
return (0);
}
/**
* xmlSchemaPValAttrBlockFinal:
* @value: the value
* @flags: the flags to be modified
* @flagAll: the specific flag for "#all"
* @flagExtension: the specific flag for "extension"
* @flagRestriction: the specific flag for "restriction"
* @flagSubstitution: the specific flag for "substitution"
* @flagList: the specific flag for "list"
* @flagUnion: the specific flag for "union"
*
* Validates the value of the attribute "final" and "block". The value
* is converted into the specified flag values and returned in @flags.
*
* Returns 0 if the value is valid, 1 otherwise.
*/
static int
int *flags,
int flagAll,
int flagExtension,
int flagRestriction,
int flagSubstitution,
int flagList,
int flagUnion)
{
int ret = 0;
/*
* TODO: This does not check for dublicate entries.
*/
return (-1);
if (value[0] == 0)
return (0);
if (flagAll != -1)
else {
if (flagExtension != -1)
*flags |= flagExtension;
if (flagRestriction != -1)
*flags |= flagRestriction;
if (flagSubstitution != -1)
*flags |= flagSubstitution;
if (flagList != -1)
if (flagUnion != -1)
}
} else {
do {
while (IS_BLANK_CH(*cur))
cur++;
end++;
break;
if (flagExtension != -1) {
if ((*flags & flagExtension) == 0)
*flags |= flagExtension;
} else
ret = 1;
if (flagRestriction != -1) {
if ((*flags & flagRestriction) == 0)
*flags |= flagRestriction;
} else
ret = 1;
if (flagSubstitution != -1) {
if ((*flags & flagSubstitution) == 0)
*flags |= flagSubstitution;
} else
ret = 1;
if (flagList != -1) {
} else
ret = 1;
if (flagUnion != -1) {
} else
ret = 1;
} else
ret = 1;
}
return (ret);
}
static int
int isField)
{
/*
* c-selector-xpath:
* Schema Component Constraint: Selector Value OK
*
* TODO: 1 The {selector} must be a valid XPath expression, as defined
* in [XPath].
*/
"Internal error: xmlSchemaCheckCSelectorXPath, "
return (-1);
}
else
/* TODO: Adjust error code. */
"The XPath expression of the selector is not valid", NULL);
return (XML_SCHEMAP_S4S_ATTR_INVALID_VALUE);
} else {
/*
* Compile the XPath expression.
*/
/*
* TODO: We need the array of in-scope namespaces for compilation.
* TODO: Call xmlPatterncompile with different options for selector/
* field.
*/
else
/*
* Build an array of prefixes and namespaces.
*/
int i, count = 0;
count++;
NULL);
return (-1);
}
for (i = 0; i < count; i++) {
}
}
/*
* TODO: Differentiate between "selector" and "field".
*/
if (isField)
else
/* TODO: Adjust error code? */
"The XPath expression '%s' could not be "
return (XML_SCHEMAP_S4S_ATTR_INVALID_VALUE);
}
}
return (0);
}
#define ADD_ANNOTATION(annot) \
return (annot); \
} \
} \
/**
* xmlSchemaAssignAnnotation:
* @item: the schema component
* @annot: the annotation
*
* Adds the annotation to the given schema component.
*
* Returns the given annotaion.
*/
static xmlSchemaAnnotPtr
{
return (NULL);
case XML_SCHEMA_TYPE_ELEMENT: {
}
break;
case XML_SCHEMA_TYPE_ATTRIBUTE: {
}
break;
case XML_SCHEMA_TYPE_ANY: {
}
break;
case XML_SCHEMA_TYPE_PARTICLE:
case XML_SCHEMA_TYPE_IDC_KEY:
case XML_SCHEMA_TYPE_IDC_UNIQUE: {
}
break;
case XML_SCHEMA_TYPE_ATTRIBUTEGROUP: {
}
break;
case XML_SCHEMA_TYPE_NOTATION: {
}
break;
case XML_SCHEMA_FACET_PATTERN:
case XML_SCHEMA_FACET_LENGTH:
case XML_SCHEMA_FACET_MINLENGTH: {
}
break;
case XML_SCHEMA_TYPE_SIMPLE:
case XML_SCHEMA_TYPE_COMPLEX: {
}
break;
case XML_SCHEMA_TYPE_GROUP: {
}
break;
case XML_SCHEMA_TYPE_SEQUENCE:
case XML_SCHEMA_TYPE_CHOICE:
case XML_SCHEMA_TYPE_ALL: {
}
break;
default:
"Internal error: xmlSchemaAddAnnotation, "
"The item is not a annotated schema component", NULL);
break;
}
return (annot);
}
/**
* xmlSchemaParseIDCSelectorAndField:
* @ctxt: a schema validation context
* @schema: the schema being built
* @node: a subtree containing XML Schema informations
*
* Parses a XML Schema identity-contraint definition's
* <selector> and <field> elements.
*
* Returns the parsed identity-constraint definition.
*/
static xmlSchemaIDCSelectPtr
int isField)
{
/*
* Check for illegal attributes.
*/
}
}
}
/*
* Create the item.
*/
"allocating a 'selector' of an identity-constraint definition",
NULL);
return (NULL);
}
/*
* Attribute "xpath" (mandatory).
*/
"name", NULL);
} else {
/*
* URGENT TODO: "field"s have an other syntax than "selector"s.
*/
isField) == -1) {
(xmlNodePtr) attr,
"Internal error: xmlSchemaParseIDCSelectorAndField, "
"validating the XPath expression of a IDC selector.\n",
}
}
/*
* And now for the children...
*/
/*
* Add the annotation to the parent IDC.
*/
}
NULL, "(annotation?)");
}
return (item);
}
/**
* xmlSchemaParseIDC:
* @ctxt: a schema validation context
* @schema: the schema being built
* @node: a subtree containing XML Schema informations
*
* Parses a XML Schema identity-contraint definition.
*
* Returns the parsed identity-constraint definition.
*/
static xmlSchemaIDCPtr
const xmlChar *targetNamespace)
{
/*
* Check for illegal attributes.
*/
((idcCategory != XML_SCHEMA_TYPE_IDC_KEYREF) ||
}
}
}
/*
* Attribute "name" (mandatory).
*/
"name", NULL);
return (NULL);
} else if (xmlSchemaPValAttrNode(ctxt,
return (NULL);
}
/* Create the component. */
idcCategory, node);
return(NULL);
if (idcCategory == XML_SCHEMA_TYPE_IDC_KEYREF) {
/*
* Attribute "refer" (mandatory).
*/
"refer", NULL);
} else {
/*
* Create a reference item.
*/
return (NULL);
}
}
/*
* And now for the children...
*/
}
"A child element is missing",
"(annotation?, (selector, field+))");
}
/*
* Child element <selector>.
*/
/*
* Child elements <field>.
*/
do {
else
}
} else {
NULL, "(annotation?, (selector, field+))");
}
}
NULL, "(annotation?, (selector, field+))");
}
return (item);
}
/**
* xmlSchemaParseElement:
* @ctxt: a schema validation context
* @schema: the schema being built
* @node: a subtree containing XML Schema informations
* @topLevel: indicates if this is global declaration
*
* Parses a XML schema element declaration.
* *WARNING* this interface is highly subject to change
*
* Returns the element declaration or a particle; NULL in case
* of an error or if the particle has minOccurs==maxOccurs==0.
*/
static xmlSchemaBasicItemPtr
{
/* 3.3.3 Constraints on XML Representations of Element Declarations */
/* TODO: Complete implementation of 3.3.6 */
return (NULL);
*isElemRef = 0;
/*
* If we get a "ref" attribute on a local <element> we will assume it's
* a reference - even if there's a "name" attribute; this seems to be more
* robust.
*/
return (NULL);
}
} else
isRef = 1;
}
/*
* Skip particle part if a global declaration.
*/
if (topLevel)
goto declaration_part;
/*
* The particle part ==================================================
*/
goto return_null;
/* ret->flags |= XML_SCHEMAS_ELEM_REF; */
if (isRef) {
/*
* The reference part =============================================
*/
*isElemRef = 1;
/*
* SPEC (3.3.3 : 2.1) "One of ref or name must be present, but not both"
*/
}
/*
* Check for illegal attributes.
*/
{
continue;
} else {
/* SPEC (3.3.3 : 2.2) */
"Only the attributes 'minOccurs', 'maxOccurs' and "
"'id' are allowed in addition to 'ref'");
break;
}
}
}
/*
* No children except <annotation> expected.
*/
}
goto return_null;
/*
* Create the reference item and attach it to the particle.
*/
goto return_null;
/*
* Add the particle to pending components, since the reference
* need to be resolved.
*/
return ((xmlSchemaBasicItemPtr) particle);
}
/*
* The declaration part ===============================================
*/
{
goto return_null;
/*
* Evaluate the target namespace.
*/
if (topLevel) {
} else {
NULL, "(qualified | unqualified)",
}
}
goto return_null;
}
/*
* Check for illegal attributes.
*/
{
if (topLevel == 0) {
{
}
}
}
}
}
/*
*/
if (topLevel) {
/*
* Process top attributes of global element declarations here.
*/
/*
* Attribute "final".
*/
} else {
-1,
NULL, "(#all | List of (extension | restriction))",
}
}
}
/*
* Attribute "block".
*/
/*
* Apply default "block" values.
*/
} else {
-1,
NULL, "(#all | List of (extension | "
"restriction | substitution))", attrValue,
}
}
}
/*
* 3.3.3 : 1
* default and fixed must not both be present.
*/
} else {
}
}
/*
* And now for the children...
*/
/*
* 3.3.3 : 3
* "type" and either <simpleType> or <complexType> are mutually
* exclusive
*/
"The attribute 'type' and the <complexType> child are "
"mutually exclusive", NULL);
} else
/*
* 3.3.3 : 3
* "type" and either <simpleType> or <complexType> are
* mutually exclusive
*/
"The attribute 'type' and the <simpleType> child are "
"mutually exclusive", NULL);
} else
}
}
else
}
NULL, "(annotation?, ((simpleType | complexType)?, "
"(unique | key | keyref)*))");
}
}
/*
* NOTE: Element Declaration Representation OK 4. will be checked at a
* different layer.
*/
if (topLevel)
return ((xmlSchemaBasicItemPtr) decl);
else {
return ((xmlSchemaBasicItemPtr) particle);
}
}
return (NULL);
}
/**
* xmlSchemaParseUnion:
* @ctxt: a schema validation context
* @schema: the schema being built
* @node: a subtree containing XML Schema informations
*
* parse a XML schema Union definition
* *WARNING* this interface is highly subject to change
*
* Returns -1 in case of internal error, 0 in case of success and a positive
* error code otherwise.
*/
static int
{
return (-1);
/* Not a component, don't create it. */
/*
* Mark the simple type as being of variety "union".
*/
/*
* SPEC (Base type) (2) "If the <list> or <union> alternative is chosen,
* then the �simple ur-type definition�."
*/
/*
* Check for illegal attributes.
*/
}
}
}
/*
* Attribute "memberTypes". This is a list of QNames.
* TODO: Check the value to contain anything.
*/
do {
while (IS_BLANK_CH(*cur))
cur++;
end++;
break;
/*
* Create the member type link.
*/
xmlMalloc(sizeof(xmlSchemaTypeLink));
"allocating a type link", NULL);
return (-1);
}
else
/*
* Create a reference item.
*/
return (-1);
}
/*
* Assign the reference to the link, it will be resolved
* later during fixup of the union simple type.
*/
}
} while (*cur != 0);
}
/*
* And now for the children...
*/
/*
* Add the annotation to the simple type ancestor.
*/
}
/*
* Anchor the member types in the "subtypes" field of the
* simple type.
*/
} else {
}
}
}
}
}
/*
* src-union-memberTypes-or-simpleTypes
* Either the memberTypes [attribute] of the <union> element must
* be non-empty or there must be at least one simpleType [child].
*/
"Either the attribute 'memberTypes' or "
"at least one <simpleType> child must be present", NULL);
}
return (0);
}
/**
* xmlSchemaParseList:
* @ctxt: a schema validation context
* @schema: the schema being built
* @node: a subtree containing XML Schema informations
*
* parse a XML schema List definition
* *WARNING* this interface is highly subject to change
*
* Returns -1 in case of error, 0 if the declaration is improper and
* 1 in case of success.
*/
static xmlSchemaTypePtr
{
return (NULL);
/* Not a component, don't create it. */
/*
* Mark the type as being of variety "list".
*/
/*
* SPEC (Base type) (2) "If the <list> or <union> alternative is chosen,
* then the �simple ur-type definition�."
*/
/*
* Check for illegal attributes.
*/
}
}
}
/*
* Attribute "itemType". NOTE that we will use the "ref" and "refNs"
* fields for holding the reference to the itemType.
*
* REVAMP TODO: Use the "base" and "baseNs" fields, since we will remove
* the "ref" fields.
*/
/*
* And now for the children...
*/
}
/*
* src-list-itemType-or-simpleType
* Either the itemType [attribute] or the <simpleType> [child] of
* the <list> element must be present, but not both.
*/
"The attribute 'itemType' and the <simpleType> child "
"are mutually exclusive", NULL);
} else {
}
"Either the attribute 'itemType' or the <simpleType> child "
"must be present", NULL);
}
}
"Either the attribute 'itemType' or the <simpleType> child "
"must be present", NULL);
}
return (NULL);
}
/**
* xmlSchemaParseSimpleType:
* @ctxt: a schema validation context
* @schema: the schema being built
* @node: a subtree containing XML Schema informations
*
* parse a XML schema Simple Type definition
* *WARNING* this interface is highly subject to change
*
* Returns -1 in case of error, 0 if the declaration is improper and
* 1 in case of success.
*/
static xmlSchemaTypePtr
{
int hasRestriction = 0;
return (NULL);
if (topLevel) {
"name", NULL);
return (NULL);
} else {
return (NULL);
/*
* Skip built-in types.
*/
if (ctxt->isRedefine) {
/*
* REDEFINE: Disallow redefinition of built-in-types.
* TODO: It seems that the spec does not say anything
* about this case.
*/
"Redefinition of built-in simple types is not "
"supported", NULL);
return(NULL);
}
return (biType);
}
}
}
/*
* TargetNamespace:
* SPEC "The �actual value� of the targetNamespace [attribute]
* of the <schema> ancestor element information item if present,
* otherwise �absent�.
*/
if (topLevel == 0) {
#ifdef ENABLE_NAMED_LOCALS
char buf[40];
#endif
/*
* Parse as local simple type definition.
*/
#ifdef ENABLE_NAMED_LOCALS
#else
#endif
return (NULL);
/*
* Check for illegal attributes.
*/
}
}
}
} else {
/*
* Parse as global simple type definition.
*
* Note that attrValue is the value of the attribute "name" here.
*/
return (NULL);
/*
* Check for illegal attributes.
*/
}
}
}
/*
* Attribute "final".
*/
} else {
XML_SCHEMAS_TYPE_FINAL_UNION) != 0) {
NULL, "(#all | List of (list | union | restriction)",
}
}
}
/*
* And now for the children...
*/
}
"(annotation?, (restriction | list | union))");
hasRestriction = 1;
}
"(annotation?, (restriction | list | union))");
}
/*
* REDEFINE: SPEC src-redefine (5)
* "Within the [children], each <simpleType> must have a
* <restriction> among its [children] ... the �actual value� of whose
* base [attribute] must be the same as the �actual value� of its own
* name attribute plus target namespace;"
*/
"<simpleType> must have a <restriction> child", NULL);
}
return (type);
}
/**
* xmlSchemaParseModelGroupDefRef:
* @ctxt: the parser context
* @schema: the schema being built
* @node: the node
*
* Parses a reference to a model group definition.
*
* We will return a particle component with a qname-component or
* NULL in case of an error.
*/
static xmlSchemaTreeItemPtr
{
return (NULL);
return (NULL);
return (NULL);
}
"(xs:nonNegativeInteger | unbounded)");
/*
* Check for illegal attributes.
*/
}
}
}
return (NULL);
/*
* Create a qname-reference and set as the term; it will be substituted
* for the model group after the reference has been resolved.
*/
/*
* And now for the children...
*/
/* TODO: Is annotation even allowed for a model group reference? */
/*
* TODO: What to do exactly with the annotation?
*/
}
"(annotation?)");
}
/*
* Corresponds to no component at all if minOccurs==maxOccurs==0.
*/
return (NULL);
return ((xmlSchemaTreeItemPtr) item);
}
/**
* xmlSchemaParseModelGroupDefinition:
* @ctxt: a schema validation context
* @schema: the schema being built
* @node: a subtree containing XML Schema informations
*
* Parses a XML schema model group definition.
*
* Note that the contraint src-redefine (6.2) can't be applied until
* references have been resolved. So we will do this at the
* component fixup level.
*
* *WARNING* this interface is highly subject to change
*
* Returns -1 in case of error, 0 if the declaration is improper and
* 1 in case of success.
*/
static xmlSchemaModelGroupDefPtr
{
return (NULL);
"name", NULL);
return (NULL);
return (NULL);
}
return (NULL);
/*
* Check for illegal attributes.
*/
}
}
}
/*
* And now for the children...
*/
}
XML_SCHEMA_TYPE_ALL, 0);
}
"(annotation?, (all | choice | sequence)?)");
}
return (item);
}
/**
* xmlSchemaCleanupDoc:
* @ctxt: a schema validation context
* @node: the root of the document.
*
* removes unwanted nodes in a schemas document tree
*/
static void
{
/*
* Remove all the blank text nodes
*/
}
if (IS_BLANK_NODE(cur)) {
}
}
goto skip_children;
}
/*
* Skip to next node
*/
continue;
}
}
continue;
}
do {
break;
break;
}
break;
}
}
}
}
static void
{
}
static int
{
/*
* Those flags should be moved to the parser context flags,
* since they are not visible at the component level. I.e.
* they are used if processing schema *documents* only.
*/
/*
* Since the version is of type xs:token, we won't bother to
* check it.
*/
/* REMOVED:
attr = xmlSchemaGetPropNode(node, "version");
if (attr != NULL) {
res = xmlSchemaPValAttrNode(ctxt, NULL, NULL, attr,
xmlSchemaGetBuiltInType(XML_SCHEMAS_TOKEN), &val);
HFAILURE;
}
*/
if (res != 0) {
goto exit;
}
}
if (res != 0) {
}
}
if (res != 0) {
}
}
-1,
if (res != 0) {
"(#all | List of (extension | restriction | list | union))",
}
}
if (res != 0) {
"(#all | List of (extension | restriction | substitution))",
}
}
exit:
return(res);
return(-1);
}
/**
* xmlSchemaParseSchemaTopLevel:
* @ctxt: a schema validation context
* @schema: the schemas
* @nodes: the list of top level nodes
*
* Returns the internal XML Schema structure built from the resource or
* NULL in case of error
*/
static int
{
return(-1);
else
goto exit;
goto exit;
goto exit;
}
}
/*
* URGENT TODO: Change the functions to return int results.
* We need especially to catch internal errors.
*/
} else {
NULL, "((include | import | redefine | annotation)*, "
"(((simpleType | complexType | group | attributeGroup) "
"| element | attribute | notation), annotation*)*)");
}
/*
* TODO: We should add all annotations.
*/
else
}
}
exit:
return(res);
return(-1);
}
static xmlSchemaSchemaRelationPtr
{
xmlMalloc(sizeof(xmlSchemaSchemaRelation));
return(NULL);
}
return(ret);
}
#if 0
static void
{
}
#endif
static void
{
}
}
static void
{
/*
* After the construction context has been freed, there will be
* no schema graph available any more. Only the schema buckets
* will stay alive, which are put into the "schemasImports" and
* "includes" slots of the xmlSchema.
*/
}
static xmlSchemaConstructionCtxtPtr
{
xmlMalloc(sizeof(xmlSchemaConstructionCtxt));
"allocating schema construction context", NULL);
return (NULL);
}
"allocating list of schema buckets", NULL);
return (NULL);
}
"allocating list of pending global components", NULL);
return (NULL);
}
return(ret);
}
static xmlSchemaParserCtxtPtr
{
NULL);
return (NULL);
}
return(NULL);
}
return(ret);
}
/**
* xmlSchemaNewParserCtxtUseDict:
* @URL: the location of the schema
* @dict: the dictionary to be used
*
* to contain an XML Schemas file.
*
* Returns the parser context or NULL in case of error
*/
static xmlSchemaParserCtxtPtr
{
return (NULL);
return (ret);
}
static int
{
else
VERROR_INT("xmlSchemaCreatePCtxtOnVCtxt",
"failed to create a temp. parser context");
return (-1);
}
/* TODO: Pass user data. */
}
return (0);
}
/**
* xmlSchemaGetSchemaBucket:
* @pctxt: the schema parser context
* @schemaLocation: the URI of the schema document
*
* Returns a schema bucket if it was already parsed.
*
* Returns a schema bucket if it was already parsed from
* @schemaLocation, NULL otherwise.
*/
static xmlSchemaBucketPtr
const xmlChar *schemaLocation)
{
return(NULL);
else {
int i;
/* Pointer comparison! */
return(cur);
}
}
return(NULL);
}
static xmlSchemaBucketPtr
const xmlChar *schemaLocation,
const xmlChar *targetNamespace)
{
return(NULL);
else {
int i;
/* Pointer comparison! */
return(cur);
}
}
return(NULL);
}
#define IS_BAD_SCHEMA_DOC(b) \
static xmlSchemaBucketPtr
const xmlChar *targetNamespace,
int imported)
{
return(NULL);
else {
int i;
if ((! IS_BAD_SCHEMA_DOC(cur)) &&
return(cur);
}
}
return(NULL);
}
static int
{
int oldFlags;
/*
* Save old values; reset the *main* schema.
* URGENT TODO: This is not good; move the per-document information
* to the parser. Get rid of passing the main schema to the
* parsing functions.
*/
/*
* Keep the current target namespace on the parser *not* on the
* main schema.
*/
/*
* We are parsing the schema for schemas!
*/
}
/* Mark it as parsed, even if parsing fails. */
/* Compile the schema doc. */
if (ret != 0)
goto exit;
/* An empty schema; just get out. */
goto exit;
if (ret != 0)
goto exit;
/*
* TODO: Not nice, but I'm not 100% sure we will get always an error
* as a result of the obove functions; so better rely on pctxt->err
* as well.
*/
goto exit;
}
exit:
/* Restore schema values. */
return(ret);
}
static int
{
int res = 0;
return(0);
PERROR_INT("xmlSchemaParseNewDoc",
"reparsing a schema doc");
return(-1);
}
PERROR_INT("xmlSchemaParseNewDoc",
"parsing a schema doc, but there's no doc");
return(-1);
}
PERROR_INT("xmlSchemaParseNewDoc",
"no constructor");
return(-1);
}
/* Create and init the temporary parser context. */
return(-1);
/*
* TODO: Can we avoid that the parser knows about the main schema?
* It would be better if he knows about the current schema bucket
* only.
*/
/* Channel back errors and cleanup the temporary parser context. */
if (res != 0)
/* Free the parser context. */
return(res);
}
static void
{
return;
}
}
static const xmlChar *
{
/*
* Build an absolue location URI.
*/
return(location);
else {
} else {
}
return(ret);
}
}
}
return(NULL);
}
/**
* xmlSchemaAddSchemaDoc:
* @pctxt: a schema validation context
* @schema: the schema being built
* @node: a subtree containing XML Schema informations
*
* Parse an included (and to-be-redefined) XML schema document.
*
* Returns 0 on success, a positive error code on errors and
* -1 in case of an internal or API error.
*/
static int
int type, /* import or include or redefine */
const xmlChar *schemaLocation,
const char *schemaBuffer,
int schemaBufferLen,
const xmlChar *sourceTargetNamespace,
const xmlChar *importNamespace,
{
switch (type) {
case XML_SCHEMA_SCHEMA_IMPORT:
case XML_SCHEMA_SCHEMA_MAIN:
break;
break;
break;
}
/* Special handling for the main schema:
* skip the location and relation logic and just parse the doc.
* We need just a bucket to be returned in this case.
*/
goto doc_load;
/* Note that we expect the location to be an absulute URI. */
if (schemaLocation != NULL) {
/* Report self-imports/inclusions/redefinitions. */
goto exit;
}
}
/*
* Create a relation for the graph of schemas.
*/
return(-1);
relation);
/*
* Save the namespace import information.
*/
if (WXS_IS_BUCKET_IMPMAIN(type)) {
if (schemaLocation == NULL) {
/*
* No location; this is just an import of the namespace.
* Note that we don't assign a bucket to the relation
* in this case.
*/
goto exit;
}
}
/* Did we already fetch the doc? */
/* TODO: The following nasty cases will produce an error. */
if (schemaLocation == NULL)
"The schema document '%s' cannot be imported, since "
"it was already included or redefined",
goto exit;
if (schemaLocation == NULL)
"The schema document '%s' cannot be included or "
"redefined, since it was already imported",
goto exit;
}
}
if (WXS_IS_BUCKET_IMPMAIN(type)) {
/*
* Given that the schemaLocation [attribute] is only a hint, it is open
* to applications to ignore all but the first <import> for a given
* namespace, regardless of the �actual value� of schemaLocation, but
* such a strategy risks missing useful information when new
* schemaLocations are offered.
*
* We will use the first <import> that comes with a location.
* Further <import>s *with* a location, will result in an error.
* TODO: Better would be to just report a warning here, but
* we'll try it this way until someone complains.
*
* Schema Document Location Strategy:
* 3 Based on the namespace name, identify an existing schema document,
* either as a resource which is an XML document or a <schema> element
* information item, in some local schema repository;
* 5 Attempt to resolve the namespace name to locate such a resource.
*
* NOTE: (3) and (5) are not supported.
*/
goto exit;
}
importNamespace, 1);
/* First given location of the schema; load the doc. */
} else {
if (!xmlStrEqual(schemaLocation,
bkt->schemaLocation)) {
/*
* Additional location given; just skip it.
* URGENT TODO: We should report a warning here.
* res = XML_SCHEMAP_SRC_IMPORT;
*/
if (schemaLocation == NULL)
"Skipping import of schema located at '%s' for the "
"namespace '%s', since this namespace was already "
"imported with the schema located at '%s'",
}
goto exit;
}
}
/*
* No bucket + first location: load the doc and create a
* bucket.
*/
} else {
/* <include> and <redefine> */
/*
* aleady build for the targetNamespace of the including
* schema.
*/
/*
* URGENT TODO: If the schema is a chameleon-include then copy
* the components into the including schema and modify the
* targetNamespace of those components, do nothing otherwise.
* NOTE: This is currently worked-around by compiling the
* chameleon for every destinct including targetNamespace; thus
* not performant at the moment.
* TODO: Check when the namespace in wildcards for chameleons
* needs to be converted: before we built wildcard intersections
* or after.
* Answer: after!
*/
/* A fitting chameleon was already parsed; NOP. */
goto exit;
}
/*
* We need to parse the chameleon again for a different
* targetNamespace.
* CHAMELEON TODO: Optimize this by only parsing the
* chameleon once, and then copying the components to
* the new targetNamespace.
*/
} else {
goto exit;
}
}
}
PERROR_INT("xmlSchemaAddSchemaDoc",
"trying to load a schema doc, but a doc is already "
"assigned to the schema bucket");
goto exit_failure;
}
/*
* Load the document.
*/
/* Don' free this one, since it was provided by the caller. */
preserveDoc = 1;
/* TODO: Does the context or the doc hold the location? */
else
if (parserCtxt == NULL) {
"allocating a parser context", NULL);
goto exit_failure;
}
/*
* TODO: Do we have to burden the schema parser dict with all
* the content of the schema doc?
*/
}
if (schemaLocation != NULL) {
/* Parse from file. */
} else if (schemaBuffer != NULL) {
/* Parse from memory buffer. */
}
/*
* For <import>:
* 2.1 The referent is (a fragment of) a resource which is an
* XML document (see clause 1.1), which in turn corresponds to
* a <schema> element information item in a well-formed information
* set, which in turn corresponds to a valid schema.
* TODO: (2.1) fragments of XML documents are not supported.
*
* 2.2 The referent is a <schema> element information item in
* a well-formed information set, which in turn corresponds
* to a valid schema.
* TODO: (2.2) is not supported.
*/
lerr = xmlGetLastError();
/*
* Check if this a parser error, or if the document could
* just not be located.
* TODO: Try to find specific error codes to react only on
* localisation failures.
*/
/*
* We assume a parser error here.
*/
located = 1;
/* TODO: Error code ?? */
"Failed to parse the XML resource '%s'",
}
}
goto exit_error;
} else {
"No information for parsing was provided with the "
"given schema parser context.\n",
goto exit_failure;
}
/*
* Preprocess the document.
*/
located = 1;
"The document '%s' has no document element",
goto exit_error;
}
/*
* Remove all the blank text nodes.
*/
/*
* Check the schema's top level element.
*/
"The XML document '%s' is not a schema document",
goto exit_error;
}
/*
* Note that we don't apply a type check for the
* targetNamespace value here.
*/
"targetNamespace");
}
/* after_doc_loading: */
/* Only create a bucket if the schema was located. */
goto exit_failure;
}
if (preserveDoc)
}
if (WXS_IS_BUCKET_IMPMAIN(type))
/*
* Add it to the graph of schemas.
*/
}
exit:
/*
* Return the bucket explicitely; this is needed for the
* main schema.
*/
return (0);
}
}
return (-1);
}
/**
* xmlSchemaParseImport:
* @ctxt: a schema validation context
* @schema: the schema being built
* @node: a subtree containing XML Schema informations
*
* parse a XML schema Import definition
* *WARNING* this interface is highly subject to change
*
* Returns 0 in case of success, a positive error code if
* not valid and -1 in case of an internal error.
*/
static int
{
const xmlChar *thisTargetNamespace;
int ret = 0;
return (-1);
/*
* Check for illegal attributes.
*/
}
}
}
/*
* Extract and validate attributes.
*/
&namespaceName) != 0) {
}
&schemaLocation) != 0) {
}
/*
* And now for the children...
*/
/*
* the annotation here is simply discarded ...
* TODO: really?
*/
}
"(annotation?)");
}
/*
* Apply additional constraints.
*
* Note that it is important to use the original @targetNamespace
* (or none at all), to rule out imports of schemas _with_ a
* @targetNamespace if the importing schema is a chameleon schema
* (with no @targetNamespace).
*/
if (namespaceName != NULL) {
/*
* 1.1 If the namespace [attribute] is present, then its �actual value�
* must not match the �actual value� of the enclosing <schema>'s
* targetNamespace [attribute].
*/
"The value of the attribute 'namespace' must not match "
"the target namespace '%s' of the importing schema",
}
} else {
/*
* 1.2 If the namespace [attribute] is not present, then the enclosing
* <schema> must have a targetNamespace [attribute].
*/
if (thisTargetNamespace == NULL) {
"The attribute 'namespace' must be existent if "
"the importing schema has no target namespace",
NULL);
}
}
/*
* Locate and acquire the schema document.
*/
if (schemaLocation != NULL)
namespaceName, &bucket);
if (ret != 0)
return(ret);
/*
* For <import>: "It is *not* an error for the application
* schema reference strategy to fail."
* So just don't parse if no schema document was found.
* Note that we will get no bucket if the schema could not be
* located or if there was no schemaLocation.
*/
"Failed to locate a schema at location '%s'. "
}
}
return (ret);
}
static int
int type)
{
(schemaLocation == NULL))
return (-1);
*schemaLocation = NULL;
/*
* Check for illegal attributes.
* Applies for both <include> and <redefine>.
*/
}
}
}
/*
* Preliminary step, extract the URI-Reference and make an URI
* from the base.
*/
/*
* Attribute "schemaLocation" is mandatory.
*/
(const xmlChar **) schemaLocation) != 0)
goto exit_error;
} else {
}
PERROR_INT("xmlSchemaParseIncludeOrRedefine",
"could not build an URI from the schemaLocation")
goto exit_failure;
}
} else {
goto exit_error;
}
/*
* Report self-inclusion and self-redefinition.
*/
if (type == XML_SCHEMA_SCHEMA_REDEFINE) {
"The schema document '%s' cannot redefine itself.",
} else {
"The schema document '%s' cannot include itself.",
}
goto exit_error;
}
return(0);
return(-1);
}
static int
int type)
{
int res = 0; /* hasRedefinitions = 0 */
int isChameleon = 0, wasChameleon = 0;
return (-1);
/*
* Parse attributes. Note that the returned schemaLocation will
* be already converted to an absolute URI.
*/
if (res != 0)
return(res);
/*
* Load and add the schema document.
*/
if (res != 0)
return(res);
/*
* If we get no schema bucket back, then this means that the schema
* document could not be located or was broken XML or was not
* a schema document.
*/
if (type == XML_SCHEMA_SCHEMA_INCLUDE) {
/*
* WARNING for <include>:
* We will raise an error if the schema cannot be located
* for inclusions, since the that was the feedback from the
* schema people. I.e. the following spec piece will *not* be
* satisfied:
* SPEC src-include: "It is not an error for the �actual value� of the
* schemaLocation [attribute] to fail to resolve it all, in which
* case no corresponding inclusion is performed.
* So do we need a warning report here?"
*/
"Failed to load the document '%s' for inclusion",
} else {
/*
* NOTE: This was changed to raise an error even if no redefinitions
* are specified.
*
* SPEC src-redefine (1)
* "If there are any element information items among the [children]
* other than <annotation> then the �actual value� of the
* schemaLocation [attribute] must successfully resolve."
* TODO: Ask the WG if a the location has always to resolve
* here as well!
*/
"Failed to load the document '%s' for redefinition",
}
} else {
/*
* Check targetNamespace sanity before parsing the new schema.
* TODO: Note that we won't check further content if the
* targetNamespace was bad.
*/
/*
* SPEC src-include (2.1)
* "SII has a targetNamespace [attribute], and its �actual
* value� is identical to the �actual value� of the targetNamespace
* [attribute] of SII� (which must have such an [attribute])."
*/
"'%s' has to be absent, since the including/redefining "
"schema has no target namespace",
goto exit_error;
pctxt->targetNamespace)) {
/* TODO: Change error function. */
"schema '%s' differs from '%s' of the "
"including/redefining schema",
goto exit_error;
}
/*
* Chameleons: the original target namespace will
* differ from the resulting namespace.
*/
isChameleon = 1;
/*
* This is a sanity check, I dunno yet if this can happen.
*/
PERROR_INT("xmlSchemaParseIncludeOrRedefine",
"trying to use an already parsed schema for a "
"different targetNamespace");
return(-1);
}
}
}
/*
* Parse the schema.
*/
if (isChameleon) {
/* TODO: Get rid of this flag on the schema itself. */
} else
wasChameleon = 1;
}
/* Restore chameleon flag. */
if (isChameleon && (!wasChameleon))
}
/*
* And now for the children...
*/
if (type == XML_SCHEMA_SCHEMA_REDEFINE) {
/*
* Parse (simpleType | complexType | group | attributeGroup))*
*/
/*
* How to proceed if the redefined schema was not located?
*/
/*
* TODO: discard or not?
*/
/* hasRedefinitions = 1; */
/* hasRedefinitions = 1; */
/* hasRedefinitions = 1; */
child);
}
}
pctxt->isRedefine = 0;
} else {
/*
* TODO: discard or not?
*/
}
}
if (type == XML_SCHEMA_SCHEMA_REDEFINE) {
"(annotation | (simpleType | complexType | group | attributeGroup))*");
} else {
"(annotation?)");
}
}
return(res);
}
static int
{
int res;
#ifndef ENABLE_REDEFINE
return(0);
#endif
if (res != 0)
return(res);
return(0);
}
static int
{
int res;
if (res != 0)
return(res);
return(0);
}
/**
* xmlSchemaParseModelGroup:
* @ctxt: a schema validation context
* @schema: the schema being built
* @node: a subtree containing XML Schema informations
* @type: the "compositor" type
* @particleNeeded: if a a model group with a particle
*
* parse a XML schema Sequence definition.
* Applies parts of:
* Schema Representation Constraint:
* Redefinition Constraints and Semantics (src-redefine)
* (6.1), (6.1.1), (6.1.2)
*
* Schema Component Constraint:
* All Group Limited (cos-all-limited) (2)
* TODO: Actually this should go to component-level checks,
* but is done here due to performance. Move it to an other layer
* is schema construction via an API is implemented.
*
* *WARNING* this interface is highly subject to change
*
* Returns -1 in case of error, 0 if the declaration is improper and
* 1 in case of success.
*/
static xmlSchemaTreeItemPtr
int withParticle)
{
return (NULL);
/*
* Create a model group with the given compositor.
*/
return (NULL);
if (withParticle) {
if (type == XML_SCHEMA_TYPE_ALL) {
} else {
/* choice + sequence */
"(xs:nonNegativeInteger | unbounded)");
}
/*
* Create a particle
*/
return (NULL);
/*
* Check for illegal attributes.
*/
}
}
}
} else {
/*
* Check for illegal attributes.
*/
}
}
}
}
/*
* Extract and validate attributes.
*/
/*
* And now for the children...
*/
}
if (type == XML_SCHEMA_TYPE_ALL) {
/*
* SPEC cos-all-limited (2)
* "The {max occurs} of all the particles in the {particles}
* of the ('all') group must be 0 or 1.
*/
if (isElemRef)
hasRefs++;
"Invalid value for minOccurs (must be 0 or 1)",
NULL);
/* Reset to 1. */
}
"Invalid value for maxOccurs (must be 0 or 1)",
NULL);
/* Reset to 1. */
}
else
}
}
"(annotation?, (annotation?, element*)");
}
} else {
/* choice + sequence */
hasRefs++;
part =
hasRefs++;
/*
* Handle redefinitions.
*/
{
{
/*
* SPEC src-redefine:
* (6.1) "If it has a <group> among its contents at
* some level the �actual value� of whose ref
* [attribute] is the same as the �actual value� of
* its own name attribute plus target namespace, then
* all of the following must be true:"
* (6.1.1) "It must have exactly one such group."
*/
if (ctxt->redefCounter != 0) {
"The redefining model group definition "
"'%s' must not contain more than one "
"reference to the redefined definition",
NULL);
{
/*
* SPEC src-redefine:
* (6.1.2) "The �actual value� of both that
* group's minOccurs and maxOccurs [attribute]
* must be 1 (or �absent�).
*/
"The redefining model group definition "
"'%s' must not contain a reference to the "
"redefined definition with a "
NULL);
}
ctxt->redefCounter++;
}
}
}
else
}
}
"(annotation?, (element | group | choice | sequence | any)*)");
}
}
return (NULL);
if (hasRefs) {
/*
* We need to resolve references.
*/
}
if (withParticle)
return ((xmlSchemaTreeItemPtr) particle);
else
return ((xmlSchemaTreeItemPtr) item);
}
/**
* xmlSchemaParseRestriction:
* @ctxt: a schema validation context
* @schema: the schema being built
* @node: a subtree containing XML Schema informations
*
* parse a XML schema Restriction definition
* *WARNING* this interface is highly subject to change
*
* Returns the type definition or NULL in case of error
*/
static xmlSchemaTypePtr
{
return (NULL);
/* Not a component, don't create it. */
/*
* Check for illegal attributes.
*/
}
}
}
/*
* Extract and validate attributes.
*/
/*
* Attribute
*/
/*
* Extract the base type. The "base" attribute is mandatory if inside
* a complex type or if redefining.
*
* SPEC (1.2) "...otherwise (<restriction> has no <simpleType> "
* among its [children]), the simple type definition which is
* the {content type} of the type definition �resolved� to by
* the �actual value� of the base [attribute]"
*/
{
} else if ((ctxt->isRedefine) &&
{
{
/*
* REDEFINE: SPEC src-redefine (5)
* "Within the [children], each <simpleType> must have a
* <restriction> among its [children] ... the �actual value� of
* whose base [attribute] must be the same as the �actual value�
* of its own name attribute plus target namespace;"
*/
"value '%s' of the 'base' attribute does not match the "
"type's designation '%s'",
/* Avoid confusion and erase the values. */
}
}
}
/*
* And now for the children...
*/
/*
* Add the annotation to the simple type ancestor.
*/
}
if (parentType == XML_SCHEMA_TYPE_SIMPLE) {
/*
* Corresponds to <simpleType><restriction><simpleType>.
*/
/*
* src-restriction-base-or-simpleType
* Either the base [attribute] or the simpleType [child] of the
* <restriction> element must be present, but not both.
*/
"The attribute 'base' and the <simpleType> child are "
"mutually exclusive", NULL);
} else {
}
"Either the attribute 'base' or a <simpleType> child "
"must be present", NULL);
}
} else if (parentType == XML_SCHEMA_TYPE_COMPLEX_CONTENT) {
/*
* Corresponds to <complexType><complexContent><restriction>...
* followed by:
*
* Model groups <all>, <choice> and <sequence>.
*/
XML_SCHEMA_TYPE_ALL, 1);
/*
* Model group reference <group>.
*/
/*
* Note that the reference will be resolved in
* xmlSchemaResolveTypeReferences();
*/
}
} else if (parentType == XML_SCHEMA_TYPE_SIMPLE_CONTENT) {
/*
* Corresponds to <complexType><simpleContent><restriction>...
*
* "1.1 the simple type definition corresponding to the <simpleType>
* among the [children] of <restriction> if there is one;"
*/
/*
* We will store the to-be-restricted simple type in
* type->contentTypeDef *temporarily*.
*/
return (NULL);
}
}
if ((parentType == XML_SCHEMA_TYPE_SIMPLE) ||
/*
* Corresponds to <complexType><simpleContent><restriction>...
* <simpleType><restriction>...
*/
/*
* Add the facets to the simple type ancestor.
*/
/*
* TODO: Datatypes: 4.1.3 Constraints on XML Representation of
* Simple Type Definition Schema Representation Constraint:
* *Single Facet Value*
*/
else
}
}
/*
* Create links for derivation and validation.
*/
do {
xmlMalloc(sizeof(xmlSchemaFacetLink));
return (NULL);
}
if (lastFacetLink == NULL)
else
}
}
/*
* Attribute uses/declarations.
*/
return(NULL);
/*
* Attribute wildcard.
*/
}
}
if (parentType == XML_SCHEMA_TYPE_COMPLEX_CONTENT) {
"annotation?, (group | all | choice | sequence)?, "
"((attribute | attributeGroup)*, anyAttribute?))");
} else if (parentType == XML_SCHEMA_TYPE_SIMPLE_CONTENT) {
"(annotation?, (simpleType?, (minExclusive | minInclusive | "
"maxExclusive | maxInclusive | totalDigits | fractionDigits | "
"length | minLength | maxLength | enumeration | whiteSpace | "
"pattern)*)?, ((attribute | attributeGroup)*, anyAttribute?))");
} else {
/* Simple type */
"(annotation?, (simpleType?, (minExclusive | minInclusive | "
"maxExclusive | maxInclusive | totalDigits | fractionDigits | "
"length | minLength | maxLength | enumeration | whiteSpace | "
"pattern)*))");
}
}
return (NULL);
}
/**
* xmlSchemaParseExtension:
* @ctxt: a schema validation context
* @schema: the schema being built
* @node: a subtree containing XML Schema informations
*
* Parses an <extension>, which is found inside a
* <simpleContent> or <complexContent>.
* *WARNING* this interface is highly subject to change.
*
* TODO: Returns the type definition or NULL in case of error
*/
static xmlSchemaTypePtr
{
return (NULL);
/* Not a component, don't create it. */
/*
* Check for illegal attributes.
*/
}
}
}
/*
* Attribute "base" - mandatory.
*/
}
/*
* And now for the children...
*/
/*
* Add the annotation to the type ancestor.
*/
}
if (parentType == XML_SCHEMA_TYPE_COMPLEX_CONTENT) {
/*
* Corresponds to <complexType><complexContent><extension>... and:
*
* Model groups <all>, <choice>, <sequence> and <group>.
*/
/*
* Note that the reference will be resolved in
* xmlSchemaResolveTypeReferences();
*/
}
}
/*
* Attribute uses/declarations.
*/
return(NULL);
/*
* Attribute wildcard.
*/
}
}
if (parentType == XML_SCHEMA_TYPE_COMPLEX_CONTENT) {
/* Complex content extension. */
"(annotation?, ((group | all | choice | sequence)?, "
"((attribute | attributeGroup)*, anyAttribute?)))");
} else {
/* Simple content extension. */
"(annotation?, ((attribute | attributeGroup)*, "
"anyAttribute?))");
}
}
return (NULL);
}
/**
* xmlSchemaParseSimpleContent:
* @ctxt: a schema validation context
* @schema: the schema being built
* @node: a subtree containing XML Schema informations
*
* parse a XML schema SimpleContent definition
* *WARNING* this interface is highly subject to change
*
* Returns the type definition or NULL in case of error
*/
static int
{
return (-1);
/* Not a component, don't create it. */
/*
* Check for illegal attributes.
*/
}
}
}
/*
* And now for the children...
*/
/*
* Add the annotation to the complex type ancestor.
*/
}
"(annotation?, (restriction | extension))");
}
"(annotation?, (restriction | extension))");
}
(*hasRestrictionOrExtension) = 1;
(*hasRestrictionOrExtension) = 1;
}
"(annotation?, (restriction | extension))");
}
return (0);
}
/**
* xmlSchemaParseComplexContent:
* @ctxt: a schema validation context
* @schema: the schema being built
* @node: a subtree containing XML Schema informations
*
* parse a XML schema ComplexContent definition
* *WARNING* this interface is highly subject to change
*
* Returns the type definition or NULL in case of error
*/
static int
{
return (-1);
/* Not a component, don't create it. */
/*
* Check for illegal attributes.
*/
{
}
}
}
/*
* Set the 'mixed' on the complex type ancestor.
*/
}
/*
* Add the annotation to the complex type ancestor.
*/
}
NULL, "(annotation?, (restriction | extension))");
}
NULL, "(annotation?, (restriction | extension))");
}
(*hasRestrictionOrExtension) = 1;
(*hasRestrictionOrExtension) = 1;
}
NULL, "(annotation?, (restriction | extension))");
}
return (0);
}
/**
* xmlSchemaParseComplexType:
* @ctxt: a schema validation context
* @schema: the schema being built
* @node: a subtree containing XML Schema informations
*
* parse a XML schema Complex Type definition
* *WARNING* this interface is highly subject to change
*
* Returns the type definition or NULL in case of error
*/
static xmlSchemaTypePtr
{
#ifdef ENABLE_NAMED_LOCALS
char buf[40];
#endif
return (NULL);
if (topLevel) {
return (NULL);
return (NULL);
}
}
if (topLevel == 0) {
/*
* Parse as local complex type definition.
*/
#ifdef ENABLE_NAMED_LOCALS
#else
#endif
return (NULL);
/*
* TODO: We need the target namespace.
*/
} else {
/*
* Parse as global complex type definition.
*/
return (NULL);
}
/*
* Handle attributes.
*/
/*
* Attribute "id".
*/
/*
* Attribute "mixed".
*/
} else if (topLevel) {
/*
* Attributes of global complex type definitions.
*/
/* Pass. */
/*
* Attribute "abstract".
*/
/*
* Attribute "final".
*/
(xmlNodePtr) attr);
-1,
-1, -1, -1) != 0)
{
"(#all | List of (extension | restriction))",
} else
final = 1;
/*
* Attribute "block".
*/
(xmlNodePtr) attr);
-1,
-1, -1, -1) != 0) {
"(#all | List of (extension | restriction)) ",
} else
block = 1;
} else {
}
} else {
}
}
}
if (! block) {
/*
* Apply default "block" values.
*/
}
if (! final) {
/*
* Apply default "block" values.
*/
}
/*
* And now for the children...
*/
}
/*
* <complexType><simpleContent>...
* 3.4.3 : 2.2
* Specifying mixed='true' when the <simpleContent>
* alternative is chosen has no effect
*/
/*
* <complexType><complexContent>...
*/
} else {
/*
* E.g <complexType><sequence>... or <complexType><attribute>... etc.
*
* SPEC
* "...the third alternative (neither <simpleContent> nor
* <complexContent>) is chosen. This case is understood as shorthand
* for complex content restricting the �ur-type definition�, and the
* details of the mappings should be modified as necessary.
*/
/*
* Parse model groups.
*/
XML_SCHEMA_TYPE_ALL, 1);
/*
* Note that the reference will be resolved in
* xmlSchemaResolveTypeReferences();
*/
}
/*
*/
return(NULL);
/*
* Parse attribute wildcard.
*/
}
}
NULL, "(annotation?, (simpleContent | complexContent | "
"((group | all | choice | sequence)?, ((attribute | "
"attributeGroup)*, anyAttribute?))))");
}
/*
* REDEFINE: SPEC src-redefine (5)
*/
"<complexType> must have a <restriction> or <extension> "
"grand-child", NULL);
}
return (type);
}
/************************************************************************
* *
* Validating using Schemas *
* *
************************************************************************/
/************************************************************************
* *
* *
************************************************************************/
#if 0 /* Will be enabled if it is clear what options are needed. */
/**
* xmlSchemaParserCtxtSetOptions:
* @ctxt: a schema parser context
* @options: a combination of xmlSchemaParserOption
*
* Sets the options to be used during the parse.
*
* Returns 0 in case of success, -1 in case of an
* API error.
*/
static int
int options)
{
int i;
return (-1);
/*
* WARNING: Change the start value if adding to the
* xmlSchemaParseOption.
*/
for (i = 1; i < (int) sizeof(int) * 8; i++) {
if (options & 1<<i) {
return (-1);
}
}
return (0);
}
/**
* xmlSchemaValidCtxtGetOptions:
* @ctxt: a schema parser context
*
* Returns the option combination of the parser context.
*/
static int
{
return (-1);
else
}
#endif
/**
* xmlSchemaNewParserCtxt:
* @URL: the location of the schema
*
* to contain an XML Schemas file.
*
* Returns the parser context or NULL in case of error
*/
xmlSchemaNewParserCtxt(const char *URL)
{
return (NULL);
return(NULL);
return (ret);
}
/**
* xmlSchemaNewMemParserCtxt:
* @buffer: a pointer to a char array containing the schemas
* @size: the size of the array
*
* Create an XML Schemas parse context for that memory buffer expected
* to contain an XML Schemas file.
*
* Returns the parser context or NULL in case of error
*/
{
return (NULL);
return(NULL);
return (ret);
}
/**
* xmlSchemaNewDocParserCtxt:
* @doc: a preparsed document tree
*
* Create an XML Schemas parse context for that document.
* NB. The document may be modified during the parsing process.
*
* Returns the parser context or NULL in case of error
*/
{
return (NULL);
return(NULL);
/* The application has responsibility for the document */
return (ret);
}
/**
* xmlSchemaFreeParserCtxt:
* @ctxt: the schema parser context
*
* Free the resources associated to the schema parser context
*/
void
{
return;
}
ctxt->ownsConstructor = 0;
}
}
/************************************************************************
* *
* Building the content models *
* *
************************************************************************/
static void
{
int i;
/*
* Wrap the substitution group with a CHOICE.
*/
if (substGroup == NULL) {
"Internal error: xmlSchemaBuildContentModelForSubstGroup, "
"declaration is marked having a subst. group but none "
return;
}
if (counter >= 0) {
/*
* NOTE that we put the declaration in, even if it's abstract.
* However, an error will be raised during *validation* if an element
* information item shall be validated against an abstract element
* declaration.
*/
/*
* Add subst. group members.
*/
}
/*
* NOTE that we put the declaration in, even if it's abstract,
*/
/*
* Add subst. group members.
*/
/*
* NOTE: This fixes bug #341150. xmlAutomataNewOnceTrans2()
* was incorrectly used instead of xmlAutomataNewTransition2()
* (seems like a copy&paste bug from the XML_SCHEMA_TYPE_ALL
* section in xmlSchemaBuildAContentModel() ).
* TODO: Check if xmlAutomataNewOnceTrans2() was instead
* intended for the above "counter" section originally. I.e.,
* check xs:all with subst-groups.
*
* tmp = xmlAutomataNewOnceTrans2(pctxt->am, start, NULL,
* member->name, member->targetNamespace,
* 1, 1, member);
*/
}
} else {
counter =
hop);
/*
* Add subst. group members.
*/
hop);
}
}
}
static void
{
/*
* Substitution groups.
*/
} else {
return;
/* Special case. */
} else {
int counter;
}
}
}
/**
* xmlSchemaBuildAContentModel:
* @ctxt: the schema parser context
* @particle: the particle component
* @name: the complex type's name whose content is being built
*
* Create the automaton for the {content type} of a complex type.
*
*/
static void
{
return;
}
/*
* Just return in this case. A missing "term" of the particle
* might arise due to an invalid "term" component.
*/
return;
}
case XML_SCHEMA_TYPE_ANY: {
/*
* We need to add both transitions:
*
* 1. the {"*", "*"} for elements in a namespace.
*/
/*
* 2. the {"*"} for elements in no namespace.
*/
do {
wild);
}
} else {
int counter;
int maxOccurs =
int minOccurs =
do {
wild);
}
}
}
break;
}
case XML_SCHEMA_TYPE_ELEMENT:
break;
case XML_SCHEMA_TYPE_SEQUENCE:{
/*
* If max and min occurances are default (1) then
* simply iterate over the particles of the <sequence>.
*/
}
} else {
int counter;
}
} else {
}
oldstate);
/*
* epsilon needed to block previous trans from
* being allowed to enter back from another
* construct
*/
}
}
int counter;
}
counter);
}
} else {
}
}
}
}
break;
}
case XML_SCHEMA_TYPE_CHOICE:{
/*
* iterate over the subtypes and remerge the end with an
* epsilon transition
*/
}
} else {
int counter;
int minOccurs =
/*
* use a counter to keep track of the number of transtions
* which went through the choice.
*/
counter =
}
}
}
break;
}
case XML_SCHEMA_TYPE_ALL:{
int lax;
break;
PERROR_INT("xmlSchemaBuildAContentModel",
"<element> particle has no term");
return;
};
/*
* NOTE: The {max occurs} of all the particles in the
* {particles} of the group must be 0 or 1; this is
* already ensured during the parse of the content of
* <all>.
*/
int counter;
/*
* This is an abstract group, we need to share
* the same counter for all the element transitions
* derived from the group
*/
} else {
0,
1,
elemDecl);
}
}
}
break;
}
case XML_SCHEMA_TYPE_GROUP:
/*
* If we hit a model group definition, then this means that
* it was empty, thus was not substituted for the containing
* model group. Just do nothing in this case.
* TODO: But the group should be substituted and not occur at
* all in the content model at this point. Fix this.
*/
break;
default:
"xmlSchemaBuildAContentModel",
"found unexpected term of type '%s' in content model",
return;
}
}
/**
* xmlSchemaBuildContentModel:
* @ctxt: the schema parser context
* @type: the complex type definition
* @name: the element name
*
* Builds the content model of the complex type.
*/
static void
{
return;
#ifdef DEBUG_CONTENT
"Building content model for %s\n", name);
#endif
return;
}
/*
* Build the automaton.
*/
"Failed to compile the content model", NULL);
/* XML_SCHEMAS_ERR_NOTDETERMINIST, */
"The content model is not determinist", NULL);
} else {
#ifdef DEBUG_CONTENT_REGEXP
#endif
}
}
/**
* xmlSchemaResolveElementReferences:
* @elem: the schema element context
* @ctxt: the schema parser context
*
* Resolves the references of an element declaration
* or particle, which has an element declaration as it's
* term.
*/
static void
{
return;
/* (type definition) ... otherwise the type definition �resolved�
* to by the �actual value� of the type [attribute] ...
*/
XML_SCHEMA_TYPE_BASIC, "type definition");
} else
}
/*
* FIXME TODO: Do we need a new field in _xmlSchemaElement for
* substitutionGroup?
*/
} else {
/*
* Set the "substitution group affiliation".
* NOTE that now we use the "refDecl" field for this.
*/
/*
* The type definitions is set to:
* SPEC "...the {type definition} of the element
* declaration �resolved� to by the �actual value�
* of the substitutionGroup [attribute], if present"
*/
}
}
/*
* SPEC "The definition of anyType serves as the default type definition
* for element declarations whose XML representation does not specify one."
*/
}
/**
* xmlSchemaResolveUnionMemberTypes:
* @ctxt: the schema parser context
* @type: the schema simple type definition
*
* Checks and builds the "member type definitions" property of the union
* simple type. This handles part (1), part (2) is done in
* xmlSchemaFinishMemberTypeDefinitionsProperty()
*
* Returns -1 in case of an internal error, 0 otherwise.
*/
static int
{
/*
* SPEC (1) "If the <union> alternative is chosen, then [Definition:]
* define the explicit members as the type definitions �resolved�
* to by the items in the �actual value� of the memberTypes [attribute],
* if any, followed by the type definitions corresponding to the
* <simpleType>s among the [children] of <union>, if any."
*/
/*
* Resolve references.
*/
/*
* Remove the member type link.
*/
else
} else {
}
}
/*
* Add local simple types,
*/
while (memberType != NULL) {
return (-1);
}
else
}
return (0);
}
/**
* xmlSchemaIsDerivedFromBuiltInType:
* @ctxt: the schema parser context
* @type: the type definition
* @valType: the value type
*
*
* Returns 1 if the type has the given value type, or
* is derived from such a type.
*/
static int
{
return (0);
if (WXS_IS_COMPLEX(type))
return (0);
return(1);
return (0);
}
}
#if 0
/**
* xmlSchemaIsDerivedFromBuiltInType:
* @ctxt: the schema parser context
* @type: the type definition
* @valType: the value type
*
*
* Returns 1 if the type has the given value type, or
* is derived from such a type.
*/
static int
{
return (0);
if (WXS_IS_COMPLEX(type))
return (0);
return(1);
return (0);
} else
return (0);
}
#endif
static xmlSchemaTypePtr
{
return (NULL);
if (WXS_IS_COMPLEX(type))
return (NULL);
return(type);
}
/**
* xmlSchemaGetPrimitiveType:
* @type: the simpleType definition
*
* Returns the primitive type of the given type or
* NULL in case of error.
*/
static xmlSchemaTypePtr
{
/*
* Note that anySimpleType is actually not a primitive type
* but we need that here.
*/
return (type);
}
return (NULL);
}
#if 0
/**
* xmlSchemaGetBuiltInTypeAncestor:
* @type: the simpleType definition
*
* Returns the primitive type of the given type or
* NULL in case of error.
*/
static xmlSchemaTypePtr
{
return (0);
return (type);
}
return (NULL);
}
#endif
/**
* xmlSchemaCloneWildcardNsConstraints:
* @ctxt: the schema parser context
* @dest: the destination wildcard
* @source: the source wildcard
*
* Clones the namespace constraints of source
* and assignes them to dest.
* Returns -1 on internal error, 0 otherwise.
*/
static int
{
return(-1);
return(-1);
else
}
return(-1);
} else
return(0);
}
/**
* xmlSchemaUnionWildcards:
* @ctxt: the schema parser context
* @completeWild: the first wildcard
* @curWild: the second wildcard
*
* Unions the namespace constraints of the given wildcards.
* @completeWild will hold the resulting union.
* Returns a positive error code on failure, -1 in case of an
* internal error, 0 otherwise.
*/
static int
{
/*
* 1 If O1 and O2 are the same value, then that value must be the
* value.
*/
int found = 0;
/*
* Check equality of sets.
*/
found = 0;
found = 1;
break;
}
}
if (!found)
break;
}
if (found)
return(0);
} else
return(0);
}
}
/*
* 2 If either O1 or O2 is any, then any must be the value
*/
if (completeWild->any == 0) {
}
}
}
return (0);
}
/*
* 3 If both O1 and O2 are sets of (namespace names or �absent�),
* then the union of those sets must be the value.
*/
int found;
found = 0;
found = 1;
break;
}
}
if (!found) {
return (-1);
}
}
return(0);
}
/*
* 4 If the two are negations of different values (namespace names
* or �absent�), then a pair of not and �absent� must be the value.
*/
return(0);
}
/*
* 5.
*/
int nsFound, absentFound = 0;
} else {
}
nsFound = 0;
absentFound = 1;
nsFound = 1;
if (nsFound && absentFound)
break;
}
if (nsFound && absentFound) {
/*
* 5.1 If the set S includes both the negated namespace
* name and �absent�, then any must be the value.
*/
}
}
} else if (nsFound && (!absentFound)) {
/*
* 5.2 If the set S includes the negated namespace name
* but not �absent�, then a pair of not and �absent� must
* be the value.
*/
}
return (-1);
}
} else if ((!nsFound) && absentFound) {
/*
* 5.3 If the set S includes �absent� but not the negated
* namespace name, then the union is not expressible.
*/
"The union of the wilcard is not expressible.\n",
return(XML_SCHEMAP_UNION_NOT_EXPRESSIBLE);
} else if ((!nsFound) && (!absentFound)) {
/*
* 5.4 If the set S does not include either the negated namespace
* name or �absent�, then whichever of O1 or O2 is a pair of not
* and a namespace name must be the value.
*/
}
return (-1);
}
}
return (0);
}
/*
* 6.
*/
} else {
}
/*
* 6.1 If the set S includes �absent�, then any must be the
* value.
*/
}
}
return (0);
}
}
/*
* 6.2 If the set S does not include �absent�, then a pair of not
* and �absent� must be the value.
*/
}
return (-1);
}
return (0);
}
return (0);
}
/**
* xmlSchemaIntersectWildcards:
* @ctxt: the schema parser context
* @completeWild: the first wildcard
* @curWild: the second wildcard
*
* Intersects the namespace constraints of the given wildcards.
* @completeWild will hold the resulting intersection.
* Returns a positive error code on failure, -1 in case of an
* internal error, 0 otherwise.
*/
static int
{
/*
* 1 If O1 and O2 are the same value, then that value must be the
* value.
*/
int found = 0;
/*
* Check equality of sets.
*/
found = 0;
found = 1;
break;
}
}
if (!found)
break;
}
if (found)
return(0);
} else
return(0);
}
}
/*
* 2 If either O1 or O2 is any, then the other must be the value.
*/
return(-1);
return(0);
}
/*
* 3 If either O1 or O2 is a pair of not and a value (a namespace
* name or �absent�) and the other is a set of (namespace names or
* �absent�), then that set, minus the negated value if it was in
* the set, minus �absent� if it was in the set, must be the value.
*/
return(-1);
} else
/*
* Remove absent and negated.
*/
else
break;
}
}
else
break;
}
}
}
return(0);
}
/*
* 4 If both O1 and O2 are sets of (namespace names or �absent�),
* then the intersection of those sets must be the value.
*/
int found;
found = 0;
found = 1;
break;
}
}
if (!found) {
else
continue;
}
}
return(0);
}
/* 5 If the two are negations of different namespace names,
* then the intersection is not expressible
*/
"The intersection of the wilcard is not expressible.\n",
}
/*
* 6 If the one is a negation of a namespace name and the other
* is a negation of �absent�, then the one which is the negation
* of a namespace name must be the value.
*/
}
return(0);
}
/**
* xmlSchemaIsWildcardNsConstraintSubset:
* @ctxt: the schema parser context
* @sub: the first wildcard
* @super: the second wildcard
*
* Schema Component Constraint: Wildcard Subset (cos-ns-subset)
*
* Returns 0 if the namespace constraint of @sub is an intensional
* subset of @super, 1 otherwise.
*/
static int
{
/*
* 1 super must be any.
*/
return (0);
/*
* 2.1 sub must be a pair of not and a namespace name or �absent�.
* 2.2 super must be a pair of not and the same value.
*/
return (0);
/*
* 3.1 sub must be a set whose members are either namespace names or �absent�.
*/
/*
* 3.2.1 super must be the same set or a superset thereof.
*/
int found = 0;
found = 0;
found = 1;
break;
}
}
if (!found)
return (1);
}
if (found)
return (0);
/*
* 3.2.2 super must be a pair of not and a namespace name or
* �absent� and that value must not be in sub's set.
*/
return (1);
}
return (0);
}
}
return (1);
}
static int
int *fixed,
{
*fixed = 0;
if (val != 0)
*fixed = 1;
return(1);
*fixed = 1;
return(1);
}
return(0);
}
/**
* xmlSchemaCheckCVCWildcardNamespace:
* @wild: the wildcard
* @ns: the namespace
*
* Validation Rule: Wildcard allows Namespace Name
* (cvc-wildcard-namespace)
*
* Returns 0 if the given namespace matches the wildcard,
* 1 otherwise and -1 on API errors.
*/
static int
{
return(-1);
return(0);
return(0);
}
return(0);
return(1);
}
#define XML_SCHEMA_ACTION_DERIVE 0
#define XML_SCHEMA_ACTION_REDEFINE 1
#define WXS_ACTION_STR(a) \
/*
* Schema Component Constraint:
* Derivation Valid (Restriction, Complex)
* derivation-ok-restriction (2) - (4)
*
* ATTENTION:
* In XML Schema 1.1 this will be:
* Validation Rule:
* Checking complex type subsumption (practicalSubsumption) (1, 2 and 3)
*
*/
static int
int action,
{
int i, j, found; /* err = 0; */
int effFixed;
found = 0;
goto not_found;
if ((WXS_ATTRUSE_DECL_NAME(cur) ==
(WXS_ATTRUSE_DECL_TNS(cur) ==
{
/*
* (2.1) "If there is an attribute use in the {attribute
* uses} of the {base type definition} (call this B) whose
* {attribute declaration} has the same {name} and {target
* namespace}, then all of the following must be true:"
*/
found = 1;
{
/*
* (2.1.1) "one of the following must be true:"
* (2.1.1.1) "B's {required} is false."
* (2.1.1.2) "R's {required} is true."
*/
"The 'optional' attribute use is inconsistent "
"with the corresponding 'required' attribute use of "
"the %s %s",
/* err = pctxt->err; */
WXS_ATTRUSE_TYPEDEF(bcur), 0) != 0)
{
/*
* SPEC (2.1.2) "R's {attribute declaration}'s
* {type definition} must be validly derived from
* B's {type definition} given the empty set as
* defined in Type Derivation OK (Simple) (�3.14.6)."
*/
"The attribute declaration's %s "
"is not validly derived from "
"the corresponding %s of the "
"attribute declaration in the %s %s",
/* xmlSchemaGetComponentDesignation(&str, baseItem), */
/* err = pctxt->err; */
} else {
/*
* 2.1.3 [Definition:] Let the effective value
* constraint of an attribute use be its {value
* constraint}, if present, otherwise its {attribute
* declaration}'s {value constraint} .
*/
/*
* 2.1.3 ... one of the following must be true
*
* 2.1.3.1 B's �effective value constraint� is
* �absent� or default.
*/
(effFixed == 1)) {
/*
* 2.1.3.2 R's �effective value constraint� is
* fixed with the same string as B's.
* MAYBE TODO: Compare the computed values.
* Hmm, it says "same string" so
* string-equality might really be sufficient.
*/
if ((effFixed == 0) ||
{
"The effective value constraint of the "
"attribute use is inconsistent with "
"its correspondent in the %s %s",
baseItem),
/* err = pctxt->err; */
}
}
}
break;
}
}
if (!found) {
/*
* (2.2) "otherwise the {base type definition} must have an
* {attribute wildcard} and the {target namespace} of the
* R's {attribute declaration} must be �valid� with respect
* to that wildcard, as defined in Wildcard allows Namespace
* Name (�3.10.4)."
*/
{
"Neither a matching attribute use, "
"nor a matching wildcard exists in the %s %s",
/* err = pctxt->err; */
}
}
}
}
/*
* SPEC derivation-ok-restriction (3):
* (3) "For each attribute use in the {attribute uses} of the {base type
* definition} whose {required} is true, there must be an attribute
* use with an {attribute declaration} with the same {name} and
* {target namespace} as its {attribute declaration} in the {attribute
* uses} of the complex type definition itself whose {required} is true.
*/
continue;
found = 0;
if ((WXS_ATTRUSE_DECL_NAME(cur) ==
(WXS_ATTRUSE_DECL_TNS(cur) ==
WXS_ATTRUSE_DECL_TNS(bcur))) {
found = 1;
break;
}
}
}
if (!found) {
"A matching attribute use for the "
"'required' %s of the %s %s is missing",
NULL);
}
}
}
/*
* derivation-ok-restriction (4)
*/
/*
* (4) "If there is an {attribute wildcard}, all of the
* following must be true:"
*/
/*
* (4.1) "The {base type definition} must also have one."
*/
"The %s has an attribute wildcard, "
"but the %s %s '%s' does not have one",
{
/*
* (4.2) "The complex type definition's {attribute wildcard}'s
* {namespace constraint} must be a subset of the {base type
* definition}'s {attribute wildcard}'s {namespace constraint},
* as defined by Wildcard Subset (�3.10.6)."
*/
"The attribute wildcard is not a valid "
"subset of the wildcard in the %s %s '%s'",
NULL);
}
/* 4.3 Unless the {base type definition} is the �ur-type
* definition�, the complex type definition's {attribute
* wildcard}'s {process contents} must be identical to or
* stronger than the {base type definition}'s {attribute
* wildcard}'s {process contents}, where strict is stronger
* than lax is stronger than skip.
*/
if ((! WXS_IS_ANYTYPE(baseItem)) &&
"The {process contents} of the attribute wildcard is "
"weaker than the one in the %s %s '%s'",
NULL);
}
}
return(0);
}
static int
/**
* xmlSchemaFixupTypeAttributeUses:
* @ctxt: the schema parser context
* @type: the complex type definition
*
*
* Builds the wildcard and the attribute uses on the given complex type.
* Returns -1 if an internal error occurs, 0 otherwise.
*
* ATTENTION TODO: Experimantally this uses pointer comparisons for
* strings, so recheck this if we start to hardcode some schemata, since
* they might not be in the same dict.
* NOTE: It is allowed to "extend" the xs:anyType type.
*/
static int
{
PERROR_INT("xmlSchemaFixupTypeAttributeUses",
"no base type");
return (-1);
}
return(-1);
/*
* Expand attribute group references. And build the 'complete'
* wildcard, i.e. intersect multiple wildcards.
* Move attribute prohibitions into a separate list.
*/
if (WXS_IS_RESTRICTION(type)) {
/*
* This one will transfer all attr. prohibitions
* into pctxt->attrProhibs.
*/
{
PERROR_INT("xmlSchemaFixupTypeAttributeUses",
"failed to expand attributes");
}
} else {
NULL) == -1)
{
PERROR_INT("xmlSchemaFixupTypeAttributeUses",
"failed to expand attributes");
}
}
}
/*
* Inherit the attribute uses of the base type.
*/
int i, j;
if (WXS_IS_RESTRICTION(type)) {
int usesCount;
else
usesCount = 0;
/* Restriction. */
if (prohibs) {
/*
* Filter out prohibited uses.
*/
(WXS_ATTRUSE_DECL_TNS(use) ==
{
goto inherit_next;
}
}
}
if (usesCount) {
/*
* Filter out existing uses.
*/
for (j = 0; j < usesCount; j++) {
if ((WXS_ATTRUSE_DECL_NAME(use) ==
WXS_ATTRUSE_DECL_NAME(tmp)) &&
(WXS_ATTRUSE_DECL_TNS(use) ==
{
goto inherit_next;
}
}
}
goto exit_failure;
}
inherit_next: {}
}
} else {
/* Extension. */
goto exit_failure;
}
}
}
}
/*
* Shrink attr. uses.
*/
if (uses) {
}
/*
* TODO: We could shrink the size of the array
* to fit the actual number of items.
*/
}
/*
* Compute the complete wildcard.
*/
if (WXS_IS_EXTENSION(type)) {
/*
* (3.2.2.1) "If the �base wildcard� is non-�absent�, then
* the appropriate case among the following:"
*/
/*
* Union the complete wildcard with the base wildcard.
* SPEC {attribute wildcard}
* (3.2.2.1.2) "otherwise a wildcard whose {process contents}
* and {annotation} are those of the �complete wildcard�,
* and whose {namespace constraint} is the intensional union
* of the {namespace constraint} of the �complete wildcard�
* and of the �base wildcard�, as defined in Attribute
* Wildcard Union (�3.10.6)."
*/
goto exit_failure;
} else {
/*
* (3.2.2.1.1) "If the �complete wildcard� is �absent�,
* then the �base wildcard�."
*/
}
} else {
/*
* (3.2.2.2) "otherwise (the �base wildcard� is �absent�) the
* �complete wildcard"
* NOOP
*/
}
} else {
/*
* SPEC {attribute wildcard}
* (3.1) "If the <restriction> alternative is chosen, then the
* �complete wildcard�;"
* NOOP
*/
}
return (0);
return(-1);
}
/**
* xmlSchemaTypeFinalContains:
* @schema: the schema
* @type: the type definition
* @final: the final
*
* Evaluates if a type definition contains the given "final".
* This does take "finalDefault" into account as well.
*
* Returns 1 if the type does containt the given "final",
* 0 otherwise.
*/
static int
{
return (0);
return (1);
else
return (0);
}
/**
* xmlSchemaGetUnionSimpleTypeMemberTypes:
* @type: the Union Simple Type
*
* Returns a list of member types of @type if existing,
* returns NULL otherwise.
*/
static xmlSchemaTypeLinkPtr
{
return (type->memberTypes);
else
}
return (NULL);
}
/**
* xmlSchemaGetParticleTotalRangeMin:
* @particle: the particle
*
* Schema Component Constraint: Effective Total Range
* (all and sequence) + (choice)
*
* Returns the minimun Effective Total Range.
*/
static int
{
return (0);
return (0);
else
if (cur == 0)
return (0);
}
} else {
/* <all> and <sequence> */
int sum = 0;
return (0);
do {
else
}
}
/**
* xmlSchemaGetParticleTotalRangeMax:
* @particle: the particle
*
* Schema Component Constraint: Effective Total Range
* (all and sequence) + (choice)
*
* Returns the maximum Effective Total Range.
*/
static int
{
return (0);
continue;
else
return (UNBOUNDED);
}
/* TODO: Handle overflows? */
} else {
/* <all> and <sequence> */
continue;
else
return (UNBOUNDED);
return (UNBOUNDED);
}
/* TODO: Handle overflows? */
}
}
/**
* xmlSchemaIsParticleEmptiable:
* @particle: the particle
*
* Schema Component Constraint: Particle Emptiable
* Checks whether the given particle is emptiable.
*
* Returns 1 if emptiable, 0 otherwise.
*/
static int
{
/*
* SPEC (1) "Its {min occurs} is 0."
*/
return (1);
/*
* SPEC (2) "Its {term} is a group and the minimum part of the
* effective total range of that group, [...] is 0."
*/
if (xmlSchemaGetParticleTotalRangeMin(particle) == 0)
return (1);
}
return (0);
}
/**
* xmlSchemaCheckCOSSTDerivedOK:
* @actxt: a context
* @type: the derived simple type definition
* @baseType: the base type definition
* @subset: the subset of ('restriction', ect.)
*
* Schema Component Constraint:
* Type Derivation OK (Simple) (cos-st-derived-OK)
*
* Checks wheter @type can be validly
* derived from @baseType.
*
* Returns 0 on success, an positive error code otherwise.
*/
static int
int subset)
{
/*
* 1 They are the same type definition.
* TODO: The identy check might have to be more complex than this.
*/
return (0);
/*
* 2.1 restriction is not in the subset, or in the {final}
* of its own {base type definition};
*
* NOTE that this will be used also via "xsi:type".
*
* TODO: Revise this, it looks strange. How can the "type"
* not be fixed or *in* fixing?
*/
if (WXS_IS_TYPE_NOT_FIXED(type))
return(-1);
return(-1);
if ((subset & SUBSET_RESTRICTION) ||
return (XML_SCHEMAP_COS_ST_DERIVED_OK_2_1);
}
/* 2.2 */
/*
* 2.2.1 D's �base type definition� is B.
*/
return (0);
}
/*
* 2.2.2 D's �base type definition� is not the �ur-type definition�
* and is validly derived from B given the subset, as defined by this
* constraint.
*/
return (0);
}
/*
* 2.2.3 D's {variety} is list or union and B is the �simple ur-type
* definition�.
*/
if (WXS_IS_ANY_SIMPLE_TYPE(baseType) &&
return (0);
}
/*
* 2.2.4 B's {variety} is union and D is validly derived from a type
* definition in B's {member type definitions} given the subset, as
* defined by this constraint.
*
* NOTE: This seems not to involve built-in types, since there is no
* built-in Union Simple Type.
*/
if (WXS_IS_UNION(baseType)) {
return(-1);
{
/*
* It just has to be validly derived from at least one
* member-type.
*/
return (0);
}
}
}
return (XML_SCHEMAP_COS_ST_DERIVED_OK_2_2);
}
/**
* xmlSchemaCheckTypeDefCircularInternal:
* @pctxt: the schema parser context
* @ctxtType: the type definition
* @ancestor: an ancestor of @ctxtType
*
* Checks st-props-correct (2) + ct-props-correct (3).
* Circular type definitions are not allowed.
*
* Returns XML_SCHEMAP_ST_PROPS_CORRECT_2 if the given type is
* circular, 0 otherwise.
*/
static int
{
int ret;
return (0);
"The definition is circular", NULL);
return (XML_SCHEMAP_ST_PROPS_CORRECT_2);
}
/*
* Avoid inifinite recursion on circular types not yet checked.
*/
return (0);
}
return (ret);
}
/**
* xmlSchemaCheckTypeDefCircular:
* @ctxt: the parser context
* @name: the name
*
* Checks for circular type definitions.
*/
static void
{
return;
}
/*
* Simple Type Definition Representation OK (src-simple-type) 4
*
* "4 Circular union type definition is disallowed. That is, if the
* <union> alternative is chosen, there must not be any entries in the
* memberTypes [attribute] at any depth which resolve to the component
* corresponding to the <simpleType>."
*
* Note that this should work on the *representation* of a component,
* thus assumes any union types in the member types not being yet
* substituted. At this stage we need the variety of the types
* to be already computed.
*/
static int
{
while ((memberType != NULL) &&
if (memberType == ctxType) {
"The union type definition is circular", NULL);
return (XML_SCHEMAP_SRC_SIMPLE_TYPE_4);
}
if ((WXS_IS_UNION(memberType)) &&
{
int res;
if (res != 0)
return(res);
}
}
}
return(0);
}
static int
{
if (! WXS_IS_UNION(type))
return(0);
type->memberTypes));
}
/**
* xmlSchemaResolveTypeReferences:
* @ctxt: the parser context
* @name: the name
*
* Resolvese type definition references
*/
static void
{
return;
/*
* Resolve the base type.
*/
return;
}
}
if (WXS_IS_SIMPLE(typeDef)) {
if (WXS_IS_UNION(typeDef)) {
/*
* Resolve the memberTypes.
*/
return;
} else if (WXS_IS_LIST(typeDef)) {
/*
* Resolve the itemType.
*/
{
}
}
return;
}
}
/*
* The ball of letters below means, that if we have a particle
* which has a QName-helper component as its {term}, we want
* to resolve it...
*/
{
/*
* URGENT TODO: Test this.
*/
/*
* Resolve the MG definition reference.
*/
groupDef =
NULL);
/* Remove the particle. */
/* Remove the particle. */
else {
/*
* Assign the MG definition's {model group} to the
* particle's {term}.
*/
/*
* SPEC cos-all-limited (1.2)
* "1.2 the {term} property of a particle with
* {max occurs}=1 which is part of a pair which constitutes
* the {content type} of a complex type definition."
*/
/* TODO: error code */
"The particle's {max occurs} must be 1, since the "
"reference resolves to an 'all' model group",
}
}
}
}
}
/**
* xmlSchemaCheckSTPropsCorrect:
* @ctxt: the schema parser context
* @type: the simple type definition
*
* Checks st-props-correct.
*
* Returns 0 if the properties are correct,
* if not, a positive error code and -1 on internal
* errors.
*/
static int
{
/* STATE: error funcs converted. */
/*
* Schema Component Constraint: Simple Type Definition Properties Correct
*
* NOTE: This is somehow redundant, since we actually built a simple type
* to have all the needed information; this acts as an self test.
*/
/* Base type: If the datatype has been �derived� by �restriction�
* then the Simple Type Definition component from which it is �derived�,
* otherwise the Simple Type Definition for anySimpleType (�4.1.6).
*/
/*
* TODO: Think about: "modulo the impact of Missing
* Sub-components (�5.3)."
*/
"No base type existent", NULL);
return (XML_SCHEMAP_ST_PROPS_CORRECT_1);
}
if (! WXS_IS_SIMPLE(baseType)) {
"The base type '%s' is not a simple type",
return (XML_SCHEMAP_ST_PROPS_CORRECT_1);
}
(WXS_IS_RESTRICTION(type) == 0) &&
(! WXS_IS_ANY_SIMPLE_TYPE(baseType))) {
"A type, derived by list or union, must have"
"the simple ur-type definition as base type, not '%s'",
return (XML_SCHEMAP_ST_PROPS_CORRECT_1);
}
/*
* Variety: One of {atomic, list, union}.
*/
(! WXS_IS_LIST(type))) {
"The variety is absent", NULL);
return (XML_SCHEMAP_ST_PROPS_CORRECT_1);
}
/* TODO: Finish this. Hmm, is this finished? */
/*
* 3 The {final} of the {base type definition} must not contain restriction.
*/
"The 'final' of its base type '%s' must not contain "
"'restriction'",
return (XML_SCHEMAP_ST_PROPS_CORRECT_3);
}
/*
* 2 All simple type definitions must be derived ultimately from the �simple
* ur-type definition (so� circular definitions are disallowed). That is, it
* must be possible to reach a built-in primitive datatype or the �simple
* ur-type definition� by repeatedly following the {base type definition}.
*
* NOTE: this is done in xmlSchemaCheckTypeDefCircular().
*/
return (0);
}
/**
* xmlSchemaCheckCOSSTRestricts:
* @ctxt: the schema parser context
* @type: the simple type definition
*
* Schema Component Constraint:
* Derivation Valid (Restriction, Simple) (cos-st-restricts)
* Checks if the given @type (simpleType) is derived validly by restriction.
* STATUS:
*
* Returns -1 on internal errors, 0 if the type is validly derived,
* a positive error code otherwise.
*/
static int
{
PERROR_INT("xmlSchemaCheckCOSSTRestricts",
"given type is not a user-derived simpleType");
return (-1);
}
if (WXS_IS_ATOMIC(type)) {
/*
* 1.1 The {base type definition} must be an atomic simple
* type definition or a built-in primitive datatype.
*/
"The base type '%s' is not an atomic simple type",
return (XML_SCHEMAP_COS_ST_RESTRICTS_1_1);
}
/* 1.2 The {final} of the {base type definition} must not contain
* restriction.
*/
/* OPTIMIZE TODO : This is already done in xmlSchemaCheckStPropsCorrect */
"The final of its base type '%s' must not contain 'restriction'",
return (XML_SCHEMAP_COS_ST_RESTRICTS_1_2);
}
/*
* 1.3.1 DF must be an allowed constraining facet for the {primitive
* type definition}, as specified in the appropriate subsection of 3.2
* Primitive datatypes.
*/
int ok = 1;
PERROR_INT("xmlSchemaCheckCOSSTRestricts",
"failed to get primitive type");
return (-1);
}
do {
ok = 0;
}
if (ok == 0)
return (XML_SCHEMAP_COS_ST_RESTRICTS_1_3_1);
}
/*
* SPEC (1.3.2) "If there is a facet of the same kind in the {facets}
* of the {base type definition} (call this BF),then the DF's {value}
* must be a valid restriction of BF's {value} as defined in
* [XML Schemas: Datatypes]."
*
* NOTE (1.3.2) Facet derivation constraints are currently handled in
* xmlSchemaDeriveAndValidateFacets()
*/
} else if (WXS_IS_LIST(type)) {
PERROR_INT("xmlSchemaCheckCOSSTRestricts",
"failed to evaluate the item type");
return (-1);
}
/*
* 2.1 The {item type definition} must have a {variety} of atomic or
* union (in which case all the {member type definitions}
* must be atomic).
*/
if ((! WXS_IS_ATOMIC(itemType)) &&
(! WXS_IS_UNION(itemType))) {
"The item type '%s' does not have a variety of atomic or union",
return (XML_SCHEMAP_COS_ST_RESTRICTS_2_1);
} else if (WXS_IS_UNION(itemType)) {
"The item type is a union type, but the "
"member type '%s' of this item type is not atomic",
return (XML_SCHEMAP_COS_ST_RESTRICTS_2_1);
}
}
}
/*
* This is the case if we have: <simpleType><list ..
*/
/*
* 2.3.1
* 2.3.1.1 The {final} of the {item type definition} must not
* contain list.
*/
"The final of its item type '%s' must not contain 'list'",
return (XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_1);
}
/*
* 2.3.1.2 The {facets} must only contain the whiteSpace
* facet component.
* OPTIMIZE TODO: the S4S already disallows any facet
* to be specified.
*/
do {
return (XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_2);
}
}
/*
* MAYBE TODO: (Hmm, not really) Datatypes states:
* A �list� datatype can be �derived� from an �atomic� datatype
* whose �lexical space� allows space (such as string or anyURI)or
* a �union� datatype any of whose {member type definitions}'s
* �lexical space� allows space.
*/
} else {
/*
* This is the case if we have: <simpleType><restriction ...
* I.e. the variety of "list" is inherited.
*/
/*
* 2.3.2
* 2.3.2.1 The {base type definition} must have a {variety} of list.
*/
"The base type '%s' must be a list type",
return (XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_1);
}
/*
* 2.3.2.2 The {final} of the {base type definition} must not
* contain restriction.
*/
"The 'final' of the base type '%s' must not contain 'restriction'",
return (XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_2);
}
/*
* 2.3.2.3 The {item type definition} must be validly derived
* from the {base type definition}'s {item type definition} given
* the empty set, as defined in Type Derivation OK (Simple) (�3.14.6).
*/
{
PERROR_INT("xmlSchemaCheckCOSSTRestricts",
"failed to eval the item type of a base type");
return (-1);
}
if ((itemType != baseItemType) &&
baseItemType, 0) != 0)) {
"The item type '%s' is not validly derived from "
"the item type '%s' of the base type '%s'",
return (XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_3);
}
}
int ok = 1;
/*
* 2.3.2.4 Only length, minLength, maxLength, whiteSpace, pattern
* and enumeration facet components are allowed among the {facets}.
*/
do {
case XML_SCHEMA_FACET_LENGTH:
/*
* TODO: 2.5.1.2 List datatypes
* The value of �whiteSpace� is fixed to the value collapse.
*/
case XML_SCHEMA_FACET_PATTERN:
break;
default: {
/*
* We could return, but it's nicer to report all
* invalid facets.
*/
ok = 0;
}
}
if (ok == 0)
return (XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_4);
/*
* SPEC (2.3.2.5) (same as 1.3.2)
*
* NOTE (2.3.2.5) This is currently done in
* xmlSchemaDeriveAndValidateFacets()
*/
}
}
} else if (WXS_IS_UNION(type)) {
/*
* 3.1 The {member type definitions} must all have {variety} of
* atomic or list.
*/
"The member type '%s' is neither an atomic, nor a list type",
return (XML_SCHEMAP_COS_ST_RESTRICTS_3_1);
}
}
/*
* 3.3.1 If the {base type definition} is the �simple ur-type
* definition�
*/
/*
* 3.3.1.1 All of the {member type definitions} must have a
* {final} which does not contain union.
*/
"The 'final' of member type '%s' contains 'union'",
return (XML_SCHEMAP_COS_ST_RESTRICTS_3_3_1);
}
}
/*
* 3.3.1.2 The {facets} must be empty.
*/
"No facets allowed", NULL);
return (XML_SCHEMAP_COS_ST_RESTRICTS_3_3_1_2);
}
} else {
/*
* 3.3.2.1 The {base type definition} must have a {variety} of union.
* I.e. the variety of "list" is inherited.
*/
"The base type '%s' is not a union type",
return (XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_1);
}
/*
* 3.3.2.2 The {final} of the {base type definition} must not contain restriction.
*/
"The 'final' of its base type '%s' must not contain 'restriction'",
return (XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_2);
}
/*
* 3.3.2.3 The {member type definitions}, in order, must be validly
* derived from the corresponding type definitions in the {base
* type definition}'s {member type definitions} given the empty set,
* as defined in Type Derivation OK (Simple) (�3.14.6).
*/
{
/*
* OPTIMIZE: if the type is restricting, it has no local defined
* member types and inherits the member types of the base type;
* thus a check for equality can be skipped.
*/
/*
* Even worse: I cannot see a scenario where a restricting
* union simple type can have other member types as the member
* types of it's base type. This check seems not necessary with
* respect to the derivation process in libxml2.
* But necessary if constructing types with an API.
*/
PERROR_INT("xmlSchemaCheckCOSSTRestricts",
"different number of member types in base");
}
if (baseMember == NULL) {
PERROR_INT("xmlSchemaCheckCOSSTRestricts",
"different number of member types in base");
"The member type %s is not validly "
"derived from its corresponding member "
"type %s of the base type %s",
return (XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_3);
}
}
}
}
/*
* 3.3.2.4 Only pattern and enumeration facet components are
* allowed among the {facets}.
*/
int ok = 1;
do {
ok = 0;
}
if (ok == 0)
return (XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_4);
}
/*
* SPEC (3.3.2.5) (same as 1.3.2)
*
* NOTE (3.3.2.5) This is currently done in
* xmlSchemaDeriveAndValidateFacets()
*/
}
}
return (0);
}
/**
* xmlSchemaCheckSRCSimpleType:
* @ctxt: the schema parser context
* @type: the simple type definition
*
* Checks crc-simple-type constraints.
*
* Returns 0 if the constraints are satisfied,
* if not a positive error code and -1 on internal
* errors.
*/
#if 0
static int
{
/*
* src-simple-type.1 The corresponding simple type definition, if any,
* must satisfy the conditions set out in Constraints on Simple Type
* Definition Schema Components (�3.14.6).
*/
if (WXS_IS_RESTRICTION(type)) {
/*
* src-simple-type.2 "If the <restriction> alternative is chosen,
* either it must have a base [attribute] or a <simpleType> among its
* [children], but not both."
* NOTE: This is checked in the parse function of <restriction>.
*/
/*
*
*/
} else if (WXS_IS_LIST(type)) {
/* src-simple-type.3 "If the <list> alternative is chosen, either it must have
* an itemType [attribute] or a <simpleType> among its [children],
* but not both."
*
* NOTE: This is checked in the parse function of <list>.
*/
} else if (WXS_IS_UNION(type)) {
/*
* src-simple-type.4 is checked in xmlSchemaCheckUnionTypeDefCircular().
*/
}
return (0);
}
#endif
static int
{
"Internal error: xmlSchemaCreateVCtxtOnPCtxt, "
"failed to create a temp. validation context.\n",
return (-1);
}
/* TODO: Pass user data. */
}
return (0);
}
static int
int fireErrors,
int normalize,
int isNormalized);
/**
* xmlSchemaParseCheckCOSValidDefault:
* @pctxt: the schema parser context
* @type: the simple type definition
* @value: the default value
* @node: an optional node (the holder of the value)
*
* Schema Component Constraint: Element Default Valid (Immediate)
* (cos-valid-default)
* This will be used by the parser only. For the validator there's
* an other version.
*
* Returns 0 if the constraints are satisfied,
* if not, a positive error code and -1 on internal
* errors.
*/
static int
{
int ret = 0;
/*
* cos-valid-default:
* Schema Component Constraint: Element Default Valid (Immediate)
* For a string to be a valid default with respect to a type
* definition the appropriate case among the following must be true:
*/
if WXS_IS_COMPLEX(type) {
/*
* Complex type.
*
* SPEC (2.1) "its {content type} must be a simple type definition
* or mixed."
* SPEC (2.2.2) "If the {content type} is mixed, then the {content
* type}'s particle must be �emptiable� as defined by
* Particle Emptiable (�3.9.6)."
*/
if ((! WXS_HAS_SIMPLE_CONTENT(type)) &&
/* NOTE that this covers (2.2.2) as well. */
"For a string to be a valid default, the type definition "
"must be a simple type or a complex type with mixed content "
"and a particle emptiable", NULL);
return(XML_SCHEMAP_COS_VALID_DEFAULT_2_1);
}
}
/*
* 1 If the type definition is a simple type definition, then the string
* must be �valid� with respect to that definition as defined by String
* Valid (�3.14.4).
*
* AND
*
* 2.2.1 If the {content type} is a simple type definition, then the
* string must be �valid� with respect to that simple type definition
* as defined by String Valid (�3.14.4).
*/
if (WXS_IS_SIMPLE(type))
else if (WXS_HAS_SIMPLE_CONTENT(type))
else
return (ret);
if (ret < 0) {
PERROR_INT("xmlSchemaParseCheckCOSValidDefault",
"calling xmlSchemaVCheckCVCSimpleType()");
}
return (ret);
}
/**
* xmlSchemaCheckCTPropsCorrect:
* @ctxt: the schema parser context
* @type: the complex type definition
*
*.(4.6) Constraints on Complex Type Definition Schema Components
* Schema Component Constraint:
* Complex Type Definition Properties Correct (ct-props-correct)
* STATUS: (seems) complete
*
* Returns 0 if the constraints are satisfied, a positive
* error code if not and -1 if an internal error occured.
*/
static int
{
/*
* TODO: Correct the error code; XML_SCHEMAP_SRC_CT_1 is used temporarily.
*
* SPEC (1) "The values of the properties of a complex type definition must
* be as described in the property tableau in The Complex Type Definition
* Schema Component (�3.4.1), modulo the impact of Missing
* Sub-components (�5.3)."
*/
(WXS_IS_EXTENSION(type) == 0)) {
/*
* SPEC (2) "If the {base type definition} is a simple type definition,
* the {derivation method} must be extension."
*/
"If the base type is a simple type, the derivation method must be "
return (XML_SCHEMAP_SRC_CT_1);
}
/*
* SPEC (3) "Circular definitions are disallowed, except for the �ur-type
* definition�. That is, it must be possible to reach the �ur-type
* definition by repeatedly following the {base type definition}."
*
* NOTE (3) is done in xmlSchemaCheckTypeDefCircular().
*/
/*
* NOTE that (4) and (5) need the following:
* - attribute uses need to be already inherited (apply attr. prohibitions)
* - attribute group references need to be expanded already
* - simple types need to be typefixed already
*/
{
int i, j, hasId = 0;
/*
* SPEC ct-props-correct
* (4) "Two distinct attribute declarations in the
* {attribute uses} must not have identical {name}s and
* {target namespace}s."
*/
if (i > 0) {
for (j = i -1; j >= 0; j--) {
if ((WXS_ATTRUSE_DECL_NAME(use) ==
WXS_ATTRUSE_DECL_NAME(tmp)) &&
(WXS_ATTRUSE_DECL_TNS(use) ==
{
"Duplicate %s",
NULL);
/*
* Remove the duplicate.
*/
goto exit_failure;
goto next_use;
}
}
}
/*
* SPEC ct-props-correct
* (5) "Two distinct attribute declarations in the
* {attribute uses} must not have {type definition}s which
* are or are derived from ID."
*/
{
if (hasId) {
"There must not exist more than one attribute "
"declaration of type 'xs:ID' "
"(or derived from 'xs:ID'). The %s violates this "
"constraint",
NULL);
goto exit_failure;
}
hasId = 1;
}
}
next_use: {}
}
}
return (0);
return(-1);
}
static int
{
/*
* TODO: This should implement component-identity
* in the future.
*/
return (0);
}
/**
* xmlSchemaCheckCOSCTDerivedOK:
* @ctxt: the schema parser context
* @type: the to-be derived complex type definition
* @baseType: the base complex type definition
* @set: the given set
*
* Schema Component Constraint:
* Type Derivation OK (Complex) (cos-ct-derived-ok)
*
* STATUS: completed
*
* Returns 0 if the constraints are satisfied, or 1
* if not.
*/
static int
int set)
{
/* TODO: Error codes. */
/*
* SPEC "For a complex type definition (call it D, for derived)
* to be validly derived from a type definition (call this
* B, for base) given a subset of {extension, restriction}
* all of the following must be true:"
*/
if (! equal) {
/*
* SPEC (1) "If B and D are not the same type definition, then the
* {derivation method} of D must not be in the subset."
*/
return (1);
} else {
/*
* SPEC (2.1) "B and D must be the same type definition."
*/
return (0);
}
/*
* SPEC (2.2) "B must be D's {base type definition}."
*/
return (0);
/*
* SPEC (2.3.1) "D's {base type definition} must not be the �ur-type
* definition�."
*/
return (1);
/*
* SPEC (2.3.2.1) "If D's {base type definition} is complex, then it
* must be validly derived from B given the subset as defined by this
* constraint."
*/
} else {
/*
* SPEC (2.3.2.2) "If D's {base type definition} is simple, then it
* must be validly derived from B given the subset as defined in Type
* Derivation OK (Simple) (�3.14.6).
*/
}
}
/**
* xmlSchemaCheckCOSDerivedOK:
* @type: the derived simple type definition
* @baseType: the base type definition
*
* Calls:
* Type Derivation OK (Simple) AND Type Derivation OK (Complex)
*
* Checks wheter @type can be validly derived from @baseType.
*
* Returns 0 on success, an positive error code otherwise.
*/
static int
int set)
{
if (WXS_IS_SIMPLE(type))
else
}
/**
* xmlSchemaCheckCOSCTExtends:
* @ctxt: the schema parser context
* @type: the complex type definition
*
* (3.4.6) Constraints on Complex Type Definition Schema Components
* Schema Component Constraint:
* Derivation Valid (Extension) (cos-ct-extends)
*
* STATUS:
* missing:
* (1.5)
* (1.4.3.2.2.2) "Particle Valid (Extension)"
*
* Returns 0 if the constraints are satisfied, a positive
* error code if not and -1 if an internal error occured.
*/
static int
{
/*
* TODO: Correct the error code; XML_SCHEMAP_COS_CT_EXTENDS_1_1 is used
* temporarily only.
*/
/*
* SPEC (1) "If the {base type definition} is a complex type definition,
* then all of the following must be true:"
*/
if (WXS_IS_COMPLEX(base)) {
/*
* SPEC (1.1) "The {final} of the {base type definition} must not
* contain extension."
*/
"The 'final' of the base type definition "
"contains 'extension'", NULL);
return (XML_SCHEMAP_COS_CT_EXTENDS_1_1);
}
/*
* ATTENTION: The constrains (1.2) and (1.3) are not applied,
* since they are automatically satisfied through the
* inheriting mechanism.
* Note that even if redefining components, the inheriting mechanism
* is used.
*/
#if 0
/*
* SPEC (1.2) "Its {attribute uses} must be a subset of the {attribute
* uses}
* of the complex type definition itself, that is, for every attribute
* use in the {attribute uses} of the {base type definition}, there
* must be an attribute use in the {attribute uses} of the complex
* type definition itself whose {attribute declaration} has the same
* {name}, {target namespace} and {type definition} as its attribute
* declaration"
*/
int i, j, found;
found = 0;
{
if ((WXS_ATTRUSE_DECL_NAME(use) ==
(WXS_ATTRUSE_DECL_TNS(use) ==
WXS_ATTRUSE_DECL_TNS(buse)) &&
(WXS_ATTRUSE_TYPEDEF(use) ==
{
found = 1;
break;
}
}
}
if (! found) {
/*
* TODO: The report does not indicate that also the
* type needs to be the same.
*/
"This type is missing a matching correspondent "
"for its {base type}'s %s in its {attribute uses}",
NULL);
}
}
}
/*
* SPEC (1.3) "If it has an {attribute wildcard}, the complex type
* definition must also have one, and the base type definition's
* {attribute wildcard}'s {namespace constraint} must be a subset
* of the complex type definition's {attribute wildcard}'s {namespace
* constraint}, as defined by Wildcard Subset (�3.10.6)."
*/
/*
* MAYBE TODO: Enable if ever needed. But this will be needed only
* if created the type via a schema construction API.
*/
"The base %s has an attribute wildcard, "
"but this type is missing an attribute wildcard",
} else if (xmlSchemaCheckCOSNSSubset(
{
"The attribute wildcard is not a valid "
"superset of the one in the base %s",
}
}
#endif
/*
* SPEC (1.4) "One of the following must be true:"
*/
/*
* SPEC (1.4.1) "The {content type} of the {base type definition}
* and the {content type} of the complex type definition itself
* must be the same simple type definition"
* PASS
*/
/*
* SPEC (1.4.2) "The {content type} of both the {base type
* definition} and the complex type definition itself must
* be empty."
* PASS
*/
} else {
/*
* SPEC (1.4.3) "All of the following must be true:"
*/
/*
* SPEC 1.4.3.1 The {content type} of the complex type
* definition itself must specify a particle.
*/
"The content type must specify a particle", NULL);
return (XML_SCHEMAP_COS_CT_EXTENDS_1_1);
}
/*
* SPEC (1.4.3.2) "One of the following must be true:"
*/
/*
* SPEC (1.4.3.2.1) "The {content type} of the {base type
* definition} must be empty.
* PASS
*/
} else {
/*
* SPEC (1.4.3.2.2) "All of the following must be true:"
*/
/*
* SPEC (1.4.3.2.2.1) "Both {content type}s must be mixed
* or both must be element-only."
*/
"The content type of both, the type and its base "
"type, must either 'mixed' or 'element-only'", NULL);
return (XML_SCHEMAP_COS_CT_EXTENDS_1_1);
}
/*
* URGENT TODO SPEC (1.4.3.2.2.2) "The particle of the
* complex type definition must be a �valid extension�
* of the {base type definition}'s particle, as defined
* in Particle Valid (Extension) (�3.9.6)."
*
* NOTE that we won't check "Particle Valid (Extension)",
* since it is ensured by the derivation process in
* xmlSchemaTypeFixup(). We need to implement this when heading
* for a construction API
* TODO: !! This is needed to be checked if redefining a type !!
*/
}
/*
* URGENT TODO (1.5)
*/
}
} else {
/*
* SPEC (2) "If the {base type definition} is a simple type definition,
* then all of the following must be true:"
*/
/*
* SPEC (2.1) "The {content type} must be the same simple type
* definition."
*/
"The content type must be the simple base type", NULL);
return (XML_SCHEMAP_COS_CT_EXTENDS_1_1);
}
/*
* SPEC (2.2) "The {final} of the {base type definition} must not
* contain extension"
* NOTE that this is the same as (1.1).
*/
"The 'final' of the base type definition "
"contains 'extension'", NULL);
return (XML_SCHEMAP_COS_CT_EXTENDS_1_1);
}
}
return (0);
}
/**
* xmlSchemaCheckDerivationOKRestriction:
* @ctxt: the schema parser context
* @type: the complex type definition
*
* (3.4.6) Constraints on Complex Type Definition Schema Components
* Schema Component Constraint:
* Derivation Valid (Restriction, Complex) (derivation-ok-restriction)
*
* STATUS:
* missing:
* (5.4.2) ???
*
* ATTENTION:
* In XML Schema 1.1 this will be:
* Validation Rule: Checking complex type subsumption
*
* Returns 0 if the constraints are satisfied, a positive
* error code if not and -1 if an internal error occured.
*/
static int
{
/*
* TODO: Correct the error code; XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1 is used
* temporarily only.
*/
if (! WXS_IS_COMPLEX(base)) {
}
/*
* SPEC (1) "The {base type definition} must be a complex type
* definition whose {final} does not contain restriction."
*/
"The 'final' of the base type definition "
}
/*
* SPEC (2), (3) and (4)
* Those are handled in a separate function, since the
* same constraints are needed for redefinition of
* attribute groups as well.
*/
{
return(-1);
}
/*
* SPEC (5) "One of the following must be true:"
*/
/*
* SPEC (5.1) "The {base type definition} must be the
* �ur-type definition�."
* PASS
*/
/*
* SPEC (5.2.1) "The {content type} of the complex type definition
* must be a simple type definition"
*
* SPEC (5.2.2) "One of the following must be true:"
*/
{
int err;
/*
* SPEC (5.2.2.1) "The {content type} of the {base type
* definition} must be a simple type definition from which
* the {content type} is validly derived given the empty
* set as defined in Type Derivation OK (Simple) (�3.14.6)."
*
* ATTENTION TODO: This seems not needed if the type implicitely
* derived from the base type.
*
*/
if (err != 0) {
if (err == -1)
return(-1);
"The {content type} %s is not validly derived from the "
"base type's {content type} %s",
base->contentTypeDef));
}
/*
* SPEC (5.2.2.2) "The {base type definition} must be mixed
* and have a particle which is �emptiable� as defined in
* Particle Emptiable (�3.9.6)."
* PASS
*/
} else {
"The content type of the base type must be either "
"a simple type or 'mixed' and an emptiable particle", NULL);
}
/*
* SPEC (5.3.1) "The {content type} of the complex type itself must
* be empty"
*/
/*
* SPEC (5.3.2.1) "The {content type} of the {base type
* definition} must also be empty."
* PASS
*/
/*
* SPEC (5.3.2.2) "The {content type} of the {base type
* definition} must be elementOnly or mixed and have a particle
* which is �emptiable� as defined in Particle Emptiable (�3.9.6)."
* PASS
*/
} else {
"The content type of the base type must be either "
"empty or 'mixed' (or 'elements-only') and an emptiable "
"particle", NULL);
}
/*
* SPEC (5.4.1.1) "The {content type} of the complex type definition
* itself must be element-only"
*/
/*
* SPEC (5.4.1.2) "The {content type} of the complex type
* definition itself and of the {base type definition} must be
* mixed"
*/
"If the content type is 'mixed', then the content type of the "
"base type must also be 'mixed'", NULL);
}
/*
* SPEC (5.4.2) "The particle of the complex type definition itself
* must be a �valid restriction� of the particle of the {content
* type} of the {base type definition} as defined in Particle Valid
* (Restriction) (�3.9.6).
*
* URGENT TODO: (5.4.2)
*/
} else {
"The type is not a valid restriction of its base type", NULL);
}
return (0);
}
/**
* xmlSchemaCheckCTComponent:
* @ctxt: the schema parser context
* @type: the complex type definition
*
* (3.4.6) Constraints on Complex Type Definition Schema Components
*
* Returns 0 if the constraints are satisfied, a positive
* error code if not and -1 if an internal error occured.
*/
static int
{
int ret;
/*
* Complex Type Definition Properties Correct
*/
if (ret != 0)
return (ret);
if (WXS_IS_EXTENSION(type))
else
return (ret);
}
/**
* xmlSchemaCheckSRCCT:
* @ctxt: the schema parser context
* @type: the complex type definition
*
* (3.4.3) Constraints on XML Representations of Complex Type Definitions:
* Schema Representation Constraint:
* Complex Type Definition Representation OK (src-ct)
*
* Returns 0 if the constraints are satisfied, a positive
* error code if not and -1 if an internal error occured.
*/
static int
{
int ret = 0;
/*
* TODO: Adjust the error codes here, as I used
* XML_SCHEMAP_SRC_CT_1 only yet.
*/
if (! WXS_HAS_SIMPLE_CONTENT(type)) {
/*
* 1 If the <complexContent> alternative is chosen, the type definition
* �resolved� to by the �actual value� of the base [attribute]
* must be a complex type definition;
*/
if (! WXS_IS_COMPLEX(base)) {
"If using <complexContent>, the base type is expected to be "
"a complex type. The base type '%s' is a simple type",
return (XML_SCHEMAP_SRC_CT_1);
}
} else {
/*
* SPEC
* 2 If the <simpleContent> alternative is chosen, all of the
* following must be true:
* 2.1 The type definition �resolved� to by the �actual value� of the
* base [attribute] must be one of the following:
*/
if (WXS_IS_SIMPLE(base)) {
if (WXS_IS_EXTENSION(type) == 0) {
/*
* 2.1.3 only if the <extension> alternative is also
* chosen, a simple type definition.
*/
/* TODO: Change error code to ..._SRC_CT_2_1_3. */
"If using <simpleContent> and <restriction>, the base "
"type must be a complex type. The base type '%s' is "
"a simple type",
return (XML_SCHEMAP_SRC_CT_1);
}
} else {
/* Base type is a complex type. */
/*
* 2.1.1 a complex type definition whose {content type} is a
* simple type definition;
* PASS
*/
"Internal error: xmlSchemaCheckSRCCT, "
"'%s', base type has no content type",
return (-1);
}
(WXS_IS_RESTRICTION(type))) {
/*
* 2.1.2 only if the <restriction> alternative is also
* chosen, a complex type definition whose {content type}
* is mixed and a particle emptiable.
*/
if (! xmlSchemaIsParticleEmptiable(
} else
/*
* Attention: at this point the <simpleType> child is in
* ->contentTypeDef (put there during parsing).
*/
/*
* 2.2 If clause 2.1.2 above is satisfied, then there
* must be a <simpleType> among the [children] of
* <restriction>.
*/
/* TODO: Change error code to ..._SRC_CT_2_2. */
"A <simpleType> is expected among the children "
"of <restriction>, if <simpleContent> is used and "
"the base type '%s' is a complex type",
return (XML_SCHEMAP_SRC_CT_1);
}
} else {
}
}
if (ret > 0) {
if (WXS_IS_RESTRICTION(type)) {
"If <simpleContent> and <restriction> is used, the "
"base type must be a simple type or a complex type with "
"mixed content and particle emptiable. The base type "
"'%s' is none of those",
} else {
"If <simpleContent> and <extension> is used, the "
"base type must be a simple type. The base type '%s' "
"is a complex type",
}
}
}
/*
* SPEC (3) "The corresponding complex type definition component must
* satisfy the conditions set out in Constraints on Complex Type
* Definition Schema Components (�3.4.6);"
* NOTE (3) will be done in xmlSchemaTypeFixup().
*/
/*
* SPEC (4) If clause 2.2.1 or clause 2.2.2 in the correspondence specification
* above for {attribute wildcard} is satisfied, the intensional
* intersection must be expressible, as defined in Attribute Wildcard
* Intersection (�3.10.6).
* NOTE (4) is done in xmlSchemaFixupTypeAttributeUses().
*/
return (ret);
}
#ifdef ENABLE_PARTICLE_RESTRICTION
/**
* xmlSchemaCheckParticleRangeOK:
* @ctxt: the schema parser context
* @type: the complex type definition
*
* (3.9.6) Constraints on Particle Schema Components
* Schema Component Constraint:
* Occurrence Range OK (range-ok)
*
* STATUS: complete
*
* Returns 0 if the constraints are satisfied, a positive
* error code if not and -1 if an internal error occured.
*/
static int
{
return (1);
return (1);
return (0);
}
/**
* xmlSchemaCheckRCaseNameAndTypeOK:
* @ctxt: the schema parser context
* @r: the restricting element declaration particle
* @b: the base element declaration particle
*
* (3.9.6) Constraints on Particle Schema Components
* Schema Component Constraint:
* Particle Restriction OK (Elt:Elt -- NameAndTypeOK)
* (rcase-NameAndTypeOK)
*
* STATUS:
* MISSING (3.2.3)
* CLARIFY: (3.2.2)
*
* Returns 0 if the constraints are satisfied, a positive
* error code if not and -1 if an internal error occured.
*/
static int
{
/* TODO: Error codes (rcase-NameAndTypeOK). */
/*
* SPEC (1) "The declarations' {name}s and {target namespace}s are
* the same."
*/
return (1);
/*
* SPEC (2) "R's occurrence range is a valid restriction of B's
* occurrence range as defined by Occurrence Range OK (�3.9.6)."
*/
return (1);
/*
* SPEC (3.1) "Both B's declaration's {scope} and R's declaration's
* {scope} are global."
*/
return (0);
/*
* SPEC (3.2.1) "Either B's {nillable} is true or R's {nillable} is false."
*/
return (1);
/*
* SPEC (3.2.2) "either B's declaration's {value constraint} is absent,
* or is not fixed, or R's declaration's {value constraint} is fixed
* with the same value."
*/
/* TODO: Equality of the initial value or normalized or canonical? */
return (1);
/*
* TODO: SPEC (3.2.3) "R's declaration's {identity-constraint
* definitions} is a subset of B's declaration's {identity-constraint
* definitions}, if any."
*/
/* TODO */
}
/*
* SPEC (3.2.4) "R's declaration's {disallowed substitutions} is a
* superset of B's declaration's {disallowed substitutions}."
*/
return (1);
/*
* SPEC (3.2.5) "R's {type definition} is validly derived given
* {extension, list, union} from B's {type definition}"
*
* BADSPEC TODO: What's the point of adding "list" and "union" to the
* set, if the corresponding constraints handle "restriction" and
* "extension" only?
*
*/
{
int set = 0;
set |= SUBSET_EXTENSION;
set |= SUBSET_LIST;
set |= SUBSET_UNION;
return (1);
}
return (0);
}
/**
* xmlSchemaCheckRCaseNSCompat:
* @ctxt: the schema parser context
* @r: the restricting element declaration particle
* @b: the base wildcard particle
*
* (3.9.6) Constraints on Particle Schema Components
* Schema Component Constraint:
* Particle Derivation OK (Elt:Any -- NSCompat)
* (rcase-NSCompat)
*
* STATUS: complete
*
* Returns 0 if the constraints are satisfied, a positive
* error code if not and -1 if an internal error occured.
*/
static int
{
/* TODO:Error codes (rcase-NSCompat). */
/*
* SPEC "For an element declaration particle to be a �valid restriction�
* of a wildcard particle all of the following must be true:"
*
* SPEC (1) "The element declaration's {target namespace} is �valid�
* with respect to the wildcard's {namespace constraint} as defined by
* Wildcard allows Namespace Name (�3.10.4)."
*/
return (1);
/*
* SPEC (2) "R's occurrence range is a valid restriction of B's
* occurrence range as defined by Occurrence Range OK (�3.9.6)."
*/
return (1);
return (0);
}
/**
* xmlSchemaCheckRCaseRecurseAsIfGroup:
* @ctxt: the schema parser context
* @r: the restricting element declaration particle
* @b: the base model group particle
*
* (3.9.6) Constraints on Particle Schema Components
* Schema Component Constraint:
* (rcase-RecurseAsIfGroup)
*
* STATUS: TODO
*
* Returns 0 if the constraints are satisfied, a positive
* error code if not and -1 if an internal error occured.
*/
static int
{
/* TODO: Error codes (rcase-RecurseAsIfGroup). */
return (0);
}
/**
* xmlSchemaCheckRCaseNSSubset:
* @ctxt: the schema parser context
* @r: the restricting wildcard particle
* @b: the base wildcard particle
*
* (3.9.6) Constraints on Particle Schema Components
* Schema Component Constraint:
* Particle Derivation OK (Any:Any -- NSSubset)
* (rcase-NSSubset)
*
* STATUS: complete
*
* Returns 0 if the constraints are satisfied, a positive
* error code if not and -1 if an internal error occured.
*/
static int
int isAnyTypeBase)
{
/* TODO: Error codes (rcase-NSSubset). */
/*
* SPEC (1) "R's occurrence range is a valid restriction of B's
* occurrence range as defined by Occurrence Range OK (�3.9.6)."
*/
return (1);
/*
* SPEC (2) "R's {namespace constraint} must be an intensional subset
* of B's {namespace constraint} as defined by Wildcard Subset (�3.10.6)."
*/
(xmlSchemaWildcardPtr) b->children))
return (1);
/*
* SPEC (3) "Unless B is the content model wildcard of the �ur-type
* definition�, R's {process contents} must be identical to or stronger
* than B's {process contents}, where strict is stronger than lax is
* stronger than skip."
*/
if (! isAnyTypeBase) {
return (1);
}
return (0);
}
/**
* xmlSchemaCheckCOSParticleRestrict:
* @ctxt: the schema parser context
* @type: the complex type definition
*
* (3.9.6) Constraints on Particle Schema Components
* Schema Component Constraint:
* Particle Valid (Restriction) (cos-particle-restrict)
*
* STATUS: TODO
*
* Returns 0 if the constraints are satisfied, a positive
* error code if not and -1 if an internal error occured.
*/
static int
{
int ret = 0;
/*part = WXS_TYPE_PARTICLE(type);
basePart = WXS_TYPE_PARTICLE(base);
*/
/*
* SPEC (1) "They are the same particle."
*/
if (r == b)
return (0);
return (0);
}
/**
* xmlSchemaCheckRCaseNSRecurseCheckCardinality:
* @ctxt: the schema parser context
* @r: the model group particle
* @b: the base wildcard particle
*
* (3.9.6) Constraints on Particle Schema Components
* Schema Component Constraint:
* NSRecurseCheckCardinality)
* (rcase-NSRecurseCheckCardinality)
*
* STATUS: TODO: subst-groups
*
* Returns 0 if the constraints are satisfied, a positive
* error code if not and -1 if an internal error occured.
*/
static int
{
/* TODO: Error codes (rcase-NSRecurseCheckCardinality). */
return (-1);
/*
* SPEC "For a group particle to be a �valid restriction� of a
* wildcard particle..."
*
* SPEC (1) "Every member of the {particles} of the group is a �valid
* restriction� of the wildcard as defined by
* Particle Valid (Restriction) (�3.9.6)."
*/
do {
return (1);
/*
* SPEC (2) "The effective total range of the group [...] is a
* valid restriction of B's occurrence range as defined by
* Occurrence Range OK (�3.9.6)."
*/
return (1);
return (0);
}
/**
* xmlSchemaCheckRCaseRecurse:
* @ctxt: the schema parser context
* @r: the <all> or <sequence> model group particle
* @b: the base <all> or <sequence> model group particle
*
* (3.9.6) Constraints on Particle Schema Components
* Schema Component Constraint:
* Particle Derivation OK (All:All,Sequence:Sequence --
Recurse)
* (rcase-Recurse)
*
* STATUS: ?
* TODO: subst-groups
*
* Returns 0 if the constraints are satisfied, a positive
* error code if not and -1 if an internal error occured.
*/
static int
{
/* xmlSchemaParticlePtr part; */
/* TODO: Error codes (rcase-Recurse). */
return (-1);
/*
* SPEC "For an all or sequence group particle to be a �valid
* restriction� of another group particle with the same {compositor}..."
*
* SPEC (1) "R's occurrence range is a valid restriction of B's
* occurrence range as defined by Occurrence Range OK (�3.9.6)."
*/
return (1);
return (0);
}
#endif
"It is an error for both '%s' and '%s' to be specified on the "\
"same type definition", \
#define FACET_RESTR_FIXED_ERR(fac) \
"The base type's facet is 'fixed', thus the value must not " \
"differ", NULL);
static void
int lessGreater,
int orEqual,
int ofBase)
{
if (lessGreater == 0)
if (lessGreater == 1)
else
if (orEqual)
if (ofBase)
else
}
/*
* xmlSchemaDeriveAndValidateFacets:
*
* Schema Component Constraint: Simple Type Restriction (Facets)
* (st-restrict-facets)
*/
static int
{
int res; /* err = 0, fixedErr; */
/*
* SPEC st-restrict-facets 1:
* "The {variety} of R is the same as that of B."
*/
/*
* SPEC st-restrict-facets 2:
* "If {variety} is atomic, the {primitive type definition}
* of R is the same as that of B."
*
* NOTE: we leave 1 & 2 out for now, since this will be
* satisfied by the derivation process.
* CONSTRUCTION TODO: Maybe needed if using a construction API.
*/
/*
* SPEC st-restrict-facets 3:
* "The {facets} of R are the union of S and the {facets}
* of B, eliminating duplicates. To eliminate duplicates,
* when a facet of the same kind occurs in both S and the
* {facets} of B, the one in the {facets} of B is not
* included, with the exception of enumeration and pattern
* facets, for which multiple occurrences with distinct values
* are allowed."
*/
return (0);
case XML_SCHEMA_FACET_LENGTH:
default:
break;
}
}
case XML_SCHEMA_FACET_LENGTH:
default:
break;
}
}
/*
* length and minLength or maxLength (2.2) + (3.2)
*/
"either of 'minLength' or 'maxLength' to be specified on "
"the same type definition")
}
/*
* Mutual exclusions in the same derivation step.
*/
/*
* SCC "maxInclusive and maxExclusive"
*/
}
/*
* SCC "minInclusive and minExclusive"
*/
}
/*
* SCC "length valid restriction"
* The values have to be equal.
*/
if (res == -2)
goto internal_error;
if (res != 0)
}
}
/*
* SCC "minLength valid restriction"
* minLength >= BASE minLength
*/
if (res == -2)
goto internal_error;
if (res == -1)
}
}
/*
* SCC "maxLength valid restriction"
* maxLength <= BASE minLength
*/
if (res == -2)
goto internal_error;
if (res == 1)
}
}
/*
* SCC "length and minLength or maxLength"
*/
if (! flength)
if (flength) {
if (! fminlen)
if (fminlen) {
/* (1.1) length >= minLength */
if (res == -2)
goto internal_error;
if (res == -1)
}
if (! fmaxlen)
if (fmaxlen) {
/* (2.1) length <= maxLength */
if (res == -2)
goto internal_error;
if (res == 1)
}
}
if (fmaxinc) {
/*
* "maxInclusive"
*/
if (fmininc) {
/* SCC "maxInclusive >= minInclusive" */
if (res == -2)
goto internal_error;
if (res == -1) {
}
}
/*
* SCC "maxInclusive valid restriction"
*/
if (bfmaxinc) {
/* maxInclusive <= BASE maxInclusive */
if (res == -2)
goto internal_error;
if (res == 1)
}
}
if (bfmaxexc) {
/* maxInclusive < BASE maxExclusive */
if (res == -2)
goto internal_error;
if (res != -1) {
}
}
if (bfmininc) {
/* maxInclusive >= BASE minInclusive */
if (res == -2)
goto internal_error;
if (res == -1) {
}
}
if (bfminexc) {
/* maxInclusive > BASE minExclusive */
if (res == -2)
goto internal_error;
if (res != 1) {
}
}
}
if (fmaxexc) {
/*
* "maxExclusive >= minExclusive"
*/
if (fminexc) {
if (res == -2)
goto internal_error;
if (res == -1) {
}
}
/*
* "maxExclusive valid restriction"
*/
if (bfmaxexc) {
/* maxExclusive <= BASE maxExclusive */
if (res == -2)
goto internal_error;
if (res == 1) {
}
}
}
if (bfmaxinc) {
/* maxExclusive <= BASE maxInclusive */
if (res == -2)
goto internal_error;
if (res == 1) {
}
}
if (bfmininc) {
/* maxExclusive > BASE minInclusive */
if (res == -2)
goto internal_error;
if (res != 1) {
}
}
if (bfminexc) {
/* maxExclusive > BASE minExclusive */
if (res == -2)
goto internal_error;
if (res != 1) {
}
}
}
if (fminexc) {
/*
* "minExclusive < maxInclusive"
*/
if (fmaxinc) {
if (res == -2)
goto internal_error;
if (res != -1) {
}
}
/*
* "minExclusive valid restriction"
*/
if (bfminexc) {
/* minExclusive >= BASE minExclusive */
if (res == -2)
goto internal_error;
if (res == -1) {
}
}
}
if (bfmaxinc) {
/* minExclusive <= BASE maxInclusive */
if (res == -2)
goto internal_error;
if (res == 1) {
}
}
if (bfmininc) {
/* minExclusive >= BASE minInclusive */
if (res == -2)
goto internal_error;
if (res == -1) {
}
}
if (bfmaxexc) {
/* minExclusive < BASE maxExclusive */
if (res == -2)
goto internal_error;
if (res != -1) {
}
}
}
if (fmininc) {
/*
* "minInclusive < maxExclusive"
*/
if (fmaxexc) {
if (res == -2)
goto internal_error;
if (res != -1) {
}
}
/*
* "minExclusive valid restriction"
*/
if (bfmininc) {
/* minInclusive >= BASE minInclusive */
if (res == -2)
goto internal_error;
if (res == -1) {
}
}
}
if (bfmaxinc) {
/* minInclusive <= BASE maxInclusive */
if (res == -2)
goto internal_error;
if (res == 1) {
}
}
if (bfminexc) {
/* minInclusive > BASE minExclusive */
if (res == -2)
goto internal_error;
if (res != 1)
}
if (bfmaxexc) {
/* minInclusive < BASE maxExclusive */
if (res == -2)
goto internal_error;
if (res != -1)
}
}
/*
* SCC " totalDigits valid restriction"
* totalDigits <= BASE totalDigits
*/
if (res == -2)
goto internal_error;
if (res == 1)
-1, 1, 1);
}
}
/*
* SCC "fractionDigits valid restriction"
* fractionDigits <= BASE fractionDigits
*/
if (res == -2)
goto internal_error;
if (res == 1)
-1, 1, 1);
}
}
/*
* SCC "fractionDigits less than or equal to totalDigits"
*/
if (! ftotdig)
if (! ffracdig)
if (res == -2)
goto internal_error;
if (res == 1)
-1, 1, 0);
}
/*
* *Enumerations* won' be added here, since only the first set
* of enumerations in the ancestor-or-self axis is used
* for validation, plus we need to use the base type of those
* enumerations for whitespace.
*
* *Patterns*: won't be add here, since they are ORed at
* type level and ANDed at ancestor level. This will
* happed during validation by walking the base axis
* of the type.
*/
/*
* Special handling of enumerations and patterns.
* TODO: hmm, they should not appear in the set, so remove this.
*/
continue;
/*
* Search for a duplicate facet in the current type.
*/
/* err = 0; */
/* fixedErr = 0; */
/*
* The whitespace must be stronger.
*/
"The 'whitespace' value has to be equal to "
"or stronger than the 'whitespace' value of "
"the base type")
}
}
break;
default:
break;
}
/* Duplicate found. */
break;
}
}
/*
* If no duplicate was found: add the base types's facet
* to the set.
*/
xmlMalloc(sizeof(xmlSchemaFacetLink));
"deriving facets, creating a facet link", NULL);
return (-1);
}
else
}
}
return (0);
PERROR_INT("xmlSchemaDeriveAndValidateFacets",
"an error occured");
return (-1);
}
static int
{
/*
* The actual value is then formed by replacing any union type
* definition in the �explicit members� with the members of their
* {member type definitions}, in order.
*
* TODO: There's a bug entry at
* which indicates that we'll keep the union types the future.
*/
xmlMalloc(sizeof(xmlSchemaTypeLink));
NULL);
return (-1);
}
}
}
}
}
}
return (0);
}
static void
{
if (has) {
XML_SCHEMAS_TYPE_FACETSNEEDVALUE) ? 1 : 0;
XML_SCHEMAS_TYPE_NORMVALUENEEDED) ? 1 : 0;
}
break;
case XML_SCHEMA_FACET_PATTERN:
normVal = 1;
has = 1;
break;
needVal = 1;
normVal = 1;
has = 1;
break;
default:
has = 1;
break;
}
}
}
if (normVal)
if (needVal)
if (has)
/*
* OPTIMIZE VAL TODO: Some facets need a computed value.
*/
}
}
}
static int
{
/*
* Evaluate the whitespace-facet value.
*/
if (WXS_IS_LIST(type)) {
return (0);
} else if (WXS_IS_UNION(type))
return (0);
break;
break;
break;
default:
return (-1);
}
return (0);
}
}
}
/*
* For all �atomic� datatypes other than string (and types �derived�
* by �restriction� from it) the value of whiteSpace is fixed to
* collapse
*/
{
} else
break;
}
}
}
return (0);
}
static int
{
return(0);
if (! WXS_IS_TYPE_NOT_FIXED_1(type))
return(0);
if (WXS_IS_LIST(type)) {
/*
* Corresponds to <simpleType><list>...
*/
/*
* This one is really needed, so get out.
*/
PERROR_INT("xmlSchemaFixupSimpleTypeStageOne",
"list type has no item-type assigned");
return(-1);
}
} else if (WXS_IS_UNION(type)) {
/*
* Corresponds to <simpleType><union>...
*/
/*
* This one is really needed, so get out.
*/
PERROR_INT("xmlSchemaFixupSimpleTypeStageOne",
"union type has no member-types assigned");
return(-1);
}
} else {
/*
* Corresponds to <simpleType><restriction>...
*/
PERROR_INT("xmlSchemaFixupSimpleTypeStageOne",
"type has no base-type assigned");
return(-1);
}
return(-1);
/*
* Variety
* If the <restriction> alternative is chosen, then the
* {variety} of the {base type definition}.
*/
/*
* Inherit the itemType.
*/
/*
* NOTE that we won't assign the memberTypes of the base,
* since this will make trouble when freeing them; we will
* use a lookup function to access them instead.
*/
}
}
return(0);
}
#ifdef DEBUG_TYPE
static void
{
"Type of %s : %s:%d :", name,
} else {
}
switch (type->contentType) {
break;
break;
break;
case XML_SCHEMA_CONTENT_EMPTY:
break;
case XML_SCHEMA_CONTENT_MIXED:
"mixed as emptiable particle\n");
else
break;
/* Removed, since not used. */
/*
case XML_SCHEMA_CONTENT_MIXED_OR_ELEMENTS:
xmlGenericError(xmlGenericErrorContext, "mixed or elems\n");
break;
*/
case XML_SCHEMA_CONTENT_BASIC:
break;
default:
"not registered !!!\n");
break;
}
}
}
#endif
/*
* 3.14.6 Constraints on Simple Type Definition Schema Components
*/
static int
{
return(-1);
if (! WXS_IS_TYPE_NOT_FIXED(type))
return(0);
PERROR_INT("xmlSchemaFixupSimpleTypeStageTwo",
"missing baseType");
goto exit_failure;
}
/*
* If a member type of a union is a union itself, we need to substitute
* that member type for its member types.
* NOTE that this might change in WXS 1.1; i.e. we will keep the union
* types in WXS 1.1.
*/
return(-1);
/*
* SPEC src-simple-type 1
* "The corresponding simple type definition, if any, must satisfy
* the conditions set out in Constraints on Simple Type Definition
* Schema Components (�3.14.6)."
*/
/*
* Schema Component Constraint: Simple Type Definition Properties Correct
* (st-props-correct)
*/
/*
* Schema Component Constraint: Derivation Valid (Restriction, Simple)
* (cos-st-restricts)
*/
/*
* TODO: Removed the error report, since it got annoying to get an
* extra error report, if anything failed until now.
* Enable this if needed.
*
* xmlSchemaPErr(ctxt, type->node,
* XML_SCHEMAP_SRC_SIMPLE_TYPE_1,
* "Simple type '%s' does not satisfy the constraints "
* "on simple type definitions.\n",
* type->name, NULL);
*/
/*
* Schema Component Constraint: Simple Type Restriction (Facets)
* (st-restrict-facets)
*/
}
/*
* Whitespace value.
*/
#ifdef DEBUG_TYPE
#endif
return(0);
#ifdef DEBUG_TYPE
#endif
return(-1);
}
static int
{
if (! WXS_IS_TYPE_NOT_FIXED(type))
return(0);
PERROR_INT("xmlSchemaFixupComplexType",
"missing baseType");
goto exit_failure;
}
/*
* Fixup the base type.
*/
/*
* Skip fixup if the base type is invalid.
* TODO: Generate a warning!
*/
return(0);
}
/*
* This basically checks if the base type can be derived.
*/
/*
* Fixup the content type.
*/
/*
* Corresponds to <complexType><simpleContent>...
*/
if ((WXS_IS_COMPLEX(baseType)) &&
(WXS_IS_RESTRICTION(type))) {
#ifdef ENABLE_NAMED_LOCALS
char buf[30];
#endif
/*
* SPEC (1) If <restriction> + base type is <complexType>,
* "whose own {content type} is a simple type..."
*/
/*
* SPEC (1.1) "the simple type definition corresponding to the
* <simpleType> among the [children] of <restriction> if there
* is one;"
* Note that this "<simpleType> among the [children]" was put
* into ->contentTypeDef during parsing.
*/
} else {
/*
* (1.2) "...otherwise (<restriction> has no <simpleType>
* among its [children]), the simple type definition which
* is the {content type} of the ... base type."
*/
}
/*
* SPEC
* "... a simple type definition which restricts the simple
* type definition identified in clause 1.1 or clause 1.2
* with a set of facet components"
*
* Create the anonymous simple type, which will be the content
* type of the complex type.
*/
#ifdef ENABLE_NAMED_LOCALS
#else
#endif
goto exit_failure;
/*
* We will use the same node as for the <complexType>
* to have it somehow anchored in the schema doc.
*/
/*
* Move the facets, previously anchored on the
* complexType during parsing.
*/
/*
* Fixup the newly created type. We don't need to check
* for circularity here.
*/
} else if ((WXS_IS_COMPLEX(baseType)) &&
(WXS_IS_RESTRICTION(type))) {
/*
* SPEC (2) If <restriction> + base is a mixed <complexType> with
* an emptiable particle, then a simple type definition which
* restricts the <restriction>'s <simpleType> child.
*/
/*
* TODO: Check if this ever happens.
*/
"Internal error: xmlSchemaTypeFixup, "
"complex type '%s': the <simpleContent><restriction> "
"is missing a <simpleType> child, but was not catched "
goto exit_failure;
}
/*
* SPEC (3) If <extension> + base is <complexType> with
* <simpleType> content, "...then the {content type} of that
* complex type definition"
*/
/*
* TODO: Check if this ever happens. xmlSchemaCheckSRCCT
* should have catched this already.
*/
"Internal error: xmlSchemaTypeFixup, "
"complex type '%s': the <extension>ed base type is "
"a complex type with no simple content type",
goto exit_failure;
}
/*
* SPEC (4) <extension> + base is <simpleType>
* "... then that simple type definition"
*/
} else {
/*
* TODO: Check if this ever happens.
*/
"Internal error: xmlSchemaTypeFixup, "
"complex type '%s' with <simpleContent>: unhandled "
goto exit_failure;
}
} else {
int dummySequence = 0;
/*
* Corresponds to <complexType><complexContent>...
*
* NOTE that the effective mixed was already set during parsing of
* <complexType> and <complexContent>; its flag value is
* XML_SCHEMAS_TYPE_MIXED.
*
* Compute the "effective content":
* (2.1.1) + (2.1.2) + (2.1.3)
*/
/*
* SPEC (2.1.4) "If the �effective mixed� is true, then
* a particle whose properties are as follows:..."
*
* Empty sequence model group with
* NOTE that we sill assign it the <complexType> node to
* somehow anchor it in the doc.
*/
/*
* Create the particle.
*/
goto exit_failure;
/*
* Create the model group.
*/ /* URGENT TODO: avoid adding to pending items. */
goto exit_failure;
}
dummySequence = 1;
} else {
/*
* SPEC (2.1.5) "otherwise empty"
*/
}
} else {
/*
* SPEC (2.2) "otherwise the particle corresponding to the
* <all>, <choice>, <group> or <sequence> among the
* [children]."
*/
}
/*
* Compute the "content type".
*/
if (WXS_IS_RESTRICTION(type)) {
/*
* SPEC (3.1) "If <restriction>..."
* (3.1.1) + (3.1.2) */
}
} else {
/*
* SPEC (3.2) "If <extension>..."
*/
/*
* SPEC (3.2.1)
* "If the �effective content� is empty, then the
* {content type} of the [...] base ..."
*/
/*
* Fixes bug #347316:
* This is the case when the base type has a simple
* type definition as content.
*/
/*
* NOTE that the effective mixed is ignored here.
*/
/*
* SPEC (3.2.2)
*/
} else {
/*
* SPEC (3.2.3)
*/
/*
* "A model group whose {compositor} is sequence and whose
* {particles} are..."
*/
{
/*
* SPEC cos-all-limited (1)
*/
/* TODO: error code */
"The type has an 'all' model group in its "
"{content type} and thus cannot be derived from "
"a non-empty type, since this would produce a "
"'sequence' model group containing the 'all' "
"model group; 'all' model groups are not "
"allowed to appear inside other model groups",
{
/*
* SPEC cos-all-limited (1)
*/
/* TODO: error code */
"A type cannot be derived by extension from a type "
"which has an 'all' model group in its "
"{content type}, since this would produce a "
"'sequence' model group containing the 'all' "
"model group; 'all' model groups are not "
"allowed to appear inside other model groups",
} else if (! dummySequence) {
/*
* Create the particle.
*/
goto exit_failure;
/*
* Create the "sequence" model group.
*/
goto exit_failure;
/*
* SPEC "the particle of the {content type} of
* the ... base ..."
* Create a duplicate of the base type's particle
* and assign its "term" to it.
*/
goto exit_failure;
/*
* SPEC "followed by the �effective content�."
*/
/*
* This all will result in:
* new-particle
* --> new-sequence(
* new-particle
* --> base-model,
* this-particle
* --> this-model
* )
*/
} else {
/*
* This is the case when there is already an empty
* <sequence> with minOccurs==maxOccurs==1.
* Just add the base types's content type.
* NOTE that, although we miss to add an intermediate
* <sequence>, this should produce no difference to
* neither the regex compilation of the content model,
* nor to the complex type contraints.
*/
}
}
}
}
/*
* Now fixup attribute uses:
* - expand attr. group references
* - intersect attribute wildcards
* - inherit attribute uses of the base type
* - inherit or union attr. wildcards if extending
* - apply attr. use prohibitions if restricting
*/
/*
* Apply the complex type component constraints; this will not
* check attributes, since this is done in
* xmlSchemaFixupTypeAttributeUses().
*/
#ifdef DEBUG_TYPE
#endif
else
return(0);
#ifdef DEBUG_TYPE
#endif
#ifdef DEBUG_TYPE
#endif
return(-1);
}
/**
* xmlSchemaTypeFixup:
* @typeDecl: the schema type definition
* @ctxt: the schema parser context
*
* Fixes the content model of the type.
* URGENT TODO: We need an int result!
*/
static int
{
return(0);
AERROR_INT("xmlSchemaTypeFixup",
"this function needs a parser context");
return(-1);
}
if (! WXS_IS_TYPE_NOT_FIXED(type))
return(0);
return(0);
}
/**
* xmlSchemaCheckFacet:
* @facet: the facet
* @typeDecl: the schema type definition
* @pctxt: the schema parser context or NULL
* @name: the optional name of the type
*
* Checks and computes the values of facets.
*
* Returns 0 if valid, a positive error code if not valid and
* -1 in case of an internal or API error.
*/
int
{
return(-1);
/*
* TODO: will the parser context be given if used from
* the relaxNG module?
*/
ctxtGiven = 0;
else
ctxtGiven = 1;
case XML_SCHEMA_FACET_ENUMERATION: {
/*
* Okay we need to validate the value
* at that point.
*/
/* 4.3.5.5 Constraints on enumeration Schema Components
* Schema Component Constraint: enumeration valid restriction
* It is an �error� if any member of {value} is not in the
* �value space� of {base type definition}.
*
* minInclusive, maxInclusive, minExclusive, maxExclusive:
* The value �must� be in the
* �value space� of the �base type�.
*/
/*
* This function is intended to deliver a compiled value
* on the facet. In this implementation of XML Schemata the
* type holding a facet, won't be a built-in type.
* Thus to ensure that other API
* calls (relaxng) do work, if the given type is a built-in
* type, we will assume that the given built-in type *is
* already* the base type.
*/
PERROR_INT("xmlSchemaCheckFacet",
"a type user derived type has no base type");
return (-1);
}
} else
if (! ctxtGiven) {
/*
* A context is needed if called from RelaxNG.
*/
return (-1);
}
/*
* NOTE: This call does not check the content nodes,
* since they are not available:
* facet->node is just the node holding the facet
* definition, *not* the attribute holding the *value*
* of the facet.
*/
if (ret != 0) {
if (ret < 0) {
/* No error message for RelaxNG. */
if (ctxtGiven) {
"Internal error: xmlSchemaCheckFacet, "
"failed to validate the value '%s' of the "
"facet '%s' against the base type",
}
goto internal_error;
}
/* No error message for RelaxNG. */
if (ctxtGiven) {
"The value '%s' of the facet does not validate "
"against the base type '%s'",
}
goto exit;
if (ctxtGiven) {
PERROR_INT("xmlSchemaCheckFacet",
"value was not computed");
}
}
break;
}
case XML_SCHEMA_FACET_PATTERN:
/* No error message for RelaxNG. */
if (ctxtGiven) {
"The value '%s' of the facet 'pattern' is not a "
"valid regular expression",
}
}
break;
case XML_SCHEMA_FACET_LENGTH:
} else {
}
if (ret != 0) {
if (ret < 0) {
/* No error message for RelaxNG. */
if (ctxtGiven) {
PERROR_INT("xmlSchemaCheckFacet",
"validating facet value");
}
goto internal_error;
}
/* No error message for RelaxNG. */
if (ctxtGiven) {
/* error code */
"The value '%s' of the facet '%s' is not a valid '%s'",
BAD_CAST "nonNegativeInteger" :
BAD_CAST "positiveInteger",
NULL);
}
}
break;
case XML_SCHEMA_FACET_WHITESPACE:{
} else {
/* No error message for RelaxNG. */
if (ctxtGiven) {
/* error was previously: XML_SCHEMAP_INVALID_WHITE_SPACE */
"The value '%s' of the facet 'whitespace' is not "
}
}
}
default:
break;
}
exit:
return (ret);
return (-1);
}
/**
* xmlSchemaCheckFacetValues:
* @typeDecl: the schema type definition
* @ctxt: the schema parser context
*
* Checks the default values types, especially for facets
*/
static int
{
/*
* NOTE: It is intended to use the facets list, instead
* of facetSet.
*/
/*
* Temporarily assign the "schema" to the validation context
* of the parser context. This is needed for NOTATION validation.
*/
return(-1);
}
}
}
return(0);
return(-1);
}
/**
* xmlSchemaGetCircModelGrDefRef:
* @ctxtMGroup: the searched model group
* @selfMGroup: the second searched model group
* @particle: the first particle
*
* This one is intended to be used by
* xmlSchemaCheckGroupDefCircular only.
*
* Returns the particle with the circular model group definition reference,
* otherwise NULL.
*/
static xmlSchemaTreeItemPtr
{
continue;
case XML_SCHEMA_TYPE_GROUP:
return (particle);
/*
* Mark this model group definition to avoid infinite
* recursion on circular references not yet examined.
*/
continue;
return (circ);
}
break;
case XML_SCHEMA_TYPE_SEQUENCE:
case XML_SCHEMA_TYPE_CHOICE:
case XML_SCHEMA_TYPE_ALL:
return (circ);
break;
default:
break;
}
}
return (NULL);
}
/**
* xmlSchemaCheckGroupDefCircular:
* @item: the model group definition
* @ctxt: the parser context
* @name: the name
*
* Checks for circular references to model group definitions.
*/
static void
{
/*
* Schema Component Constraint: Model Group Correct
* 2 Circular groups are disallowed. That is, within the {particles}
* of a group there must not be at any depth a particle whose {term}
* is the group itself.
*/
return;
{
/*
* TODO: The error report is not adequate: this constraint
* is defined for model groups but not definitions, but since
* there cannot be any circular model groups without a model group
* definition (if not using a construction API), we check those
* defintions only.
*/
"Circular reference to the model group definition '%s' "
/*
* NOTE: We will cut the reference to avoid further
* confusion of the processor. This is a fatal error.
*/
}
}
}
/**
* xmlSchemaModelGroupToModelGroupDefFixup:
* @ctxt: the parser context
* @mg: the model group
*
* Assigns the model group of model group definitions to the "term"
* of the referencing particle.
* In xmlSchemaResolveModelGroupParticleReferences the model group
* definitions were assigned to the "term", since needed for the
* circularity check.
*
* Schema Component Constraint:
* All Group Limited (cos-all-limited) (1.2)
*/
static void
{
{
continue;
}
/*
* TODO: Remove the particle.
*/
continue;
}
/*
* Assign the model group to the {term} of the particle.
*/
}
}
/**
* xmlSchemaCheckAttrGroupCircularRecur:
* @ctxtGr: the searched attribute group
* @attr: the current attribute list to be processed
*
* This one is intended to be used by
* xmlSchemaCheckAttrGroupCircular only.
*
* Returns the circular attribute grou reference, otherwise NULL.
*/
static xmlSchemaQNameRefPtr
{
int i;
/*
* We will search for an attribute group reference which
* references the context attribute group.
*/
{
return(ref);
continue;
/*
* Mark as visited to avoid infinite recursion on
* circular references not yet examined.
*/
{
return (circ);
}
}
}
return (NULL);
}
/**
* xmlSchemaCheckAttrGroupCircular:
* attrGr: the attribute group definition
* @ctxt: the parser context
* @name: the name
*
* Checks for circular references of attribute groups.
*/
static int
{
/*
* Schema Representation Constraint:
* Attribute Group Definition Representation OK
* 3 Circular group reference is disallowed outside <redefine>.
* That is, unless this element information item's parent is
* <redefine>, then among the [children], if any, there must
* not be an <attributeGroup> with ref [attribute] which resolves
* to the component corresponding to this <attributeGroup>. Indirect
* circularity is also ruled out. That is, when QName resolution
* (Schema Document) (�3.15.3) is applied to a �QName� arising from
* any <attributeGroup>s with a ref [attribute] among the [children],
* it must not be the case that a �QName� is encountered at any depth
* which resolves to the component corresponding to this <attributeGroup>.
*/
return(0);
return(0);
else {
/*
* TODO: Report the referenced attr group as QName.
*/
"Circular reference to the attribute group '%s' "
/*
* NOTE: We will cut the reference to avoid further
* confusion of the processor.
* BADSPEC TODO: The spec should define how to process in this case.
*/
}
}
return(0);
}
static int
/**
* xmlSchemaExpandAttributeGroupRefs:
* @pctxt: the parser context
* @node: the node of the component holding the attribute uses
* @completeWild: the intersected wildcard to be returned
* @list: the attribute uses
*
* Substitutes contained attribute group references
* for their attribute uses. Wilcards are intersected.
* Attribute use prohibitions are removed from the list
* and returned via the @prohibs list.
* Pointlessness of attr. prohibs, if a matching attr. decl
* is existent a well, are checked.
*/
static int
{
int i, j;
if (prohibs)
PERROR_INT("xmlSchemaExpandAttributeGroupRefs",
"unexpected attr prohibition found");
return(-1);
}
/*
* Remove from attribute uses.
*/
return(-1);
i--;
/*
* Note that duplicate prohibitions were already
* handled at parsing time.
*/
/*
* Add to list of prohibitions.
*/
continue;
}
{
return(-1);
/*
* Expand the referenced attr. group.
* TODO: remove this, this is done in a previous step, so
* already done here.
*/
return(-1);
}
/*
* Build the 'complete' wildcard; i.e. intersect multiple
* wildcards.
*/
if (*completeWild == NULL) {
} else {
if (! created) {
/*
* Copy the first encountered wildcard as context,
* except for the annotation.
*
* Although the complete wildcard might not correspond
* to any node in the schema, we will anchor it on
* the node of the owner component.
*/
return(-1);
return (-1);
*completeWild = tmpWild;
created = 1;
}
return(-1);
}
}
/*
* Just remove the reference if the referenced group does not
* contain any attribute uses.
*/
return(-1);
i--;
continue;
}
/*
* Add the attribute uses.
*/
i++;
return(-1);
}
}
}
}
/*
* Handle pointless prohibitions of declared attributes.
*/
{
"Skipping pointless attribute use prohibition "
"'%s', since a corresponding attribute use "
"exists already in the type definition",
/*
* Remove the prohibition.
*/
return(-1);
break;
}
}
}
}
return(0);
}
/**
* xmlSchemaAttributeGroupExpandRefs:
* @pctxt: the parser context
* @attrGr: the attribute group definition
*
* Computation of:
* {attribute uses} property
* {attribute wildcard} property
*
* Substitutes contained attribute group references
* for their attribute uses. Wilcards are intersected.
*/
static int
{
return(0);
return(-1);
return(0);
}
/**
* xmlSchemaAttributeGroupExpandRefs:
* @pctxt: the parser context
* @attrGr: the attribute group definition
*
* Substitutes contained attribute group references
* for their attribute uses. Wilcards are intersected.
*
* Schema Component Constraint:
* Attribute Group Definition Properties Correct (ag-props-correct)
*/
static int
{
/*
* SPEC ag-props-correct
* (1) "The values of the properties of an attribute group definition
* must be as described in the property tableau in The Attribute
* Group Definition Schema Component (�3.6.1), modulo the impact of
* Missing Sub-components (�5.3);"
*/
{
int i, j, hasId = 0;
/*
* SPEC ag-props-correct
* (2) "Two distinct members of the {attribute uses} must not have
* {attribute declaration}s both of whose {name}s match and whose
* {target namespace}s are identical."
*/
if (i > 0) {
for (j = i -1; j >= 0; j--) {
if ((WXS_ATTRUSE_DECL_NAME(use) ==
WXS_ATTRUSE_DECL_NAME(tmp)) &&
(WXS_ATTRUSE_DECL_TNS(use) ==
{
"Duplicate %s",
NULL);
/*
* Remove the duplicate.
*/
return(-1);
goto next_use;
}
}
}
/*
* SPEC ag-props-correct
* (3) "Two distinct members of the {attribute uses} must not have
* {attribute declaration}s both of whose {type definition}s are or
* are derived from ID."
* TODO: Does 'derived' include member-types of unions?
*/
{
if (hasId) {
"There must not exist more than one attribute "
"declaration of type 'xs:ID' "
"(or derived from 'xs:ID'). The %s violates this "
"constraint",
NULL);
return(-1);
}
hasId = 1;
}
}
next_use: {}
}
}
return(0);
}
/**
* xmlSchemaResolveAttrGroupReferences:
* @attrgrpDecl: the schema attribute definition
* @ctxt: the schema parser context
* @name: the attribute name
*
* Resolves references to attribute group definitions.
*/
static int
{
return(0);
}
return(0);
}
/**
* xmlSchemaCheckAttrPropsCorrect:
* @item: an schema attribute declaration/use
* @ctxt: a schema parser context
* @name: the name of the attribute
*
*
* Schema Component Constraint:
* Attribute Declaration Properties Correct (a-props-correct)
*
* Validates the value constraints of an attribute declaration/use.
* NOTE that this needs the simle type definitions to be already
* builded and checked.
*/
static int
{
/*
* SPEC a-props-correct (1)
* "The values of the properties of an attribute declaration must
* be as described in the property tableau in The Attribute
* Declaration Schema Component (�3.2.1), modulo the impact of
* Missing Sub-components (�5.3)."
*/
return(0);
int ret;
/*
* SPEC a-props-correct (3)
* "If the {type definition} is or is derived from ID then there
* must not be a {value constraint}."
*/
{
"Value constraints are not allowed if the type definition "
"is or is derived from xs:ID",
}
/*
* SPEC a-props-correct (2)
* "if there is a {value constraint}, the canonical lexical
* representation of its value must be �valid� with respect
* to the {type definition} as defined in String Valid (�3.14.4)."
* TODO: Don't care about the *cononical* stuff here, this requirement
* will be removed in WXS 1.1 anyway.
*/
1, 1, 0);
if (ret != 0) {
if (ret < 0) {
PERROR_INT("xmlSchemaCheckAttrPropsCorrect",
"calling xmlSchemaVCheckCVCSimpleType()");
return(-1);
}
"The value of the value constraint is not valid",
}
}
return(0);
}
static xmlSchemaElementPtr
{
return (NULL);
return (ancestor);
return (NULL);
return (ret);
}
/**
* xmlSchemaCheckElemPropsCorrect:
* @ctxt: a schema parser context
* @decl: the element declaration
* @name: the name of the attribute
*
* Schema Component Constraint:
* Element Declaration Properties Correct (e-props-correct)
*
* STATUS:
* missing: (6)
*/
static int
{
int ret = 0;
/*
* SPEC (1) "The values of the properties of an element declaration
* must be as described in the property tableau in The Element
* Declaration Schema Component (�3.3.1), modulo the impact of Missing
* Sub-components (�5.3)."
*/
/*
* SPEC (3) "If there is a non-�absent� {substitution group
* affiliation}, then {scope} must be global."
*/
"Only global element declarations can have a "
"substitution group affiliation", NULL);
}
/*
* TODO: SPEC (6) "Circular substitution groups are disallowed.
* That is, it must not be possible to return to an element declaration
* by repeatedly following the {substitution group affiliation}
* property."
*/
else
"The element declaration '%s' defines a circular "
"substitution group to element declaration '%s'",
NULL);
}
/*
* SPEC (4) "If there is a {substitution group affiliation},
* the {type definition}
* of the element declaration must be validly derived from the {type
* definition} of the {substitution group affiliation}, given the value
* of the {substitution group exclusions} of the {substitution group
* affiliation}, as defined in Type Derivation OK (Complex) (�3.4.6)
* (if the {type definition} is complex) or as defined in
* Type Derivation OK (Simple) (�3.14.6) (if the {type definition} is
* simple)."
*
* NOTE: {substitution group exclusions} means the values of the
* attribute "final".
*/
int set = 0;
set |= SUBSET_EXTENSION;
"The type definition '%s' was "
"either rejected by the substitution group "
"affiliation '%s', or not validly derived from its type "
"definition '%s'",
}
}
}
/*
* SPEC (5) "If the {type definition} or {type definition}'s
* {content type}
* is or is derived from ID then there must not be a {value constraint}.
* Note: The use of ID as a type definition for elements goes beyond
* XML 1.0, and should be avoided if backwards compatibility is desired"
*/
((WXS_IS_SIMPLE(typeDef) &&
(WXS_IS_COMPLEX(typeDef) &&
XML_SCHEMAS_ID)))) {
"The type definition (or type definition's content type) is or "
"is derived from ID; value constraints are not allowed in "
"conjunction with such a type definition", NULL);
int vcret;
/*
* SPEC (2) "If there is a {value constraint}, the canonical lexical
* representation of its value must be �valid� with respect to the
* {type definition} as defined in Element Default Valid (Immediate)
* (�3.3.6)."
*/
"Internal error: xmlSchemaCheckElemPropsCorrect, "
"type is missing... skipping validation of "
return (-1);
}
BAD_CAST "fixed");
else
BAD_CAST "default");
}
if (vcret != 0) {
if (vcret < 0) {
PERROR_INT("xmlSchemaElemCheckValConstr",
"failed to validate the value constraint of an "
"element declaration");
return (-1);
}
return (vcret);
}
}
return (ret);
}
/**
* xmlSchemaCheckElemSubstGroup:
* @ctxt: a schema parser context
* @decl: the element declaration
* @name: the name of the attribute
*
* Schema Component Constraint:
* Substitution Group (cos-equiv-class)
*
* In Libxml2 the subst. groups will be precomputed, in terms of that
* a list will be built for each subst. group head, holding all direct
* referents to this head.
* NOTE that this function needs:
* 1. circular subst. groups to be checked beforehand
* 2. the declaration's type to be derived from the head's type
*
* STATUS:
*
*/
static void
{
/* SPEC (1) "Its {abstract} is false." */
return;
{
/*
* SPEC (2) "It is validly substitutable for HEAD subject to HEAD's
* {disallowed substitutions} as the blocking constraint, as defined in
* Substitution Group OK (Transitive) (�3.3.6)."
*/
set = 0;
methSet = 0;
/*
* The blocking constraints.
*/
continue;
goto add_member;
/*
* SPEC: Substitution Group OK (Transitive) (2.3)
* "The set of all {derivation method}s involved in the
* derivation of D's {type definition} from C's {type definition}
* does not intersect with the union of the blocking constraint,
* C's {prohibited substitutions} (if C is complex, otherwise the
* empty set) and the {prohibited substitutions} (respectively the
* empty set) of any intermediate {type definition}s in the
* derivation of D's {type definition} from C's {type definition}."
*/
/*
* OPTIMIZE TODO: Optimize this a bit, since, if traversing the
* subst.head axis, the methSet does not need to be computed for
* the full depth over and over.
*/
/*
* The set of all {derivation method}s involved in the derivation
*/
if ((WXS_IS_EXTENSION(type)) &&
((methSet & XML_SCHEMAS_TYPE_BLOCK_RESTRICTION) == 0))
if (WXS_IS_RESTRICTION(type) &&
((methSet & XML_SCHEMAS_TYPE_BLOCK_RESTRICTION) == 0))
}
/*
* The {prohibited substitutions} of all intermediate types +
* the head's type.
*/
if (WXS_IS_COMPLEX(type)) {
((set & XML_SCHEMAS_TYPE_BLOCK_EXTENSION) == 0))
((set & XML_SCHEMAS_TYPE_BLOCK_RESTRICTION) == 0))
} else
break;
break;
}
if ((set != 0) &&
(((set & XML_SCHEMAS_TYPE_BLOCK_EXTENSION) &&
continue;
}
}
}
}
#ifdef WXS_ELEM_DECL_CONS_ENABLED /* enable when finished */
/**
* xmlSchemaCheckElementDeclComponent
* @pctxt: the schema parser context
* @ctxtComponent: the context component (an element declaration)
* @ctxtParticle: the first particle of the context component
* @searchParticle: the element declaration particle to be analysed
*
* Schema Component Constraint: Element Declarations Consistent
*/
static int
int search)
{
return(0);
int ret = 0;
if (curParticle == NULL) {
return(0);
}
/*
* Just return in this case. A missing "term" of the particle
* might arise due to an invalid "term" component.
*/
return(0);
}
case XML_SCHEMA_TYPE_ANY:
break;
case XML_SCHEMA_TYPE_ELEMENT:
if (search == 0) {
if (ret != 0)
return(ret);
} else {
/*
* SPEC Element Declarations Consistent:
* "If the {particles} contains, either directly,
* indirectly (that is, within the {particles} of a
* contained model group, recursively) or �implicitly�
* two or more element declaration particles with
* the same {name} and {target namespace}, then
* all their type definitions must be the same
* top-level definition [...]"
*/
{
/* TODO: error code */
"In the content model of %s, there are multiple "
"element declarations for '%s' with different "
"type definitions",
return(XML_SCHEMAP_COS_NONAMBIG);
}
}
break;
case XML_SCHEMA_TYPE_SEQUENCE: {
break;
}
case XML_SCHEMA_TYPE_CHOICE:{
/*
xmlSchemaTreeItemPtr sub;
sub = WXS_PARTICLE_TERM(particle)->children; (xmlSchemaParticlePtr)
while (sub != NULL) {
ret = xmlSchemaCheckElementDeclConsistent(pctxt, ctxtComponent,
ctxtParticle, ctxtElem);
if (ret != 0)
return(ret);
sub = sub->next;
}
*/
break;
}
case XML_SCHEMA_TYPE_ALL:
break;
case XML_SCHEMA_TYPE_GROUP:
break;
default:
"xmlSchemaCheckElementDeclConsistent",
"found unexpected term of type '%s' in content model",
return(-1);
}
}
exit:
return(ret);
}
#endif
/**
* xmlSchemaCheckElementDeclComponent
* @item: an schema element declaration/particle
* @ctxt: a schema parser context
* @name: the name of the attribute
*
* Validates the value constraints of an element declaration.
* Adds substitution group members.
*/
static void
{
return;
return;
/*
* Adds substitution group members.
*/
}
}
/**
* xmlSchemaResolveModelGroupParticleReferences:
* @particle: a particle component
* @ctxt: a parser context
*
* Resolves references of a model group's {particles} to
* model group definitions and to element declarations.
*/
static void
{
/*
* URGENT TODO: Test this.
*/
{
goto next_particle;
}
/*
* Resolve the reference.
* NULL the {term} by default.
*/
/* TODO: remove the particle. */
goto next_particle;
}
/* TODO: remove the particle. */
goto next_particle;
/*
* NOTE that we will assign the model group definition
* itself to the "term" of the particle. This will ease
* the check for circular model group definitions. After
* that the "term" will be assigned the model group of the
* model group definition.
*/
/*
* SPEC cos-all-limited (1)
* SPEC cos-all-limited (1.2)
* "It appears only as the value of one or both of the
* following properties:"
* (1.1) "the {model group} property of a model group
* definition."
* (1.2) "the {term} property of a particle [... of] the "
* {content type} of a complex type definition."
*/
/* TODO: error code */
"A model group definition is referenced, but "
"it contains an 'all' model group, which "
"cannot be contained by model groups",
/* TODO: remove the particle. */
goto next_particle;
}
} else {
/*
* TODO: Are referenced element declarations the only
* other components we expect here?
*/
}
}
}
static int
{
int ret;
while (x != NULL) {
/* Same types. */
/*
* (1) if a datatype T' is �derived� by �restriction� from an
* atomic datatype T then the �value space� of T' is a subset of
* the �value space� of T. */
/*
* (2) if datatypes T' and T'' are �derived� by �restriction�
* from a common atomic ancestor T then the �value space�s of T'
* and T'' may overlap.
*/
return(0);
/*
* We assume computed values to be normalized, so do a fast
* string comparison for string based types.
*/
if (! xmlStrEqual(
return (0);
} else {
if (ret == -2)
return(-1);
if (ret != 0)
return(0);
}
/*
* Lists.
*/
x = xmlSchemaValueGetNext(x);
if (x != NULL) {
y = xmlSchemaValueGetNext(y);
if (y == NULL)
return (0);
} else if (xmlSchemaValueGetNext(y) != NULL)
return (0);
else
return (1);
}
return (0);
}
/**
* xmlSchemaResolveAttrUseReferences:
* @item: an attribute use
* @ctxt: a parser context
*
* Resolves the referenced attribute declaration.
*/
static int
{
return(-1);
return(0);
{
/*
* TODO: Evaluate, what errors could occur if the declaration is not
* found.
*/
}
}
return(0);
}
/**
* xmlSchemaCheckAttrUsePropsCorrect:
* @ctxt: a parser context
* @use: an attribute use
*
* Schema Component Constraint:
* Attribute Use Correct (au-props-correct)
*
*/
static int
{
return(-1);
return(0);
/*
* SPEC au-props-correct (1)
* "The values of the properties of an attribute use must be as
* described in the property tableau in The Attribute Use Schema
* Component (�3.5.1), modulo the impact of Missing
* Sub-components (�5.3)."
*/
{
"The attribute declaration has a 'fixed' value constraint "
", thus the attribute use must also have a 'fixed' value "
"constraint",
NULL);
}
/*
* Compute and check the value constraint's value.
*/
int ret;
/*
* TODO: The spec seems to be missing a check of the
* value constraint of the attribute use. We will do it here.
*/
/*
* SPEC a-props-correct (3)
*/
{
"Value constraints are not allowed if the type definition "
"is or is derived from xs:ID",
}
1, 1, 0);
if (ret != 0) {
if (ret < 0) {
PERROR_INT2("xmlSchemaCheckAttrUsePropsCorrect",
"calling xmlSchemaVCheckCVCSimpleType()");
return(-1);
}
"The value of the value constraint is not valid",
}
}
/*
* SPEC au-props-correct (2)
* "If the {attribute declaration} has a fixed
* {value constraint}, then if the attribute use itself has a
* {value constraint}, it must also be fixed and its value must match
* that of the {attribute declaration}'s {value constraint}."
*/
{
{
"The 'fixed' value constraint of the attribute use "
"must match the attribute declaration's value "
"constraint '%s'",
}
}
return(0);
}
/**
* xmlSchemaResolveAttrTypeReferences:
* @item: an attribute declaration
* @ctxt: a parser context
*
* Resolves the referenced type definition component.
*/
static int
{
/*
* The simple type definition corresponding to the <simpleType> element
* information item in the [children], if present, otherwise the simple
* type definition �resolved� to by the �actual value� of the type
* [attribute], if present, otherwise the �simple ur-type definition�.
*/
return(0);
return(0);
} else
} else {
/*
* The type defaults to the xs:anySimpleType.
*/
}
return(0);
}
/**
* xmlSchemaResolveIDCKeyReferences:
* @idc: the identity-constraint definition
* @ctxt: the schema parser context
* @name: the attribute name
*
* Schema Component Constraint:
* Identity-constraint Definition Properties Correct (c-props-correct)
*/
static int
{
return(0);
/*
* TODO: It is actually not an error to fail to resolve
* at this stage. BUT we need to be that strict!
*/
/*
* SPEC c-props-correct (1)
*/
"The keyref references a keyref",
} else {
/*
* SPEC c-props-correct(2)
* "If the {identity-constraint category} is keyref,
* the cardinality of the {fields} must equal that of
* the {fields} of the {referenced key}.
*/
"The cardinality of the keyref differs from the "
NULL);
}
}
}
return(0);
}
static int
{
return(XML_SCHEMAP_SRC_RESOLVE);
}
return(0);
}
#define WXS_REDEFINED_TYPE(c) \
#define WXS_REDEFINED_MODEL_GROUP_DEF(c) \
#define WXS_REDEFINED_ATTR_GROUP(c) \
static int
{
int err = 0;
int wasRedefined;
return(0);
do {
/*
* First try to locate the redefined component in the
* schema graph starting with the redefined schema.
* NOTE: According to this schema bug entry:
* it's not clear if the referenced component needs to originate
* from the <redefine>d schema _document_ or the schema; the latter
* would include all imported and included sub-schemas of the
* <redefine>d schema. Currenlty we latter approach is used.
* SUPPLEMENT: It seems that the WG moves towards the latter
* approach, so we are doing it right.
*
*/
/*
* SPEC src-redefine:
* (6.2.1) "The �actual value� of its own name attribute plus
* target namespace must successfully �resolve� to a model
* group definition in I."
* (7.2.1) "The �actual value� of its own name attribute plus
* target namespace must successfully �resolve� to an attribute
* group definition in I."
*
* Note that, if we are redefining with the use of references
* to components, the spec assumes the src-resolve to be used;
* but this won't assure that we search only *inside* the
* redefined schema.
*/
else
/*
* TODO: error code.
* Probably XML_SCHEMAP_SRC_RESOLVE, if this is using the
* reference kind.
*/
"The %s '%s' to be redefined could not be found in "
"the redefined schema",
continue;
}
/*
* TODO: Obtaining and setting the redefinition state is really
* clumsy.
*/
wasRedefined = 0;
case XML_SCHEMA_TYPE_COMPLEX:
case XML_SCHEMA_TYPE_SIMPLE:
{
wasRedefined = 1;
break;
}
/* Mark it as redefined. */
/*
* Assign the redefined type to the
* base type of the redefining type.
* TODO: How
*/
break;
case XML_SCHEMA_TYPE_GROUP:
{
wasRedefined = 1;
break;
}
/* Mark it as redefined. */
/*
* Overwrite the QName-reference with the
* referenced model group def.
*/
}
break;
{
wasRedefined = 1;
break;
}
/*
* Assign the redefined attribute group to the
* QName-reference component.
* This is the easy case, since we will just
* expand the redefined group.
*/
} else {
/*
* This is the complicated case: we need
* to apply src-redefine (7.2.2) at a later
* stage, i.e. when attribute group references
* have beed expanded and simple types have
* beed fixed.
*/
}
break;
default:
PERROR_INT("xmlSchemaResolveRedefReferences",
"Unexpected redefined component type");
return(-1);
}
if (wasRedefined) {
else
/* TODO: error code. */
"The referenced %s was already redefined. Multiple "
"redefinition of the same component is not supported",
NULL);
continue;
}
return(err);
}
static int
{
int err = 0;
return(0);
do {
continue;
}
case XML_SCHEMA_TYPE_SIMPLE:
case XML_SCHEMA_TYPE_COMPLEX:
/*
* Since the spec wants the {name} of the redefined
* type to be 'absent', we'll NULL it.
*/
/*
* TODO: Seems like there's nothing more to do. The normal
* inheritance mechanism is used. But not 100% sure.
*/
break;
case XML_SCHEMA_TYPE_GROUP:
/*
* URGENT TODO:
* SPEC src-redefine:
* (6.2.2) "The {model group} of the model group definition
* which corresponds to it per XML Representation of Model
* Group Definition Schema Components (�3.7.2) must be a
* �valid restriction� of the {model group} of that model
* group definition in I, as defined in Particle Valid
* (Restriction) (�3.9.6)."
*/
break;
/*
* SPEC src-redefine:
* (7.2.2) "The {attribute uses} and {attribute wildcard} of
* the attribute group definition which corresponds to it
* per XML Representation of Attribute Group Definition Schema
* Components (�3.6.2) must be �valid restrictions� of the
* {attribute uses} and {attribute wildcard} of that attribute
* group definition in I, as defined in clause 2, clause 3 and
* clause 4 of Derivation Valid (Restriction, Complex)
* (�3.4.6) (where references to the base type definition are
* understood as references to the attribute group definition
* in I)."
*/
if (err == -1)
return(-1);
break;
default:
break;
}
return(0);
}
static int
{
int err;
int i;
#define WXS_GET_GLOBAL_HASH(c, slot) { \
if (WXS_IS_BUCKET_IMPMAIN((c)->type)) \
else \
/*
* Add global components to the schema's hash tables.
* This is the place where duplicate components will be
* detected.
* TODO: I think normally we should support imports of the
* same namespace from multiple locations. We don't do currently,
* but if we do then according to:
* we would need, if imported directly, to import redefined
* components as well to be able to catch clashing components.
* (I hope I'll still know what this means after some months :-()
*/
return(-1);
return(0);
case XML_SCHEMA_TYPE_COMPLEX:
case XML_SCHEMA_TYPE_SIMPLE:
if (WXS_REDEFINED_TYPE(item))
continue;
break;
case XML_SCHEMA_TYPE_ELEMENT:
break;
break;
case XML_SCHEMA_TYPE_GROUP:
continue;
break;
if (WXS_REDEFINED_ATTR_GROUP(item))
continue;
break;
case XML_SCHEMA_TYPE_IDC_KEY:
break;
case XML_SCHEMA_TYPE_NOTATION:
break;
default:
PERROR_INT("xmlSchemaAddComponents",
"Unexpected global component type");
continue;
}
PERROR_INT("xmlSchemaAddComponents",
"failed to create a component hash table");
return(-1);
}
}
if (err != 0) {
"A global %s '%s' does already exist",
}
}
/*
*/
do {
return(-1);
}
}
return(0);
}
static int
{
return(0);
/*
* Since xmlSchemaFixupComplexType() will create new particles
* (local components), and those particle components need a bucket
* on the constructor, we'll assure here that the constructor has
* a bucket.
* TODO: Think about storing locals _only_ on the main bucket.
*/
/* TODO:
* SPEC (src-redefine):
* (6.2) "If it has no such self-reference, then all of the
* following must be true:"
* (6.2.2) The {model group} of the model group definition which
* corresponds to it per XML Representation of Model Group
* Definition Schema Components (�3.7.2) must be a �valid
* restriction� of the {model group} of that model group definition
* in I, as defined in Particle Valid (Restriction) (�3.9.6)."
*/
/*
* Add global components to the schemata's hash tables.
*/
/*
* Now that we have parsed *all* the schema document(s) and converted
* them to schema components, we can resolve references, apply component
* constraints, create the FSA from the content model, etc.
*/
/*
* Resolve references of..
*
* 1. element declarations:
* - the type definition
* - the substitution group affiliation
* - the base type definition
* - the memberTypes of union types
* - the itemType of list types
* 3. attributes declarations and attribute uses:
* - the type definition
* - if an attribute use, then the attribute declaration
* 4. attribute group references:
* - the attribute group definition
* 5. particles:
* - the term of the particle (e.g. a model group)
* 6. IDC key-references:
* - the referenced IDC 'key' or 'unique' definition
* 7. Attribute prohibitions which had a "ref" attribute.
*/
for (i = 0; i < nbItems; i++) {
case XML_SCHEMA_TYPE_ELEMENT:
break;
case XML_SCHEMA_TYPE_COMPLEX:
case XML_SCHEMA_TYPE_SIMPLE:
break;
break;
break;
{
}
break;
case XML_SCHEMA_TYPE_SEQUENCE:
case XML_SCHEMA_TYPE_CHOICE:
case XML_SCHEMA_TYPE_ALL:
break;
case XML_SCHEMA_TYPE_IDC_KEY:
break;
/*
* Handle attribue prohibition which had a
* "ref" attribute.
*/
break;
default:
break;
}
}
goto exit_error;
/*
* Now that all references are resolved we
* can check for circularity of...
* 1. the base axis of type definitions
* 2. nested model group definitions
* 3. nested attribute group definitions
* TODO: check for circual substitution groups.
*/
for (i = 0; i < nbItems; i++) {
/*
* Let's better stop on the first error here.
*/
case XML_SCHEMA_TYPE_COMPLEX:
case XML_SCHEMA_TYPE_SIMPLE:
goto exit_error;
break;
case XML_SCHEMA_TYPE_GROUP:
goto exit_error;
break;
goto exit_error;
break;
default:
break;
}
}
goto exit_error;
/*
* Model group definition references:
* Such a reference is reflected by a particle at the component
* level. Until now the 'term' of such particles pointed
* to the model group definition; this was done, in order to
* ease circularity checks. Now we need to set the 'term' of
* such particles to the model group of the model group definition.
*/
for (i = 0; i < nbItems; i++) {
case XML_SCHEMA_TYPE_SEQUENCE:
case XML_SCHEMA_TYPE_CHOICE:
break;
default:
break;
}
}
goto exit_error;
/*
* Expand attribute group references of attribute group definitions.
*/
for (i = 0; i < nbItems; i++) {
if ((! WXS_ATTR_GROUP_EXPANDED(item)) &&
{
}
break;
default:
break;
}
}
goto exit_error;
/*
* First compute the variety of simple types. This is needed as
* a seperate step, since otherwise we won't be able to detect
* circular union types in all cases.
*/
for (i = 0; i < nbItems; i++) {
case XML_SCHEMA_TYPE_SIMPLE:
(xmlSchemaTypePtr) item);
}
break;
default:
break;
}
}
goto exit_error;
/*
* Detect circular union types. Note that this needs the variety to
* be already computed.
*/
for (i = 0; i < nbItems; i++) {
case XML_SCHEMA_TYPE_SIMPLE:
(xmlSchemaTypePtr) item);
}
break;
default:
break;
}
}
goto exit_error;
/*
* Do the complete type fixup for simple types.
*/
for (i = 0; i < nbItems; i++) {
case XML_SCHEMA_TYPE_SIMPLE:
}
break;
default:
break;
}
}
goto exit_error;
/*
* At this point we need build and check all simple types.
*/
/*
* Apply contraints for attribute declarations.
*/
for (i = 0; i < nbItems; i++) {
break;
default:
break;
}
}
goto exit_error;
/*
* Apply constraints for attribute uses.
*/
for (i = 0; i < nbItems; i++) {
}
break;
default:
break;
}
}
goto exit_error;
/*
* Apply constraints for attribute group definitions.
*/
for (i = 0; i < nbItems; i++) {
{
}
break;
default:
break;
}
}
goto exit_error;
/*
* Apply constraints for redefinitions.
*/
goto exit_error;
/*
* Complex types are builded and checked.
*/
for (i = 0; i < nbItems; i++) {
case XML_SCHEMA_TYPE_COMPLEX:
}
break;
default:
break;
}
}
goto exit_error;
/*
* The list could have changed, since xmlSchemaFixupComplexType()
* will create particles and model groups in some cases.
*/
/*
* Apply some constraints for element declarations.
*/
for (i = 0; i < nbItems; i++) {
case XML_SCHEMA_TYPE_ELEMENT:
{
}
#ifdef WXS_ELEM_DECL_CONS_ENABLED
/*
* Schema Component Constraint: Element Declarations Consistent
* Apply this constraint to local types of element declarations.
*/
{
}
#endif
break;
default:
break;
}
}
goto exit_error;
/*
* Finally we can build the automaton from the content model of
* complex types.
*/
for (i = 0; i < nbItems; i++) {
case XML_SCHEMA_TYPE_COMPLEX:
/* FIXHFAILURE; */
break;
default:
break;
}
}
goto exit_error;
/*
* URGENT TODO: cos-element-consistent
*/
goto exit;
goto exit;
ret = -1;
exit:
/*
* Reset the constructor. This is needed for XSI acquisition, since
* those items will be processed over and over again for every XSI
* if not cleared here.
*/
}
}
return(ret);
}
/**
* xmlSchemaParse:
* @ctxt: a schema validation context
*
* parse a schema definition resource and build an internal
* XML Shema struture which can be used to validate instances.
*
* Returns the internal XML Schema structure built from the resource or
* NULL in case of error
*/
{
int res;
/*
* This one is used if the schema to be parsed was specified via
* the API; i.e. not automatically by the validated instance document.
*/
return (NULL);
/* TODO: Init the context. Is this all we need?*/
/* Create the *main* schema. */
if (mainSchema == NULL)
goto exit_failure;
/*
* Create the schema constructor.
*/
return(NULL);
/* Take ownership of the constructor to be able to free it. */
}
/*
* Locate and add the schema document.
*/
if (res == -1)
goto exit_failure;
if (res != 0)
goto exit;
/* TODO: Error code, actually we failed to *locate* the schema. */
"Failed to locate the main schema resource at '%s'",
else
"Failed to locate the main schema resource",
goto exit;
}
/* Then do the parsing for good. */
goto exit_failure;
goto exit;
goto exit_failure;
/*
* TODO: This is not nice, since we cannot distinguish from the
* result if there was an internal error or not.
*/
exit:
if (mainSchema) {
mainSchema = NULL;
}
if (ctxt->constructor) {
ctxt->ownsConstructor = 0;
}
}
return(mainSchema);
/*
* Quite verbose, but should catch internal errors, which were
* not communitated.
*/
if (mainSchema) {
mainSchema = NULL;
}
if (ctxt->constructor) {
ctxt->ownsConstructor = 0;
}
PERROR_INT2("xmlSchemaParse",
"An internal error occured");
return(NULL);
}
/**
* xmlSchemaSetParserErrors:
* @ctxt: a schema 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;
}
/**
* xmlSchemaSetParserStructuredErrors:
* @ctxt: a schema parser context
* @serror: the structured error function
* @ctx: the functions context
*
* Set the structured error callback
*/
void
void *ctx)
{
return;
}
/**
* xmlSchemaGetParserErrors:
* @ctxt: a XMl-Schema parser 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 parser context
*
* Returns -1 in case of failure, 0 otherwise
*/
int
{
return(-1);
return(0);
}
/**
* xmlSchemaFacetTypeToString:
* @type: the facet type
*
* Convert the xmlSchemaTypeType to a char string.
*
* Returns the char string representation of the facet type if the
* type is a facet and an "Internal Error" string otherwise.
*/
static const xmlChar *
{
switch (type) {
case XML_SCHEMA_FACET_PATTERN:
return (BAD_CAST "pattern");
return (BAD_CAST "maxExclusive");
return (BAD_CAST "maxInclusive");
return (BAD_CAST "minExclusive");
return (BAD_CAST "minInclusive");
return (BAD_CAST "whiteSpace");
return (BAD_CAST "enumeration");
case XML_SCHEMA_FACET_LENGTH:
return (BAD_CAST "length");
return (BAD_CAST "maxLength");
return (BAD_CAST "minLength");
return (BAD_CAST "totalDigits");
return (BAD_CAST "fractionDigits");
default:
break;
}
return (BAD_CAST "Internal Error");
}
static xmlSchemaWhitespaceValueType
{
/*
* The normalization type can be changed only for types which are derived
* from xsd:string.
*/
/*
* Note that we assume a whitespace of preserve for anySimpleType.
*/
return(XML_SCHEMA_WHITESPACE_PRESERVE);
return(XML_SCHEMA_WHITESPACE_REPLACE);
else {
/*
* For all �atomic� datatypes other than string (and types �derived�
* by �restriction� from it) the value of whiteSpace is fixed to
* collapse
* Note that this includes built-in list datatypes.
*/
return(XML_SCHEMA_WHITESPACE_COLLAPSE);
}
} else if (WXS_IS_LIST(type)) {
/*
* For list types the facet "whiteSpace" is fixed to "collapse".
*/
return (XML_SCHEMA_WHITESPACE_COLLAPSE);
} else if (WXS_IS_UNION(type)) {
return (XML_SCHEMA_WHITESPACE_UNKNOWN);
} else if (WXS_IS_ATOMIC(type)) {
return (XML_SCHEMA_WHITESPACE_PRESERVE);
return (XML_SCHEMA_WHITESPACE_REPLACE);
else
return (XML_SCHEMA_WHITESPACE_COLLAPSE);
}
return (-1);
}
/************************************************************************
* *
* Simple type validation *
* *
************************************************************************/
/************************************************************************
* *
* DOM Validation code *
* *
************************************************************************/
/**
* xmlSchemaAssembleByLocation:
* @pctxt: a schema parser context
* @vctxt: a schema validation context
* @schema: the existing schema
* @node: the node that fired the assembling
* @nsName: the namespace name of the new schema
* @location: the location of the schema
*
* Expands an existing schema by an additional schema.
*
* Returns 0 if the new schema is correct, a positive error code
* number otherwise and -1 in case of an internal or API error.
*/
static int
{
int ret = 0;
return (-1);
VERROR_INT("xmlSchemaAssembleByLocation",
"no parser context available");
return(-1);
}
PERROR_INT("xmlSchemaAssembleByLocation",
"no constructor");
return(-1);
}
/*
* Acquire the schema document.
*/
/*
* Note that we pass XML_SCHEMA_SCHEMA_IMPORT here;
* the process will automatically change this to
* XML_SCHEMA_SCHEMA_MAIN if it is the first schema document.
*/
&bucket);
if (ret != 0)
return(ret);
/*
* Generate a warning that the document could not be located.
*/
"The document at location '%s' could not be acquired",
return(ret);
}
/*
* The first located schema will be handled as if all other
* schemas imported by XSI were imported by this first schema.
*/
/*
* TODO: Is this handled like an import? I.e. is it not an error
* if the schema cannot be located?
*/
return(0);
/*
* We will reuse the parser context for every schema imported
* directly via XSI. So reset the context.
*/
if (ret == -1) {
goto exit_failure;
}
/* Paranoid error channelling. */
/*
* Only bother to fixup pending components, if there was
* no error yet.
* For every XSI acquired schema (and its sub-schemata) we will
* fixup the components.
*/
/*
* Not nice, but we need somehow to channel the schema parser
* error to the validation context.
*/
} else {
/* Add to validation error sum. */
}
return(ret);
return (-1);
}
static xmlSchemaAttrInfoPtr
int metaType)
{
if (vctxt->nbAttrInfos == 0)
return (NULL);
{
int i;
for (i = 0; i < vctxt->nbAttrInfos; i++) {
return (iattr);
}
}
return (NULL);
}
/**
* xmlSchemaAssembleByXSI:
* @vctxt: a schema validation context
*
* Expands an existing schema by an additional schema using
* the xsi:schemaLocation or xsi:noNamespaceSchemaLocation attribute
* of an instance. If xsi:noNamespaceSchemaLocation is used, @noNamespace
* must be set to 1.
*
* Returns 0 if the new schema is correct, a positive error code
* number otherwise and -1 in case of an internal or API error.
*/
static int
{
int count = 0;
int ret = 0;
/*
* Parse the value; we will assume an even number of values
* to be given (this is how Xerces and XSV work).
*
* URGENT TODO: !! This needs to work for both
* @noNamespaceSchemaLocation AND @schemaLocation on the same
* element !!
*/
return (0);
do {
/*
* TODO: Move the string parsing mechanism away from here.
*/
/*
* Get the namespace name.
*/
while (IS_BLANK_CH(*cur))
cur++;
end++;
break;
count++; /* TODO: Don't use the schema's dict. */
}
/*
* Get the URI.
*/
while (IS_BLANK_CH(*cur))
cur++;
end++;
{
/*
* If using @schemaLocation then tuples are expected.
* I.e. the namespace name *and* the document's URI.
*/
"The value must consist of tuples: the target namespace "
}
break;
}
count++; /* TODO: Don't use the schema's dict. */
if (ret == -1) {
VERROR_INT("xmlSchemaAssembleByXSI",
"assembling schemata");
return (-1);
}
} while (*cur != 0);
return (ret);
}
static const xmlChar *
{
int i, j;
inode->nsBindings[j]))) {
/*
* Note that the namespace bindings are already
* in a string dict.
*/
}
}
}
}
return (NULL);
#ifdef LIBXML_WRITER_ENABLED
return (ret);
} else
return (NULL);
#endif
} else {
VERROR_INT("xmlSchemaLookupNamespace",
"no node or node's doc avaliable");
return (NULL);
}
return (NULL);
}
}
/*
* This one works on the schema of the validation context.
*/
static int
int valNeeded)
{
int ret;
VERROR_INT("xmlSchemaValidateNotation",
"a schema is needed on the validation context");
return (-1);
}
if (ret != 0)
return (ret);
{
} else {
return (1);
}
return (1);
}
ret = -1;
}
} else
ret = 1;
} else {
(*val) = xmlSchemaNewNOTATIONValue(
ret = -1;
}
} else
return (1);
}
}
return (ret);
}
static int
{
int i;
return(-1);
return(-1);
}
/* Already there */
return(i);
}
/* Add new entry. */
return(i);
}
/************************************************************************
* *
* Validation of identity-constraints (IDC) *
* *
************************************************************************/
/**
* xmlSchemaAugmentIDC:
* @idcDef: the IDC definition
*
* Creates an augmented IDC definition item.
*
* Returns the item, or NULL on internal errors.
*/
static void
{
"xmlSchemaAugmentIDC: allocating an augmented IDC definition",
NULL);
return;
}
else {
}
/*
* Save if we have keyrefs at all.
*/
if ((vctxt->hasKeyrefs == 0) &&
}
/**
* xmlSchemaAugmentImportedIDC:
* @imported: the imported schema
*
* Creates an augmented IDC definition for the imported schema.
*/
static void
}
}
/**
* xmlSchemaIDCNewBinding:
* @idcDef: the IDC definition of this binding
*
* Creates a new IDC binding.
*
* Returns the new IDC binding, NULL on internal errors.
*/
static xmlSchemaPSVIIDCBindingPtr
{
sizeof(xmlSchemaPSVIIDCBinding));
"allocating a PSVI IDC binding item", NULL);
return (NULL);
}
return (ret);
}
/**
* xmlSchemaIDCStoreNodeTableItem:
* @vctxt: the WXS validation context
* @item: the IDC node table item
*
* The validation context is used to store IDC node table items.
* They are stored to avoid copying them if IDC node-tables are merged
* with corresponding parent IDC node-tables (bubbling).
*
* Returns 0 if succeeded, -1 on internal errors.
*/
static int
{
/*
* Add to gobal list.
*/
"allocating the IDC node table item list", NULL);
return (-1);
}
sizeof(xmlSchemaPSVIIDCNodePtr));
"re-allocating the IDC node table item list", NULL);
return (-1);
}
}
return (0);
}
/**
* xmlSchemaIDCStoreKey:
* @vctxt: the WXS validation context
* @item: the IDC key
*
* The validation context is used to store an IDC key.
*
* Returns 0 if succeeded, -1 on internal errors.
*/
static int
{
/*
* Add to gobal list.
*/
"allocating the IDC key storage list", NULL);
return (-1);
}
sizeof(xmlSchemaPSVIIDCKeyPtr));
"re-allocating the IDC key storage list", NULL);
return (-1);
}
}
return (0);
}
/**
* xmlSchemaIDCAppendNodeTableItem:
* @bind: the IDC binding
* @ntItem: the node-table item
*
* Appends the IDC node-table item to the binding.
*
* Returns 0 on success and -1 on internal errors.
*/
static int
{
"allocating an array of IDC node-table items", NULL);
return(-1);
}
sizeof(xmlSchemaPSVIIDCNodePtr));
"re-allocating an array of IDC node-table items", NULL);
return(-1);
}
}
return(0);
}
/**
* xmlSchemaIDCAcquireBinding:
* @vctxt: the WXS validation context
* @matcher: the IDC matcher
*
* Looks up an PSVI IDC binding, for the IDC definition and
* of the given matcher. If none found, a new one is created
* and added to the IDC table.
*
* Returns an IDC binding or NULL on internal errors.
*/
static xmlSchemaPSVIIDCBindingPtr
{
return (NULL);
} else {
do {
return(bind);
return (NULL);
}
}
return (NULL);
}
static xmlSchemaItemListPtr
{
}
/**
* xmlSchemaIDCFreeKey:
* @key: the IDC key
*
* Frees an IDC key together with its compiled value.
*/
static void
{
}
/**
* xmlSchemaIDCFreeBinding:
*
* Frees an IDC binding. Note that the node table-items
* are not freed.
*/
static void
{
}
/**
* xmlSchemaIDCFreeIDCTable:
* @bind: the first IDC binding in the list
*
* Frees an IDC table, i.e. all the IDC bindings in the list.
*/
static void
{
}
}
/**
* xmlSchemaIDCFreeMatcherList:
* @matcher: the first IDC matcher in the list
*
* Frees a list of IDC matchers.
*/
static void
{
int i;
for (i = 0; i < matcher->sizeKeySeqs; i++)
}
int i;
/*
* Node-table items for keyrefs are not stored globally
* to the validation context, since they are not bubbled.
* We need to free them here.
*/
idcNode =
}
}
}
}
}
/**
* xmlSchemaIDCReleaseMatcherList:
* @vctxt: the WXS validation context
* @matcher: the first IDC matcher in the list
*
* Caches a list of IDC matchers for reuse.
*/
static void
{
int i;
/*
* Don't free the array, but only the content.
*/
for (i = 0; i < matcher->sizeKeySeqs; i++)
}
}
int i;
/*
* Node-table items for keyrefs are not stored globally
* to the validation context, since they are not bubbled.
* We need to free them here.
*/
idcNode =
}
}
}
/*
* Cache the matcher.
*/
}
}
/**
* xmlSchemaIDCAddStateObject:
* @vctxt: the WXS validation context
* @matcher: the IDC matcher
* @sel: the XPath information
* @parent: the parent "selector" state object if any
* @type: "selector" or "field"
*
* XPath information; if the XPath expression consists of unions,
* multiple state objects are created for every unioned expression.
*
* Returns 0 on success and -1 on internal errors.
*/
static int
int type)
{
/*
* Reuse the state objects from the pool.
*/
} else {
/*
* Create a new state object.
*/
"allocating an IDC state object", NULL);
return (-1);
}
}
/*
* Add to global list.
*/
/*
* Free the old xpath validation context.
*/
/*
* Create a new XPath (pattern) validation context.
*/
VERROR_INT("xmlSchemaIDCAddStateObject",
"failed to create an XPath validation context");
return (-1);
}
#ifdef DEBUG_IDC
#endif
return (0);
}
/**
* xmlSchemaXPathEvaluate:
* @vctxt: the WXS validation context
* @nodeType: the nodeType of the current node
*
* Evaluates all active XPath state objects.
*
* Returns the number of IC "field" state objects which resolved to
* this node, 0 if none resolved and -1 on internal errors.
*/
static int
{
return (0);
if (nodeType == XML_ATTRIBUTE_NODE)
depth++;
#ifdef DEBUG_IDC
{
"IDC: EVAL on %s, depth %d, type %d\n",
}
#endif
/*
* Process all active XPath state objects.
*/
#ifdef DEBUG_IDC
else
#endif
if (nodeType == XML_ELEMENT_NODE)
else
if (res == -1) {
VERROR_INT("xmlSchemaXPathEvaluate",
"calling xmlStreamPush()");
return (-1);
}
if (res == 0)
goto next_sto;
/*
* Full match.
*/
#ifdef DEBUG_IDC
"MATCH\n");
#endif
/*
* Register a match in the state object history.
*/
"allocating the state object history", NULL);
return(-1);
}
sto->sizeHistory * sizeof(int));
"re-allocating the state object history", NULL);
return(-1);
}
}
#ifdef DEBUG_IDC
#endif
/*
* Activate state objects for the IDC fields of
* the IDC selector.
*/
#ifdef DEBUG_IDC
"activating field states\n");
#endif
return (-1);
}
/*
* An IDC key node was found by the IDC field.
*/
#ifdef DEBUG_IDC
"IDC: key found\n");
#endif
/*
* Notify that the character value of this node is
* needed.
*/
if (resolved == 0) {
}
resolved++;
}
/*
* Evaluate field state objects created on this node as well.
*/
} else
}
return (resolved);
}
static const xmlChar *
int count)
{
int i, res;
for (i = 0; i < count; i++) {
&value);
if (res == 0)
else {
VERROR_INT("xmlSchemaFormatIDCKeySequence",
"failed to compute a canonical value");
}
if (i < count -1)
else
}
}
}
/**
* xmlSchemaXPathPop:
* @vctxt: the WXS validation context
*
* Pops all XPath states.
*
* Returns 0 on success and -1 on internal errors.
*/
static int
{
int res;
return(0);
do {
if (res == -1)
return (-1);
return(0);
}
/**
* xmlSchemaXPathProcessHistory:
* @vctxt: the WXS validation context
* @val: the precompiled value
*
* Processes and pops the history items of the IDC state objects.
*
* Returns 0 on success and -1 on internal errors.
*/
static int
int depth)
{
int res, matchDepth;
return (0);
#ifdef DEBUG_IDC
{
"IDC: BACK on %s, depth %d\n",
}
#endif
/*
* Evaluate the state objects.
*/
if (res == -1) {
VERROR_INT("xmlSchemaXPathProcessHistory",
"calling xmlStreamPop()");
return (-1);
}
#ifdef DEBUG_IDC
#endif
goto deregister_check;
/*
* Only matches at the current depth are of interest.
*/
if (matchDepth != depth) {
continue;
}
/*
* NOTE: According to
* ... the simple-content of complex types is also allowed.
*/
if (WXS_IS_COMPLEX(type)) {
if (WXS_HAS_SIMPLE_CONTENT(type)) {
/*
* Sanity check for complex types with simple content.
*/
if (simpleType == NULL) {
VERROR_INT("xmlSchemaXPathProcessHistory",
"field resolves to a CT with simple content "
"but the CT is missing the ST definition");
return (-1);
}
} else
simpleType = NULL;
} else
simpleType = type;
if (simpleType == NULL) {
/*
* Not qualified if the field resolves to a node of non
* simple type.
*/
"The XPath '%s' of a field of %s does evaluate to a node of "
"non-simple type",
goto deregister_check;
}
/*
* Failed to provide the normalized value; maybe
* the value was invalid.
*/
"Warning: No precomputed value available, the value "
"was either invalid or something strange happend");
goto deregister_check;
} else {
/*
* The key will be anchored on the matcher's list of
* key-sequences. The position in this list is determined
* by the target node's depth relative to the matcher's
* depth of creation (i.e. the depth of the scope element).
*
* Element Depth Pos List-entries
* <scope> 0 NULL
* <bar> 1 NULL
* <target/> 2 2 target
* <bar>
* </scope>
*
* The size of the list is only dependant on the depth of
* the tree.
* An entry will be NULLed in selector_leave, i.e. when
* we hit the target's
*/
/*
*/
if (pos > 9)
else
sizeof(xmlSchemaPSVIIDCKeyPtr *));
"allocating an array of key-sequences",
NULL);
return(-1);
}
sizeof(xmlSchemaPSVIIDCKeyPtr *));
int i = matcher->sizeKeySeqs;
sizeof(xmlSchemaPSVIIDCKeyPtr *));
"reallocating an array of key-sequences",
NULL);
return (-1);
}
/*
* The array needs to be NULLed.
* TODO: Use memset?
*/
for (; i < matcher->sizeKeySeqs; i++)
}
/*
*/
goto create_sequence;
/*
* cvc-identity-constraint:
* 3 For each node in the �target node set� all
* of the {fields}, with that node as the context
* node, evaluate to either an empty node-set or
* a node-set with exactly one member, which must
* have a simple type.
*
* The key was already set; report an error.
*/
"The XPath '%s' of a field of %s evaluates to a "
"node-set with more than one member",
goto deregister_check;
} else
goto create_key;
/*
* Create a key-sequence.
*/
sizeof(xmlSchemaPSVIIDCKeyPtr));
"allocating an IDC key-sequence", NULL);
return(-1);
}
sizeof(xmlSchemaPSVIIDCKeyPtr));
/*
* Create a key once per node only.
*/
sizeof(xmlSchemaPSVIIDCKey));
"allocating a IDC key", NULL);
return(-1);
}
/*
* Consume the compiled value.
*/
/*
* Store the key in a global list.
*/
return (-1);
}
}
}
/* xmlSchemaPSVIIDCBindingPtr bind; */
/*
* Here we have the following scenario:
* An IDC 'selector' state object resolved to a target node,
* during the time this target node was in the
* ancestor-or-self axis, the 'field' state object(s) looked
* out for matching nodes to create a key-sequence for this
* target node. Now we are back to this target node and need
* to put the key-sequence, together with the target node
* itself, into the node-table of the corresponding IDC
* binding.
*/
/*
* Check if the matcher has any key-sequences at all, plus
* if it has a key-sequence for the current target node.
*/
goto selector_key_error;
else
goto selector_leave;
}
goto selector_key_error;
else
goto selector_leave;
}
for (i = 0; i < nbKeys; i++) {
/*
* Not qualified, if not all fields did resolve.
*/
/*
* All fields of a "key" IDC must resolve.
*/
goto selector_key_error;
}
goto selector_leave;
}
}
/*
* All fields did resolve.
*/
/*
* 4.1 If the {identity-constraint category} is unique(/key),
* then no two members of the �qualified node set� have
* �key-sequences� whose members are pairwise equal, as
* defined by Equal in [XML Schemas: Datatypes].
*
* Get the IDC binding from the matcher and check for
* duplicate key-sequences.
*/
#if 0
#endif
i = 0;
res = 0;
/*
* Compare the key-sequences, key by key.
*/
do {
bkeySeq =
for (j = 0; j < nbKeys; j++) {
if (res == -1) {
return (-1);
} else if (res == 0) {
/*
* One of the keys differs, so the key-sequence
* won't be equal; get out.
*/
break;
}
}
if (res == 1) {
/*
* Duplicate key-sequence found.
*/
break;
}
i++;
/*
* TODO: Try to report the key-sequence.
*/
"Duplicate key-sequence %s in %s",
goto selector_leave;
}
}
/*
* Add a node-table item to the IDC binding.
*/
sizeof(xmlSchemaPSVIIDCNode));
"allocating an IDC node-table item", NULL);
return(-1);
}
/*
* Store the node-table item in a global list.
*/
return (-1);
}
} else {
/*
* Save a cached QName for this node on the IDC node, to be
* able to report it, even if the node is not saved.
*/
return (-1);
}
}
/*
* Init the node-table item: Save the node, position and
* consume the key-sequence.
*/
#if 0
#endif
/*
* Free the item, since keyref items won't be
* put on a global list.
*/
}
return (-1);
}
goto selector_leave;
{
/*
* 4.2.1 (KEY) The �target node set� and the
* �qualified node set� are equal, that is, every
* member of the �target node set� is also a member
* of the �qualified node set� and vice versa.
*/
"Not all fields of %s evaluate to a node",
}
/*
* Free the key-sequence if not added to the IDC table.
*/
}
} /* if selector */
/*
* Deregister state objects if they reach the depth of creation.
*/
#ifdef DEBUG_IDC
#endif
VERROR_INT("xmlSchemaXPathProcessHistory",
"The state object to be removed is not the first "
"in the list");
}
/*
* Unlink from the list of active XPath state objects.
*/
/*
* Link it to the pool of reusable state objects.
*/
} else
} /* while (sto != NULL) */
return (0);
}
/**
* xmlSchemaIDCRegisterMatchers:
* @vctxt: the WXS validation context
* @elemDecl: the element declaration
*
* successively.
*
* Returns 0 if OK and -1 on internal errors.
*/
static int
{
return (0);
#ifdef DEBUG_IDC
{
"IDC: REGISTER on %s, depth %d\n",
}
#endif
VERROR_INT("xmlSchemaIDCRegisterMatchers",
"The chain of IDC matchers is expected to be empty");
return (-1);
}
do {
/*
* Since IDCs bubbles are expensive we need to know the
* depth at which the bubbles should stop; this will be
* the depth of the top-most keyref IDC. If no keyref
* be -1, indicating that no bubbles are needed.
*/
/*
* Remember that we have keyrefs on this node.
*/
/*
* Lookup the referenced augmented IDC info.
*/
break;
}
VERROR_INT("xmlSchemaIDCRegisterMatchers",
"Could not find an augmented IDC item for an IDC "
"definition");
return (-1);
}
}
}
/*
* Lookup the augmented IDC item for the IDC definition.
*/
break;
}
VERROR_INT("xmlSchemaIDCRegisterMatchers",
"Could not find an augmented IDC item for an IDC definition");
return (-1);
}
/*
* Create an IDC matcher for every IDC definition.
*/
/*
* Reuse a cached matcher.
*/
} else {
xmlMalloc(sizeof(xmlSchemaIDCMatcher));
"allocating an IDC matcher", NULL);
return (-1);
}
}
else
#ifdef DEBUG_IDC
#endif
/*
* Init the automaton state object.
*/
return (-1);
return (0);
}
static int
{
/* vctxt->createIDCNodeTables */
/*
* Skip keyref IDCs and empty IDC target-lists.
*/
{
continue;
}
/*
* If we _want_ the IDC node-table to be created in any case
* then do so. Otherwise create them only if keyrefs need them.
*/
if ((! vctxt->createIDCNodeTables) &&
{
continue;
}
/*
*/
} else {
nbDupls = 0;
}
} else {
nbNodeTable = 0;
}
if ((nbNodeTable == 0) && (nbDupls == 0)) {
/*
* Transfer all IDC target-nodes to the IDC node-table.
*/
} else {
/*
* Compare the key-sequences and add to the IDC node-table.
*/
i = 0;
do {
if (nbDupls) {
/*
* Search in already found duplicates first.
*/
j = 0;
do {
if (nbFields == 1) {
if (res == -1)
goto internal_error;
if (res == 1) {
/*
* Equal key-sequence.
*/
goto next_target;
}
} else {
res = 0;
for (k = 0; k < nbFields; k++) {
if (res == -1)
goto internal_error;
if (res == 0) {
/*
* One of the keys differs.
*/
break;
}
}
if (res == 1) {
/*
* Equal key-sequence found.
*/
goto next_target;
}
}
j++;
} while (j < nbDupls);
}
if (nbNodeTable) {
j = 0;
do {
if (nbFields == 1) {
if (res == -1)
goto internal_error;
if (res == 0) {
/*
* The key-sequence differs.
*/
goto next_node_table_entry;
}
} else {
res = 0;
for (k = 0; k < nbFields; k++) {
if (res == -1)
goto internal_error;
if (res == 0) {
/*
* One of the keys differs.
*/
goto next_node_table_entry;
}
}
}
/*
* Add the duplicate to the list of duplicates.
*/
goto internal_error;
}
goto internal_error;
/*
* Remove the duplicate entry from the IDC node-table.
*/
goto next_target;
j++;
} while (j < nbNodeTable);
}
/*
* If everything is fine, then add the IDC target-node to
* the IDC node-table.
*/
goto internal_error;
i++;
} while (i < nbTargets);
}
}
return(0);
return(-1);
}
/**
* xmlSchemaBubbleIDCNodeTables:
* @depth: the current tree depth
*
* Merges IDC bindings of an element at @depth into the corresponding IDC
* bindings of its parent element. If a duplicate note-table entry is found,
* both, the parent node-table entry and child entry are discarded from the
* node-table of the parent.
*
* Returns 0 if OK and -1 on internal errors.
*/
static int
{
/* Fine, no table, no bubbles. */
return (0);
}
/*
* Walk all bindings; create new or add to existing bindings.
* Remove duplicate key-sequences.
*/
goto next_binding;
/*
*/
if (! vctxt->createIDCNodeTables) {
do {
goto next_binding;
}
break;
}
}
/*
* Search a matching parent binding for the
* IDC definition.
*/
break;
}
/*
* Compare every node-table entry of the child node,
* i.e. the key-sequence within, ...
*/
} else {
oldDupls = 0;
}
continue;
/*
* ...with every key-sequence of the parent node, already
* evaluated to be a duplicate key-sequence.
*/
if (oldDupls) {
j = 0;
while (j < oldDupls) {
if (nbFields == 1) {
if (ret == -1)
goto internal_error;
if (ret == 0) {
j++;
continue;
}
} else {
for (k = 0; k < nbFields; k++) {
if (ret == -1)
goto internal_error;
if (ret == 0)
break;
}
}
if (ret == 1)
/* Duplicate found. */
break;
j++;
}
if (j != oldDupls) {
/* Duplicate found. Skip this entry. */
continue;
}
}
/*
* ... and with every key-sequence of the parent node.
*/
if (oldNum) {
j = 0;
while (j < oldNum) {
if (nbFields == 1) {
if (ret == -1)
goto internal_error;
if (ret == 0) {
j++;
continue;
}
} else {
for (k = 0; k < nbFields; k++) {
if (ret == -1)
goto internal_error;
if (ret == 0)
break;
}
}
if (ret == 1)
/* Duplicate found. */
break;
j++;
}
if (j != oldNum) {
/*
* Handle duplicates. Move the duplicate in
* the parent's node-table to the list of
* duplicates.
*/
oldNum--;
/*
* Move last old item to pos of duplicate.
*/
/*
* If new items exist, move last new item to
* last of old items.
*/
}
goto internal_error;
}
} else {
/*
* Add the node-table entry (node and key-sequence) of
* the child node to the node table of the parent node.
*/
"allocating IDC list of node-table items", NULL);
goto internal_error;
}
sizeof(xmlSchemaPSVIIDCNodePtr));
"re-allocating IDC list of node-table items", NULL);
goto internal_error;
}
}
/*
* Append the new node-table entry to the 'new node-table
* entries' section.
*/
}
}
}
} else {
/*
* No binding for the IDC was found: create a new one and
* copy all node-tables.
*/
goto internal_error;
/*
* TODO: Hmm, how to optimize the initial number of
* allocated entries?
*/
/*
* Add all IDC node-table entries.
*/
if (! vctxt->psviExposeIDCNodeTables) {
/*
* Just move the entries.
* NOTE: this is quite save here, since
* all the keyref lookups have already been
* performed.
*/
} else {
/*
* Copy the entries.
*/
sizeof(xmlSchemaPSVIIDCNodePtr));
"allocating an array of IDC node-table "
"items", NULL);
goto internal_error;
}
}
}
/*
* Move the duplicates.
*/
}
else {
}
}
}
return (0);
return(-1);
}
/**
* xmlSchemaCheckCVCIDCKeyRef:
* @vctxt: the WXS validation context
* @elemDecl: the element declaration
*
* Check the cvc-idc-keyref constraints.
*/
static int
{
/*
* Find a keyref.
*/
{
/*
*/
break;
}
/*
* Search for a matching key-sequences.
*/
res = 0;
for (k = 0; k < nbFields; k++) {
if (res == 0)
break;
else if (res == -1) {
return (-1);
}
}
if (res == 1) {
/*
* Match found.
*/
break;
}
}
/*
* Search in duplicates
*/
for (k = 0; k < nbFields; k++) {
if (res == 0)
break;
else if (res == -1) {
return (-1);
}
}
if (res == 1) {
/*
* Match in duplicates found.
*/
"More than one match found for "
"key-sequence %s of keyref '%s'",
break;
}
}
}
}
if (res == 0) {
"No match found for key-sequence %s of keyref '%s'",
}
}
}
}
/* TODO: Return an error if any error encountered. */
return (0);
}
/************************************************************************
* *
* XML Reader validation code *
* *
************************************************************************/
static xmlSchemaAttrInfoPtr
{
/*
*/
xmlMalloc(sizeof(xmlSchemaAttrInfoPtr));
"allocating attribute info list", NULL);
return (NULL);
}
vctxt->sizeAttrInfos++;
"re-allocating attribute info list", NULL);
return (NULL);
}
} else {
VERROR_INT("xmlSchemaGetFreshAttrInfo",
"attr info not cleared");
return (NULL);
}
return (iattr);
}
/*
* Create an attribute info.
*/
xmlMalloc(sizeof(xmlSchemaAttrInfo));
return (NULL);
}
return (iattr);
}
static int
int nodeLine,
int ownedNames,
int ownedValue)
{
VERROR_INT("xmlSchemaPushAttribute",
"calling xmlSchemaGetFreshAttrInfo()");
return (-1);
}
if (ownedNames)
/*
* Evaluate if it's an XSI attribute.
*/
}
}
}
}
}
}
if (ownedValue)
return (0);
}
/**
* xmlSchemaClearElemInfo:
* @vctxt: the WXS validation context
* @ielem: the element information item
*/
static void
{
ielem->hasKeyrefs = 0;
ielem->appliedXPath = 0;
} else {
}
} else {
}
/*
* PSVI TODO: Be careful not to free it when the value is
* exposed via PSVI.
*/
}
/*
* REVISIT OPTIMIZE TODO: Use a pool of IDC matchers.
* Does it work?
*/
#if 0
#endif
}
/*
* OPTIMIZE TODO: Use a pool of IDC tables??.
*/
}
}
ielem->nbNsBindings = 0;
ielem->sizeNsBindings = 0;
}
}
/**
* xmlSchemaGetFreshElemInfo:
* @vctxt: the schema validation context
*
* the currect tree depth.
*
* Returns the element info item or NULL on API or internal errors.
*/
static xmlSchemaNodeInfoPtr
{
VERROR_INT("xmlSchemaGetFreshElemInfo",
"inconsistent depth encountered");
return (NULL);
}
"allocating the element info array", NULL);
return (NULL);
}
int i = vctxt->sizeElemInfos;
sizeof(xmlSchemaNodeInfoPtr));
"re-allocating the element info array", NULL);
return (NULL);
}
/*
* We need the new memory to be NULLed.
* TODO: Use memset instead?
*/
for (; i < vctxt->sizeElemInfos; i++)
} else
xmlMalloc(sizeof(xmlSchemaNodeInfo));
"allocating an element info", NULL);
return (NULL);
}
} else {
VERROR_INT("xmlSchemaGetFreshElemInfo",
"elem info has not been cleared");
return (NULL);
}
}
return (info);
}
static int
unsigned long length,
int fireErrors)
{
unsigned long len = 0;
/*
* In Libxml2, derived built-in types have currently no explicit facets.
*/
return (0);
/*
* NOTE: Do not jump away, if the facetSet of the given type is
* empty: until now, "pattern" and "enumeration" facets of the
* *base types* need to be checked as well.
*/
goto pattern_and_enum;
if (! WXS_IS_ATOMIC(type)) {
if (WXS_IS_LIST(type))
goto WXS_IS_LIST;
else
goto pattern_and_enum;
}
/*
* Whitespace handling is only of importance for string-based
* types.
*/
} else
/*
* If the value was not computed (for string or
* anySimpleType based types), then use the provided
* type.
*/
else
ret = 0;
/*
* Skip the pattern "whiteSpace": it is used to
* format the character content beforehand.
*/
case XML_SCHEMA_FACET_PATTERN:
continue;
case XML_SCHEMA_FACET_LENGTH:
break;
default:
break;
}
if (ret < 0) {
AERROR_INT("xmlSchemaValidateFacets",
"validating against a atomic type facet");
return (-1);
} else if (ret > 0) {
if (fireErrors)
else
return (ret);
if (error == 0)
}
ret = 0;
}
if (! WXS_IS_LIST(type))
goto pattern_and_enum;
/*
* "length", "minLength" and "maxLength" of list types.
*/
ret = 0;
case XML_SCHEMA_FACET_LENGTH:
break;
default:
continue;
}
if (ret < 0) {
AERROR_INT("xmlSchemaValidateFacets",
"validating against a list type facet");
return (-1);
} else if (ret > 0) {
if (fireErrors)
else
return (ret);
if (error == 0)
}
ret = 0;
}
if (error >= 0) {
int found = 0;
/*
* Process enumerations. Facet values are in the value space
* of the defining type's base type. This seems to be a bug in the
* XML Schema 1.0 spec. Use the whitespace type of the base type.
* Only the first set of enumerations in the ancestor-or-self axis
* is used for validation.
*/
ret = 0;
do {
continue;
found = 1;
if (ret == 1)
break;
else if (ret < 0) {
AERROR_INT("xmlSchemaValidateFacets",
"validating against an enumeration facet");
return (-1);
}
}
if (ret != 0)
break;
/*
* Break on the first set of enumerations. Any additional
* enumerations which might be existent on the ancestors
* of the current type are restricted by this set; thus
* *must* *not* be taken into account.
*/
if (found)
break;
if (fireErrors) {
} else
return (ret);
if (error == 0)
}
}
if (error >= 0) {
int found;
/*
* Process patters. Pattern facets are ORed at type level
* and ANDed if derived. Walk the base type axis.
*/
do {
found = 0;
continue;
found = 1;
/*
* NOTE that for patterns, @value needs to be the
* normalized vaule.
*/
if (ret == 1)
break;
else if (ret < 0) {
AERROR_INT("xmlSchemaValidateFacets",
"validating against a pattern facet");
return (-1);
} else {
/*
* Save the last non-validating facet.
*/
}
}
if (fireErrors) {
} else
return (ret);
if (error == 0)
break;
}
}
return (error);
}
static xmlChar *
{
switch (xmlSchemaGetWhiteSpaceFacetValue(type)) {
return (xmlSchemaCollapseString(value));
return (xmlSchemaWhiteSpaceReplace(value));
default:
return (NULL);
}
}
static int
int valNeeded)
{
int ret;
if (ret != 0) {
if (ret == -1) {
VERROR_INT("xmlSchemaValidateQName",
"calling xmlValidateQName()");
return (-1);
}
return( XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1);
}
/*
* NOTE: xmlSplitQName2 will always return a duplicated
* strings.
*/
/*
* OPTIMIZE TODO: Use flags for:
* - is there any namespace binding?
* - is there a default namespace?
*/
/*
* A namespace must be found if the prefix is
* NOT NULL.
*/
"The QName value '%s' has no "
"corresponding namespace declaration in "
return (ret);
}
}
else
} else
return (0);
}
/*
* cvc-simple-type
*/
static int
int fireErrors,
int normalize,
int isNormalized)
{
/* xmlSchemaWhitespaceValueType ws; */
if ((! isNormalized) && \
isNormalized = 1; \
}
}
/*
* 3.14.4 Simple Type Definition Validation Rules
* Validation Rule: String Valid
*/
/*
* 1 It is schema-valid with respect to that definition as defined
* by Datatype Valid in [XML Schemas: Datatypes].
*/
/*
* 2.1 If The definition is ENTITY or is validly derived from ENTITY given
* the empty set, as defined in Type Derivation OK (Simple) (�3.14.6), then
* the string must be a �declared entity name�.
*/
/*
* 2.2 If The definition is ENTITIES or is validly derived from ENTITIES
* given the empty set, as defined in Type Derivation OK (Simple) (�3.14.6),
* then every whitespace-delimited substring of the string must be a �declared
* entity name�.
*/
/*
* 2.3 otherwise no further condition applies.
*/
valNeeded = 1;
/*
* SPEC (1.2.1) "if {variety} is �atomic� then the string must �match�
* a literal in the �lexical space� of {base type definition}"
*/
/*
* Whitespace-normalize.
*/
/*
* Get the built-in type.
*/
AERROR_INT("xmlSchemaVCheckCVCSimpleType",
"could not get the built-in type");
goto internal_error;
}
} else
/*
* NOTATIONs need to be processed here, since they need
* to lookup in the hashtable of NOTATION declarations of the schema.
*/
switch (biType->builtInType) {
case XML_SCHEMAS_NOTATION:
break;
case XML_SCHEMAS_QNAME:
break;
default:
/* ws = xmlSchemaGetWhiteSpaceFacetValue(type); */
if (valNeeded)
else
break;
}
switch (biType->builtInType) {
case XML_SCHEMAS_NOTATION:
break;
default:
/* ws = xmlSchemaGetWhiteSpaceFacetValue(type); */
if (valNeeded)
else
break;
}
} else {
/*
* Validation via a public API is not implemented yet.
*/
goto internal_error;
}
if (ret != 0) {
if (ret < 0) {
AERROR_INT("xmlSchemaVCheckCVCSimpleType",
"validating against a built-in type");
goto internal_error;
}
if (WXS_IS_LIST(type))
else
}
/*
* Check facets.
*/
0, fireErrors);
if (ret != 0) {
if (ret < 0) {
AERROR_INT("xmlSchemaVCheckCVCSimpleType",
"validating facets of atomic simple type");
goto internal_error;
}
if (WXS_IS_LIST(type))
else
}
}
if (fireErrors && (ret > 0))
} else if (WXS_IS_LIST(type)) {
unsigned long len = 0;
/* 1.2.2 if {variety} is �list� then the string must be a sequence
* of white space separated tokens, each of which �match�es a literal
* in the �lexical space� of {item type definition}
*/
/*
* Note that XML_SCHEMAS_TYPE_NORMVALUENEEDED will be set if
* the list type has an enum or pattern facet.
*/
/*
* VAL TODO: Optimize validation of empty values.
* VAL TODO: We do not have computed values for lists.
*/
do {
while (IS_BLANK_CH(*cur))
cur++;
end++;
break;
len++;
if (valNeeded)
else
/*
* Add to list of computed values.
*/
else
}
if (ret != 0) {
if (ret < 0) {
AERROR_INT("xmlSchemaVCheckCVCSimpleType",
"validating an item of list simple type");
goto internal_error;
}
break;
}
} while (*cur != 0);
/*
* Apply facets (pattern, enumeration).
*/
len, fireErrors);
if (ret != 0) {
if (ret < 0) {
AERROR_INT("xmlSchemaVCheckCVCSimpleType",
"validating facets of list simple type");
goto internal_error;
}
}
}
if (fireErrors && (ret > 0)) {
/*
* Report the normalized value.
*/
normalize = 1;
}
} else if (WXS_IS_UNION(type)) {
/*
* TODO: For all datatypes �derived� by �union� whiteSpace does
* not apply directly; however, the normalization behavior of �union�
* types is controlled by the value of whiteSpace on that one of the
* �memberTypes� against which the �union� is successfully validated.
*
* This means that the value is normalized by the first validating
* member type, then the facets of the union type are applied. This
* needs changing of the value!
*/
/*
* 1.2.3 if {variety} is �union� then the string must �match� a
* literal in the �lexical space� of at least one member of
* {member type definitions}
*/
if (memberLink == NULL) {
AERROR_INT("xmlSchemaVCheckCVCSimpleType",
"union simple type has no member types");
goto internal_error;
}
/*
* Always normalize union type values, since we currently
* cannot store the whitespace information with the value
* itself; otherwise a later value-comparison would be
* not possible.
*/
while (memberLink != NULL) {
if (valNeeded)
else
if (ret <= 0)
break;
}
if (ret != 0) {
if (ret < 0) {
AERROR_INT("xmlSchemaVCheckCVCSimpleType",
"validating members of union simple type");
goto internal_error;
}
}
/*
* Apply facets (pattern, enumeration).
*/
/*
* The normalization behavior of �union� types is controlled by
* the value of whiteSpace on that one of the �memberTypes�
* against which the �union� is successfully validated.
*/
0, fireErrors);
if (ret != 0) {
if (ret < 0) {
AERROR_INT("xmlSchemaVCheckCVCSimpleType",
"validating facets of union simple type");
goto internal_error;
}
}
}
if (fireErrors && (ret > 0))
}
if (ret == 0) {
return (ret);
return (-1);
}
static int
{
int ret = 0;
return (-1);
if (ret == -1)
return (-1);
if (ret > 0) {
return (1);
}
{
/*
* NOTE: xmlSplitQName2 will return a duplicated
* string.
*/
else {
}
/*
* A namespace must be found if the prefix is NOT NULL.
*/
"The QName value '%s' has no "
"corresponding namespace declaration in scope",
return (2);
}
}
}
return (0);
}
static int
{
int ret = 0;
/*
* cvc-elt (3.3.4) : (4)
* AND
* Schema-Validity Assessment (Element) (cvc-assess-elt)
* (1.2.1.2.1) - (1.2.1.2.4)
* Handle 'xsi:type'.
*/
return (-1);
return (0);
else {
/*
* TODO: We should report a *warning* that the type was overriden
* by the instance.
*/
/*
* (cvc-elt) (3.3.4) : (4.1)
* (cvc-assess-elt) (1.2.1.2.2)
*/
if (ret != 0) {
if (ret < 0) {
VERROR_INT("xmlSchemaValidateElementByDeclaration",
"calling xmlSchemaQNameExpand() to validate the "
"attribute 'xsi:type'");
goto internal_error;
}
goto exit;
}
/*
* (cvc-elt) (3.3.4) : (4.2)
* (cvc-assess-elt) (1.2.1.2.3)
*/
"The QName value '%s' of the xsi:type attribute does not "
"resolve to a type definition",
goto exit;
}
int set = 0;
/*
* SPEC cvc-elt (3.3.4) : (4.3) (Type Derivation OK)
* "The �local type definition� must be validly
* derived from the {type definition} given the union of
* the {disallowed substitutions} and the {type definition}'s
* {prohibited substitutions}, as defined in
* Type Derivation OK (Complex) (�3.4.6)
* (if it is a complex type definition),
* or given {disallowed substitutions} as defined in Type
* Derivation OK (Simple) (�3.14.6) (if it is a simple type
* definition)."
*
* {disallowed substitutions}: the "block" on the element decl.
* {prohibited substitutions}: the "block" on the type def.
*/
/*
* OPTIMIZE TODO: We could map types already evaluated
* to be validly derived from other types to avoid checking
* this over and over for the same types.
*/
set |= SUBSET_EXTENSION;
/*
* REMOVED and CHANGED since this produced a parser context
* which adds to the string dict of the schema. So this would
* change the schema and we don't want this. We don't need
* the parser context anymore.
*
* if ((vctxt->pctxt == NULL) &&
* (xmlSchemaCreatePCtxtOnVCtxt(vctxt) == -1))
* return (-1);
*/
"The type definition '%s', specified by xsi:type, is "
"blocked or not validly derived from the type definition "
"of the element declaration",
(*localType)->targetNamespace,
NULL);
}
}
}
exit:
return (ret);
return (-1);
}
static int
{
/*
* cvc-elt (3.3.4) : 1
*/
"No matching declaration available");
}
/*
* cvc-elt (3.3.4) : 2
*/
"The element declaration is abstract");
}
if (actualType == NULL) {
"The type definition is absent");
return (XML_SCHEMAV_CVC_TYPE_1);
}
if (vctxt->nbAttrInfos != 0) {
int ret;
/*
* cvc-elt (3.3.4) : 3
* Handle 'xsi:nil'.
*/
if (iattr) {
/*
* Validate the value.
*/
if (ret < 0) {
VERROR_INT("xmlSchemaValidateElemDecl",
"calling xmlSchemaVCheckCVCSimpleType() to "
"validate the attribute 'xsi:nil'");
return (-1);
}
if (ret == 0) {
/*
* cvc-elt (3.3.4) : 3.1
*/
"The element is not 'nillable'");
/* Does not return an error on purpose. */
} else {
/*
* cvc-elt (3.3.4) : 3.2.2
*/
"The element cannot be 'nilled' because "
"there is a fixed value constraint defined "
"for it");
/* Does not return an error on purpose. */
} else
}
}
}
}
/*
* cvc-elt (3.3.4) : 4
* Handle 'xsi:type'.
*/
if (iattr) {
elemDecl);
if (ret != 0) {
if (ret == -1) {
VERROR_INT("xmlSchemaValidateElemDecl",
"calling xmlSchemaProcessXSIType() to "
"process the attribute 'xsi:type'");
return (-1);
}
/* Does not return an error on purpose. */
}
}
}
}
/*
* IDC: Register identity-constraint XPath matchers.
*/
return (-1);
/*
* No actual type definition.
*/
if (actualType == NULL) {
"The type definition is absent");
return (XML_SCHEMAV_CVC_TYPE_1);
}
/*
* Remember the actual type definition.
*/
return (0);
}
static int
{
int ret = 0, i;
/*
* SPEC cvc-type (3.1.1)
* "The attributes of must be empty, excepting those whose namespace
* name is identical to http://www.w3.org/2001/XMLSchema-instance and
* whose local name is one of type, nil, schemaLocation or
* noNamespaceSchemaLocation."
*/
if (vctxt->nbAttrInfos == 0)
return (0);
for (i = 0; i < vctxt->nbAttrInfos; i++) {
}
}
return (ret);
}
/*
* Cleanup currently used attribute infos.
*/
static void
{
int i;
if (vctxt->nbAttrInfos == 0)
return;
for (i = 0; i < vctxt->nbAttrInfos; i++) {
}
}
}
}
vctxt->nbAttrInfos = 0;
}
/*
* 3.4.4 Complex Type Definition Validation Rules
* Element Locally Valid (Complex Type) (cvc-complex-type)
* 3.2.4 Attribute Declaration Validation Rules
* Validation Rule: Attribute Locally Valid (cvc-attribute)
* Attribute Locally Valid (Use) (cvc-au)
*
* Only "assessed" attribute information items will be visible to
* IDCs. I.e. not "lax" (without declaration) and "skip" wild attributes.
*/
static int
{
/*
* SPEC (cvc-attribute)
* (1) "The declaration must not be �absent� (see Missing
* Sub-components (�5.3) for how this can fail to be
* the case)."
* (2) "Its {type definition} must not be absent."
*
* NOTE (1) + (2): This is not handled here, since we currently do not
* allow validation against schemas which have missing sub-components.
*
* SPEC (cvc-complex-type)
* (3) "For each attribute information item in the element information
* item's [attributes] excepting those whose [namespace name] is
* identical to http://www.w3.org/2001/XMLSchema-instance and whose
* [local name] is one of type, nil, schemaLocation or
* noNamespaceSchemaLocation, the appropriate case among the following
* must be true:
*
*/
/*
* @nbAttrs is the number of attributes present in the instance.
*/
if (attrUseList != NULL)
else
nbUses = 0;
for (i = 0; i < nbUses; i++) {
found = 0;
for (j = 0; j < nbAttrs; j++) {
/*
* SPEC (cvc-complex-type) (3)
* Skip meta attributes.
*/
continue;
continue;
continue;
continue;
found = 1;
/*
* SPEC (cvc-complex-type)
* (3.1) "If there is among the {attribute uses} an attribute
* use with an {attribute declaration} whose {name} matches
* the attribute information item's [local name] and whose
* {target namespace} is identical to the attribute information
* item's [namespace name] (where an �absent� {target namespace}
* is taken to be identical to a [namespace name] with no value),
* then the attribute information must be �valid� with respect
* to that attribute use as per Attribute Locally Valid (Use)
* (�3.5.4). In this case the {attribute declaration} of that
* attribute use is the �context-determined declaration� for the
* attribute information item with respect to Schema-Validity
* Assessment (Attribute) (�3.2.4) and
* Assessment Outcome (Attribute) (�3.2.5).
*/
/*
* Context-determined declaration.
*/
break;
}
if (found)
continue;
/*
* Handle non-existent, required attributes.
*
* SPEC (cvc-complex-type)
* (4) "The {attribute declaration} of each attribute use in
* the {attribute uses} whose {required} is true matches one
* of the attribute information items in the element information
* item's [attributes] as per clause 3.1 above."
*/
"xmlSchemaVAttributesComplex",
"calling xmlSchemaGetFreshAttrInfo()");
return (-1);
}
/*
*/
"xmlSchemaVAttributesComplex",
"calling xmlSchemaGetFreshAttrInfo()");
return (-1);
}
}
}
if (vctxt->nbAttrInfos == 0)
return (0);
/*
* Validate against the wildcard.
*/
/*
* SPEC (cvc-complex-type)
* (3.2.1) "There must be an {attribute wildcard}."
*/
for (i = 0; i < nbAttrs; i++) {
/*
* SPEC (cvc-complex-type) (3)
* Skip meta attributes.
*/
continue;
/*
* SPEC (cvc-complex-type)
* (3.2.2) "The attribute information item must be �valid� with
* respect to it as defined in Item Valid (Wildcard) (�3.10.4)."
*
* SPEC Item Valid (Wildcard) (cvc-wildcard)
* "... its [namespace name] must be �valid� with respect to
* the wildcard constraint, as defined in Wildcard allows
* Namespace Name (�3.10.4)."
*/
/*
* Handle processContents.
*
* SPEC (cvc-wildcard):
* processContents | context-determined declaration:
* "strict" "mustFind"
* "lax" "none"
* "skip" "skip"
*/
/*
* context-determined declaration = "skip"
*
* SPEC PSVI Assessment Outcome (Attribute)
* [validity] = "notKnown"
* [validation attempted] = "none"
*/
continue;
}
/*
* Find an attribute declaration.
*/
/*
* SPEC (cvc-complex-type)
* (5) "Let [Definition:] the wild IDs be the set of
* all attribute information item to which clause 3.2
* applied and whose �validation� resulted in a
* �context-determined declaration� of mustFind or no
* �context-determined declaration� at all, and whose
* [local name] and [namespace name] resolve (as
* defined by QName resolution (Instance) (�3.15.4)) to
* an attribute declaration whose {type definition} is
* or is derived from ID. Then all of the following
* must be true:"
*/
/*
* SPEC (5.1) "There must be no more than one
* item in �wild IDs�."
*/
if (wildIDs != 0) {
/* VAL TODO */
continue;
}
wildIDs++;
/*
* SPEC (cvc-complex-type)
* (5.2) "If �wild IDs� is non-empty, there must not
* be any attribute uses among the {attribute uses}
* whose {attribute declaration}'s {type definition}
* is or is derived from ID."
*/
for (j = 0; j < attrUseList->nbItems; j++) {
XML_SCHEMAS_ID)) {
/* URGENT VAL TODO: implement */
break;
}
}
}
/*
* SPEC PSVI Assessment Outcome (Attribute)
* [validity] = "notKnown"
* [validation attempted] = "none"
*/
} else {
}
}
}
}
if (vctxt->nbAttrInfos == 0)
return (0);
/*
* Get the owner element; needed for creation of default attributes.
* This fixes bug #341337, reported by David Grohmann.
*/
}
/*
* Validate values, create default attributes, evaluate IDCs.
*/
for (i = 0; i < vctxt->nbAttrInfos; i++) {
/*
* VAL TODO: Note that we won't try to resolve IDCs to
* "lax" and "skip" validated attributes. Check what to
* do in this case.
*/
continue;
/*
* VAL TODO: What to do if the type definition is missing?
*/
continue;
}
fixed = 0;
xpathRes = 0;
/*
* Evaluate IDCs.
*/
if (xpathRes == -1) {
VERROR_INT("xmlSchemaVAttributesComplex",
"calling xmlSchemaXPathEvaluate()");
goto internal_error;
}
}
/*
* We need the value only if we need to resolve IDCs or
* will create default attributes.
*/
if ((xpathRes) || (defAttrOwnerElem)) {
} else {
}
/*
* IDCs will consume the precomputed default value,
* so we need to clone it.
*/
VERROR_INT("xmlSchemaVAttributesComplex",
"not precomputed");
goto internal_error;
}
VERROR_INT("xmlSchemaVAttributesComplex",
"calling xmlSchemaCopyValue()");
goto internal_error;
}
}
/*
* PSVI: Add the default attribute to the current element.
* VAL TODO: Should we use the *normalized* value? This currently
* uses the *initial* value.
*/
if (defAttrOwnerElem) {
/*
* Normalize the value.
*/
VERROR_INT("xmlSchemaVAttributesComplex",
"callling xmlNewProp()");
goto internal_error;
}
} else {
int counter = 0;
/*
* Create a namespace declaration on the validation
* root node if no namespace declaration is in scope.
*/
do {
if (counter > 1000) {
"xmlSchemaVAttributesComplex",
"could not compute a ns prefix for a "
goto internal_error;
}
}
/*
* TODO:
* If we have QNames: do we need to ensure there's a
* prefix defined for the QName?
*/
}
}
/*
* Go directly to IDC evaluation.
*/
goto eval_idcs;
}
/*
* Validate the value.
*/
/*
* Free last computed value; just for safety reasons.
*/
}
/*
* Note that the attribute *use* can be unavailable, if
* the attribute was a wild attribute.
*/
fixed = 1;
else
fixed = 0;
/*
* SPEC (cvc-attribute)
* (3) "The item's �normalized value� must be locally �valid�
* with respect to that {type definition} as per
* String Valid (�3.14.4)."
*
* VAL TODO: Do we already have the
* "normalized attribute value" here?
*/
/*
* Request a computed value.
*/
1, 1, 0);
} else {
1, 0, 0);
}
if (res != 0) {
if (res == -1) {
VERROR_INT("xmlSchemaVAttributesComplex",
"calling xmlSchemaStreamValidateSimpleTypeValue()");
goto internal_error;
}
/*
* SPEC PSVI Assessment Outcome (Attribute)
* [validity] = "invalid"
*/
goto eval_idcs;
}
if (fixed) {
/*
* SPEC Attribute Locally Valid (Use) (cvc-au)
* "For an attribute information item to be�valid�
* with respect to an attribute use its *normalized*
* value� must match the *canonical* lexical
* representation of the attribute use's {value
* constraint}value, if it is present and fixed."
*
* VAL TODO: The requirement for the *canonical* value
* will be removed in XML Schema 1.1.
*/
/*
* SPEC Attribute Locally Valid (cvc-attribute)
* (4) "The item's *actual* value� must match the *value* of
* the {value constraint}, if it is present and fixed."
*/
/* VAL TODO: A value was not precomputed. */
goto eval_idcs;
}
/* VAL TODO: A default value was not precomputed. */
goto eval_idcs;
}
/*
if (xmlSchemaCompareValuesWhtsp(attr->val,
(xmlSchemaWhitespaceValueType) ws,
attr->use->defVal,
(xmlSchemaWhitespaceValueType) ws) != 0) {
*/
} else {
/* VAL TODO: A default value was not precomputed. */
goto eval_idcs;
}
/*
if (xmlSchemaCompareValuesWhtsp(attr->val,
(xmlSchemaWhitespaceValueType) ws,
attrDecl->defVal,
(xmlSchemaWhitespaceValueType) ws) != 0) {
*/
}
/*
* [validity] = "valid"
*/
}
/*
* Evaluate IDCs.
*/
if (xpathRes) {
VERROR_INT("xmlSchemaVAttributesComplex",
"calling xmlSchemaXPathEvaluate()");
goto internal_error;
}
}
/*
* Report errors.
*/
for (i = 0; i < vctxt->nbAttrInfos; i++) {
continue;
case XML_SCHEMAS_ATTR_ERR_MISSING: {
"The attribute '%s' is required but missing",
NULL);
break;
}
"The type definition is absent");
break;
"The value '%s' does not match the fixed "
"value constraint '%s'",
break;
"No matching global attribute declaration available, but "
"demanded by the strict wildcard");
break;
case XML_SCHEMAS_ATTR_UNKNOWN:
break;
/*
* MAYBE VAL TODO: One might report different error messages
* for the following errors.
*/
} else {
}
break;
default:
break;
}
}
return (0);
return (-1);
}
static int
int *skip)
{
/*
* The namespace of the element was already identified to be
* matching the wildcard.
*/
VERROR_INT("xmlSchemaValidateElemWildcard",
"bad arguments");
return (-1);
}
*skip = 0;
/*
* URGENT VAL TODO: Either we need to position the stream to the
* next sibling, or walk the whole subtree.
*/
*skip = 1;
return (0);
}
{
return (0);
}
}
/* VAL TODO: Change to proper error code. */
"No matching global element declaration available, but "
"demanded by the strict wildcard");
}
if (vctxt->nbAttrInfos != 0) {
/*
* SPEC Validation Rule: Schema-Validity Assessment (Element)
* (1.2.1.2.1) - (1.2.1.2.3 )
*
* Use the xsi:type attribute for the type definition.
*/
VERROR_INT("xmlSchemaValidateElemWildcard",
"calling xmlSchemaProcessXSIType() to "
"process the attribute 'xsi:nil'");
return (-1);
}
/*
* Don't return an error on purpose.
*/
return (0);
}
}
/*
* SPEC Validation Rule: Schema-Validity Assessment (Element)
*
* Fallback to "anyType".
*/
return (0);
}
/*
* xmlSchemaCheckCOSValidDefault:
*
* value is provided.
*/
static int
{
int ret = 0;
/*
* cos-valid-default:
* Schema Component Constraint: Element Default Valid (Immediate)
* For a string to be a valid default with respect to a type
* definition the appropriate case among the following must be true:
*/
/*
* Complex type.
*
* SPEC (2.1) "its {content type} must be a simple type definition
* or mixed."
* SPEC (2.2.2) "If the {content type} is mixed, then the {content
* type}'s particle must be �emptiable� as defined by
* Particle Emptiable (�3.9.6)."
*/
/* NOTE that this covers (2.2.2) as well. */
"For a string to be a valid default, the type definition "
"must be a simple type or a complex type with simple content "
"or mixed content and a particle emptiable");
return(ret);
}
}
/*
* 1 If the type definition is a simple type definition, then the string
* must be �valid� with respect to that definition as defined by String
* Valid (�3.14.4).
*
* AND
*
* 2.2.1 If the {content type} is a simple type definition, then the
* string must be �valid� with respect to that simple type definition
* as defined by String Valid (�3.14.4).
*/
}
if (ret < 0) {
VERROR_INT("xmlSchemaCheckCOSValidDefault",
"calling xmlSchemaVCheckCVCSimpleType()");
}
return (ret);
}
static void
{
#ifdef DEBUG_CONTENT
{
"AUTOMATON callback for '%s' [declaration]\n",
} else {
"AUTOMATON callback for '%s' [wildcard]\n",
}
}
#endif
}
static int
{
VERROR_INT("xmlSchemaValidatorPushElem",
"calling xmlSchemaGetFreshElemInfo()");
return (-1);
}
vctxt->nbAttrInfos = 0;
return (0);
}
static int
{
return (xmlSchemaVCheckCVCSimpleType(
else
return (xmlSchemaVCheckCVCSimpleType(
}
/*
* Process END of element.
*/
static int
{
int ret = 0;
if (vctxt->nbAttrInfos != 0)
/*
* This element was not expected;
* we will not validate child elements of broken parents.
* Skip validation of all content of the parent.
*/
goto end_elem;
}
/*
* 1. the type definition might be missing if the element was
* error prone
* 2. it might be abstract.
*/
goto end_elem;
}
/*
* Check the content model.
*/
/*
* Workaround for "anyType".
*/
goto character_content;
/*
* Create the regex context.
*/
vctxt);
VERROR_INT("xmlSchemaValidatorPopElem",
"failed to create a regex context");
goto internal_error;
}
#ifdef DEBUG_AUTOMATA
#endif
}
/*
* Get hold of the still expected content, since a further
* call to xmlRegExecPushString() will loose this information.
*/
/*
* Still missing something.
*/
ret = 1;
"Missing child element(s)",
#ifdef DEBUG_AUTOMATA
"AUTOMATON missing ERROR on '%s'\n",
#endif
} else {
/*
* Content model is satisfied.
*/
ret = 0;
#ifdef DEBUG_AUTOMATA
"AUTOMATON succeeded on '%s'\n",
#endif
}
}
}
goto end_elem;
}
/*
* Check character content.
*/
/*
* Speedup if no declaration exists.
*/
}
if (ret < 0) {
VERROR_INT("xmlSchemaValidatorPopElem",
"calling xmlSchemaVCheckCVCSimpleType()");
goto internal_error;
}
goto end_elem;
}
/*
* cvc-elt (3.3.4) : 5
* The appropriate case among the following must be true:
*/
/*
* cvc-elt (3.3.4) : 5.1
* If the declaration has a {value constraint},
* the item has neither element nor character [children] and
* clause 3.2 has not applied, then all of the following must be true:
*/
(! INODE_NILLED(inode))) {
/*
* cvc-elt (3.3.4) : 5.1.1
* If the �actual type definition� is a �local type definition�
* then the canonical lexical representation of the {value constraint}
* value must be a valid default for the �actual type definition� as
* defined in Element Default Valid (Immediate) (�3.3.6).
*/
/*
* NOTE: 'local' above means types acquired by xsi:type.
* NOTE: Although the *canonical* value is stated, it is not
* relevant if canonical or not. Additionally XML Schema 1.1
* will removed this requirement as well.
*/
if (ret != 0) {
if (ret < 0) {
VERROR_INT("xmlSchemaValidatorPopElem",
"calling xmlSchemaCheckCOSValidDefault()");
goto internal_error;
}
goto end_elem;
}
/*
* Stop here, to avoid redundant validation of the value
* (see following).
*/
goto default_psvi;
}
/*
* cvc-elt (3.3.4) : 5.1.2
* The element information item with the canonical lexical
* representation of the {value constraint} value used as its
* �normalized value� must be �valid� with respect to the
* �actual type definition� as defined by Element Locally Valid (Type)
* (�3.3.4).
*/
}
if (ret != 0) {
if (ret < 0) {
VERROR_INT("xmlSchemaValidatorPopElem",
"calling xmlSchemaVCheckCVCSimpleType()");
goto internal_error;
}
goto end_elem;
}
/*
* PSVI: Create a text node on the instance element.
*/
/*
* VAL TODO: Normalize the value.
*/
} else
VERROR_INT("xmlSchemaValidatorPopElem",
"calling xmlNewText()");
goto internal_error;
} else
}
} else if (! INODE_NILLED(inode)) {
/*
* 5.2.1 The element information item must be �valid� with respect
* to the �actual type definition� as defined by Element Locally
* Valid (Type) (�3.3.4).
*/
/*
* SPEC (cvc-type) (3.1)
* "If the type definition is a simple type definition, ..."
* (3.1.3) "If clause 3.2 of Element Locally Valid
* (Element) (�3.3.4) did not apply, then the �normalized value�
* must be �valid� with respect to the type definition as defined
* by String Valid (�3.14.4).
*/
/*
* SPEC (cvc-type) (3.2) "If the type definition is a complex type
* definition, then the element information item must be
* �valid� with respect to the type definition as per
* Element Locally Valid (Complex Type) (�3.4.4);"
*
* SPEC (cvc-complex-type) (2.2)
* "If the {content type} is a simple type definition, ...
* the �normalized value� of the element information item is
* �valid� with respect to that simple type definition as
* defined by String Valid (�3.14.4)."
*/
}
if (ret != 0) {
if (ret < 0) {
VERROR_INT("xmlSchemaValidatorPopElem",
"calling xmlSchemaVCheckCVCSimpleType()");
goto internal_error;
}
goto end_elem;
}
/*
* 5.2.2 If there is a fixed {value constraint} and clause 3.2 has
* not applied, all of the following must be true:
*/
/*
* TODO: We will need a computed value, when comparison is
* done on computed values.
*/
/*
* 5.2.2.1 The element information item must have no element
* information item [children].
*/
"The content must not containt element nodes since "
"there is a fixed value constraint");
goto end_elem;
} else {
/*
* 5.2.2.2 The appropriate case among the following must
* be true:
*/
/*
* 5.2.2.2.1 If the {content type} of the �actual type
* definition� is mixed, then the *initial value* of the
* item must match the canonical lexical representation
* of the {value constraint} value.
*
* ... the *initial value* of an element information
* item is the string composed of, in order, the
* [character code] of each character information item in
* the [children] of that element information item.
*/
/*
* VAL TODO: Report invalid & expected values as well.
* VAL TODO: Implement the canonical stuff.
*/
"The initial value '%s' does not match the fixed "
"value constraint '%s'",
goto end_elem;
}
/*
* 5.2.2.2.2 If the {content type} of the �actual type
* definition� is a simple type definition, then the
* *actual value* of the item must match the canonical
* lexical representation of the {value constraint} value.
*/
/*
* VAL TODO: *actual value* is the normalized value, impl.
* this.
* VAL TODO: Report invalid & expected values as well.
* VAL TODO: Implement a comparison with the computed values.
*/
"The actual value '%s' does not match the fixed "
"value constraint '%s'",
goto end_elem;
}
}
}
}
}
/* TODO: raise error? */
return (0);
}
/*
* Evaluate the history of XPath state objects.
*/
if (inode->appliedXPath &&
goto internal_error;
/*
* MAYBE TODO:
* SPEC (6) "The element information item must be �valid� with
* respect to each of the {identity-constraint definitions} as per
* Identity-constraint Satisfied (�3.11.4)."
*/
/*
* PSVI TODO: If we expose IDC node-tables via PSVI then the tables
* need to be built in any case.
* We will currently build IDC node-tables and bubble them only if
* keyrefs do exist.
*/
/*
* Add the current IDC target-nodes to the IDC node-tables.
*/
{
goto internal_error;
}
/*
* Validate IDC keyrefs.
*/
goto internal_error;
/*
*/
#ifdef DEBUG_IDC_NODE_TABLE
#endif
{
/*
* Merge the IDC node table with the table of the parent node.
*/
goto internal_error;
}
}
/*
* Clear the current ielem.
* VAL TODO: Don't free the PSVI IDC tables if they are
* requested for the PSVI.
*/
/*
* Skip further processing if we are on the validation root.
*/
return (0);
}
/*
* Reset the keyrefDepth if needed.
*/
do {
/*
* depth, this means that we are leaving the scope of the
* top-most keyref IDC which refers to this IDC.
*/
}
}
/*
* VAL TODO: 7 If the element information item is the �validation root�, it must be
*/
return (ret);
return (-1);
}
/*
* 3.4.4 Complex Type Definition Validation Rules
* Validation Rule: Element Locally Valid (Complex Type) (cvc-complex-type)
*/
static int
{
int ret = 0;
VERROR_INT("xmlSchemaValidateChildElem",
"not intended for the validation root");
return (-1);
}
/*
* Handle 'nilled' elements.
*/
if (INODE_NILLED(pielem)) {
/*
* SPEC (cvc-elt) (3.3.4) : (3.2.1)
*/
"Neither character nor element content is allowed, "
"because the element was 'nilled'");
goto unexpected_elem;
}
/*
* Workaround for "anyType": we have currently no content model
* assigned for "anyType", so handle it explicitely.
* "anyType" has an unbounded, lax "any" wildcard.
*/
/*
* Process "xsi:type".
* SPEC (cvc-assess-elt) (1.2.1.2.1) - (1.2.1.2.3)
*/
if (ret != 0) {
if (ret == -1) {
VERROR_INT("xmlSchemaValidateChildElem",
"calling xmlSchemaProcessXSIType() to "
"process the attribute 'xsi:nil'");
return (-1);
}
return (ret);
}
} else {
/*
* Fallback to "anyType".
*
* SPEC (cvc-assess-elt)
* "If the item cannot be �strictly assessed�, [...]
* an element information item's schema validity may be laxly
* assessed if its �context-determined declaration� is not
* skip by �validating� with respect to the �ur-type
* definition� as per Element Locally Valid (Type) (�3.3.4)."
*/
}
}
return (0);
}
switch (ptype->contentType) {
case XML_SCHEMA_CONTENT_EMPTY:
/*
* SPEC (2.1) "If the {content type} is empty, then the
* element information item has no character or element
* information item [children]."
*/
"Element content is not allowed, "
"because the content type is empty");
goto unexpected_elem;
break;
case XML_SCHEMA_CONTENT_MIXED:
case XML_SCHEMA_CONTENT_ELEMENTS: {
/* VAL TODO: Optimized "anyType" validation.*/
VERROR_INT("xmlSchemaValidateChildElem",
"type has elem content but no content model");
return (-1);
}
/*
* Safety belf for evaluation if the cont. model was already
* examined to be invalid.
*/
VERROR_INT("xmlSchemaValidateChildElem",
"validating elem, but elem content is already invalid");
return (-1);
}
/*
* Create the regex context.
*/
vctxt);
VERROR_INT("xmlSchemaValidateChildElem",
"failed to create a regex context");
return (-1);
}
#ifdef DEBUG_AUTOMATA
#endif
}
/*
* SPEC (2.4) "If the {content type} is element-only or mixed,
* then the sequence of the element information item's
* element information item [children], if any, taken in
* order, is �valid� with respect to the {content type}'s
* particle, as defined in Element Sequence Locally Valid
* (Particle) (�3.9.4)."
*/
#ifdef DEBUG_AUTOMATA
if (ret < 0)
"AUTOMATON push ERROR for '%s' on '%s'\n",
else
"AUTOMATON push OK for '%s' on '%s'\n",
#endif
VERROR_INT("xmlSchemaValidateChildElem",
"calling xmlRegExecPushString2()");
return (-1);
}
if (ret < 0) {
"This element is not expected",
goto unexpected_elem;
} else
ret = 0;
}
break;
case XML_SCHEMA_CONTENT_BASIC:
if (WXS_IS_COMPLEX(ptype)) {
/*
* SPEC (cvc-complex-type) (2.2)
* "If the {content type} is a simple type definition, then
* the element information item has no element information
* item [children], ..."
*/
"because the content type is a simple type definition");
} else {
/*
* SPEC (cvc-type) (3.1.2) "The element information item must
* have no element information item [children]."
*/
"because the type definition is simple");
}
goto unexpected_elem;
break;
default:
break;
}
return (ret);
/*
* Pop this element and set the skipDepth to skip
* all further content of the parent element.
*/
return (ret);
}
#define XML_SCHEMA_PUSH_TEXT_PERSIST 1
#define XML_SCHEMA_PUSH_TEXT_CREATED 2
#define XML_SCHEMA_PUSH_TEXT_VOLATILE 3
static int
{
/*
* Unfortunately we have to duplicate the text sometimes.
* OPTIMIZE: Maybe we could skip it, if:
* 1. content type is simple
* 2. whitespace is "collapse"
* 3. it consists of whitespace only
*
* Process character content.
*/
*consumed = 0;
/*
* SPEC cvc-elt (3.3.4 - 3.2.1)
* "The element information item must have no character or
* element information item [children]."
*/
"Neither character nor element content is allowed "
"because the element is 'nilled'");
}
/*
* SPEC (2.1) "If the {content type} is empty, then the
* element information item has no character or element
* information item [children]."
*/
"Character content is not allowed, "
"because the content type is empty");
}
if ((nodeType != XML_TEXT_NODE) ||
/*
* SPEC cvc-complex-type (2.3)
* "If the {content type} is element-only, then the
* element information item has no character information
* item [children] other than those whose [character
* code] is defined as a white space in [XML 1.0 (Second
* Edition)]."
*/
"Character content other than whitespace is not allowed "
"because the content type is 'element-only'");
}
return (0);
}
return (0);
/*
* Save the value.
* NOTE that even if the content type is *mixed*, we need the
*/
return (0);
/*
* Set the value.
*/
switch (mode) {
/*
* When working on a tree.
*/
break;
/*
* When working with the reader.
* The value will be freed by the element info.
*/
*consumed = 1;
break;
/*
* When working with SAX.
* The value will be freed by the element info.
*/
if (len != -1)
else
break;
default:
break;
}
} else {
if (len < 0)
/*
* Concat the value.
*/
} else {
}
}
return (0);
}
static int
{
int ret = 0;
VERROR_INT("xmlSchemaValidateElem",
"in skip-state");
goto internal_error;
}
if (vctxt->xsiAssemble) {
/*
* We will stop validation if there was an error during
* dynamic schema construction.
* Note that we simply set @skipDepth to 0, this could
* mean that a streaming document via SAX would be
* still read to the end but it won't be validated any more.
* TODO: If we are sure how to stop the validation at once
* for all input scenarios, then this should be changed to
* instantly stop the validation.
*/
if (ret != 0) {
if (ret == -1)
goto internal_error;
return(ret);
}
}
/*
* Validate this element against the content model
* of the parent.
*/
if (ret != 0) {
if (ret < 0) {
VERROR_INT("xmlSchemaValidateElem",
"calling xmlSchemaStreamValidateChildElement()");
goto internal_error;
}
goto exit;
}
goto exit;
VERROR_INT("xmlSchemaValidateElem",
"the child element was valid but neither the "
"declaration nor the type was set");
goto internal_error;
}
} else {
/*
* Get the declaration of the validation root.
*/
"No matching global declaration available "
"for the validation root");
goto exit;
}
}
goto type_validation;
int skip;
/*
* Wildcards.
*/
if (ret != 0) {
if (ret < 0) {
VERROR_INT("xmlSchemaValidateElem",
"calling xmlSchemaValidateElemWildcard()");
goto internal_error;
}
goto exit;
}
if (skip) {
goto exit;
}
/*
* The declaration might be set by the wildcard validation,
* when the processContents is "lax" or "strict".
*/
/*
* Clear the "decl" field to not confuse further processing.
*/
goto type_validation;
}
}
/*
* Validate against the declaration.
*/
if (ret != 0) {
if (ret < 0) {
VERROR_INT("xmlSchemaValidateElem",
"calling xmlSchemaValidateElemDecl()");
goto internal_error;
}
goto exit;
}
/*
* Validate against the type definition.
*/
"The type definition is absent");
goto exit;
}
"The type definition is abstract");
goto exit;
}
/*
* Evaluate IDCs. Do it here, since new IDC matchers are registered
* during validation against the declaration. This must be done
* _before_ attribute validation.
*/
if (ret == -1) {
VERROR_INT("xmlSchemaValidateElem",
"calling xmlSchemaXPathEvaluate()");
goto internal_error;
}
}
/*
* Validate attributes.
*/
if ((vctxt->nbAttrInfos != 0) ||
}
} else if (vctxt->nbAttrInfos != 0) {
}
/*
* Clear registered attributes.
*/
if (vctxt->nbAttrInfos != 0)
if (ret == -1) {
VERROR_INT("xmlSchemaValidateElem",
"calling attributes validation");
goto internal_error;
}
/*
* Don't return an error if attributes are invalid on purpose.
*/
ret = 0;
exit:
if (ret != 0)
return (ret);
return (-1);
}
#ifdef XML_SCHEMA_READER_ENABLED
static int
{
/*
* Move to the document element.
*/
while (ret == 1) {
if (nodeType == XML_ELEMENT_NODE)
goto root_found;
}
goto exit;
do {
if (nodeType == XML_ELEMENT_NODE) {
VERROR_INT("xmlSchemaVReaderWalk",
"calling xmlSchemaValidatorPushElem()");
goto internal_error;
}
/*
* Is the element empty?
*/
if (ret == -1) {
VERROR_INT("xmlSchemaVReaderWalk",
"calling xmlTextReaderIsEmptyElement()");
goto internal_error;
}
if (ret) {
}
/*
* Register attributes.
*/
vctxt->nbAttrInfos = 0;
if (ret == -1) {
VERROR_INT("xmlSchemaVReaderWalk",
"calling xmlTextReaderMoveToFirstAttribute()");
goto internal_error;
}
if (ret == 1) {
do {
/*
* VAL TODO: How do we know that the reader works on a
* node tree, to be able to pass a node here?
*/
VERROR_INT("xmlSchemaVReaderWalk",
"calling xmlSchemaValidatorPushAttribute()");
goto internal_error;
}
if (ret == -1) {
VERROR_INT("xmlSchemaVReaderWalk",
"calling xmlTextReaderMoveToFirstAttribute()");
goto internal_error;
}
} while (ret == 1);
/*
* Back to element position.
*/
if (ret == -1) {
VERROR_INT("xmlSchemaVReaderWalk",
"calling xmlTextReaderMoveToElement()");
goto internal_error;
}
}
/*
* Validate the element.
*/
if (ret != 0) {
if (ret == -1) {
VERROR_INT("xmlSchemaVReaderWalk",
"calling xmlSchemaValidateElem()");
goto internal_error;
}
goto exit;
}
int curDepth;
/*
* Skip all content.
*/
}
if (ret < 0) {
/*
* VAL TODO: A reader error occured; what to do here?
*/
ret = 1;
goto exit;
}
}
goto leave_elem;
}
/*
* READER VAL TODO: Is an END_ELEM really never called
* if the elem is empty?
*/
goto leave_elem;
/*
* Process END of element.
*/
if (ret != 0) {
if (ret < 0) {
VERROR_INT("xmlSchemaVReaderWalk",
"calling xmlSchemaValidatorPopElem()");
goto internal_error;
}
goto exit;
}
else
} else if ((nodeType == XML_TEXT_NODE) ||
(nodeType == XML_CDATA_SECTION_NODE) ||
(nodeType == SIGN_WHTSP)) {
/*
* Process character content.
*/
if (! consumed)
if (ret == -1) {
VERROR_INT("xmlSchemaVReaderWalk",
"calling xmlSchemaVPushText()");
goto internal_error;
}
} else if ((nodeType == XML_ENTITY_NODE) ||
(nodeType == XML_ENTITY_REF_NODE)) {
/*
* VAL TODO: What to do with entities?
*/
}
/*
* Read next node.
*/
} while (ret == 1);
exit:
return (ret);
return (-1);
}
#endif
/************************************************************************
* *
* SAX validation handlers *
* *
************************************************************************/
/*
* Process text content.
*/
static void
xmlSchemaSAXHandleText(void *ctx,
int len)
{
return;
return;
VERROR_INT("xmlSchemaSAXHandleCDataSection",
"calling xmlSchemaVPushText()");
}
}
/*
* Process CDATA content.
*/
static void
int len)
{
return;
return;
VERROR_INT("xmlSchemaSAXHandleCDataSection",
"calling xmlSchemaVPushText()");
}
}
static void
{
return;
return;
/* SAX VAL TODO: What to do here? */
}
static void
int nb_namespaces,
const xmlChar ** namespaces,
int nb_attributes,
const xmlChar ** attributes)
{
int ret;
int i, j;
/*
* SAX VAL TODO: What to do with nb_defaulted?
*/
/*
* Skip elements if inside a "skip" wildcard or invalid.
*/
return;
/*
* Push the element.
*/
VERROR_INT("xmlSchemaSAXHandleStartElementNs",
"calling xmlSchemaValidatorPushElem()");
goto internal_error;
}
/*
* TODO: Is this OK?
*/
/*
* Register namespaces on the elem info.
*/
if (nb_namespaces != 0) {
/*
* Although the parser builds its own namespace list,
* we have no access to it, so we'll use an own one.
*/
for (i = 0, j = 0; i < nb_namespaces; i++, j += 2) {
/*
* Store prefix and namespace name.
*/
ielem->nsBindings =
sizeof(const xmlChar *));
"allocating namespace bindings for SAX validation",
NULL);
goto internal_error;
}
ielem->nbNsBindings = 0;
ielem->nsBindings =
(const xmlChar **) xmlRealloc(
(void *) ielem->nsBindings,
"re-allocating namespace bindings for SAX validation",
NULL);
goto internal_error;
}
}
if (namespaces[j+1][0] == 0) {
/*
* Handle xmlns="".
*/
} else
namespaces[j+1];
ielem->nbNsBindings++;
}
}
/*
* Register attributes.
* SAX VAL TODO: We are not adding namespace declaration
* attributes yet.
*/
if (nb_attributes != 0) {
for (j = 0, i = 0; i < nb_attributes; i++, j += 5) {
/*
* Duplicate the value.
*/
/*
* TODO: Set the node line.
*/
value, 1);
if (ret == -1) {
VERROR_INT("xmlSchemaSAXHandleStartElementNs",
"calling xmlSchemaValidatorPushAttribute()");
goto internal_error;
}
}
}
/*
* Validate the element.
*/
if (ret != 0) {
if (ret == -1) {
VERROR_INT("xmlSchemaSAXHandleStartElementNs",
"calling xmlSchemaValidateElem()");
goto internal_error;
}
goto exit;
}
exit:
return;
return;
}
static void
{
int res;
/*
* Skip elements if inside a "skip" wildcard or if invalid.
*/
return;
} else
}
/*
* SAX VAL TODO: Just a temporary check.
*/
VERROR_INT("xmlSchemaSAXHandleEndElementNs",
"elem pop mismatch");
}
if (res != 0) {
if (res < 0) {
VERROR_INT("xmlSchemaSAXHandleEndElementNs",
"calling xmlSchemaValidatorPopElem()");
goto internal_error;
}
goto exit;
}
exit:
return;
return;
}
/************************************************************************
* *
* Validation interfaces *
* *
************************************************************************/
/**
* xmlSchemaNewValidCtxt:
* @schema: a precompiled XML Schemas
*
* Create an XML Schemas validation context based on the given schema.
*
* Returns the validation context or NULL in case of error
*/
{
return (NULL);
}
return (ret);
}
/**
* xmlSchemaClearValidCtxt:
* @ctxt: the schema validation context
*
* Free the resources associated to the schema validation context;
* leaves some fields alive intended for reuse of the context.
*/
static void
{
return;
/*
* TODO: Should we clear the flags?
* Might be problematic if one reuses the context
* and assumes that the options remain the same.
*/
#ifdef LIBXML_READER_ENABLED
#endif
vctxt->hasKeyrefs = 0;
}
/*
* Augmented IDC information.
*/
do {
}
while (matcher) {
}
}
int i;
for (i = 0; i < vctxt->nbIdcNodes; i++) {
}
vctxt->nbIdcNodes = 0;
vctxt->sizeIdcNodes = 0;
}
/*
* Note that we won't delete the XPath state pool here.
*/
}
/*
* Attribute info.
*/
if (vctxt->nbAttrInfos != 0) {
}
/*
* Element info.
*/
int i;
for (i = 0; i < vctxt->sizeElemInfos; i++) {
break;
}
}
/* Recreate the dict. */
/*
* TODO: Is is save to recreate it? Do we have a scenario
* where the user provides the dict?
*/
}
/**
* xmlSchemaFreeValidCtxt:
* @ctxt: the schema validation context
*
* Free the resources associated to the schema validation context
*/
void
{
return;
int i;
for (i = 0; i < ctxt->nbIdcNodes; i++) {
}
}
int i;
}
}
}
/*
* Augmented IDC information.
*/
do {
}
int i;
/* Just a paranoid call to the cleanup. */
if (ctxt->nbAttrInfos != 0)
for (i = 0; i < ctxt->sizeAttrInfos; i++) {
}
}
int i;
for (i = 0; i < ctxt->sizeElemInfos; i++) {
break;
}
}
}
/**
* xmlSchemaIsValid:
* @ctxt: the schema validation context
*
* Check if any error was detected during validation.
*
* Returns 1 if valid so far, 0 if errors were detected, and -1 in case
* of internal error.
*/
int
{
return(-1);
}
/**
* xmlSchemaSetValidErrors:
* @ctxt: a schema validation context
* @err: the error function
* @warn: the warning function
* @ctx: the functions context
*
* Set the error and warning callback informations
*/
void
{
return;
}
/**
* xmlSchemaSetValidStructuredErrors:
* @ctxt: a schema validation context
* @serror: the structured error function
* @ctx: the functions context
*
* Set the structured error callback
*/
void
{
return;
}
/**
* xmlSchemaGetValidErrors:
* @ctxt: a XML-Schema 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);
}
/**
* xmlSchemaSetValidOptions:
* @ctxt: a schema validation context
* @options: a combination of xmlSchemaValidOption
*
* Sets the options to be used during the validation.
*
* Returns 0 in case of success, -1 in case of an
* API error.
*/
int
int options)
{
int i;
return (-1);
/*
* WARNING: Change the start value if adding to the
* xmlSchemaValidOption.
* TODO: Is there an other, more easy to maintain,
* way?
*/
for (i = 1; i < (int) sizeof(int) * 8; i++) {
if (options & 1<<i)
return (-1);
}
return (0);
}
/**
* xmlSchemaValidCtxtGetOptions:
* @ctxt: a schema validation context
*
* Get the validation context options.
*
* Returns the option combination or -1 on error.
*/
int
{
return (-1);
else
}
static int
{
int ret = 0;
/* DOC VAL TODO: Move this to the start function. */
/* VAL TODO: Error code? */
return (1);
}
goto next_sibling;
/*
* Init the node-info.
*/
goto internal_error;
/*
* Register attributes.
* DOC VAL TODO: We do not register namespace declaration
* attributes yet.
*/
vctxt->nbAttrInfos = 0;
do {
else
(xmlNodePtr) attr,
/*
* Note that we give it the line number of the
* parent element.
*/
if (ret == -1) {
VERROR_INT("xmlSchemaDocWalk",
"calling xmlSchemaValidatorPushAttribute()");
goto internal_error;
}
} while (attr);
}
/*
* Validate the element.
*/
if (ret != 0) {
if (ret == -1) {
VERROR_INT("xmlSchemaDocWalk",
"calling xmlSchemaValidateElem()");
goto internal_error;
}
/*
* Don't stop validation; just skip the content
* of this element.
*/
goto leave_node;
}
goto leave_node;
/*
* Process character content.
*/
if (ret < 0) {
VERROR_INT("xmlSchemaVDocWalk",
"calling xmlSchemaVPushText()");
goto internal_error;
}
/*
* DOC VAL TODO: Should we skip further validation of the
* element content here?
*/
/*
* DOC VAL TODO: What to do with entities?
*/
VERROR_INT("xmlSchemaVDocWalk",
"there is at least one entity reference in the node-tree "
"currently being validated. Processing of entities with "
"this XML Schema processor is not supported (yet). Please "
"substitute entities before validation.");
goto internal_error;
} else {
goto leave_node;
/*
* DOC VAL TODO: XInclude nodes, etc.
*/
}
/*
* Walk the doc.
*/
continue;
}
/*
* Leaving the scope of an element.
*/
VERROR_INT("xmlSchemaVDocWalk",
"element position mismatch");
goto internal_error;
}
if (ret != 0) {
if (ret < 0) {
VERROR_INT("xmlSchemaVDocWalk",
"calling xmlSchemaValidatorPopElem()");
goto internal_error;
}
}
goto exit;
}
else {
goto leave_node;
}
}
exit:
return (ret);
return (-1);
}
static int
/*
* Some initialization.
*/
vctxt->xsiAssemble = 0;
vctxt->hasKeyrefs = 0;
#ifdef ENABLE_IDC_NODE_TABLES_TEST
#else
vctxt->createIDCNodeTables = 0;
#endif
/*
* Create a schema + parser if necessary.
*/
/*
* If not schema was given then we will create a schema
* dynamically using XSI schema locations.
*
* Create the schema parser context.
*/
return (-1);
/*
* Create the schema.
*/
return (-1);
/*
* Create the schema construction context.
*/
return(-1);
/*
* Take ownership of the constructor to be able to free it.
*/
}
/*
* Augment the IDC definitions for the main schema and all imported ones
* NOTE: main schema if the first in the imported list
*/
return(0);
}
static void
if (vctxt->xsiAssemble) {
}
}
}
static int
{
int ret = 0;
if (xmlSchemaPreRun(vctxt) < 0)
return(-1);
/*
* Tree validation.
*/
#ifdef LIBXML_READER_ENABLED
/*
* XML Reader validation.
*/
#ifdef XML_SCHEMA_READER_ENABLED
#endif
#endif
/*
* SAX validation.
*/
} else {
VERROR_INT("xmlSchemaVStart",
"no instance to validate");
ret = -1;
}
if (ret == 0)
return (ret);
}
/**
* xmlSchemaValidateOneElement:
* @ctxt: a schema validation context
* @elem: an element node
*
* Validate a branch of a tree, starting with the given @elem.
*
* Returns 0 if the element and its subtree is valid, a positive error
* code number otherwise and -1 in case of an internal or API error.
*/
int
{
return (-1);
return (-1);
return(xmlSchemaVStart(ctxt));
}
/**
* xmlSchemaValidateDoc:
* @ctxt: a schema validation context
* @doc: a parsed document tree
*
* Validate a document tree in memory.
*
* Returns 0 if the document is schemas valid, a positive error code
* number otherwise and -1 in case of internal or API error.
*/
int
{
return (-1);
}
return (xmlSchemaVStart(ctxt));
}
/************************************************************************
* *
* Function and data for SAX streaming API *
* *
************************************************************************/
typedef struct _xmlSchemaSplitSAXData xmlSchemaSplitSAXData;
struct _xmlSchemaSplitSAXData {
void *user_data;
};
#define XML_SAX_PLUG_MAGIC 0xdc43ba21
struct _xmlSchemaSAXPlug {
unsigned int magic;
/* the original callbacks informations */
void **user_data_ptr;
void *user_data;
/* the block plugged back and validation informations */
};
/* All those functions just bounces to the user provided SAX handlers */
static void
{
SystemID);
}
static int
isStandaloneSplit(void *ctx)
{
return(0);
}
static int
hasInternalSubsetSplit(void *ctx)
{
return(0);
}
static int
hasExternalSubsetSplit(void *ctx)
{
return(0);
}
static void
{
SystemID);
}
static xmlParserInputPtr
{
systemId));
return(NULL);
}
static xmlEntityPtr
{
return(NULL);
}
static xmlEntityPtr
{
return(NULL);
}
static void
{
}
static void
{
} else {
}
}
static void
{
}
static void
{
systemId);
}
static void
const xmlChar *notationName)
{
}
static void
{
}
static void
startDocumentSplit(void *ctx)
{
}
static void
endDocumentSplit(void *ctx)
{
}
static void
{
}
static void
{
}
/*
* Varargs error callbacks to the user application, harder ...
*/
static void XMLCDECL
}
}
static void XMLCDECL
}
}
static void XMLCDECL
}
}
/*
* Those are function where both the user handler and the schemas handler
* need to be called.
*/
static void
{
return;
}
static void
{
return;
}
static void
{
return;
}
static void
{
return;
}
static void
int nb_attributes, int nb_defaulted,
const xmlChar ** attributes) {
return;
}
static void
return;
}
/**
* xmlSchemaSAXPlug:
* @ctxt: a schema validation context
* @sax: a pointer to the original xmlSAXHandlerPtr
* @user_data: a pointer to the original SAX user data pointer
*
* Plug a SAX based validation layer in a SAX parsing event flow.
* The original @saxptr and @dataptr data are replaced by new pointers
* but the calls to the original will be maintained.
*
* Returns a pointer to a data structure needed to unplug the validation layer
* or NULL in case of errors.
*/
{
return(NULL);
/*
* We only allow to plug into SAX2 event streams
*/
return(NULL);
return(NULL);
/*
* everything seems right allocate the local data needed for that layer
*/
return(NULL);
}
/*
* go direct, no need for the split block and functions.
*/
/*
* Note that we use the same text-function for both, to prevent
* the parser from testing for ignorable whitespace.
*/
} else {
/*
* for each callback unused by Schemas initialize it to the Split
* routine only if non NULL in the user block, this can speed up
* things at the SAX level.
*/
/*
* the 6 schemas callback have to go to the splitter functions
* Note that we use the same text-function for ignorableWhitespace
* if possible, to prevent the parser from testing for ignorable
* whitespace.
*/
else
}
/*
* plug the pointers back.
*/
return(ret);
}
/**
* xmlSchemaSAXUnplug:
* @plug: a data structure returned by xmlSchemaSAXPlug
*
* Unplug a SAX based validation layer in a SAX parsing event flow.
* The original pointers used in the call are restored.
*
* Returns 0 in case of success and -1 in case of failure.
*/
int
{
void **user_data;
return(-1);
/* restore the data */
}
/* free and return */
return(0);
}
/**
* xmlSchemaValidateStream:
* @ctxt: a schema validation context
* @input: the input to use for reading the data
* @enc: an optional encoding information
* @sax: a SAX handler for the resulting events
* @user_data: the context to provide to the SAX handler.
*
* Validate an input based on a flow of SAX event from the parser
* and forward the events to the @sax handler with the provided @user_data
* the user provided @sax handler must be a SAX2 one.
*
* Returns 0 if the document is schemas valid, a positive error code
* number otherwise and -1 in case of internal or API error.
*/
int
{
int ret;
return (-1);
/*
* prepare the parser
*/
pctxt = xmlNewParserCtxt();
return (-1);
#if 0
if (options)
#endif
if (inputStream == NULL) {
ret = -1;
goto done;
}
/*
* Plug the validation and launch the parsing
*/
ret = -1;
goto done;
}
if (ret == 0)
ret = 1;
}
done:
}
/* cleanup */
}
return (ret);
}
/**
* xmlSchemaValidateFile:
* @ctxt: a schema validation context
* @filename: the URI of the instance
* @options: a future set of options, currently unused
*
* Do a schemas validation of the given resource, it will use the
* SAX streamable validation internally.
*
* Returns 0 if the document is valid, a positive error code
* number otherwise and -1 in case of an internal or API error.
*/
int
const char * filename,
int options ATTRIBUTE_UNUSED)
{
int ret;
return (-1);
return (-1);
return (ret);
}
#define bottom_xmlschemas
#include "elfgcchack.h"
#endif /* LIBXML_SCHEMAS_ENABLED */