Package com.sun.msv.grammar.xmlschema

Examples of com.sun.msv.grammar.xmlschema.XMLSchemaSchema


           
            // maybe we are parsing the schema for schema.
            // consult externally specified schema.
        }
       
        final XMLSchemaSchema schema = reader.grammar.getByNamespace(baseTypeName[0]);
       
        // we don't know whether it's a complex type or a simple type.
        // so back patch it
        final ReferenceExp ref = new ReferenceExp(null);
        reader.addBackPatchJob( new GrammarReader.BackPatch(){
View Full Code Here


*/
public class AnyAttributeState extends AnyState {

    protected Expression createExpression( final String namespace, final String process ) {
        final XMLSchemaReader reader = (XMLSchemaReader)this.reader;
        final XMLSchemaSchema currentSchema = reader.currentSchema;

        int mode;
       
        if(process.equals("skip"))        mode = AttributeWildcard.SKIP;
        else
View Full Code Here

           
            // back patch "key" field of KeyRefConstraint.
            reader.addBackPatchJob( new GrammarReader.BackPatch(){
                public State getOwnerState() { return IdentityConstraintState.this; }
                public void patch() {
                    XMLSchemaSchema s = reader.grammar.getByNamespace(qn[0]);
                    if(s==null) {
                        reader.reportError( XMLSchemaReader.ERR_UNDEFINED_SCHEMA, qn[0] );
                        return;
                    }
                    IdentityConstraint idc = s.identityConstraints.get(qn[1]);
View Full Code Here

        if( reader.isSchemaDefined(reader.currentSchema) )  {
            reader.reportError( XMLSchemaReader.ERR_DUPLICATE_SCHEMA_DEFINITION, targetNs );
            // recover by providing dummy grammar object.
            // this object is not registered to the map,
            // so it cannot be referenced.
            reader.currentSchema = new XMLSchemaSchema(targetNs,reader.grammar);
        }
       
        reader.markSchemaAsDefined(reader.currentSchema);
    }
View Full Code Here

            )
        );

        this.grammar = new XMLSchemaGrammar(pool);
       
        xsdSchema = new XMLSchemaSchema( XMLSchemaNamespace, grammar );
        // since we might parse the schema-for-schema, we cannot mark
        // this schema as "already defined."
//        markSchemaAsDefined(xsdSchema);
   
        ElementPattern e = new ElementPattern( NameClass.ALL, Expression.nullSet );
View Full Code Here

     * If there is no such object, this method creates a new instance and
     * returns it.
     */
    public XMLSchemaSchema getOrCreateSchema( String namespaceURI ) {
       
        XMLSchemaSchema g = (XMLSchemaSchema)grammar.getByNamespace(namespaceURI);
        if(g!=null)        return g;
       
        // create new one.
        g = new XMLSchemaSchema(namespaceURI,grammar);
       
        // memorize the first link so that we can report the source of error
        // if this namespace turns out to be undefined.
        backwardReference.memorizeLink(g);
       
View Full Code Here

       
        // TODO: undefined grammar check.
        Expression grammarTopLevel = Expression.nullSet;
        itr = grammar.iterateSchemas();
        while( itr.hasNext() ) {
            XMLSchemaSchema schema = (XMLSchemaSchema)itr.next();
           
            if( !isSchemaDefined(schema) ) {
                reportError(
                    backwardReference.getReferer(schema),
                    ERR_UNDEFINED_SCHEMA,
                    new Object[]{schema.targetNamespace} );
                return;    // surpress excessive error messages.
            }
           
            // detect undefined declarations.
            detectUndefinedOnes( schema.attributeDecls,        ERR_UNDEFINED_ATTRIBUTE_DECL );
            detectUndefinedOnes( schema.attributeGroups,    ERR_UNDEFINED_ATTRIBUTE_GROUP );
            detectUndefinedOnes( schema.complexTypes,        ERR_UNDEFINED_COMPLEX_TYPE );
            detectUndefinedOnes( schema.elementDecls,        ERR_UNDEFINED_ELEMENT_DECL );
            detectUndefinedOnes( schema.groupDecls,            ERR_UNDEFINED_GROUP );
            detectUndefinedOnes( schema.simpleTypes,        ERR_UNDEFINED_SIMPLE_TYPE );
           
           
            // TODO: it is now possible to check that the derivation doesn't
            // violate the final property of the parent type.
           
            // prepare top-level expression.
            // at the same time, compute the substitutions field of ElementDeclExps.
            // TODO: make sure this is a correct implementation
            // any globally declared element can be a top-level element.
            Expression exp = Expression.nullSet;
            ReferenceExp[] elems = schema.elementDecls.getAll();
            for( int i=0; i<elems.length; i++ )
                exp = pool.createChoice( exp, elems[i] );
           
            schema.topLevel = exp;
           
            // toplevel of the grammar will be choices of toplevels of all modules.
            grammarTopLevel = pool.createChoice( grammarTopLevel, exp );
        }

        // some of the back-patching process relies on this grammar.topLevel field.
        grammar.topLevel = grammarTopLevel;

        // perform all back patching.
        runBackPatchJob();

       
       
       
        // perform substitutability computation
        //-----------------------------------------
        // this process depends on the result of back-patching.
       
        // a buffer which will be used to check the recursive substitution group definition.
        final Set recursiveSubstBuffer = new java.util.HashSet();
       
        itr = grammar.iterateSchemas();
        while( itr.hasNext() ) {
            XMLSchemaSchema schema = (XMLSchemaSchema)itr.next();

            ReferenceExp[] elems = schema.elementDecls.getAll();
            for( int i=0; i<elems.length; i++ ) {
                final ElementDeclExp e = (ElementDeclExp)elems[i];
           
View Full Code Here

                    DatatypeFactory.getTypeByName(typeName[1]) );
            } catch( DatatypeException e ) {
                return onTypeResolutionFailure(sti,type,refErr);
            }
        } else {
            XMLSchemaSchema schema = _docDecl.grammar.getByNamespace(typeName[0]);
            if(schema==null)
                return onTypeResolutionFailure(sti,type,refErr);
       
            final XMLSchemaTypeExp currentType = xe.parent.getTypeDefinition();
            ComplexTypeExp cexp = schema.complexTypes.get(typeName[1]);
View Full Code Here

        final XMLSchemaReader reader = (XMLSchemaReader)this.reader;
        LaxDefaultNameClass laxNc = new LaxDefaultNameClass(allowedNc);
               
        Iterator itr = reader.grammar.iterateSchemas();
        while( itr.hasNext() ) {
            XMLSchemaSchema schema = (XMLSchemaSchema)itr.next();
            if(allowedNc.accepts( schema.targetNamespace, NameClass.LOCALNAME_WILDCARD )) {
                ReferenceExp[] refs = res.get(schema).getAll();
                for( int i=0; i<refs.length; i++ ) {
                    NameClass name = getNameClassFrom(refs[i]);
                           
View Full Code Here

*/
public class AnyElementState extends AnyState
{
    protected Expression createExpression( final String namespace, final String process ) {
        final XMLSchemaReader reader = (XMLSchemaReader)this.reader;
        final XMLSchemaSchema currentSchema = reader.currentSchema;
       
        if( process.equals("skip") ) {
            // "skip" can be expanded now.
            NameClass nc = getNameClass(namespace,currentSchema);
           
            ElementPattern ep = new ElementPattern(nc,Expression.nullSet);
               
            ep.contentModel =
                // <mixed><zeroOrMore><choice><attribute /><element /></choice></zeroOrMore></mixed>
                reader.pool.createMixed(
                    reader.pool.createZeroOrMore(
                        reader.pool.createChoice(
                            ep,
                            reader.pool.createAttribute(nc)
                        )
                    )
                );
               
            // minOccurs/maxOccurs is processed through interception
            return ep;
        }
       
        // "lax"/"strict" has to be back-patched later.
        final ReferenceExp exp = new ReferenceExp("any("+process+":"+namespace+")");
        reader.addBackPatchJob( new GrammarReader.BackPatch(){
            public State getOwnerState() { return AnyElementState.this; }
            public void patch() {

                if( !process.equals("lax")
                &&  !process.equals("strict") )  {
                    reader.reportError( XMLSchemaReader.ERR_BAD_ATTRIBUTE_VALUE, "processContents", process );
                    exp.exp = Expression.nullSet;
                    return;
                }
               
                exp.exp = Expression.nullSet;
                NameClass nc = getNameClass(namespace,currentSchema);
                Iterator itr;
                itr = reader.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(nc.accepts( schema.targetNamespace, NameClass.LOCALNAME_WILDCARD ))
                        // schema.topLevel is choices of globally declared elements.
View Full Code Here

TOP

Related Classes of com.sun.msv.grammar.xmlschema.XMLSchemaSchema

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.