< prev index next >

src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/ModelLoader.java

Print this page




  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.tools.internal.xjc;
  27 
  28 import java.io.IOException;
  29 import java.io.StringReader;
  30 
  31 import com.sun.codemodel.internal.JCodeModel;
  32 import com.sun.tools.internal.xjc.model.Model;
  33 import com.sun.tools.internal.xjc.reader.Const;
  34 import com.sun.tools.internal.xjc.reader.ExtensionBindingChecker;
  35 import com.sun.tools.internal.xjc.reader.dtd.TDTDReader;
  36 import com.sun.tools.internal.xjc.reader.internalizer.DOMForest;
  37 import com.sun.tools.internal.xjc.reader.internalizer.DOMForestScanner;
  38 import com.sun.tools.internal.xjc.reader.internalizer.InternalizationLogic;
  39 import com.sun.tools.internal.xjc.reader.internalizer.SCDBasedBindingSet;
  40 import com.sun.tools.internal.xjc.reader.internalizer.VersionChecker;


  41 import com.sun.tools.internal.xjc.reader.xmlschema.BGMBuilder;
  42 import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.AnnotationParserFactoryImpl;
  43 import com.sun.tools.internal.xjc.reader.xmlschema.parser.CustomizationContextChecker;
  44 import com.sun.tools.internal.xjc.reader.xmlschema.parser.IncorrectNamespaceURIChecker;
  45 import com.sun.tools.internal.xjc.reader.xmlschema.parser.SchemaConstraintChecker;
  46 import com.sun.tools.internal.xjc.reader.xmlschema.parser.XMLSchemaInternalizationLogic;
  47 import com.sun.tools.internal.xjc.util.ErrorReceiverFilter;
  48 import com.sun.xml.internal.bind.v2.util.XmlFactory;
  49 import com.sun.xml.internal.xsom.XSSchemaSet;
  50 import com.sun.xml.internal.xsom.parser.JAXPParser;
  51 import com.sun.xml.internal.xsom.parser.XMLParser;
  52 import com.sun.xml.internal.xsom.parser.XSOMParser;
  53 import javax.xml.XMLConstants;
  54 









  55 import org.w3c.dom.Document;
  56 import org.w3c.dom.Element;
  57 import org.w3c.dom.NodeList;
  58 import org.xml.sax.Attributes;
  59 import org.xml.sax.ContentHandler;
  60 import org.xml.sax.EntityResolver;
  61 import org.xml.sax.ErrorHandler;
  62 import org.xml.sax.InputSource;
  63 import org.xml.sax.SAXException;
  64 import org.xml.sax.SAXParseException;
  65 import org.xml.sax.helpers.XMLFilterImpl;
  66 
  67 /**
  68  * Builds a {@link Model} object.
  69  *
  70  * This is an utility class that makes it easy to load a grammar object
  71  * from various sources.
  72  *
  73  * @author
  74  *     Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)


 320 
 321         if(opt.getBindFiles().length==0) {
 322             // no external binding. try the speculative no DOMForest execution,
 323             // which is faster if the speculation succeeds.
 324             try {
 325                 return createXSOMSpeculative();
 326             } catch( SpeculationFailure e) {
 327                 // failed. go the slow way
 328             }
 329         }
 330 
 331         // the default slower way is to parse everything into DOM first.
 332         // so that we can take external annotations into account.
 333         DOMForest forest = buildDOMForest( new XMLSchemaInternalizationLogic() );
 334         return createXSOM(forest, scdBasedBindingSet);
 335     }
 336 
 337     /**
 338      * Parses a set of schemas inside a WSDL file.
 339      *
 340      * A WSDL file may contain multiple &lt;xsd:schema> elements.
 341      */
 342     private XSSchemaSet loadWSDL()
 343         throws SAXException {
 344 
 345 
 346         // build DOMForest just like we handle XML Schema
 347         DOMForest forest = buildDOMForest( new XMLSchemaInternalizationLogic() );
 348 
 349         DOMForestScanner scanner = new DOMForestScanner(forest);
 350 
 351         XSOMParser xsomParser = createXSOMParser( forest );
 352 
 353         // find <xsd:schema>s and parse them individually
 354         for( InputSource grammar : opt.getGrammars() ) {
 355             Document wsdlDom = forest.get( grammar.getSystemId() );
 356             if (wsdlDom == null) {
 357                 String systemId = Options.normalizeSystemId(grammar.getSystemId());
 358                 if (forest.get(systemId) != null) {
 359                     grammar.setSystemId(systemId);
 360                     wsdlDom = forest.get( grammar.getSystemId() );




  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.tools.internal.xjc;
  27 
  28 import java.io.IOException;
  29 import java.io.StringReader;
  30 
  31 import com.sun.codemodel.internal.JCodeModel;
  32 import com.sun.tools.internal.xjc.model.Model;
  33 import com.sun.tools.internal.xjc.reader.Const;
  34 import com.sun.tools.internal.xjc.reader.ExtensionBindingChecker;
  35 import com.sun.tools.internal.xjc.reader.dtd.TDTDReader;
  36 import com.sun.tools.internal.xjc.reader.internalizer.DOMForest;
  37 import com.sun.tools.internal.xjc.reader.internalizer.DOMForestScanner;
  38 import com.sun.tools.internal.xjc.reader.internalizer.InternalizationLogic;
  39 import com.sun.tools.internal.xjc.reader.internalizer.SCDBasedBindingSet;
  40 import com.sun.tools.internal.xjc.reader.internalizer.VersionChecker;
  41 import com.sun.tools.internal.xjc.reader.relaxng.RELAXNGCompiler;
  42 import com.sun.tools.internal.xjc.reader.relaxng.RELAXNGInternalizationLogic;
  43 import com.sun.tools.internal.xjc.reader.xmlschema.BGMBuilder;
  44 import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.AnnotationParserFactoryImpl;
  45 import com.sun.tools.internal.xjc.reader.xmlschema.parser.CustomizationContextChecker;
  46 import com.sun.tools.internal.xjc.reader.xmlschema.parser.IncorrectNamespaceURIChecker;
  47 import com.sun.tools.internal.xjc.reader.xmlschema.parser.SchemaConstraintChecker;
  48 import com.sun.tools.internal.xjc.reader.xmlschema.parser.XMLSchemaInternalizationLogic;
  49 import com.sun.tools.internal.xjc.util.ErrorReceiverFilter;
  50 import com.sun.xml.internal.bind.v2.util.XmlFactory;
  51 import com.sun.xml.internal.xsom.XSSchemaSet;
  52 import com.sun.xml.internal.xsom.parser.JAXPParser;
  53 import com.sun.xml.internal.xsom.parser.XMLParser;
  54 import com.sun.xml.internal.xsom.parser.XSOMParser;
  55 import javax.xml.XMLConstants;
  56 
  57 import com.sun.xml.internal.rngom.ast.builder.SchemaBuilder;
  58 import com.sun.xml.internal.rngom.ast.util.CheckingSchemaBuilder;
  59 import com.sun.xml.internal.rngom.digested.DPattern;
  60 import com.sun.xml.internal.rngom.digested.DSchemaBuilderImpl;
  61 import com.sun.xml.internal.rngom.parse.IllegalSchemaException;
  62 import com.sun.xml.internal.rngom.parse.Parseable;
  63 import com.sun.xml.internal.rngom.parse.compact.CompactParseable;
  64 import com.sun.xml.internal.rngom.parse.xml.SAXParseable;
  65 import com.sun.xml.internal.rngom.xml.sax.XMLReaderCreator;
  66 import org.w3c.dom.Document;
  67 import org.w3c.dom.Element;
  68 import org.w3c.dom.NodeList;
  69 import org.xml.sax.Attributes;
  70 import org.xml.sax.ContentHandler;
  71 import org.xml.sax.EntityResolver;
  72 import org.xml.sax.ErrorHandler;
  73 import org.xml.sax.InputSource;
  74 import org.xml.sax.SAXException;
  75 import org.xml.sax.SAXParseException;
  76 import org.xml.sax.helpers.XMLFilterImpl;
  77 
  78 /**
  79  * Builds a {@link Model} object.
  80  *
  81  * This is an utility class that makes it easy to load a grammar object
  82  * from various sources.
  83  *
  84  * @author
  85  *     Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)


 331 
 332         if(opt.getBindFiles().length==0) {
 333             // no external binding. try the speculative no DOMForest execution,
 334             // which is faster if the speculation succeeds.
 335             try {
 336                 return createXSOMSpeculative();
 337             } catch( SpeculationFailure e) {
 338                 // failed. go the slow way
 339             }
 340         }
 341 
 342         // the default slower way is to parse everything into DOM first.
 343         // so that we can take external annotations into account.
 344         DOMForest forest = buildDOMForest( new XMLSchemaInternalizationLogic() );
 345         return createXSOM(forest, scdBasedBindingSet);
 346     }
 347 
 348     /**
 349      * Parses a set of schemas inside a WSDL file.
 350      *
 351      * A WSDL file may contain multiple {@code <xsd:schema>} elements.
 352      */
 353     private XSSchemaSet loadWSDL()
 354         throws SAXException {
 355 
 356 
 357         // build DOMForest just like we handle XML Schema
 358         DOMForest forest = buildDOMForest( new XMLSchemaInternalizationLogic() );
 359 
 360         DOMForestScanner scanner = new DOMForestScanner(forest);
 361 
 362         XSOMParser xsomParser = createXSOMParser( forest );
 363 
 364         // find <xsd:schema>s and parse them individually
 365         for( InputSource grammar : opt.getGrammars() ) {
 366             Document wsdlDom = forest.get( grammar.getSystemId() );
 367             if (wsdlDom == null) {
 368                 String systemId = Options.normalizeSystemId(grammar.getSystemId());
 369                 if (forest.get(systemId) != null) {
 370                     grammar.setSystemId(systemId);
 371                     wsdlDom = forest.get( grammar.getSystemId() );


< prev index next >