Examples of SchemaException


Examples of org.exolab.castor.xml.schema.SchemaException

        //-- check for name mismatches
        if (unmarshaller != null) {
            if (!name.equals(unmarshaller.elementName())) {
                String err = "missing end element for ";
                err += unmarshaller.elementName();
                throw new SchemaException(err);
            }
        }

        //-- have unmarshaller perform any necessary clean up
        unmarshaller.finish();
View Full Code Here

Examples of org.exolab.castor.xml.schema.SchemaException

        }
        else {
            StringBuffer err = new StringBuffer("illegal element <");
            err.append(name);
            err.append("> found in <group>.");
            throw new SchemaException(err.toString());
        }

    } //-- startElement
View Full Code Here

Examples of org.exolab.castor.xml.schema.SchemaException

        //-- check for name mismatches
        if (unmarshaller != null) {
            if (!name.equals(unmarshaller.elementName())) {
                String err = "missing end element for ";
                err += unmarshaller.elementName();
                throw new SchemaException(err);
            }
        }

        if (SchemaNames.ANNOTATION.equals(name)) {
            Annotation ann = (Annotation)unmarshaller.getObject();
View Full Code Here

Examples of org.exolab.castor.xml.schema.SchemaException

            final SchemaUnmarshallerState state)
    throws XMLException {
        super(schemaContext);
        if (schema == null) {
          String err = SchemaNames.REDEFINE + " must be used with an existing parent XML Schema.";
          throw new SchemaException(err);
        }
        setURIResolver(uriResolver);

        URILocation uri = null;
    //-- Get schemaLocation
    String schemaLocation = atts.getValue(SchemaNames.SCHEMALOCATION_ATTR);
    _schema = schema;
   
    if (schemaLocation == null) {
        //-- <redefine/> or <redefine> <annotation>(*) </redefine>
        _redefineSchema = new RedefineSchema(schema);
        _schema.addRedefineSchema(_redefineSchema);
      return;
    }

       
        if (schemaLocation.indexOf("\\") != -1) {
            String err = "'" + schemaLocation +
                "' is not a valid URI as defined by IETF RFC 2396.";
            err += "The URI mustn't contain '\\'.";
            error(err);
      }

        try {
            String documentBase = locator.getSystemId();
            if (documentBase != null) {
                if (!documentBase.endsWith("/"))
                    documentBase = documentBase.substring(0, documentBase.lastIndexOf('/') +1 );
            }
          uri = getURIResolver().resolve(schemaLocation, documentBase);
            if (uri != null) {
                schemaLocation = uri.getAbsoluteURI();
            }
        }
        catch (URIException urix) {
            throw new XMLException(urix);
        }

        //-- Schema object to hold import schema
    boolean addSchema = false;
    _redefineSchema = schema.getRedefineSchema(schemaLocation);
    Schema importedSchema = null;
   
    boolean alreadyLoaded = false;
   
        //-- The schema is not yet loaded
    if (_redefineSchema == null) {
            if (uri instanceof SchemaLocation) {
                importedSchema = ((SchemaLocation)uri).getSchema();
                //-- set the main schema in order to handle
                //-- redefinition at runtime
               
                // importedSchema.addMainSchema(schema);
               
                _redefineSchema = new RedefineSchema(schema, importedSchema);
          schema.addRedefineSchema(_redefineSchema);
          alreadyLoaded = true;
            }
            else {
          importedSchema = new Schema();
          addSchema = true;
      }
    }
    else {
      //-- check schema location, if different, allow merge
        String tmpLocation = _redefineSchema.getOriginalSchema().getSchemaLocation();
        alreadyLoaded = schemaLocation.equals(tmpLocation);
    }

        state.markAsProcessed(schemaLocation, importedSchema);

        if (alreadyLoaded) return;
       
        //-- Parser Schema
    Parser parser = null;
    try {
        parser = getSchemaContext().getParser();
    }
    catch(RuntimeException rte) {}
    if (parser == null) {
        throw new SchemaException("Error failed to create parser for import");
    }
    //-- Create Schema object and setup unmarshaller
    SchemaUnmarshaller schemaUnmarshaller = new SchemaUnmarshaller(getSchemaContext(), state);
    schemaUnmarshaller.setURIResolver(getURIResolver());
    schemaUnmarshaller.setSchema(importedSchema);
    Sax2ComponentReader handler = new Sax2ComponentReader(schemaUnmarshaller);
    parser.setDocumentHandler(handler);
    parser.setErrorHandler(handler);

    try {
        InputSource source = new InputSource(uri.getReader());
            source.setSystemId(uri.getAbsoluteURI());
            parser.parse(source);
    }
    catch(java.io.IOException ioe) {
        throw new SchemaException("Error reading import file '"+schemaLocation+"': "+ ioe);
    }
    catch(org.xml.sax.SAXException sx) {
        throw new SchemaException(sx);
    }
   
    //-- namespace checking
    String namespace = importedSchema.getTargetNamespace();
    if ( namespace != null ) {
View Full Code Here

Examples of org.exolab.castor.xml.schema.SchemaException

          error(err);
        }
      }
      else {
        String err = "error: missing start element for " + name;
        throw new SchemaException(err);
      }

      //-- call unmarshaller.finish() to perform any necessary cleanup
      _unmarshaller.finish();
View Full Code Here

Examples of org.exolab.castor.xml.schema.SchemaException

            StringBuffer err = new StringBuffer("illegal element <");
            err.append(name);
            err.append("> found in <");
            err.append(_element);
            err.append(">");
            throw new SchemaException(err.toString());
        }

    } //-- startElement
View Full Code Here

Examples of org.exolab.castor.xml.schema.SchemaException

        //-- check for name mismatches
        if (unmarshaller != null) {
            if (!name.equals(unmarshaller.elementName())) {
                String err = "missing end element for ";
                err += unmarshaller.elementName();
                throw new SchemaException(err);
            }
        }

        //-- have unmarshaller perform any necessary clean up
        unmarshaller.finish();
View Full Code Here

Examples of org.exolab.castor.xml.schema.SchemaException

                else
                    _complexType.setBaseType(baseType);
            }
            else if (derivedBy.equals(KEYWORD_RESTRICTIONS)) {
                String err = "restrictions not yet supported for <type>.";
                throw new SchemaException(err);
            }
            else {
                String err = "invalid value for derivedBy attribute of ";
                err += "<type>: " + derivedBy;
                throw new SchemaException(err);
            }

        }

        //-- read @abstract attribute
View Full Code Here

Examples of org.exolab.castor.xml.schema.SchemaException

            --depth;
            return;
        }

        if (unmarshaller == null)
            throw new SchemaException("missing start element: " + name);
        else if (SchemaNames.ANNOTATION.equals(name)) {
            Annotation annotation = (Annotation)unmarshaller.getObject();
            _facet.addAnnotation(annotation);
        }
View Full Code Here

Examples of org.exolab.castor.xml.schema.SchemaException

            }
            else {
                String err = "The value of the '" + SchemaNames.REF_ATTR +
                    "' attribute for attribute group must contain a " +
                    "valid value.";
                throw new SchemaException(err);
            }
        }
        else {
            AttributeGroupDecl attDecl = new AttributeGroupDecl(schema);
            _attributeGroup = attDecl;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.