/**
* Creates the expression that corresponds to
* the current attribute wildcard specification.
*/
public Expression createExpression( XMLSchemaGrammar grammar ) {
final ExpressionPool pool = grammar.pool;
switch(processMode) {
case SKIP:
return pool.createZeroOrMore(pool.createAttribute(name));
case STRICT:
case LAX:
Expression exp = Expression.epsilon;
LaxDefaultNameClass laxNc = new LaxDefaultNameClass(name);
Iterator itr = grammar.iterateSchemas();
while( itr.hasNext() ) {
XMLSchemaSchema schema = (XMLSchemaSchema)itr.next();
// nc is built by using NamespaceNameClass.
// "strict" allows global element declarations of
// specified namespaces.
if(name.accepts( schema.targetNamespace, NameClass.LOCALNAME_WILDCARD )) {
// gather global attributes.
ReferenceExp[] atts = schema.attributeDecls.getAll();
for( int i=0; i<atts.length; i++ ) {
exp = pool.createSequence( pool.createOptional(atts[i]), exp );
laxNc.addName( schema.targetNamespace, atts[i].name );
}
}
}
if( processMode==STRICT )
// if processContents="strict", then that's it.
return exp;
// if "lax", we have to add an expression to
// match other attributes.
return pool.createSequence(
pool.createZeroOrMore(pool.createAttribute(laxNc)), exp );
default:
throw new Error("undefined process mode:"+processMode);
}
}