Package org.exolab.castor.xml.schema.reader

Examples of org.exolab.castor.xml.schema.reader.SchemaUnmarshaller


            _dialog.notify("fatal error: unable to create SAX parser.");
            return;
        }

        SchemaContext schemaContext = new SchemaContextImpl();
        SchemaUnmarshaller schemaUnmarshaller = null;
        try {
           schemaUnmarshaller = new SchemaUnmarshaller(schemaContext);
        } catch (XMLException e) {
            //--The default constructor cannot throw exception so this should never happen
            //--just log the exception
            e.printStackTrace();
            System.exit(1);
        }

        Sax2ComponentReader handler = new Sax2ComponentReader(schemaUnmarshaller);
        parser.setDocumentHandler(handler);
        parser.setErrorHandler(handler);

        try {
            parser.parse(source);
        } catch (java.io.IOException ioe) {
            _dialog.notify("error reading XML Schema file");
            if (_failOnFirstError) {
                throw ioe;
            }
            return;
        } catch (org.xml.sax.SAXException sx) {
            Exception except = sx.getException();
            if (except == null) {
                except = sx;
            }

            if (except instanceof SAXParseException) {
                SAXParseException spe = (SAXParseException) except;
                _dialog.notify("SAXParseException: " + spe);
                _dialog.notify(" - occured at line ");
                _dialog.notify(Integer.toString(spe.getLineNumber()));
                _dialog.notify(", column ");
                _dialog.notify(Integer.toString(spe.getColumnNumber()));
            } else {
                except.printStackTrace();
            }
            if (_failOnFirstError) {
                String msg = "Source Generator: schema parser threw an Exception";
                throw new CastorRuntimeException(msg, sx);
            }
            return;
        }

        Schema schema = schemaUnmarshaller.getSchema();
       
        try {
            schema.validate();
        } catch (ValidationException vx) {
            throw new NestedIOException(vx);
View Full Code Here


            if (parser == null) {
                throw new BuildException("Unable to create SAX parser.");
            }

            SchemaContext schemaContext = new SchemaContextImpl();
            SchemaUnmarshaller schemaUnmarshaller = null;
            try {
                schemaUnmarshaller = new SchemaUnmarshaller(schemaContext);
            } catch (XMLException e) {
                throw new BuildException("Unable to create schema unmarshaller.", e);
            }

            Sax2ComponentReader handler = new Sax2ComponentReader(schemaUnmarshaller);
            parser.setDocumentHandler(handler);
            parser.setErrorHandler(handler);
            try {
                parser.parse(source);
            } catch (IOException e) {
                String msg = "Can't read input file " + source.getSystemId() + ".\n" + e;
                throw new BuildException(msg, e);
            } catch (SAXException e) {
                String msg = "Can't parse input file " + source.getSystemId() + ".\n" + e;
                throw new BuildException(msg, e);
            }
            Schema schema = schemaUnmarshaller.getSchema();
            try {
                generateSource(schema, packageName);
            } catch (Exception iox) {
                throw new BuildException(iox);
            }
View Full Code Here

            }
            if (parser == null) {
                throw new BuildException("Unable to create SAX parser.");
            }

            SchemaUnmarshaller schemaUnmarshaller = null;
            try {
                schemaUnmarshaller = new SchemaUnmarshaller();
            } catch (XMLException e) {
                throw new BuildException("Unable to create schema unmarshaller.", e);
            }

            Sax2ComponentReader handler = new Sax2ComponentReader(schemaUnmarshaller);
            parser.setDocumentHandler(handler);
            parser.setErrorHandler(handler);
            try {
                parser.parse(source);
            } catch (IOException e) {
                String msg = "Can't read input file " + source.getSystemId() + ".\n" + e;
                throw new BuildException(msg, e);
            } catch (SAXException e) {
                String msg = "Can't parse input file " + source.getSystemId() + ".\n" + e;
                throw new BuildException(msg, e);
            }
            Schema schema = schemaUnmarshaller.getSchema();
            try {
                generateSource(schema, packageName);
            } catch (Exception iox) {
                throw new BuildException(iox);
            }
View Full Code Here

            }
            if (parser == null) {
                throw new BuildException("Unable to create SAX parser.");
            }

            SchemaUnmarshaller schemaUnmarshaller = null;
            try {
                schemaUnmarshaller = new SchemaUnmarshaller();
            } catch (XMLException e) {
                throw new BuildException("Unable to create schema unmarshaller.", e);
            }

            Sax2ComponentReader handler = new Sax2ComponentReader(schemaUnmarshaller);
            parser.setDocumentHandler(handler);
            parser.setErrorHandler(handler);
            try {
                parser.parse(source);
            } catch (IOException e) {
                throw new BuildException("Can't read input file " + source.getSystemId() + ".\n" + e, e);
            } catch (SAXException e) {
                throw new BuildException("Can't parse input file " + source.getSystemId() + ".\n" + e, e);
            }
            Schema schema = schemaUnmarshaller.getSchema();
            generateSource(schema, packageName);
        }
View Full Code Here

TOP

Related Classes of org.exolab.castor.xml.schema.reader.SchemaUnmarshaller

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.