Package com.sun.msv.grammar

Examples of com.sun.msv.grammar.Expression


                       
        // checks ID abuse
        IdAbuseChecker.check( this, module );
       
        // supply top-level expression.
        Expression exp =
            pool.createChoice(
                choiceOfExported( module.elementRules ),
                choiceOfExported( module.hedgeRules ) );
           
        if( exp==Expression.nullSet )
View Full Code Here



    private Expression choiceOfExported( ReferenceContainer con )
    {
        Iterator itr = con.iterator();
        Expression r = Expression.nullSet;
        while( itr.hasNext() )
        {
            Exportable ex= (Exportable)itr.next();
            if( ex.isExported() )
                r = pool.createChoice(r,(Expression)ex);
View Full Code Here

       
        return onAttribute( docDecl.attToken, refErr );
    }
   
    protected boolean onAttribute( AttributeToken token, StringRef refErr ) {
        Expression r = docDecl.attFeeder.feed( this.expression, token, ignoreUndeclaredAttributes );
       
        if( r!=Expression.nullSet ) {
            // this attribute is properly consumed.
            expression = r;
           
View Full Code Here

    }
   

    public boolean onEndAttributes( StartTagInfo sti, StringRef refErr ) {
       
        Expression r = docDecl.attPruner.prune( this.expression );
        if( r!=Expression.nullSet ) {
            // there was no error.
            this.expression = r;
            return true;
        }
View Full Code Here

   
   
   
    protected boolean stepForward( Token token, StringRef errRef ) {
       
        Expression residual = docDecl.resCalc.calcResidual( expression, token );
       
        if( com.sun.msv.driver.textui.Debug.debug ) {
            System.out.println("residual of stepForward("+token+")");
            System.out.print(com.sun.msv.grammar.util.ExpressionPrinter.printContentModel(expression));
            System.out.print("   ->   ");
View Full Code Here

       
        CombinedChildContentExpCreator.ExpressionPair combinedEoC =
            cccc.get( expression, null, false );
       
        // get residual of EoC.
        Expression eocr = docDecl.resCalc.calcResidual( expression, AnyElementToken.theInstance );
       
        Expression continuation = docDecl.pool.createChoice(
            expression, eocr );
        Expression contentModel = combinedEoC.content;
       
        if( com.sun.msv.driver.textui.Debug.debug )
        {
            System.out.println("content model of recovery acceptor:"+
                com.sun.msv.grammar.util.ExpressionPrinter.printContentModel(contentModel) );
View Full Code Here

    private final String diagnoseBadTagName( StartTagInfo sti ) {
        final CombinedChildContentExpCreator cccc = docDecl.cccec;
       
       
        // try creating combined child content pattern without tag name check.
        Expression r = cccc.get(expression,sti,false).content;
           
        if( r==Expression.nullSet )
            // no element is allowed here at all.
            return docDecl.localizeMessage( REDocumentDeclaration.DIAG_ELEMENT_NOT_ALLOWED, sti.qName );
       
View Full Code Here

        {
            int cnt=0;    // use to name anonymous RefExp.
       
            Iterator itr = heads.iterator();
            while( itr.hasNext() ) {
                Expression exp = (Expression)itr.next();
                if( exp instanceof ReferenceExp ) {
                    ReferenceExp rexp = (ReferenceExp)exp;
                    if( rexp.name == null ) {
                        // generate unique name
                        while( name2exp.containsKey("anonymous"+cnt) )
                            cnt++;
                        name2exp.put( "anonymous"+cnt, exp );
                    } else
                    if( name2exp.containsKey(rexp.name) ) {
                        // name conflict. try to add suffix.
                        int i = 2;
                        while( name2exp.containsKey(rexp.name+i) )
                            i++;
                        name2exp.put( rexp.name+i, exp );
                    } else {
                        // name of this RefExp can be directly used without modification.
                        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 {
                        // generate unique name
                        while( name2exp.containsKey("element"+cnt) )
                            cnt++;
                        name2exp.put( "element"+cnt, exp );
                    }
                } else
                    throw new Error();    // assertion failed.
                    // it must be ElementExp or ReferenceExp.
            }
        }
       
        // then reverse name2ref to ref2name
        exp2name = new HashMap();
        {
            Iterator itr = name2exp.keySet().iterator();
            while( itr.hasNext() ) {
                String name = (String)itr.next();
                exp2name.put( name2exp.get(name), name );
            }
        }
       
        nameClassWriter = createNameClassWriter();       
        // generates SAX events
        try {
            final DocumentHandler handler = writer.getDocumentHandler();
            handler.setDocumentLocator( new LocatorImpl() );
            handler.startDocument();

            // to work around the bug of current serializer,
            // report xmlns declarations as attributes.
           
            if( defaultNs!=null )
                writer.start("grammar",new String[]{
                    "ns",defaultNs,
                    "xmlns",RELAXNGReader.RELAXNGNamespace,
                    "datatypeLibrary", XSDVocabulary.XMLSchemaNamespace });
            else
                writer.start("grammar", new String[]{
                    "xmlns",RELAXNGReader.RELAXNGNamespace,
                    "datatypeLibrary", XSDVocabulary.XMLSchemaNamespace });
           
           
            {// write start pattern.
                writer.start("start");
                writeIsland( g.getTopLevel() );
                writer.end("start");
            }
           
            // write all named expressions
            Iterator itr = exp2name.keySet().iterator();
            while( itr.hasNext() ) {
                Expression exp = (Expression)itr.next();
                String name = (String)exp2name.get(exp);
                if( exp instanceof ReferenceExp )
                    exp = ((ReferenceExp)exp).exp;
                writer.start("define",new String[]{"name",name});
                writeIsland( exp );
View Full Code Here

        // if the combined child content expression is not complex,
        // only binary expressions used are choice and sequence.
                           
        // this is the choice of all constraints that made this
        // attribute fail.
        Expression constraint = rtoken.getFailedExp();
                           
        // The problem here is that sti.attributes.getValue(i)
        // didn't satisfy this expression.
                           
        // test some typical expression patterns and
View Full Code Here

//            // hope is remote that we can find required attributes.
//               
//            // TODO: reduce strength by converting concur to choice?
//            return null;
       
        Expression e = expression.visit(docDecl.attPicker);
               
        if( e.isEpsilonReducible() )    throw new Error();    // assertion
        // if attribute expression is epsilon reducible, then
        // AttributePruner must return Expression other than nullSet.
        // In that case, there should have been no error.

        final Set s = new java.util.HashSet();
        boolean more = false;
               
        while( e instanceof ChoiceExp ) {
            ChoiceExp ch = (ChoiceExp)e;
                   
            NameClass nc = ((AttributeExp)ch.exp2).nameClass;
            if( nc instanceof SimpleNameClass )
                s.add( nc.toString() );
            else
                more = true;
           
            e = ch.exp1;
        }
       
        if( e==Expression.nullSet )
            // we are in the full panic mode.
            // abandon diagnosis.
            return null;
       
        if(!(e instanceof AttributeExp ))    throw new Error(e.toString());    //assertion
       
        NameClass nc = ((AttributeExp)e).nameClass;
        if( nc instanceof SimpleNameClass )
            s.add( nc.toString() );
        else
View Full Code Here

TOP

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

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.