/** loads XML Schema */ public static XMLSchemaGrammar parse( InputSource grammar, SAXParserFactory factory, GrammarReaderController controller ) { XMLSchemaReader reader = new XMLSchemaReader(controller,factory); reader.parse(grammar); return reader.getResult(); }
protected State createChildState( StartTagInfo tag ) { final XMLSchemaReader reader = (XMLSchemaReader)this.reader; State s; if( super.exp==Expression.epsilon ) { // model group must be the first expression child. s = reader.createModelGroupState(this,tag); if(s!=null ) return s; } // attribute, attributeGroup, and anyAttribtue can be specified // after content model is given. return reader.createAttributeState(this,tag); }
protected State createChildState( StartTagInfo tag ) { final XMLSchemaReader reader = (XMLSchemaReader)this.reader; if( incubator==null && tag.localName.equals("simpleType") ) return reader.sfactory.simpleType(this,tag); State s = reader.createAttributeState(this,tag); if(s!=null ) return s; return reader.createFacetState(this,tag); // facets }
if(base==null) { reader.reportError( XMLSchemaReader.ERR_MISSING_ATTRIBUTE, startTag.localName, "base"); return Expression.nullSet; final String[] baseTypeName = reader.splitQName(base); if( baseTypeName==null ) { reader.reportError( XMLSchemaReader.ERR_UNDECLARED_PREFIX, base ); return Expression.nullSet; if(reader.isSchemaNamespace(baseTypeName[0])) { XSDatatype dt = reader.resolveBuiltinDataType(baseTypeName[1]); if(dt!=null) { XSDatatypeExp dtexp = new XSDatatypeExp(dt,reader.pool); reader.addBackPatchJob( new GrammarReader.BackPatch(){ public State getOwnerState() { return SimpleContentExtensionState.this;
reader.reportError( XMLSchemaReader.ERR_MISSING_ATTRIBUTE, startTag.localName, "name" ); return; // recover by ignoring this constraint. 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; reader.addBackPatchJob( new GrammarReader.BackPatch(){ public State getOwnerState() { return IdentityConstraintState.this; } public void patch() { reader.reportError( new Locator[]{ this.location, reader.getDeclaredLocationOf(id) }, XMLSchemaReader.ERR_DUPLICATE_IDENTITY_CONSTRAINT_DEFINITION, new Object[]{name} ); reader.currentSchema.identityConstraints.add(name,id); reader.setDeclaredLocationOf(id); ((ElementDeclState)parentState).onIdentityConstraint(id);
public void switchSource(Source source, State newState) { String url = source.getSystemId(); if (url != null && sysIds.contains(url)) { return; } super.switchSource(source, newState); }
final String[] s = reader.splitQName(typeQName); if(s==null) { reader.reportError( XMLSchemaReader.ERR_UNDECLARED_PREFIX, typeQName ); reader.addBackPatchJob( new GrammarReader.BackPatch(){ public State getOwnerState() { return ElementDeclState.this; } public void patch() {
protected XMLValidationSchema loadSchema(InputSource src, Object sysRef) throws XMLStreamException { /* 26-Oct-2007, TSa: Are SAX parser factories safe to share? * If not, should just create new instances for each * parsed schema. */ SAXParserFactory saxFactory = getSaxFactory(); MyGrammarController ctrl = new MyGrammarController(); XMLSchemaGrammar grammar = XMLSchemaReader.parse(src, saxFactory, ctrl); if (grammar == null) { String msg = "Failed to load W3C Schema from '"+sysRef+"'"; String emsg = ctrl.mErrorMsg; if (emsg != null) { msg = msg + ": "+emsg; } throw new XMLStreamException(msg); } return new W3CSchema(grammar); } }
Schema s = XMLSchemaReader.getXmlSchemaForXmlSchema(); reader[0] = new XMLSchemaReader( getController(), new SAXParserFactoryImpl(getSAXParserFactory(),s), winner = setupPipeline(s); } else { winner = reader[0] = new XMLSchemaReader( getController(),getSAXParserFactory(),getPool());
protected void switchSource( State sourceState, State newRootState ) throws AbortException { final String schemaLocation = sourceState.getStartTag().getAttribute("schemaLocation"); if(schemaLocation==null) { // schemaLocation attribute is required. reportError( ERR_MISSING_ATTRIBUTE, sourceState.getStartTag().qName, "schemaLocation" ); // recover by ignoring this element } else // parse specified file switchSource( sourceState, schemaLocation, newRootState ); }
protected State createChildState( StartTagInfo tag ) { final XMLSchemaReader reader = (XMLSchemaReader)this.reader; // TODO: group reference is prohibited under group element. return reader.createModelGroupState(this,tag); }
protected State createChildState( StartTagInfo tag ) { final XMLSchemaReader reader = (XMLSchemaReader)this.reader; return reader.createAttributeState(this,tag); }
wsdlSystemId, schemas); XMLSchemaReader reader = new XMLSchemaReader(wsdlController); reader.setAdditionalNamespaceMap(wsdlNamespaceMappings); MultiSchemaReader multiSchemaReader = new MultiSchemaReader(reader); for (EmbeddedSchema schema : schemas.values()) {
/** * Adds maxOccurs/minOccurs semantics to a given expression. * * @param maxOccurs * -1 to represent "unbounded". */ public Expression processOccurs( Expression item, int minOccurs, int maxOccurs ) { Expression precise = _processOccurs(item,minOccurs,maxOccurs); if(maxOccurs==1) return precise; if(maxOccurs==-1 && minOccurs<=1 ) return precise; return new OccurrenceExp(precise,maxOccurs,minOccurs,item); }
/** easy-to-use constructor. */ public XMLSchemaReader( GrammarReaderController controller ) { this(controller,createParserFactory()); }
reader.addBackPatchJob( new GrammarReader.BackPatch(){ public State getOwnerState() { return AnyElementState.this; } public void patch() {
/** tests the existence of all messages */ public void testMessages() throws Exception { final XMLSchemaReader reader = new XMLSchemaReader(null); Checker checker = new Checker(){ public void check( String propertyName ) { // if the specified property doesn't exist, this will throw an error System.out.println( reader.localizeMessage(propertyName,new Object[]{"@@@","@@@","@@@","@@@","@@@"})); } }; String prefixes[] = new String[]{"ERR_","WRN_"}; for( int i=0; i<prefixes.length; i++ ) { ResourceChecker.check( XMLSchemaReader.class, prefixes[i], checker ); ResourceChecker.check( GrammarReader.class, prefixes[i], checker ); } } }
protected Schema getSchemaForSchema() { return XMLSchemaReader.getXmlSchemaForXmlSchema(); }
if(base==null) { reader.reportError( XMLSchemaReader.ERR_MISSING_ATTRIBUTE, startTag.localName, "base"); return Expression.nullSet; final String[] baseTypeName = reader.splitQName(base); if( baseTypeName==null ) { reader.reportError( XMLSchemaReader.ERR_UNDECLARED_PREFIX, base ); return Expression.nullSet; if(reader.isSchemaNamespace(baseTypeName[0])) { XSDatatype dt = reader.resolveBuiltinDataType(baseTypeName[1]); if(dt!=null) { XSDatatypeExp dtexp = new XSDatatypeExp(dt,reader.pool); reader.addBackPatchJob( new GrammarReader.BackPatch(){ public State getOwnerState() { return SimpleContentExtensionState.this;
reader.reportError( XMLSchemaReader.ERR_MISSING_ATTRIBUTE, startTag.localName, "name" ); return; // recover by ignoring this constraint. 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; reader.addBackPatchJob( new GrammarReader.BackPatch(){ public State getOwnerState() { return IdentityConstraintState.this; } public void patch() { reader.reportError( new Locator[]{ this.location, reader.getDeclaredLocationOf(id) }, XMLSchemaReader.ERR_DUPLICATE_IDENTITY_CONSTRAINT_DEFINITION, new Object[]{name} ); reader.currentSchema.identityConstraints.add(name,id); reader.setDeclaredLocationOf(id); ((ElementDeclState)parentState).onIdentityConstraint(id);