示例#1
0
  /**
   * Processes the global simple type declarations found in the schema.
   *
   * @param derivedArtifacts
   * @param sourceArtifact
   * @param schema
   * @param xpath
   * @throws XPathExpressionException
   */
  private void processSimpleTypeDeclarations(
      Collection<DerivedArtifactType> derivedArtifacts,
      BaseArtifactType sourceArtifact,
      Element schema,
      XPath xpath)
      throws XPathExpressionException {
    String targetNS = schema.getAttribute("targetNamespace");

    // xpath expression to find all global simple type decls
    NodeList nodes =
        (NodeList) this.query(xpath, schema, "./xsd:simpleType", XPathConstants.NODESET);
    for (int idx = 0; idx < nodes.getLength(); idx++) {
      Element node = (Element) nodes.item(idx);
      if (node.hasAttribute("name")) {
        String nsName = node.getAttribute("name");
        SimpleTypeDeclaration simpleTypeDecl = new SimpleTypeDeclaration();
        simpleTypeDecl.setArtifactType(BaseArtifactEnum.SIMPLE_TYPE_DECLARATION);
        simpleTypeDecl.setName(nsName);
        simpleTypeDecl.setNamespace(targetNS);
        simpleTypeDecl.setNCName(nsName);
        derivedArtifacts.add(simpleTypeDecl);
      }
    }
  }