Java Code Examples for org.apache.xerces.xs.XSModelGroup#COMPOSITOR_CHOICE

The following examples show how to use org.apache.xerces.xs.XSModelGroup#COMPOSITOR_CHOICE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XSContentModel.java    From jlibs with Apache License 2.0 6 votes vote down vote up
private void appendCompositor(Path path){
    if(buff.length()>0 && buff.charAt(buff.length()-1)!='('){
        XSModelGroup modelGroup = (XSModelGroup)path.getParentPath(XSModelGroup.class).getElement();
        switch(modelGroup.getCompositor()){
            case XSModelGroup.COMPOSITOR_SEQUENCE:
                buff.append(" , ");
                break;
            case XSModelGroup.COMPOSITOR_ALL:
                buff.append(" ; ");
                break;
            case XSModelGroup.COMPOSITOR_CHOICE:
                buff.append(" | ");
                break;
        }
    }
}
 
Example 2
Source File: XmlTypeToJsonSchemaConverter.java    From iaf with Apache License 2.0 6 votes vote down vote up
private void handleModelGroup(JsonObjectBuilder builder, XSModelGroup modelGroup, XSObjectList attributeUses, boolean forProperties){
	short compositor = modelGroup.getCompositor();			
	XSObjectList particles = modelGroup.getParticles();
	if (log.isTraceEnabled()) log.trace("modelGroup ["+ToStringBuilder.reflectionToString(modelGroup,ToStringStyle.MULTI_LINE_STYLE)+"]");
	if (log.isTraceEnabled()) log.trace("modelGroup particles ["+ToStringBuilder.reflectionToString(particles,ToStringStyle.MULTI_LINE_STYLE)+"]");
	switch (compositor) {
	case XSModelGroup.COMPOSITOR_SEQUENCE:
	case XSModelGroup.COMPOSITOR_ALL:
		handleCompositorsAllAndSequence(builder, particles, attributeUses);
		return;
	case XSModelGroup.COMPOSITOR_CHOICE:
		handleCompositorChoice(builder, particles, forProperties);	
		return;
	default:
		throw new IllegalStateException("handleModelGroup modelGroup.compositor is not COMPOSITOR_SEQUENCE, COMPOSITOR_ALL or COMPOSITOR_CHOICE, but ["+compositor+"]");
	} 
}
 
Example 3
Source File: XMLToJSON.java    From ts-reaktive with MIT License 5 votes vote down vote up
private Map<QName,XSParticle> getValidSubTags(XSElementDeclaration elmt) {
    if (!(elmt.getTypeDefinition() instanceof XSComplexTypeDefinition)) {
        return HashMap.empty();
    }
    
    XSComplexTypeDefinition type = (XSComplexTypeDefinition) elmt.getTypeDefinition();
    if (type.getParticle() == null || !(type.getParticle().getTerm() instanceof XSModelGroup)) {
        return HashMap.empty();
    }
    
    XSModelGroup group = (XSModelGroup) type.getParticle().getTerm();
    if (group.getCompositor() != XSModelGroup.COMPOSITOR_SEQUENCE && group.getCompositor() != XSModelGroup.COMPOSITOR_CHOICE) {
        return HashMap.empty();
    }
    
    // We don't care whether it's SEQUENCE or CHOICE, we only want to know what are the valid sub-elements at this level.
    XSObjectList particles = group.getParticles();
    Map<QName,XSParticle> content = HashMap.empty();
    for (int j = 0; j < particles.getLength(); j++) {
        XSParticle sub = (XSParticle) particles.get(j);
        if (sub.getTerm() instanceof XSElementDeclaration) {
            XSElementDeclaration term = (XSElementDeclaration) sub.getTerm();
            content = content.put(new QName(term.getNamespace(), term.getName()), sub);
        }
    }
    return content;
}