Commit 87876407 authored by Kasimier T. Buchcik's avatar Kasimier T. Buchcik

Parsing of <complexContent> - handle attribute 'mixed', catch illegal

* xmlschemas.c include/libxml/xmlerror.h include/libxml/xmlschemas.h
  include/libxml/schemasInternals.h: Parsing of <complexContent>
  - handle attribute 'mixed', catch illegal attributes.
  Parsing of <complexType> - handle attributes 'abstract',
  'final' and 'block', catch illegal attributes.
  Validation of complex types - handle abstract types.
  Added handling of default/fixed attributes and element values.
  Per validation option attribute nodes/text nodes are created
  on the instance.
  Added the corresponding constraints for fixed/default.
  Added xmlSchemaSetValidOptions, xmlSchemaGetValidOptions
  to the external API.
  Extended element declaration constraints.
  Got rid of perseverative creation of temporery validation/parser
  contexts.
  Added handling of xsi:schemaLocation and
  xsi:noNamespaceSchemaLocation.
  Fixed xsi:type component resolution if using non-prefixed
  QNames.
* xmlregexp.c xmlschemas.c include/libxml/xmlautomata.h:
  Enabled namespace awareness of the content model if using the
  model group "all".
* test/schemas/bug152470_1.xsd: Removed an "abstract" attribute,
  which broke the test.
* xstc/xstc.py:  Workaround to accomodate case insensitive
  test definitions in ms-test.def.xml (was missing in a previous
  commit).
parent bc2f2c3d
Wed Sep 29 15:00:11 CEST 2004 Kasimier Buchcik <libxml2-cvs@cazic.net>
* xmlschemas.c include/libxml/xmlerror.h include/libxml/xmlschemas.h
include/libxml/schemasInternals.h: Parsing of <complexContent>
- handle attribute 'mixed', catch illegal attributes.
Parsing of <complexType> - handle attributes 'abstract',
'final' and 'block', catch illegal attributes.
Validation of complex types - handle abstract types.
Added handling of default/fixed attributes and element values.
Per validation option attribute nodes/text nodes are created
on the instance.
Added the corresponding constraints for fixed/default.
Added xmlSchemaSetValidOptions, xmlSchemaGetValidOptions
to the external API.
Extended element declaration constraints.
Got rid of perseverative creation of temporery validation/parser
contexts.
Added handling of xsi:schemaLocation and
xsi:noNamespaceSchemaLocation.
Fixed xsi:type component resolution if using non-prefixed
QNames.
* xmlregexp.c xmlschemas.c include/libxml/xmlautomata.h:
Enabled namespace awareness of the content model if using the
model group "all".
* test/schemas/bug152470_1.xsd: Removed an "abstract" attribute,
which broke the test.
* xstc/xstc.py: Workaround to accomodate case insensitive
test definitions in ms-test.def.xml (was missing in a previous
commit).
Wed Sep 29 11:03:10 CEST 2004 Daniel Veillard <daniel@veillard.com>
* python/drv_libxml2.py: another patch from Malcolm Tredinnick
......
......@@ -216,7 +216,7 @@ struct _xmlSchemaAnnot {
*/
#define XML_SCHEMAS_ATTR_NSDEFAULT 1 << 7
/**
* XML_SCHEMAS_ATTR_NSDEFAULT:
* XML_SCHEMAS_ATTR_INTERNAL_RESOLVED:
*
* this is set when the "type" and "ref" references
* have been resolved.
......@@ -255,6 +255,8 @@ struct _xmlSchemaAttribute {
const xmlChar *targetNamespace;
int flags;
const xmlChar *refPrefix;
xmlSchemaValPtr defVal;
xmlSchemaAttributePtr refDecl;
};
/**
......@@ -470,6 +472,31 @@ struct _xmlSchemaFacetLink {
* Marks the item as marked; used for circular checks.
*/
#define XML_SCHEMAS_TYPE_MARKED 1 << 16
/**
* XML_SCHEMAS_TYPE_BLOCK_DEFAULT:
*
* the complexType did not specify 'block' so use the default of the
* <schema> item.
*/
#define XML_SCHEMAS_TYPE_BLOCK_DEFAULT 1 << 17
/**
* XML_SCHEMAS_TYPE_BLOCK_EXTENSION:
*
* the complexType has a 'block' of "extension".
*/
#define XML_SCHEMAS_TYPE_BLOCK_EXTENSION 1 << 18
/**
* XML_SCHEMAS_TYPE_FINAL_RESTRICTION:
*
* the complexType has a 'block' of "restriction".
*/
#define XML_SCHEMAS_TYPE_BLOCK_RESTRICTION 1 << 19
/**
* XML_SCHEMAS_TYPE_ABSTRACT:
*
* the simple/complexType is abstract.
*/
#define XML_SCHEMAS_TYPE_ABSTRACT 1 << 20
/**
* _xmlSchemaType:
......@@ -650,6 +677,7 @@ struct _xmlSchemaElement {
xmlRegexpPtr contModel;
xmlSchemaContentType contentType;
const xmlChar *refPrefix;
xmlSchemaValPtr defVal;
};
/*
......@@ -792,6 +820,7 @@ struct _xmlSchema {
xmlDictPtr dict;
void *includes; /* the includes, this is opaque for now */
int preserve; /* whether to free the document */
int counter; /* used to give ononymous components unique names */
};
XMLPUBFUN void XMLCALL xmlSchemaFreeType (xmlSchemaTypePtr type);
......
......@@ -72,6 +72,15 @@ XMLPUBFUN xmlAutomataStatePtr XMLCALL
int min,
int max,
void *data);
XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataNewCountTrans2 (xmlAutomataPtr am,
xmlAutomataStatePtr from,
xmlAutomataStatePtr to,
const xmlChar *token,
const xmlChar *token2,
int min,
int max,
void *data);
XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataNewOnceTrans (xmlAutomataPtr am,
xmlAutomataStatePtr from,
......@@ -80,6 +89,15 @@ XMLPUBFUN xmlAutomataStatePtr XMLCALL
int min,
int max,
void *data);
XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataNewOnceTrans2 (xmlAutomataPtr am,
xmlAutomataStatePtr from,
xmlAutomataStatePtr to,
const xmlChar *token,
const xmlChar *token2,
int min,
int max,
void *data);
XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataNewAllTrans (xmlAutomataPtr am,
xmlAutomataStatePtr from,
......
......@@ -646,6 +646,10 @@ typedef enum {
XML_SCHEMAV_CVC_COMPLEX_TYPE_5_2, /* 1870 */
XML_SCHEMAV_ELEMENT_CONTENT, /* 1871 */
XML_SCHEMAV_DOCUMENT_ELEMENT_MISSING, /* 1872 */
XML_SCHEMAV_CVC_COMPLEX_TYPE_1, /* 1873 */
XML_SCHEMAV_CVC_AU, /* 1874 */
XML_SCHEMAV_CVC_TYPE_1, /* 1875 */
XML_SCHEMAV_CVC_TYPE_2, /* 1876 */
XML_XPTR_UNKNOWN_SCHEME = 1900,
XML_XPTR_CHILDSEQ_START, /* 1901 */
XML_XPTR_EVAL_FAILED, /* 1902 */
......@@ -735,7 +739,11 @@ typedef enum {
XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_2, /* 3072 */
XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_3, /* 3073 */
XML_SCHEMAP_MG_PROPS_CORRECT_1, /* 3074 */
XML_SCHEMAP_MG_PROPS_CORRECT_2 /* 3075 */
XML_SCHEMAP_MG_PROPS_CORRECT_2, /* 3075 */
XML_SCHEMAP_SRC_CT_1, /* 3076 */
XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_3, /* 3077 */
XML_SCHEMAP_AU_PROPS_CORRECT_2, /* 3078 */
XML_SCHEMAP_A_PROPS_CORRECT_2
} xmlParserErrors;
/**
......
......@@ -54,6 +54,29 @@ typedef enum {
XML_SCHEMAS_ERR_XXX
} xmlSchemaValidError;
/*
* ATTENTION: Change xmlSchemaSetValidOptions's check
* for invalid values, if adding to the validation
* options below.
*/
/**
* xmlSchemaValidOption:
*
* This is the set of XML Schema validation options.
*/
typedef enum {
XML_SCHEMA_VAL_VC_I_CREATE = 1<<0
/* Default/fixed: create an attribute node
* or an element's text node on the instance.
*/
} xmlSchemaValidOption;
/*
XML_SCHEMA_VAL_XSI_ASSEMBLE = 1<<1,
* assemble schemata using
* xsi:schemaLocation and
* xsi:noNamespaceSchemaLocation
*/
/**
* The schemas related types are kept internal
......@@ -113,10 +136,15 @@ XMLPUBFUN void XMLCALL
xmlSchemaValidityWarningFunc warn,
void *ctx);
XMLPUBFUN int XMLCALL
xmlSchemaGetValidErrors (xmlSchemaValidCtxtPtr ctxt,
xmlSchemaValidityErrorFunc *err,
xmlSchemaValidityWarningFunc *warn,
void **ctx);
xmlSchemaGetValidErrors (xmlSchemaValidCtxtPtr ctxt,
xmlSchemaValidityErrorFunc *err,
xmlSchemaValidityWarningFunc *warn,
void **ctx);
XMLPUBFUN int XMLCALL
xmlSchemaSetValidOptions (xmlSchemaValidCtxtPtr ctxt,
int options);
XMLPUBFUN int XMLCALL
xmlSchemaValidCtxtGetOptions(xmlSchemaValidCtxtPtr ctxt);
XMLPUBFUN xmlSchemaValidCtxtPtr XMLCALL
xmlSchemaNewValidCtxt (xmlSchemaPtr schema);
......
......@@ -17,7 +17,7 @@
</choice>
</complexType>
<complexType name="KeyIdentifier" abstract="true"/>
<complexType name="KeyIdentifier" /> <!-- removed: abstract="true" -->
<complexType name="X509SPKIHash">
<complexContent>
......
......@@ -4405,6 +4405,94 @@ xmlAutomataNewTransition2(xmlAutomataPtr am, xmlAutomataStatePtr from,
return(to);
}
/**
* xmlAutomataNewCountTrans2:
* @am: an automata
* @from: the starting point of the transition
* @to: the target point of the transition or NULL
* @token: the input string associated to that transition
* @token2: the second input string associated to that transition
* @min: the minimum successive occurences of token
* @max: the maximum successive occurences of token
* @data: data associated to the transition
*
* If @to is NULL, this creates first a new target state in the automata
* and then adds a transition from the @from state to the target state
* activated by a succession of input of value @token and @token2 and
* whose number is between @min and @max
*
* Returns the target state or NULL in case of error
*/
xmlAutomataStatePtr
xmlAutomataNewCountTrans2(xmlAutomataPtr am, xmlAutomataStatePtr from,
xmlAutomataStatePtr to, const xmlChar *token,
const xmlChar *token2,
int min, int max, void *data) {
xmlRegAtomPtr atom;
int counter;
if ((am == NULL) || (from == NULL) || (token == NULL))
return(NULL);
if (min < 0)
return(NULL);
if ((max < min) || (max < 1))
return(NULL);
atom = xmlRegNewAtom(am, XML_REGEXP_STRING);
if (atom == NULL)
return(NULL);
if ((token2 == NULL) || (*token2 == 0)) {
atom->valuep = xmlStrdup(token);
} else {
int lenn, lenp;
xmlChar *str;
lenn = strlen((char *) token2);
lenp = strlen((char *) token);
str = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2);
if (str == NULL) {
xmlRegFreeAtom(atom);
return(NULL);
}
memcpy(&str[0], token, lenp);
str[lenp] = '|';
memcpy(&str[lenp + 1], token2, lenn);
str[lenn + lenp + 1] = 0;
atom->valuep = str;
}
atom->data = data;
if (min == 0)
atom->min = 1;
else
atom->min = min;
atom->max = max;
/*
* associate a counter to the transition.
*/
counter = xmlRegGetCounter(am);
am->counters[counter].min = min;
am->counters[counter].max = max;
/* xmlFAGenerateTransitions(am, from, to, atom); */
if (to == NULL) {
to = xmlRegNewState(am);
xmlRegStatePush(am, to);
}
xmlRegStateAddTrans(am, from, atom, to, counter, -1);
xmlRegAtomPush(am, atom);
am->state = to;
if (to == NULL)
to = am->state;
if (to == NULL)
return(NULL);
if (min == 0)
xmlFAGenerateEpsilonTransition(am, from, to);
return(to);
}
/**
* xmlAutomataNewCountTrans:
* @am: an automata
......@@ -4471,6 +4559,90 @@ xmlAutomataNewCountTrans(xmlAutomataPtr am, xmlAutomataStatePtr from,
return(to);
}
/**
* xmlAutomataNewOnceTrans2:
* @am: an automata
* @from: the starting point of the transition
* @to: the target point of the transition or NULL
* @token: the input string associated to that transition
* @token2: the second input string associated to that transition
* @min: the minimum successive occurences of token
* @max: the maximum successive occurences of token
* @data: data associated to the transition
*
* If @to is NULL, this creates first a new target state in the automata
* and then adds a transition from the @from state to the target state
* activated by a succession of input of value @token and @token2 and whose
* number is between @min and @max, moreover that transition can only be
* crossed once.
*
* Returns the target state or NULL in case of error
*/
xmlAutomataStatePtr
xmlAutomataNewOnceTrans2(xmlAutomataPtr am, xmlAutomataStatePtr from,
xmlAutomataStatePtr to, const xmlChar *token,
const xmlChar *token2,
int min, int max, void *data) {
xmlRegAtomPtr atom;
int counter;
if ((am == NULL) || (from == NULL) || (token == NULL))
return(NULL);
if (min < 1)
return(NULL);
if ((max < min) || (max < 1))
return(NULL);
atom = xmlRegNewAtom(am, XML_REGEXP_STRING);
if (atom == NULL)
return(NULL);
if ((token2 == NULL) || (*token2 == 0)) {
atom->valuep = xmlStrdup(token);
} else {
int lenn, lenp;
xmlChar *str;
lenn = strlen((char *) token2);
lenp = strlen((char *) token);
str = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2);
if (str == NULL) {
xmlRegFreeAtom(atom);
return(NULL);
}
memcpy(&str[0], token, lenp);
str[lenp] = '|';
memcpy(&str[lenp + 1], token2, lenn);
str[lenn + lenp + 1] = 0;
atom->valuep = str;
}
atom->data = data;
atom->quant = XML_REGEXP_QUANT_ONCEONLY;
if (min == 0)
atom->min = 1;
else
atom->min = min;
atom->max = max;
/*
* associate a counter to the transition.
*/
counter = xmlRegGetCounter(am);
am->counters[counter].min = 1;
am->counters[counter].max = 1;
/* xmlFAGenerateTransitions(am, from, to, atom); */
if (to == NULL) {
to = xmlRegNewState(am);
xmlRegStatePush(am, to);
}
xmlRegStateAddTrans(am, from, atom, to, counter, -1);
xmlRegAtomPush(am, atom);
am->state = to;
return(to);
}
/**
* xmlAutomataNewOnceTrans:
* @am: an automata
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -140,6 +140,10 @@ class MSTestCase:
#
dirs = self.schema_Folder.split("/")
self.combineName = dirs[len(dirs) -1]
if self.test_Folder == testFolderMS:
if self.combineName == "group":
self.schema_Folder = "Group"
self.instance_Folder = "Group"
elif self.test_Folder == testFolderNIST:
#
# NIST files are named in the following form:
......@@ -260,9 +264,8 @@ class MSTestCase:
else:
self.fail(msgSchemaValidButShouldNot)
else:
self.debugMsg("schema result is OK")
return schema
self.debugMsg("schema result is OK")
self.debugMsg("after checking schema result")
def processInstance(self, filePath, schema):
global msgInstanceNotValidButShould, msgInstanceValidButShouldNot
......@@ -292,7 +295,9 @@ class MSTestCase:
#
# Validate the instance.
#
validation_Ctxt = schema.schemaNewValidCtxt()
#validation_Ctxt = libxml2.schemaNewValidCtxt(None)
if (validation_Ctxt is None):
self.failCritical("Could not create the validation context.")
return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment