protected void addMinimumSize(SType<?> currentType, SIList<?> list) { if (currentType.isList() && list.isEmpty()) { final STypeList<?, ?> tl = (STypeList<?, ?>) currentType; if (tl.getMinimumSize() != null) { for (int i = 0; i < tl.getMinimumSize(); i++) { list.addNew(); } } else if (tl.isRequired()) { list.addNew(); } } }
/** * Sets the attributes minOccurs and maxOccurs of the tag element * @param element The tag element which the attributes will be added to * @param sType The SType represented by the tag element */ private static void setMinAndMaxOccursOfXsdListElement(MElement element, STypeList<?, ?> sType) { Integer min = Optional.ofNullable(sType.getMinimumSize()).orElse(0); if (min != 1) { element.setAttribute("minOccurs", min.toString()); } Integer max = sType.getMaximumSize(); if (max == null) { element.setAttribute("maxOccurs", "unbounded"); } else if (max != 1) { element.setAttribute("maxOccurs", max.toString()); } }
private static MElement toXsdFromList(MElement parent, STypeList<?, ?> type, @Nonnull FormToXSDConfig config) { MElement list = createXsdElement(parent, type); MElement element = list.addElementNS(XSD_NAMESPACE_URI, XSD_COMPLEX_TYPE); element = element.addElementNS(XSD_NAMESPACE_URI, XSD_SEQUENCE); element = toXsdFromSType(element, type.getElementsType(), config); Integer min = type.getMinimumSize(); if (min != null) { element.setAttribute("minOccurs", min.toString()); } Integer max = type.getMaximumSize(); if (max == null) { element.setAttribute("maxOccurs", "unbounded"); } else { element.setAttribute("maxOccurs", max.toString()); } return list; }