protected Object[] getXSDParticleChildren(XSDParticle particle) {

    if (particle.getTerm() instanceof XSDElementDeclaration) {
      return getXSDElementDeclarationChildren((XSDElementDeclaration) particle.getTerm());
    }

    if (particle.getTerm() instanceof XSDModelGroup) {
      return getXSDModelGroupChildren((XSDModelGroup) particle.getTerm());
    }

    if (particle.getTerm() instanceof XSDWildcard) {}

    return new Object[] {};
  }
Пример #2
0
  /**
   * Given a Model group, return a list of the XSDFeatures declared within.
   *
   * @param group
   * @return the child elements.
   */
  public static List<XSDParticleContent> getChildElements(XSDModelGroup group) {
    if (group == null) {
      return new ArrayList<XSDParticleContent>();
    }

    List<XSDParticleContent> children = new ArrayList<XSDParticleContent>();

    for (XSDParticle next : group.getContents()) {
      if (next.getContent() instanceof XSDFeature) {
        children.add(next.getContent());
      } else if (next.getTerm() instanceof XSDModelGroup) {
        children.addAll(getChildElements((XSDModelGroup) next.getTerm()));
      }
    }
    return children;
  }
  private void handleContainer(XSDModelGroup xsdModelGroup) {
    for (Iterator i = xsdModelGroup.getParticles().iterator(); i.hasNext(); ) {
      XSDParticle childXSDParticle = (XSDParticle) i.next();
      XSDTerm childXSDTerm = childXSDParticle.getTerm();

      if (childXSDTerm instanceof XSDElementDeclaration) {
        XSDElementDeclaration eldeclaration = (XSDElementDeclaration) childXSDTerm;
        if (!this.tags.containsKey(getFullDeclarationName(eldeclaration))) {
          this.handleLeaf(eldeclaration);
          this.handleElementDeclaration(eldeclaration);
        }
      } else if (childXSDTerm instanceof XSDModelGroup) {
        this.handleContainer((XSDModelGroup) childXSDTerm);
      }
    }
  }
 private void handleElementDeclaration(XSDElementDeclaration tagDeclaration) {
   XSDTypeDefinition type = tagDeclaration.getTypeDefinition();
   if (type instanceof XSDComplexTypeDefinition) {
     XSDComplexTypeDefinition xsdComplexTypeDefinition = (XSDComplexTypeDefinition) type;
     int contentType = xsdComplexTypeDefinition.getContentTypeCategory().getValue();
     if (contentType == XSDContentTypeCategory.ELEMENT_ONLY
         || contentType == XSDContentTypeCategory.MIXED) {
       XSDParticle xsdParticle = (XSDParticle) xsdComplexTypeDefinition.getContentType();
       if (xsdParticle != null) {
         XSDTerm xsdTerm = xsdParticle.getTerm();
         if (xsdTerm instanceof XSDModelGroup) {
           XSDModelGroup xsdModelGroup = (XSDModelGroup) xsdTerm;
           this.handleContainer(xsdModelGroup);
         } else if (xsdTerm instanceof XSDElementDeclaration) {
           XSDElementDeclaration eldeclaration = (XSDElementDeclaration) xsdTerm;
           this.handleLeaf(eldeclaration);
         }
       }
     }
   }
 }