public void doLoad()

in impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDOXMLResourceImpl.java [527:591]


    public void doLoad(InputSource inputSource, Map options) throws IOException {
        if (options != null) {
            /*
             * Tolerates element/attribute malform unless indicated not to
             */
            Object option = options.get(SDOHelper.XMLOptions.XML_LOAD_LAX_FORM);
            int tolerance = option == null ? loadLaxForm : ((Number) option).intValue();
            option = options.get(OPTION_EXTENDED_META_DATA);
            if (tolerance == 0) {
                if (option instanceof SDOExtendedMetaData)
                    ((SDOExtendedMetaData) option).setFeatureNamespaceMatchingLax(false);
            } else if (option instanceof SDOExtendedMetaData){
                ((SDOExtendedMetaData) option).setFeatureNamespaceMatchingLax(true);
            }
            else{
                options.put(OPTION_EXTENDED_META_DATA, option = new SDOExtendedMetaDataImpl()); // TODO copy (BasicExtendedMetaData)option
            }
            /*
             * Loads schema if necessary
             */
            if (Boolean.TRUE.equals(options.get(SDOHelper.XMLOptions.XML_LOAD_SCHEMA))){
                XMLOptions xmlOptions = (XMLOptions) options.get(OPTION_XML_OPTIONS);
                if (xmlOptions == null) {
                    xmlOptions = new XMLOptionsImpl();
                    options.put(OPTION_XML_OPTIONS, xmlOptions);
                }
                xmlOptions.setProcessSchemaLocations(true);
                if (option == null){
                    option = getDefaultLoadOptions().get(OPTION_EXTENDED_META_DATA);
                }
                ExtendedMetaData extendedMetaData;
                final XSDHelper xsdHelper;
                if (option == null) {
                    extendedMetaData = ExtendedMetaData.INSTANCE;
                    xsdHelper = XSDHelper.INSTANCE;
                } else {
                    extendedMetaData = (ExtendedMetaData) option;
                    xsdHelper = (new HelperContextImpl(extendedMetaData, false)).getXSDHelper();
                }
                xmlOptions.setEcoreBuilder(new DefaultEcoreBuilder(extendedMetaData) {
                    public Collection generate(Map targetNamespaceToURI) throws IOException {
                        for (Iterator iterator = targetNamespaceToURI.values().iterator(); iterator.hasNext();) {
                            String uri = iterator.next().toString();
                            xsdHelper.define(uri.indexOf(":/") == -1 ? Thread.currentThread().getContextClassLoader().getResourceAsStream(uri)
                                    : new URL(uri).openStream(), uri);
                        }
                        return null; // XMLHandler#processSchemaLocations doesn't take the result
                    }
                });
            }
            
            if (Boolean.TRUE.equals(options.get(SDOHelper.XMLOptions.XML_LOAD_UNKNOWN_PROPERTIES))) {
                options.put(OPTION_RECORD_UNKNOWN_FEATURE , Boolean.TRUE);
            }
        }
        else if (loadLaxForm != 0) {
            /*
             * Tolerates element/attribute malform
             */
            options = new HashMap();
            options.put(OPTION_EXTENDED_META_DATA, new SDOExtendedMetaDataImpl());
        }
        super.doLoad(inputSource, options);
        // TODO there is some thinking to be done about the restoration of options
    }