1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-29 11:41:22 +03:00

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).
This commit is contained in:
Kasimier T. Buchcik
2004-09-29 13:29:03 +00:00
parent bc2f2c3de4
commit 87876407ce
9 changed files with 2392 additions and 747 deletions

View File

@ -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