Пример #1
0
  /**
   * Adds WSDL level namespaces to schema definition if necessary.
   *
   * @param schema
   * @param wsdl
   */
  @SuppressWarnings("unchecked")
  private void inheritNamespaces(SchemaImpl schema, Definition wsdl) {
    Map<String, String> wsdlNamespaces = wsdl.getNamespaces();

    for (Entry<String, String> nsEntry : wsdlNamespaces.entrySet()) {
      if (StringUtils.hasText(nsEntry.getKey())) {
        if (!schema.getElement().hasAttributeNS(WWW_W3_ORG_2000_XMLNS, nsEntry.getKey())) {
          schema
              .getElement()
              .setAttributeNS(
                  WWW_W3_ORG_2000_XMLNS, "xmlns:" + nsEntry.getKey(), nsEntry.getValue());
        }
      } else { // handle default namespace
        if (!schema.getElement().hasAttribute("xmlns")) {
          schema
              .getElement()
              .setAttributeNS(
                  WWW_W3_ORG_2000_XMLNS, "xmlns" + nsEntry.getKey(), nsEntry.getValue());
        }
      }
    }
  }