public Acceptor createClone() { Expression[] models = new Expression[contents.length]; System.arraycopy(contents,0, models, 0, contents.length ); return new ComplexAcceptor( docDecl, getExpression(), models, owners ); }
public ComplexAcceptor( REDocumentDeclaration docDecl, Expression combined, Expression[] contentModels, ElementExp[] owners ) { // since all owners should belong to the same schema language, // ignoreUndeclaredAttributes must be the same. // that's why I'm using owners[0]. super( docDecl, combined, contentModels, owners[0].ignoreUndeclaredAttributes ); this.owners = owners; }
public void endElement( String namespaceUri, String localName, String qName ) throws SAXException { 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(); if(exps.length!=1) throw new AmbiguousDocumentException(); type = exps[0]; } else throw new Error(); // assertion failed. not supported. handler.endElement( namespaceUri, localName, qName, type ); } }
public void endChildIsland( String childURI, ElementDecl[] ruleSet ) throws SAXException { ElementExp[] exps = new ElementExp[ruleSet.length]; for( int i=0; i<ruleSet.length; i++ ) { exps[i] = (ElementExp)rule2exp.get(ruleSet[i]); if( exps[i]==null ) throw new Error(); // assertion failed. // it must be registered. } Expression [] epsilons = new Expression[exps.length]; for( int i=0; i<epsilons.length; i++ ) epsilons[i] = Expression.epsilon; // change current Acceptor to a new Acceptor. // this new Acceptor is made to accept those satisfied rules only. current = new ComplexAcceptor( (REDocumentDeclaration)docDecl, (ruleSet.length==0)?Expression.nullSet:Expression.epsilon, epsilons, exps ); // call endElement to let Verifier do the job. super.endElement( lastNamaespaceUri, lastLocalName, lastQName ); }
public void endElement( String namespaceUri, String localName, String qName ) throws SAXException { 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(); if(exps.length!=1) throw new AmbiguousDocumentException(); type = exps[0]; } else throw new Error(); // assertion failed. not supported. handler.endElement( namespaceUri, localName, qName, type ); } }
public void endChildIsland( String childURI, ElementDecl[] ruleSet ) throws SAXException { ElementExp[] exps = new ElementExp[ruleSet.length]; for( int i=0; i<ruleSet.length; i++ ) { exps[i] = (ElementExp)rule2exp.get(ruleSet[i]); if( exps[i]==null ) throw new Error(); // assertion failed. // it must be registered. } Expression [] epsilons = new Expression[exps.length]; for( int i=0; i<epsilons.length; i++ ) epsilons[i] = Expression.epsilon; // change current Acceptor to a new Acceptor. // this new Acceptor is made to accept those satisfied rules only. current = new ComplexAcceptor( (REDocumentDeclaration)docDecl, (ruleSet.length==0)?Expression.nullSet:Expression.epsilon, epsilons, exps ); // call endElement to let Verifier do the job. super.endElement( lastNamaespaceUri, lastLocalName, lastQName ); }
public Acceptor createClone() { Expression[] models = new Expression[contents.length]; System.arraycopy(contents,0, models, 0, contents.length ); return new ComplexAcceptor( docDecl, getExpression(), models, owners ); }
public void endElement( String namespaceUri, String localName, String qName ) throws SAXException { 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(); if(exps.length!=1) throw new AmbiguousDocumentException(); type = exps[0]; } else throw new Error(); // assertion failed. not supported. handler.endElement( namespaceUri, localName, qName, type ); } }
public void endChildIsland( String childURI, ElementDecl[] ruleSet ) throws SAXException { ElementExp[] exps = new ElementExp[ruleSet.length]; for( int i=0; i<ruleSet.length; i++ ) { exps[i] = (ElementExp)rule2exp.get(ruleSet[i]); if( exps[i]==null ) throw new Error(); // assertion failed. // it must be registered. } Expression [] epsilons = new Expression[exps.length]; for( int i=0; i<epsilons.length; i++ ) epsilons[i] = Expression.epsilon; // change current Acceptor to a new Acceptor. // this new Acceptor is made to accept those satisfied rules only. current = new ComplexAcceptor( (REDocumentDeclaration)docDecl, (ruleSet.length==0)?Expression.nullSet:Expression.epsilon, epsilons, exps ); // call endElement to let Verifier do the job. super.endElement( lastNamaespaceUri, lastLocalName, lastQName ); }
public ComplexAcceptor( REDocumentDeclaration docDecl, Expression combined, Expression[] contentModels, ElementExp[] owners ) { // since all owners should belong to the same schema language, // ignoreUndeclaredAttributes must be the same. // that's why I'm using owners[0]. super( docDecl, combined, contentModels, owners[0].ignoreUndeclaredAttributes ); this.owners = owners; }
public Acceptor createClone() { Expression[] models = new Expression[contents.length]; System.arraycopy(contents,0, models, 0, contents.length ); return new ComplexAcceptor( docDecl, getExpression(), models, owners ); }
public void endElement( String namespaceUri, String localName, String qName ) throws SAXException { 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(); if(exps.length!=1) throw new AmbiguousDocumentException(); type = exps[0]; } else throw new Error(); // assertion failed. not supported. handler.endElement( namespaceUri, localName, qName, type ); } }
public void endChildIsland( String childURI, ElementDecl[] ruleSet ) throws SAXException { ElementExp[] exps = new ElementExp[ruleSet.length]; for( int i=0; i<ruleSet.length; i++ ) { exps[i] = (ElementExp)rule2exp.get(ruleSet[i]); if( exps[i]==null ) throw new Error(); // assertion failed. // it must be registered. } Expression [] epsilons = new Expression[exps.length]; for( int i=0; i<epsilons.length; i++ ) epsilons[i] = Expression.epsilon; // change current Acceptor to a new Acceptor. // this new Acceptor is made to accept those satisfied rules only. current = new ComplexAcceptor( (REDocumentDeclaration)docDecl, (ruleSet.length==0)?Expression.nullSet:Expression.epsilon, epsilons, exps ); // call endElement to let Verifier do the job. super.endElement( lastNamaespaceUri, lastLocalName, lastQName ); }
public ComplexAcceptor( REDocumentDeclaration docDecl, Expression combined, Expression[] contentModels, ElementExp[] owners ) { // since all owners should belong to the same schema language, // ignoreUndeclaredAttributes must be the same. // that's why I'm using owners[0]. super( docDecl, combined, contentModels, owners[0].ignoreUndeclaredAttributes ); this.owners = owners; }
public Acceptor createClone() { Expression[] models = new Expression[contents.length]; System.arraycopy(contents,0, models, 0, contents.length ); return new ComplexAcceptor( docDecl, getExpression(), models, owners ); }
public boolean stepForward( Acceptor child, StringRef errRef ) { // TODO: explicitly mention that where the error recovery should be done. if( child instanceof SimpleAcceptor ) { SimpleAcceptor sa = (SimpleAcceptor)child; if(sa.continuation!=null) // if the continuation is available, // the stepForward will be very fast. return stepForwardByContinuation( sa.continuation, errRef ); else // otherwise we have to compute the residual. return stepForward( new ElementToken(new ElementExp[]{sa.owner}), errRef ); } if( child instanceof ComplexAcceptor ) { ComplexAcceptor ca = (ComplexAcceptor)child; return stepForward( new ElementToken( (errRef!=null)? ca.owners: // in error recovery mode, pretend that every owner is happy. ca.getSatisfiedOwners() ), errRef); } throw new Error(); // child must be either Simple or Complex. }
/** * creates actual Acceptor object from the computed result. */ protected Acceptor createAcceptor( Expression combined, Expression continuation, ElementExp[] primitives, int numPrimitives ) { if( primitives==null || numPrimitives<=1 ) { // primitives==null is possible when recovering from error. // in this special case, combined child pattern and primitive patterns are the same. // therefore we don't need to keep track of primitive patterns. return new SimpleAcceptor( docDecl, combined, (primitives==null)?null:primitives[0], continuation ); } // TODO: implements MultipleAcceptor for cases that // combined expression is unnecessary but there are more than one primitive. if( com.sun.msv.driver.textui.Debug.debug ) System.out.println("ComplexAcceptor is used"); // we need a fresh array. ElementExp[] owners = new ElementExp[numPrimitives]; System.arraycopy( primitives, 0, owners, 0, numPrimitives ); return new ComplexAcceptor( docDecl, combined, owners ); }
public ComplexAcceptor( REDocumentDeclaration docDecl, Expression combined, Expression[] contentModels, ElementExp[] owners ) { // since all owners should belong to the same schema language, // ignoreUndeclaredAttributes must be the same. // that's why I'm using owners[0]. super( docDecl, combined, contentModels, owners[0].ignoreUndeclaredAttributes ); this.owners = owners; }
public boolean stepForward( Acceptor child, StringRef errRef ) { // TODO: explicitly mention that where the error recovery should be done. if( child instanceof SimpleAcceptor ) { SimpleAcceptor sa = (SimpleAcceptor)child; if(sa.continuation!=null) // if the continuation is available, // the stepForward will be very fast. return stepForwardByContinuation( sa.continuation, errRef ); else // otherwise we have to compute the residual. return stepForward( new ElementToken(new ElementExp[]{sa.owner}), errRef ); } if( child instanceof ComplexAcceptor ) { ComplexAcceptor ca = (ComplexAcceptor)child; return stepForward( new ElementToken( (errRef!=null)? ca.owners: // in error recovery mode, pretend that every owner is happy. ca.getSatisfiedOwners() ), errRef); } throw new Error(); // child must be either Simple or Complex. }
/** * creates actual Acceptor object from the computed result. */ protected Acceptor createAcceptor( Expression combined, Expression continuation, ElementExp[] primitives, int numPrimitives ) { if( primitives==null || numPrimitives<=1 ) { // primitives==null is possible when recovering from error. // in this special case, combined child pattern and primitive patterns are the same. // therefore we don't need to keep track of primitive patterns. return new SimpleAcceptor( docDecl, combined, (primitives==null)?null:primitives[0], continuation ); } // TODO: implements MultipleAcceptor for cases that // combined expression is unnecessary but there are more than one primitive. if( com.sun.msv.driver.textui.Debug.debug ) System.out.println("ComplexAcceptor is used"); // we need a fresh array. ElementExp[] owners = new ElementExp[numPrimitives]; System.arraycopy( primitives, 0, owners, 0, numPrimitives ); return new ComplexAcceptor( docDecl, combined, owners ); }