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

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


        // 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


    public String getSchemaTargetNameSpace() {
        return schemaTargetNameSpace;
    }

    protected void addImport(XmlSchema xmlSchema, QName schemaTypeName) {
        NamespacePrefixList map = xmlSchema.getNamespaceContext();
        if (map == null ||
                ((map instanceof NamespaceMap) && ((NamespaceMap) map).values() == null) ||
                schemaTypeName == null){
            return;
        }
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

  }

  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

                    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).length() > 0) {
                xsdPrefix = "xsd";
            }
            int count = 0;
            while (ctx != null && ctx.getNamespaceURI(xsdPrefix).length() > 0) {
                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];
                if (prefix != null) {
                    String uri = ctx.getNamespaceURI(prefix);
                    if (uri.length() > 0) {
                        if ("".equals(prefix) || !schemaNamespace.containsKey(uri)) {
                            schemaNamespace.put(uri, prefix);
                        }
                        prefix = (prefix.length() > 0) ? "xmlns:" + prefix : "xmlns";
View Full Code Here

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

        if(xsdPrefix == null) {
            //find a prefix to use
            xsdPrefix = XMLConstants.DEFAULT_NS_PREFIX;
            // Note: NULL_NS_URI is *not* the same as the null reference!
            // Java 1.4 hasn't got NULL_NS_URI, it's just "".
            if (ctx != null && !"".equals(ctx.getNamespaceURI(xsdPrefix))) {
                xsdPrefix = "xsd";
            }
            int count = 0;
            while (ctx != null && !"".equals(ctx.getNamespaceURI(xsdPrefix))) {
                xsdPrefix = "xsd" + ++count;
            }
            schemaObj.schema_ns_prefix = xsdPrefix;
        }

        Element schemaEl = createNewElement(schemaDocs, "schema",
                                            schemaObj.schema_ns_prefix, 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) || !schema_ns.containsKey(uri)) {
                        schema_ns.put(uri, prefix);
                    }
                    prefix = (prefix.length() > 0) ? "xmlns:" + prefix : "xmlns";
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

        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

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.