Package org.exolab.castor.xml.schema

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


        JClass    jClass    = state.getJClass();

        initialize(jClass);

        //-- XML information
        Schema  schema = simpleType.getSchema();
        XMLInfoNature xmlNature = new XMLInfoNature(classInfo);
        xmlNature.setNamespaceURI(schema.getTargetNamespace());
        xmlNature.setNodeName(typeName);

        extractAnnotations(simpleType, jClass);

        XSClass xsClass = new XSClass(jClass, typeName);
View Full Code Here


     *
     * @see junit.framework.TestCase#setUp()
     */
    protected void setUp() throws Exception {
        super.setUp();
        _schema = new Schema();
    }
View Full Code Here

            return;
        }

        try {
            XMLInstance2Schema xi2s = new XMLInstance2Schema();
            Schema schema = xi2s.createSchema(args[0]);

            Writer dstWriter = null;
            if (args.length > 1) {
                dstWriter = new FileWriter(args[1]);
            } else {
View Full Code Here

            final AttributeSet atts,
            final URIResolver uriResolver)
    throws XMLException {
        super(schemaContext);

        _schema = new Schema();
        //--initialize the schema to ensure that the default namespace
        //--is not set
        _schema.removeNamespace("");
        if (getResolver() == null) {
            setResolver(new ScopableResolver());
View Full Code Here

        _siStack   = new Stack();
       
        _schema = schema;
        //-- create Schema and initialize
        if (_schema == null) {
            _schema = new Schema();
            _schema.addNamespace(DEFAULT_PREFIX, Schema.DEFAULT_SCHEMA_NS);
            _nsPrefix = DEFAULT_PREFIX;
        }
        //-- find or declare namespace prefix
        else {
View Full Code Here

        }
        else if (include.equals(schema.getSchemaLocation())) {
            return;
        }
       
        Schema includedSchema = null;
        boolean alreadyLoaded = false;

        //-- caching is on
        if (state.cacheIncludedSchemas) {
            if (uri instanceof SchemaLocation) {
            includedSchema = ((SchemaLocation)uri).getSchema();
            schema.cacheIncludedSchema(includedSchema);
            alreadyLoaded = true;
          }
          //-- Have we already imported this XML Schema file?
          if (state.processed(include)) {
            includedSchema = state.getSchema(include);
            schema.cacheIncludedSchema(includedSchema);
            alreadyLoaded = true;
          }
        }
     
        if (includedSchema == null)
        includedSchema = new Schema();
        else
          state.markAsProcessed(include, includedSchema);
       
        //-- keep track of the schemaLocation
        schema.addInclude(include);

        if (alreadyLoaded)
          return;
    Parser parser = null;
    try {
        parser = getSchemaContext().getParser();
    }
    catch(RuntimeException rte) {}
    if (parser == null) {
        throw new SchemaException("Error failed to create parser for include");
    }
    SchemaUnmarshaller schemaUnmarshaller = new SchemaUnmarshaller(getSchemaContext(), true, state, getURIResolver());

    if (state.cacheIncludedSchemas)
        schemaUnmarshaller.setSchema(includedSchema);
    else
      schemaUnmarshaller.setSchema(schema);
   
    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 include file '"+include+"'");
    }
    catch(org.xml.sax.SAXException sx) {
        throw new SchemaException(sx);
    }
    if (state.cacheIncludedSchemas) {
      String ns = includedSchema.getTargetNamespace();
      if (ns == null || ns == "")
        includedSchema.setTargetNamespace(schema.getTargetNamespace());
      else if (!ns.equals(schema.getTargetNamespace()))
        throw new SchemaException("The target namespace of the included components must be the same as the target namespace of the including schema");
      schema.cacheIncludedSchema(includedSchema);
    }
  }
View Full Code Here

                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

            //-- 2- ##other, ##any are not supported
            if (any.getNamespaces().hasMoreElements()) {
                String nsURI = (String) any.getNamespaces().nextElement();
                if (nsURI.length() > 0) {
                    if (nsURI.equals("##targetNamespace")) {
                        Schema schema = any.getSchema();
                        if (schema != null) {
                            xmlNature.setNamespaceURI(schema.getTargetNamespace());
                        }
                    } else if (!nsURI.startsWith("##")) {
                        xmlNature.setNamespaceURI(nsURI);
                    }
                }
View Full Code Here

                getSchemaLocation(parent, location, dealWithAnonTypes);
            }
            location.append(ExtendedBinding.PATH_SEPARATOR);
            location.append(((ElementDecl) structure).getName());
            if (parent instanceof Schema) {
                Schema schema = (Schema) parent;
                if (schema.getTargetNamespace() != null) {
                    String targetNamespace = schema.getTargetNamespace();
                    location.append("{" + targetNamespace + "}");
                }
            }
            break;
View Full Code Here

                throw new CastorRuntimeException(msg, sx);
            }
            return;
        }

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

TOP

Related Classes of org.exolab.castor.xml.schema.Schema

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.