Package com.sun.msv.grammar

Examples of com.sun.msv.grammar.ElementExp


   
    private void writeObject( ObjectOutputStream oos ) throws IOException {
        // update the content model table.
        for( Iterator itr=elementContents.entrySet().iterator(); itr.hasNext(); ) {
            Map.Entry e = (Map.Entry)itr.next();
            ElementExp exp = (ElementExp)e.getKey();
            e.setValue( exp.contentModel );
            exp.contentModel = Expression.nullSet;  // cut the reference while serializing the graph
        }
       
        oos.defaultWriteObject();
       
        // restore the references
        for( Iterator itr=elementContents.entrySet().iterator(); itr.hasNext(); ) {
            Map.Entry e = (Map.Entry)itr.next();
            ElementExp exp = (ElementExp)e.getKey();
            exp.contentModel = (Expression)e.getValue();
        }
    }
View Full Code Here


       
        // restore the references
        if( elementContents!=null ) {
            for( Iterator itr=elementContents.entrySet().iterator(); itr.hasNext(); ) {
                Map.Entry e = (Map.Entry)itr.next();
                ElementExp exp = (ElementExp)e.getKey();
                exp.contentModel = (Expression)e.getValue();
            }
        }
    }
View Full Code Here

                if(!elements.add(exp))
                    return;    // this element has already processed.
               
                StringPair _en = elementName;
                IDAttMap _curAtts = curAtts;
                ElementExp _curElm = curElm;
               
                NameClass nc = exp.getNameClass();
                if(nc instanceof SimpleNameClass) {
                    elementName = new StringPair((SimpleNameClass)nc);
                    curAtts = (IDAttMap)name2value.get(elementName);    // maybe null.
                } else
                    elementName = null;
                curElm = exp;
               
//                System.out.println("tested:" +
//                    com.sun.msv.grammar.util.ExpressionPrinter.printContentModel(
//                    exp.contentModel.visit(remover)));
                // visit the content model, but remove reference exps first.
                exp.contentModel.visit(remover).visit(this);
               
                if( elementName!=null && curAtts!=null )
                    name2value.put(elementName,curAtts);
               
                elementName = _en;
                curAtts = _curAtts;
                curElm = _curElm;
            }
           
            public void onAttribute( AttributeExp exp ) {
               
                if(!(exp.exp instanceof DataOrValueExp)) {
                    // otherwise visit the content model normally
                    // so that we can find any invalid use of ID/IDREF types.
                    exp.exp.visit(this);
                    return;
                }
               
                DataOrValueExp texp = (DataOrValueExp)exp.exp;
                           
                if(texp.getType().getIdType()==Datatype.ID_TYPE_NULL) {
                    // if this type is not ID/IDREF type, then it's OK
                    return;
                }
               
                if(!(exp.nameClass instanceof SimpleNameClass)) {
                    reportCompError(
                        new Locator[]{reader.getDeclaredLocationOf(exp)},
                        CERR_ID_TYPE_WITH_NON_SIMPLE_ATTNAME,
                        new Object[]{
                            texp.getName().localName,
                            getSemanticsStr(texp.getType().getIdType())} );
                    return;
                }
                   
                StringPair attName = new StringPair((SimpleNameClass)exp.nameClass);
               
                if( elementName==null ) {
                    reportCompError(
                        new Locator[]{
                            reader.getDeclaredLocationOf(exp),
                            reader.getDeclaredLocationOf(curElm)},
                        CERR_ID_TYPE_WITH_NON_SIMPLE_ELEMENTNAME,
                        new Object[]{
                            texp.getName().localName,
                            getSemanticsStr(texp.getType().getIdType())} );
                    return;
                }
                   
                // the enclosing attribute name is simple, and
                // the enclosing element name is simple, too.
                // this is the only place we can have ID/IDREF types.
                                   
                // store that this attribute is used for ID/IDREF.
                if(curAtts==null)
                    curAtts = new IDAttMap(curElm);
                curAtts.idatts.put(attName,texp.getName());
                           
            }
           
            public void onData( DataExp exp )    { checkIdType(exp); }
            public void onValue( ValueExp exp ) { checkIdType(exp); }
            private void checkIdType( DataOrValueExp exp ) {
                if(exp.getType().getIdType()!=Datatype.ID_TYPE_NULL) {
                    // ID/IDREF type in all other locations are subject to
                    // a compatibility error.
                    reportCompError(
                        new Locator[]{reader.getDeclaredLocationOf(exp)},
                        CERR_MALPLACED_ID_TYPE,
                        new Object[]{
                            exp.getName().localName,
                            getSemanticsStr(exp.getType().getIdType())});
                }
            }
        });
       
       
        if(!grammar.isIDcompatible)
            // if an compatibility error has been found, abort further check.
            return;
       
        /*
        2nd pass
        ========
       
        make sure that no other attributes are competing with id attributes.
        */
        Iterator itr = elements.iterator();
        final Vector vec = new Vector();    // IDAttMaps of the competing elements
        while( itr.hasNext() ) {
            final ElementExp eexp = (ElementExp)itr.next();
           
            // list up all competing elements.
            vec.clear();
            Iterator jtr = name2value.entrySet().iterator();
            while(jtr.hasNext()) {
                Map.Entry e = (Map.Entry)jtr.next();
                if( eexp.getNameClass().accepts((StringPair)e.getKey()) )
                    vec.add( e.getValue()/*IDAttMap*/ );
            }
           
            if(vec.size()==0)
                continue;    // this element does not comete with anything.
View Full Code Here

               
       
        // test that the competing elements also has the same default values.
        itr = elements.iterator();
        while(itr.hasNext()) {
            final ElementExp eexp = (ElementExp)itr.next();
           
            NameClass nc = eexp.getNameClass();
            if(!(nc instanceof SimpleNameClass)) {
                // if the element has a complex name class,
                // it cannot have a default attribute value.
                // (this is checked within the first pass.
                // so in this case, we just need to make sure that
View Full Code Here

            // default implementation.
            return super.createChildAcceptor(sti,refErr);
        }
       
        // obtain the ElementExp that mathced this start tag.
        final ElementExp element = _docDecl.getCCCEC().getMatchedElements()[0];
       
        if(!(element instanceof ElementDeclExp.XSElementExp)) {
            // it's not an element of XML Schema.
            // we don't need to handle xsi:*** for this element.
            return super.createChildAcceptor(sti,refErr);
View Full Code Here

        Acceptor child = current;
       
        super.endElement(namespaceUri,localName,qName);
       
        {// report to the handler
            ElementExp type;
            if( child instanceof SimpleAcceptor ) {
                type = ((SimpleAcceptor)child).owner;
            } else
            if( child instanceof ComplexAcceptor ) {
                ElementExp[] exps = ((ComplexAcceptor)child).getSatisfiedOwners();
View Full Code Here

                        name2exp.put( rexp.name, exp );
                    }
                }
                else
                if( exp instanceof ElementExp ) {
                    ElementExp eexp = (ElementExp)exp;
                    NameClass nc = eexp.getNameClass();
                   
                    if( nc instanceof SimpleNameClass
                     && !name2exp.containsKey( ((SimpleNameClass)nc).localName ) )
                        name2exp.put( ((SimpleNameClass)nc).localName, exp );
                    else {
View Full Code Here

       
        if( child instanceof SimpleAcceptor ) {
            // this is possible although it is very rare.
            // continuation cannot be used here, because
            // some contents[i] may reject this owner.
            ElementExp cowner = ((SimpleAcceptor)child).owner;
            if( cowner==null )
                // cowner==null means we are currently recovering from an error.
                // so use AnyElementToken to make contents[i] happy.
                token = AnyElementToken.theInstance;
            else
View Full Code Here

            exp.visit(this);
           
            while(!unprocessedElementExps.isEmpty()) {
                contentModel.clear();
                refStack.clear();
                ElementExp e = (ElementExp)unprocessedElementExps.pop();
                e.contentModel.visit(this);
            }
        } catch( RuntimeException e ) {
            if(e!=eureka)    throw e;
        }
View Full Code Here

       
        Vector vec = new Vector();
        new ElementsOfConcernCollector().collect( exp, vec );
       
        for( int i=0; i<vec.size(); i++ ) {
            ElementExp eexp = (ElementExp)vec.get(i);
            if(eexp.getNameClass().accepts(name))
                return eexp;
        }
       
        return null;
    }
View Full Code Here

TOP

Related Classes of com.sun.msv.grammar.ElementExp

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.