📄 xmlschemas.c
字号:
/** * xmlSchemaPSVIIDCBinding: * * The identity-constraint binding item of the [identity-constraint table]. */typedef struct _xmlSchemaPSVIIDCBinding xmlSchemaPSVIIDCBinding;typedef xmlSchemaPSVIIDCBinding *xmlSchemaPSVIIDCBindingPtr;struct _xmlSchemaPSVIIDCBinding { xmlSchemaPSVIIDCBindingPtr next; /* next binding of a specific node */ xmlSchemaIDCPtr definition; /* the IDC definition */ xmlSchemaPSVIIDCNodePtr *nodeTable; /* array of key-sequences */ int nbNodes; /* number of entries in the node table */ int sizeNodes; /* size of the node table */ int nbDupls; /* number of already identified duplicates in the node table */ /* int nbKeys; number of keys in each key-sequence */};#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 -3typedef 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; xmlSchemaIDCStateObjPtr next; /* next if in a list */ int depth; /* depth of creation */ int *history; /* list of (depth, state-id) tuples */ int nbHistory; int sizeHistory; xmlSchemaIDCMatcherPtr matcher; /* the correspondent field/selector matcher */ xmlSchemaIDCSelectPtr sel; void *xpathCtxt;};#define IDC_MATCHER 0/** * xmlSchemaIDCMatcher: * * Used to IDC selectors (and fields) successively. */struct _xmlSchemaIDCMatcher { int type; int depth; /* the tree depth at creation time */ xmlSchemaIDCMatcherPtr next; /* next in the list */ xmlSchemaIDCAugPtr aidc; /* the augmented IDC item */ xmlSchemaPSVIIDCKeyPtr **keySeqs; /* the key-sequences of the target elements */ int sizeKeySeqs; int targetDepth;};/** Element info flags.*/#define XML_SCHEMA_ELEM_INFO_VALUE_NEEDED 1/* #define XML_SCHEMA_ELEM_INFO_ATTR 2 *//* #define XML_SCHEMA_ELEM_INFO_ELEM 4 *//** * xmlSchemaNodeInfo: * * Holds information of an element node. */typedef struct _xmlSchemaNodeInfo xmlSchemaNodeInfo;typedef xmlSchemaNodeInfo *xmlSchemaNodeInfoPtr;struct _xmlSchemaNodeInfo { int depth; int flags; /* combination of node info flags */ xmlNodePtr node; const xmlChar *localName; const xmlChar *namespaceName; xmlSchemaTypePtr typeDef; /* the complex/simple type definition if any */ xmlSchemaTypePtr decl; /* the element/attribute declaration */ xmlSchemaValPtr value; /* the pre-computed value if any */ xmlSchemaPSVIIDCBindingPtr idcTable; /* the table of PSVI IDC bindings for the scope element*/ xmlSchemaIDCMatcherPtr idcMatchers; /* the IDC matchers for the scope element */};#define XML_SCHEMA_VALID_INVALID_NEG_WILDCARD 1<<0/** * xmlSchemaValidCtxt: * * A Schemas validation context */struct _xmlSchemaValidCtxt { void *userData; /* user specific data block */ xmlSchemaValidityErrorFunc error; /* the callback in case of errors */ xmlSchemaValidityWarningFunc warning; /* the callback in case of warning */ xmlStructuredErrorFunc serror; xmlSchemaPtr schema; /* The schema in use */ xmlDocPtr doc; xmlParserInputBufferPtr input; xmlCharEncoding enc; xmlSAXHandlerPtr sax; void *user_data; xmlDocPtr myDoc; int err; int nberrors; xmlNodePtr node; xmlNodePtr cur; xmlSchemaTypePtr type; xmlRegExecCtxtPtr regexp; xmlSchemaValPtr value; xmlSchemaAttrStatePtr attrTop; xmlSchemaAttrStatePtr attr; /* xmlNodePtr scope; not used */ int valueWS; int options; xmlNodePtr validationRoot; xmlSchemaParserCtxtPtr pctxt; int xsiAssemble; int depth; xmlSchemaNodeInfoPtr *elemInfos; /* array of element informations */ int sizeElemInfos; xmlSchemaNodeInfoPtr nodeInfo; /* the current element information */ xmlSchemaNodeInfoPtr attrInfo; /* node infor for the current attribute */ xmlSchemaIDCAugPtr aidcs; /* a list of augmented IDC informations */ xmlSchemaIDCStateObjPtr xpathStates; /* first active state object. */ xmlSchemaIDCStateObjPtr xpathStatePool; /* first stored state object. */ xmlSchemaPSVIIDCNodePtr *idcNodes; /* list of all IDC node-table entries*/ int nbIdcNodes; int sizeIdcNodes; xmlSchemaPSVIIDCKeyPtr *idcKeys; /* list of all IDC node-table entries */ int nbIdcKeys; int sizeIdcKeys; int flags;};/* * These are the entries in the schemas importSchemas hash table */typedef struct _xmlSchemaImport xmlSchemaImport;typedef xmlSchemaImport *xmlSchemaImportPtr;struct _xmlSchemaImport { const xmlChar *schemaLocation; xmlSchemaPtr schema; /* not used any more */ xmlDocPtr doc; int isMain;};/* * These are the entries associated to includes in a schemas */typedef struct _xmlSchemaInclude xmlSchemaInclude;typedef xmlSchemaInclude *xmlSchemaIncludePtr;struct _xmlSchemaInclude { xmlSchemaIncludePtr next; const xmlChar *schemaLocation; xmlDocPtr doc; const xmlChar *origTargetNamespace; const xmlChar *targetNamespace;};/************************************************************************ * * * Some predeclarations * * * ************************************************************************/static int xmlSchemaParseInclude(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, xmlNodePtr node);static voidxmlSchemaTypeFixup(xmlSchemaTypePtr typeDecl, xmlSchemaParserCtxtPtr ctxt, const xmlChar * name);static const xmlChar *xmlSchemaFacetTypeToString(xmlSchemaTypeType type);static intxmlSchemaValidateSimpleTypeValue(xmlSchemaValidCtxtPtr ctxt, xmlSchemaTypePtr type, const xmlChar *value, int fireErrors, int applyFacets, int normalize, int checkNodes);static intxmlSchemaValidateElementByDeclaration(xmlSchemaValidCtxtPtr ctxt, xmlSchemaElementPtr elemDecl); static intxmlSchemaValidateElementByWildcard(xmlSchemaValidCtxtPtr ctxt, xmlSchemaWildcardPtr wild);static intxmlSchemaHasElemOrCharContent(xmlNodePtr node);static intxmlSchemaParseImport(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, xmlNodePtr node);static voidxmlSchemaCheckFacetValues(xmlSchemaTypePtr typeDecl, xmlSchemaParserCtxtPtr ctxt);static voidxmlSchemaClearValidCtxt(xmlSchemaValidCtxtPtr vctxt);static intxmlSchemaPostCreateVal(xmlSchemaValidCtxtPtr vctxt, xmlSchemaTypePtr type, const xmlChar *value, xmlSchemaValPtr *val);static xmlSchemaTypePtrxmlSchemaGetSimpleContentType(xmlSchemaTypePtr complexType);static intxmlSchemaGetWhiteSpaceFacetValue(xmlSchemaTypePtr type);static xmlSchemaTreeItemPtrxmlSchemaParseModelGroup(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, xmlNodePtr node, xmlSchemaTypeType type, int withParticle);static const xmlChar *xmlSchemaCompTypeToString(xmlSchemaTypeType type);static xmlSchemaTypeLinkPtrxmlSchemaGetUnionSimpleTypeMemberTypes(xmlSchemaTypePtr type);/************************************************************************ * * * Datatype error handlers * * * ************************************************************************//** * xmlSchemaPErrMemory: * @node: a context node * @extra: extra informations * * Handle an out of memory condition */static voidxmlSchemaPErrMemory(xmlSchemaParserCtxtPtr ctxt, const char *extra, xmlNodePtr node){ if (ctxt != NULL) ctxt->nberrors++; __xmlSimpleError(XML_FROM_SCHEMASP, XML_ERR_NO_MEMORY, node, NULL, 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 voidxmlSchemaPErr(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error, const char *msg, const xmlChar * str1, const xmlChar * str2){ xmlGenericErrorFunc channel = NULL; xmlStructuredErrorFunc schannel = NULL; void *data = NULL; if (ctxt != NULL) { ctxt->nberrors++; channel = ctxt->error; data = ctxt->userData; schannel = ctxt->serror; } __xmlRaiseError(schannel, channel, data, ctxt, node, XML_FROM_SCHEMASP, error, XML_ERR_ERROR, NULL, 0, (const char *) str1, (const char *) str2, NULL, 0, 0, msg, str1, str2);}/** * 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 voidxmlSchemaPErr2(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, xmlNodePtr child, int error, const char *msg, const xmlChar * str1, const xmlChar * str2){ if (child != NULL) xmlSchemaPErr(ctxt, child, error, msg, str1, str2); else xmlSchemaPErr(ctxt, node, error, msg, str1, str2);}/** * 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 voidxmlSchemaPErrExt(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error, const xmlChar * strData1, const xmlChar * strData2, const xmlChar * strData3, const char *msg, const xmlChar * str1, const xmlChar * str2, const xmlChar * str3, const xmlChar * str4, const xmlChar * str5){ xmlGenericErrorFunc channel = NULL; xmlStructuredErrorFunc schannel = NULL; void *data = NULL; if (ctxt != NULL) { ctxt->nberrors++; channel = ctxt->error; data = ctxt->userData; schannel = ctxt->serror; } __xmlRaiseError(schannel, channel, data, ctxt, node, XML_FROM_SCHEMASP, error, XML_ERR_ERROR, NULL, 0, (const char *) strData1, (const char *) strData2, (const char *) strData3, 0, 0, msg, str1, str2, str3, str4, str5);}/** * xmlSchemaVTypeErrMemory: * @node: a context node * @extra: extra informations * * Handle an out of memory condition */static voidxmlSchemaVErrMemory(xmlSchemaValidCtxtPtr ctxt, const char *extra, xmlNodePtr node){ if (ctxt != NULL) { ctxt->nberrors++; ctxt->err = XML_SCHEMAV_INTERNAL; } __xmlSimpleError(XML_FROM_SCHEMASV, XML_ERR_NO_MEMORY, node, NULL, extra);}/** * xmlSchemaVErr3: * @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 voidxmlSchemaVErr3(xmlSchemaValidCtxtPtr ctxt, xmlNodePtr node, int error, const char *msg, const xmlChar *str1, const xmlChar *str2, const xmlChar *str3){ xmlStructuredErrorFunc schannel = NULL; xmlGenericErrorFunc channel = NULL; void *data = NULL; if (ctxt != NULL) { ctxt->nberrors++; ctxt->err = error; channel = ctxt->error; schannel = ctxt->serror; data = ctxt->userData; } /* reajust to global error numbers */ /* Removed, since the old schema error codes have been * substituted for the global error codes. * * error += XML_SCHEMAV_NOROOT - XML_SCHEMAS_ERR_NOROOT; */ __xmlRaiseError(schannel, channel, data, ctxt, node, XML_FROM_SCHEMASV, error, XML_ERR_ERROR, NULL, 0, (const char *) str1, (const char *) str2, (const char *) str3, 0, 0, msg, str1, str2, str3);}/** * xmlSchemaVErrExt: * @ctxt: the validation context * @node: the context node * @error: the error code * @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 validation error */static voidxmlSchemaVErrExt(xmlSchemaValidCtxtPtr ctxt, xmlNodePtr node, int error, const char *msg, const xmlChar * str1, const xmlChar * str2, const xmlChar * str3, const xmlChar * str4, const xmlChar * str5){ xmlStructuredErrorFunc schannel = NULL; xmlGenericErrorFunc channel = NULL; void *data = NULL;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -