Пример #1
0
 /**
  * Creates a new XMLInstance2SchemaHandler
  *
 **/
 public XMLInstance2SchemaHandler(Schema schema) {
     super();
     
     _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 {
         _nsPrefix = null;
         Hashtable namespaces = _schema.getNamespaces();
         Enumeration enum = namespaces.keys();
         while (enum.hasMoreElements()) {
             String key = (String) enum.nextElement();
             if (namespaces.get(key).equals(Schema.DEFAULT_SCHEMA_NS)) {
                 _nsPrefix = key;
                 break;
             }
         }
         if (_nsPrefix == null) {
             _schema.addNamespace(DEFAULT_PREFIX, Schema.DEFAULT_SCHEMA_NS);
             _nsPrefix = DEFAULT_PREFIX;
         }
     }
 } //-- XMLInstance2SchemaHandler
Пример #2
0
    /**
     * Creates a new Schema definition
     *
     * @param prefix the desired namespace prefix for the schemaNS.
     * @param schemaNS the namespace of the XML Schema itself. Note
     * this is not the same as the targetNamespace.
     */
    public Schema(String prefix, String schemaNS) {
        super();

        _attributes       = new Hashtable();
        _attributeGroups  = new Hashtable();
        _complexTypes     = new Hashtable();
        _simpleTypes      = new Hashtable();
        _elements         = new Hashtable();
        _groups           = new Hashtable();
        _importedSchemas  = new Hashtable();
        _includedSchemas  = new Vector();
        _namespaces       = new Namespaces();

        _schemaNamespace = schemaNS;
        if (_schemaNamespace == null) {
            _schemaNamespace = DEFAULT_SCHEMA_NS;
        }
        
        //-- declare default namespace bindings
        if (prefix == null) prefix = "";
        addNamespace(prefix, _schemaNamespace);

        init();
    } //-- ScehamDef