Package org.apache.ws.commons.schema.utils

Examples of org.apache.ws.commons.schema.utils.NamespacePrefixList


                if (value.indexOf(":") > -1 && !nodeName.startsWith("xmlns")) {
                    String prefix = value.substring(0, value.indexOf(":"));
                    String oldNamespace;
                    if ((oldNamespace = (String) namespaces.get(prefix)) != null) {
                        value = value.substring(value.indexOf(":") + 1);
                        NamespacePrefixList ctx = schema.getNamespaceContext();
                        String[] prefixes = ctx.getDeclaredPrefixes();
                        for (int j = 0;  j < prefixes.length;  j++) {
                            String pref = prefixes[j];
                            String uri = ctx.getNamespaceURI(pref);
                            if (uri.equals(oldNamespace)) {
                                value = prefix + ":" + value;
                            }
                        }
                    }
View Full Code Here


                    String prefix = value.substring(0, value.indexOf(":"));
                    String oldNamespace;
                    oldNamespace = namespaces.get(prefix);
                    if (oldNamespace != null) {
                        value = value.substring(value.indexOf(":") + 1);
                        NamespacePrefixList ctx = schema.getNamespaceContext();
                        String[] prefixes = ctx.getDeclaredPrefixes();
                        for (String pref : prefixes) {
                            String uri = ctx.getNamespaceURI(pref);
                            if (uri.equals(oldNamespace)) {
                                value = prefix + ":" + value;
                            }
                        }
                    }
View Full Code Here

    /**
     * Set up <schema> namespaces appropriately and append that attr
     * into specified element
     */
    private Element setupNamespaces(Document schemaDocs, XmlSchema schemaObj) {
        NamespacePrefixList ctx = schemaObj.getNamespaceContext();
        if (ctx != null) {
            xsdPrefix = ctx.getPrefix(XSD_NAMESPACE);
        } else {
            xsdPrefix = null;
        }

        if (xsdPrefix == null) {
            //find a prefix to use
            xsdPrefix = "";
            if (ctx != null && ctx.getNamespaceURI(xsdPrefix) != null) {
                xsdPrefix = "xsd";
            }
            int count = 0;
            while (ctx != null && ctx.getNamespaceURI(xsdPrefix) != null) {
                xsdPrefix = "xsd" + ++count;
            }
        }
        schemaObj.setSchemaNamespacePrefix(xsdPrefix);


        Element schemaEl = createNewElement(schemaDocs, "schema",
                                            schemaObj.getSchemaNamespacePrefix(), XmlSchema.SCHEMA_NS);

        if (ctx != null) {
            String[] prefixes = ctx.getDeclaredPrefixes();
            for (int i = 0;  i < prefixes.length;  i++) {
                String prefix = prefixes[i];
                String uri = ctx.getNamespaceURI(prefix);
                if (uri != null && prefix != null) {
                    if ("".equals(prefix) || !schemaNamespace.containsKey(uri)) {
                        schemaNamespace.put(uri, prefix);
                    }
                    prefix = (prefix.length() > 0) ? "xmlns:" + prefix : "xmlns";
View Full Code Here

        // we need an import for every namespace except the main one.
        String schemaNamespace = schemaInfo.getNamespaceURI();
        Map<String, String> queryPrefixMap = new HashMap<String, String>();
        queryPrefixMap.put("xs", WSDLConstants.NU_SCHEMA_XSD);
        XPathUtils xpu = new XPathUtils(queryPrefixMap);
        NamespacePrefixList schemaPrefixes = schemaInfo.getSchema().getNamespaceContext();
        for (String prefix : schemaPrefixes.getDeclaredPrefixes()) {
            String namespace = schemaPrefixes.getNamespaceURI(prefix);
            if (!namespace.equals(schemaNamespace)
                && !namespace.equals(WSDLConstants.NU_SCHEMA_XSD)
                && !xpu.isExist("xs:import[@namespace='" + namespace + "']",
                                 schemaElement,
                                 XPathConstants.NODE)) {
View Full Code Here

    }

    private XmlSchema addNameSpaces(int i) {
        XmlSchema schema = (XmlSchema) schemaList.get(i);
        NamespaceMap map = (NamespaceMap) nameSpacesMap.clone();
        NamespacePrefixList namespaceContext = schema.getNamespaceContext();
        String prefixes[] = namespaceContext.getDeclaredPrefixes();
        for (int j = 0; j < prefixes.length; j++) {
            String prefix = prefixes[j];
            map.add(prefix, namespaceContext.getNamespaceURI(prefix));
        }
        schema.setNamespaceContext(map);
        return schema;
    }
View Full Code Here

TOP

Related Classes of org.apache.ws.commons.schema.utils.NamespacePrefixList

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.