Package com.sun.msv.grammar.xmlschema

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


        super.endSelf();
    }
   
    protected void createIdentityConstraint() {
        final XMLSchemaReader reader = (XMLSchemaReader)this.reader;
        IdentityConstraint id;
       
        String name = startTag.getAttribute("name");
        if(name==null) {
            reader.reportError( XMLSchemaReader.ERR_MISSING_ATTRIBUTE,
                startTag.localName, "name" );
            return;    // recover by ignoring this constraint.
        }
       
        Field[] fs = (Field[])fields.toArray( new Field[fields.size()] );
       
        if( startTag.localName.equals("key") )
            id = new KeyConstraint( reader.currentSchema.targetNamespace, name, selector, fs );
        else
        if( startTag.localName.equals("unique") )
            id = new UniqueConstraint( reader.currentSchema.targetNamespace, name, selector, fs );
        else
        if( startTag.localName.equals("keyref") ) {
            final String refer = startTag.getAttribute("refer");
            if(refer==null) {
                reader.reportError( XMLSchemaReader.ERR_MISSING_ATTRIBUTE,
                    startTag.localName, "refer" );
                return;    // recover by ignoring this constraint.
            }
            final String[] qn = reader.splitQName(refer);
            if(qn==null) {
                reader.reportError( XMLSchemaReader.ERR_UNDECLARED_PREFIX, qn );
                return;
            }
           
            final KeyRefConstraint keyRef =
                new KeyRefConstraint( reader.currentSchema.targetNamespace, name, selector, fs );
            id = keyRef;
           
            // 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]);
                    if(idc==null) {
                        reader.reportError( XMLSchemaReader.ERR_UNDEFINED_KEY, refer );
                        return;
                    }
                    if(!(idc instanceof KeyConstraint )) {
View Full Code Here


                // SelectorMathcers will register themselves as active scopes
                // in their constructor.
               
                // augment the referenceScope field by adding newly introduced keyrefs.
                for( int i=0; i<m; i++ ) {
                    IdentityConstraint c = (IdentityConstraint)
                        exp.identityConstraints.get(i);
                    if(c instanceof KeyRefConstraint) {
                        SelectorMatcher keyScope =
                            getActiveScope( ((KeyRefConstraint)c).key );
                        if(keyScope==null)
View Full Code Here

                // SelectorMathcers will register themselves as active scopes
                // in their constructor.
               
                // augment the referenceScope field by adding newly introduced keyrefs.
                for( int i=0; i<m; i++ ) {
                    IdentityConstraint c = (IdentityConstraint)
                        exp.identityConstraints.get(i);
                    if(c instanceof KeyRefConstraint) {
                        SelectorMatcher keyScope =
                            getActiveScope( ((KeyRefConstraint)c).key );
                        if(keyScope==null)
View Full Code Here

        super.endSelf();
    }
   
    protected void createIdentityConstraint() {
        final XMLSchemaReader reader = (XMLSchemaReader)this.reader;
        IdentityConstraint id;
       
        String name = startTag.getAttribute("name");
        if(name==null) {
            reader.reportError( XMLSchemaReader.ERR_MISSING_ATTRIBUTE,
                startTag.localName, "name" );
            return;    // recover by ignoring this constraint.
        }
       
        Field[] fs = (Field[])fields.toArray( new Field[fields.size()] );
       
        if( startTag.localName.equals("key") )
            id = new KeyConstraint( reader.currentSchema.targetNamespace, name, selector, fs );
        else
        if( startTag.localName.equals("unique") )
            id = new UniqueConstraint( reader.currentSchema.targetNamespace, name, selector, fs );
        else
        if( startTag.localName.equals("keyref") ) {
            final String refer = startTag.getAttribute("refer");
            if(refer==null) {
                reader.reportError( XMLSchemaReader.ERR_MISSING_ATTRIBUTE,
                    startTag.localName, "refer" );
                return;    // recover by ignoring this constraint.
            }
            final String[] qn = reader.splitQName(refer);
            if(qn==null) {
                reader.reportError( XMLSchemaReader.ERR_UNDECLARED_PREFIX, qn );
                return;
            }
           
            final KeyRefConstraint keyRef =
                new KeyRefConstraint( reader.currentSchema.targetNamespace, name, selector, fs );
            id = keyRef;
           
            // 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]);
                    if(idc==null) {
                        reader.reportError( XMLSchemaReader.ERR_UNDEFINED_KEY, refer );
                        return;
                    }
                    if(!(idc instanceof KeyConstraint )) {
View Full Code Here

TOP

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

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.