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

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


        if (schemaObj.version != null) {
            serializedSchema.setAttribute("version", schemaObj.version);
        }

        //add the extra namespace decalarations if any are available
        NamespacePrefixList ctx = schemaObj.getNamespaceContext();
        String[] prefixes = ctx.getDeclaredPrefixes();
        for (int i = 0;  i < prefixes.length;  i++) {
            String prefix = prefixes[i];
            String uri = ctx.getNamespaceURI(prefix);
            if (!Constants.DEFAULT_NS_PREFIX.equals(prefix)) {
                serializedSchema.setAttributeNS(Constants.XMLNS_ATTRIBUTE_NS_URI,
                        Constants.XMLNS_ATTRIBUTE + ":" + prefix, uri);
            }
        }
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();
        schemaObj.schema_ns_prefix = xsdPrefix = ctx.getPrefix(xsdNamespace);
        if(xsdPrefix == null) {
            schemaObj.schema_ns_prefix = xsdPrefix = "";
        }
        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) {
                schema_ns.put(uri, prefix);
            }
        }
        //for schema that not set the xmlns attrib member
View Full Code Here

                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

    }

    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

        // 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.NS_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.NS_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) namespaceMap.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

        if (schemaObj.version != null) {
            serializedSchema.setAttribute("version", schemaObj.version);
        }

        //add the extra namespace decalarations if any are available
        NamespacePrefixList ctx = schemaObj.getNamespaceContext();
        String[] prefixes = ctx.getDeclaredPrefixes();
        for (int i = 0;  i < prefixes.length;  i++) {
            String prefix = prefixes[i];
            String uri = ctx.getNamespaceURI(prefix);
            if (!Constants.DEFAULT_NS_PREFIX.equals(prefix)) {
                serializedSchema.setAttributeNS(Constants.XMLNS_ATTRIBUTE_NS_URI,
                        Constants.XMLNS_ATTRIBUTE + ":" + prefix, uri);
            }
        }
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();
        schemaObj.schema_ns_prefix = xsdPrefix = ctx.getPrefix(xsdNamespace);
        if(xsdPrefix == null) {
            schemaObj.schema_ns_prefix = xsdPrefix = "";
        }
        String[] prefixes = ctx.getDeclaredPrefixes();
        for (int i = 0;  i < prefixes.length;  i++) {
            String prefix = prefixes[i];
            String uri = ctx.getNamespaceURI(prefix);
            schema_ns.put(uri, prefix);
        }
        //for schema that not set the xmlns attrib member
        if (schema_ns.get(xsdNamespace) == null) {
            schema_ns.put(xsdNamespace, xsdPrefix);
View Full Code Here

                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

            }
        }
       
        Set<String> poorPrefixURIs = new HashSet<String>();
        for (SchemaInfo schemaInfo : service.getSchemas()) {
            NamespacePrefixList schemaPrefixList = schemaInfo.getSchema().getNamespaceContext();
            for (String declaredPrefix : schemaPrefixList.getDeclaredPrefixes()) {
                String uri = schemaPrefixList.getNamespaceURI(declaredPrefix);
               
                if (!nsPrefixMap.containsKey(uri)) { // first schema to define a prefix wins.
                    if (declaredPrefix.startsWith("ns") || "tns".equals(declaredPrefix)) {
                        poorPrefixURIs.add(uri);
                    } else {
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.