Example #1
0
  public ArrayTypeInfo(MessageReader reader, TypeMapping tm) {
    this(
        reader.getXMLStreamReader().getNamespaceContext(),
        readAttributeValue(reader, SOAP_ARRAY_TYPE),
        readAttributeValue(reader, SOAP_ARRAY_OFFSET));

    // if type is xsd:ur-type replace it with xsd:anyType
    String namespace = reader.getNamespaceForPrefix(typeName.getPrefix());
    if (!StringUtils.isEmpty(namespace)) {
      if (Constants.URI_2001_SCHEMA_XSD.equals(namespace)
          && "ur-type".equals(typeName.getLocalPart())) {
        typeName = new QName(namespace, "anyType", typeName.getPrefix());
      } else {
        typeName = new QName(namespace, typeName.getLocalPart(), typeName.getPrefix());
      }
    }

    if (tm != null) {
      type = tm.getType(typeName);

      if (ranks > 0) {
        Class<?> componentType = type.getTypeClass();
        for (int i = 1; i < ranks + dimensions.size(); i++) {
          componentType = Array.newInstance(componentType, 0).getClass();
        }

        SoapArrayType arrayType = new SoapArrayType();
        arrayType.setTypeClass(componentType);
        arrayType.setTypeMapping(type.getTypeMapping());
        type = arrayType;
      }
    }
  }
Example #2
0
  /**
   * Assist in managing the required <import namespace='uri'> for imports of peer schemas.
   *
   * @param schema
   * @param namespaceUri
   */
  public static void addImportIfNeeded(XmlSchema schema, String namespaceUri) {
    // no need to import nothing or the XSD schema, or the schema we are fixing.
    if ("".equals(namespaceUri)
        || Constants.URI_2001_SCHEMA_XSD.equals(namespaceUri)
        || schema.getTargetNamespace().equals(namespaceUri)) {
      return;
    }

    List<XmlSchemaExternal> externals = schema.getExternals();
    for (XmlSchemaExternal what : externals) {
      if (what instanceof XmlSchemaImport) {
        XmlSchemaImport imp = (XmlSchemaImport) what;
        // already there.
        if (namespaceUri.equals(imp.getNamespace())) {
          return;
        }
      }
    }
    XmlSchemaImport imp = new XmlSchemaImport(schema);
    imp.setNamespace(namespaceUri);
  }