Search in sources :

Example 6 with XSModelGroup

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() + "]");
}
Also used : XSElementDeclaration(org.apache.xerces.xs.XSElementDeclaration) JsonObject(javax.json.JsonObject) XSWildcard(org.apache.xerces.xs.XSWildcard) JsonObjectBuilder(javax.json.JsonObjectBuilder) XSModelGroup(org.apache.xerces.xs.XSModelGroup)

Example 7 with XSModelGroup

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;
}
Also used : XSObjectList(org.apache.xerces.xs.XSObjectList) XSTerm(org.apache.xerces.xs.XSTerm) XSParticle(org.apache.xerces.xs.XSParticle) HashSet(java.util.HashSet) XSModelGroup(org.apache.xerces.xs.XSModelGroup)

Aggregations

XSModelGroup (org.apache.xerces.xs.XSModelGroup)7 XSElementDeclaration (org.apache.xerces.xs.XSElementDeclaration)6 XSObjectList (org.apache.xerces.xs.XSObjectList)6 XSParticle (org.apache.xerces.xs.XSParticle)6 XSTerm (org.apache.xerces.xs.XSTerm)6 XSWildcard (org.apache.xerces.xs.XSWildcard)3 QName (javax.xml.namespace.QName)2 XSSimpleType (org.apache.xerces.impl.dv.XSSimpleType)2 XSComplexTypeDefinition (org.apache.xerces.xs.XSComplexTypeDefinition)2 XSModel (org.apache.xerces.xs.XSModel)2 XSTypeDefinition (org.apache.xerces.xs.XSTypeDefinition)2 HasTargetNamespace (org.eclipse.winery.model.tosca.HasTargetNamespace)2 XsdImportManager (org.eclipse.winery.repository.backend.xsd.XsdImportManager)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 JsonObject (javax.json.JsonObject)1 JsonObjectBuilder (javax.json.JsonObjectBuilder)1 RepositoryFileReference (org.eclipse.winery.common.RepositoryFileReference)1