Esempio n. 1
0
  /**
   * Gets the "maxOccurs" attribute value for the given XSDFeature, if there is none then it returns
   * the default 1.
   *
   * @param xsdElem
   * @return max occurs
   */
  public static int getMaxOccurs(XSDFeature xsdElem) {
    int max = 1;

    // not a particle means an attribute use.  attributes are maxed at 1.
    if (!(xsdElem.eContainer() instanceof XSDParticle)) return max;

    XSDParticle particle = (XSDParticle) xsdElem.eContainer();
    if (particle.isSetMaxOccurs()) max = particle.getMaxOccurs();

    return max;
  }
Esempio n. 2
0
  /**
   * Gets the "minOccurs" attribute value for the given XSDFeature, if there is none then it returns
   * the default 1.
   *
   * @param xsdElem
   * @return min occurs
   */
  public static int getMinOccurs(XSDFeature xsdElem) {
    if (xsdElem.eContainer() instanceof XSDAttributeUse) {
      return (((XSDAttributeUse) xsdElem.eContainer()).getUse()
              == XSDAttributeUseCategory.REQUIRED_LITERAL
          ? 1
          : 0);
    }

    XSDParticle particle = (XSDParticle) xsdElem.eContainer();
    int min = 1;
    if (particle.isSetMinOccurs()) min = particle.getMinOccurs();

    return min;
  }