private boolean isXmlStringSimpleType(XSType type) {
   if (isXMLString(type)) {
     return true;
   } else if (isXMLAnyType(type)) {
     return false; // reached the bottom of the recursion. Nothing found.
   } else {
     return isXmlStringSimpleType(type.getBaseType()); // traversing down
   }
 }
コード例 #2
0
  /** Creates the ExecutableTask from the Schema tree. */
  private void createResult(XSSchema schema) {

    execTask = new ExecutableTask();

    // Get the "task" xs:element.
    XSElementDecl task = schema.getElementDecl("task");

    // We know it's an xs:complexType.
    XSComplexType taskType = task.getType().asComplexType();

    // Get the xs:sequence of elements of the anonymous xs:complexType.
    // A model group can be xs:all, xs:choice or xs:sequence.
    XSParticle taskParticle = taskType.getContentType().asParticle();
    XSModelGroup taskSequence = taskParticle.getTerm().asModelGroup();

    // Get the direct children in the xs:sequence.
    XSParticle taskElemParticles[] = taskSequence.getChildren();
    for (XSParticle taskElemParticle : taskElemParticles) {

      XSElementDecl taskElem = taskElemParticle.getTerm().asElementDecl();

      if (taskElem.getName().equals("execInfo")) { // Displayable info for the UI.

        // We have the "execInfo" element.
        ExecutableInfo execInfo = new ExecutableInfo();

        // We know it's an xs:complexType.
        XSComplexType infoType = taskElem.getType().asComplexType();

        XSParticle infoParticle = infoType.getContentType().asParticle();
        XSModelGroup infoSequence = infoParticle.getTerm().asModelGroup();

        XSParticle infoElemParticles[] = infoSequence.getChildren();
        for (XSParticle infoElemParticle : infoElemParticles) {

          XSElementDecl infoElem = infoElemParticle.getTerm().asElementDecl();
          XSSimpleType simpleType = infoElem.getType().asSimpleType();

          XSRestrictionSimpleType restrictionSimple = simpleType.asRestriction();

          XSFacet facet = restrictionSimple.getDeclaredFacets().iterator().next();
          switch (infoElem.getName()) {
            case "name":
              execInfo.setExecName(facet.getValue().toString());
              break;
            case "type":
              execInfo.setExecType(facet.getValue().toString());
              break;
            case "description":
              execInfo.setExecDescription(facet.getValue().toString());
              break;
          }
        }

        execTask.setExecInfo(execInfo);

      } else {

        XSType taskElemType = taskElem.getType();
        if (taskElemType.isSimpleType()) {

          // We do not check constraints. They will be validated later.
          ExecutableParameter param = new ExecutableParameter();
          param.setParamName(taskElem.getName());

          execTask.addParameter(param);

        } else if (taskElemType.isComplexType()) {
          // Refers to inputFile and outputFile.
          // No need to check these since they are always the same.
        }
      }
    }
  }