use of org.apache.xerces.xs.XSModelGroup in project iaf by ibissource.
the class XmlTypeToJsonSchemaConverter method handleTerm.
public void handleTerm(JsonObjectBuilder builder, XSTerm term, XSObjectList attributeUses, boolean multiOccurring, boolean forProperties) {
if (term instanceof XSModelGroup) {
handleModelGroup(builder, (XSModelGroup) term, attributeUses, forProperties);
return;
}
if (term instanceof XSElementDeclaration) {
XSElementDeclaration elementDeclaration = (XSElementDeclaration) term;
if (elementDeclaration.getScope() == XSConstants.SCOPE_GLOBAL) {
JsonObject typeDefininition = Json.createObjectBuilder().add("$ref", definitionsPath + elementDeclaration.getName()).build();
if (multiOccurring) {
JsonObjectBuilder arrayBuilder = Json.createObjectBuilder();
arrayBuilder.add("type", "array");
arrayBuilder.add("items", typeDefininition);
builder.add(elementDeclaration.getName(), arrayBuilder.build());
} else {
builder.add(elementDeclaration.getName(), typeDefininition);
}
} else {
handleElementDeclaration(builder, elementDeclaration, multiOccurring, true);
}
return;
}
if (term instanceof XSWildcard) {
handleWildcard((XSWildcard) term);
return;
}
throw new IllegalStateException("handleTerm unknown Term type [" + term.getClass().getName() + "]");
}
use of org.apache.xerces.xs.XSModelGroup in project iaf by ibissource.
the class XmlAligner method findMultipleOccurringChildElements.
protected Set<String> findMultipleOccurringChildElements(XSParticle particle) {
Set<String> result = new HashSet<String>();
if (particle == null) {
log.warn("typeDefinition particle is null, is this a problem?");
return result;
}
XSTerm term = particle.getTerm();
if (term == null) {
throw new IllegalStateException("findMultipleOccurringChildElements particle.term is null");
}
if (log.isTraceEnabled())
log.trace("term name [" + term.getName() + "] occurring unbounded [" + particle.getMaxOccursUnbounded() + "] max occur [" + particle.getMaxOccurs() + "] term [" + ToStringBuilder.reflectionToString(term) + "]");
if (particle.getMaxOccursUnbounded() || particle.getMaxOccurs() > 1) {
collectChildElements(particle, result);
return result;
}
if (term instanceof XSModelGroup) {
XSModelGroup modelGroup = (XSModelGroup) term;
XSObjectList particles = modelGroup.getParticles();
if (log.isTraceEnabled())
log.trace("modelGroup particles [" + ToStringBuilder.reflectionToString(particles) + "]");
for (int i = 0; i < particles.getLength(); i++) {
XSParticle childParticle = (XSParticle) particles.item(i);
result.addAll(findMultipleOccurringChildElements(childParticle));
}
}
return result;
}
Aggregations