com.sun.xml.xsom.XSModelGroup Java Examples

The following examples show how to use com.sun.xml.xsom.XSModelGroup. 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: XsdToJolieConverterImpl.java    From jolie with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void groupProcessing( XSModelGroup modelGroup, XSParticle particle, TypeInlineDefinition jolieType )
	throws ConversionException {
	XSModelGroup.Compositor compositor = modelGroup.getCompositor();
	// We handle "all" and "sequence", but not "choice"
	if( compositor.equals( XSModelGroup.ALL ) || compositor.equals( XSModelGroup.SEQUENCE ) ) {
		if( compositor.equals( XSModelGroup.SEQUENCE ) ) {
			log( Level.WARNING, WARNING_SEQUENCE );
		}

		for( XSParticle currParticle : modelGroup.getChildren() ) {
			XSTerm currTerm = currParticle.getTerm();
			if( currTerm.isModelGroup() ) {
				groupProcessing( currTerm.asModelGroup(), particle, jolieType );
			} else {
				// Create the new complex type for root types
				navigateSubTypes( currParticle, jolieType );
			}
		}
	} else if( compositor.equals( XSModelGroup.CHOICE ) ) {
		throw new ConversionException( ERROR_CHOICE );
	}

}
 
Example #2
Source File: MultiplicityCounterNG.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public Multiplicity modelGroup(XSModelGroup group) {
	boolean isChoice = group.getCompositor() == XSModelGroup.CHOICE;

	Multiplicity r = null;

	for (XSParticle p : group.getChildren()) {
		Multiplicity m = particle(p);

		if (r == null) {
			r = m;
			continue;
		}
		if (isChoice) {
			r = Multiplicity.choice(r, m);
		} else {
			r = Multiplicity.group(r, m);
		}
	}
	if (r == null)
	{
		return ZERO;
	}
	return r;
}
 
Example #3
Source File: GroupInterfaceGenerator.java    From jaxb2-rich-contract-plugin with MIT License 6 votes vote down vote up
private static Collection<? extends XSDeclaration> findModelGroups(final XSComplexType complexType) {
	XSContentType contentType = complexType.getExplicitContent();
	if (contentType == null) {
		contentType = complexType.getContentType();
	}
	final XSParticle particle = contentType.asParticle();
	if (particle != null && !particle.isRepeated()) {
		final XSTerm term = particle.getTerm();
		if (term instanceof XSModelGroupDecl) {
			return Collections.singletonList((XSModelGroupDecl)term);
		} else {
			final XSModelGroup modelGroup = term.asModelGroup();
			return modelGroup != null ? findModelGroups(modelGroup) : Collections.<XSModelGroupDecl>emptyList();
		}
	} else {
		return Collections.emptyList();
	}
}
 
Example #4
Source File: SoapProtocol.java    From jolie with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void groupProcessing(
	Value value,
	XSElementDecl xsDecl,
	SOAPElement element,
	SOAPEnvelope envelope,
	boolean first,
	XSModelGroup modelGroup,
	XSSchemaSet sSet,
	String messageNamespace )
	throws SOAPException {

	XSParticle[] children = modelGroup.getChildren();
	XSTerm currTerm;
	for( XSParticle child : children ) {
		currTerm = child.getTerm();
		if( currTerm.isModelGroup() ) {
			groupProcessing( value, xsDecl, element, envelope, first, currTerm.asModelGroup(), sSet,
				messageNamespace );
		} else {
			termProcessing( value, element, envelope, first, currTerm, child.getMaxOccurs(), sSet,
				messageNamespace );
		}
	}
}
 
Example #5
Source File: Axis.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Iterate all descendant model groups of the given model group, including itself.
 */
private Iterator<XSComponent> descendants(XSModelGroup mg) {
    // TODO: write a tree iterator
    // for now, we do it eagerly because I'm lazy
    List<XSComponent> r = new ArrayList<XSComponent>();
    visit(mg,r);
    return r.iterator();
}
 
Example #6
Source File: SchemaWriter.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
private void modelGroup( XSModelGroup group, String extraAtts ) {
	println(MessageFormat.format("<{0}{1}>", group.getCompositor(), extraAtts));
	indent++;

	final int len = group.getSize();
	for( int i=0; i<len; i++ )
		particle(group.getChild(i));

	indent--;
	println(MessageFormat.format("</{0}>", group.getCompositor()));
}
 
Example #7
Source File: JumbuneSchemaWriter.java    From jumbune with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void modelGroup( XSModelGroup group, String extraAtts ) {
    println(MessageFormat.format("<{0}{1}>", group.getCompositor(), extraAtts));
    indent++;

    final int len = group.getSize();
    for( int i=0; i<len; i++ )
        particle(group.getChild(i));

    indent--;
    println(MessageFormat.format("</{0}>", group.getCompositor()));
}
 
Example #8
Source File: Axis.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Iterator<XSModelGroup> filter(XSModelGroup mg) {
    if(mg==null)
        return empty();
    if(mg.getCompositor() == compositor || compositor == null)
        return singleton(mg);
    else
        return empty();
}
 
Example #9
Source File: Axis.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void visit(XSModelGroup mg, List<XSComponent> r) {
    // since model groups never form a cycle, no cycle check is needed
    r.add(mg);
    for (XSParticle p : mg) {
        XSModelGroup child = p.getTerm().asModelGroup();
        if(child!=null)
            visit(child,r);
    }
}
 
Example #10
Source File: AbstractAxisImpl.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Iterator<T> modelGroup(XSModelGroup group) {
    // compensate for particles that are ignored in SCD
    return new Iterators.Map<T,XSParticle>(group.iterator()) {
        protected Iterator<? extends T> apply(XSParticle p) {
            return particle(p);
        }
    };
}
 
Example #11
Source File: SchemaWriter.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void modelGroup( XSModelGroup group, String extraAtts ) {
    println(MessageFormat.format("<{0}{1}>",
        new Object[]{ group.getCompositor(), extraAtts }));
    indent++;

    final int len = group.getSize();
    for( int i=0; i<len; i++ )
        particle(group.getChild(i));

    indent--;
    println(MessageFormat.format("</{0}>",
        new Object[]{ group.getCompositor() }));
}
 
Example #12
Source File: SchemaTreeTraverser.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Creates node for model group with additional attributes.
 *
 * @param group     Model group.
 * @param extraAtts Additional attributes.
 */
private void modelGroup(XSModelGroup group, String extraAtts) {
    SchemaTreeNode newNode = new SchemaTreeNode(MessageFormat.format(
            "{0}{1}", new Object[]{group.getCompositor(), extraAtts}),
            group.getLocator());
    this.currNode.add(newNode);
    this.currNode = newNode;

    final int len = group.getSize();
    for (int i = 0; i < len; i++) {
        particle(group.getChild(i));
    }

    this.currNode = (SchemaTreeNode) this.currNode.getParent();
}
 
Example #13
Source File: XmlUtils.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void _valueToDocument( Value value, Element element, Document doc, XSType type ) {
	addForcedAttribute( value, element );
	if( type.isSimpleType() ) {
		element.appendChild( doc.createTextNode( value.strValue() ) );
	} else if( type.isComplexType() ) {
		String name;
		Value currValue;
		XSComplexType complexType = type.asComplexType();

		// Iterate over attributes
		Collection< ? extends XSAttributeUse > attributeUses = complexType.getAttributeUses();
		for( XSAttributeUse attrUse : attributeUses ) {
			name = attrUse.getDecl().getName();
			if( (currValue = getAttributeOrNull( value, name )) != null ) {
				element.setAttribute( name, currValue.strValue() );
			}
		}

		XSContentType contentType = complexType.getContentType();
		XSParticle particle = contentType.asParticle();
		if( contentType.asSimpleType() != null ) {
			element.appendChild( doc.createTextNode( value.strValue() ) );
		} else if( particle != null ) {
			XSTerm term = particle.getTerm();
			XSModelGroupDecl modelGroupDecl;
			XSModelGroup modelGroup = null;
			if( (modelGroupDecl = term.asModelGroupDecl()) != null ) {
				modelGroup = modelGroupDecl.getModelGroup();
			} else if( term.isModelGroup() ) {
				modelGroup = term.asModelGroup();
			}
			if( modelGroup != null ) {
				_valueToDocument( value, element, doc, modelGroup );
			}
		}
	}
}
 
Example #14
Source File: XsdToJolieConverterImpl.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
private TypeDefinition loadComplexType( XSComplexType complexType, boolean lazy, TypeDefinition lazyType )
	throws ConversionException {
	XSParticle particle;
	XSContentType contentType;
	contentType = complexType.getContentType();

	if( (particle = contentType.asParticle()) == null ) {
		return null;// createAnyOrUndefined( complexType.getName(), complexType );

	}

	TypeInlineDefinition jolieType;

	if( lazy ) {
		jolieType = (TypeInlineDefinition) lazyType;
	} else {
		jolieType =
			createComplexType( complexType, complexType.getName().replace( "-", "_" ) + TYPE_SUFFIX, particle );
	}

	if( contentType.asSimpleType() != null ) {
		checkStrictModeForSimpleType( contentType );

	} else if( (particle = contentType.asParticle()) != null ) {
		XSTerm term = particle.getTerm();
		XSModelGroup modelGroup = getModelGroup( term );
		if( modelGroup != null ) {
			groupProcessing( modelGroup, particle, jolieType );
		}
	}
	return jolieType;


}
 
Example #15
Source File: XsdToJolieConverterImpl.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
private XSModelGroup getModelGroup( XSTerm term ) {
	XSModelGroupDecl modelGroupDecl;
	if( (modelGroupDecl = term.asModelGroupDecl()) != null ) {
		return modelGroupDecl.getModelGroup();
	} else if( term.isModelGroup() ) {
		return term.asModelGroup();
	} else {
		return null;
	}
}
 
Example #16
Source File: FindXSElementDeclVisitor.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void modelGroup(XSModelGroup group) {
	for (XSParticle child : group.getChildren()) {
		child.visit(this);
	}
}
 
Example #17
Source File: SchemaWriter.java    From citygml4j with Apache License 2.0 4 votes vote down vote up
public void modelGroup( XSModelGroup group ) {
	modelGroup(group,"");
}
 
Example #18
Source File: SchemaWalker.java    From citygml4j with Apache License 2.0 4 votes vote down vote up
public void modelGroup(XSModelGroup group) {
	for (XSParticle p : group.getChildren())
		if (shouldWalk && visited.add(p))
			particle(p);
}
 
Example #19
Source File: CollectSimpleTypeNamesVisitor.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void modelGroup(XSModelGroup group) {
	for (XSParticle child : group.getChildren()) {
		child.visit(this);
	}
}
 
Example #20
Source File: CollectEnumerationValuesVisitor.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void modelGroup(XSModelGroup group) {
	for (XSParticle child : group.getChildren()) {
		child.visit(this);
	}
}
 
Example #21
Source File: MetaPlugin.java    From jaxb2-rich-contract-plugin with MIT License 4 votes vote down vote up
@Override
public Boolean modelGroup(final XSModelGroup group) {
	return false;
}
 
Example #22
Source File: MetaPlugin.java    From jaxb2-rich-contract-plugin with MIT License 4 votes vote down vote up
@Override
public QName modelGroup(final XSModelGroup group) {
	return new QName("", "");
}
 
Example #23
Source File: MetaPlugin.java    From jaxb2-rich-contract-plugin with MIT License 4 votes vote down vote up
@Override
public QName modelGroup(final XSModelGroup group) {
	return new QName("", "");
}
 
Example #24
Source File: JumbuneSchemaWriter.java    From jumbune with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void modelGroup( XSModelGroup group ) {
    modelGroup(group,"");
}
 
Example #25
Source File: XsdParser.java    From jumbune with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void traverseChilds(XSTerm rfTerm) {

		if (rfTerm.isModelGroupDecl()) {

			XSModelGroupDecl rfmodelGD = rfTerm.asModelGroupDecl();

			XSModelGroup rfmodelG = rfmodelGD.getModelGroup();
			XSParticle[] rfparrs = rfmodelG.getChildren();
			for (XSParticle rfpar : rfparrs) {
				XSTerm rfsterm = rfpar.getTerm();
				if (rfsterm.isElementDecl()) {
					XSComplexType rfcomp = rfsterm.asElementDecl().getType()
							.asComplexType();
					if (rfcomp != null) {
						traverseChilds(rfsterm);
					}

				} else {
					traverseChilds(rfsterm);
				}
			}
		} else if (rfTerm.isModelGroup()) {
			XSModelGroup rmodel = rfTerm.asModelGroup();
			XSParticle[] rparrs = rmodel.getChildren();
			for (XSParticle rpar : rparrs) {
				if (rpar != null) {
					XSTerm rterm = rpar.getTerm();
					if (rterm.isElementDecl()) {
						childelements.add(rterm.asElementDecl());
						XSComplexType rcomp = rterm.asElementDecl().getType()
								.asComplexType();
						if (rcomp != null) {
							traverseChilds(rterm);
						}
					} else {
						traverseChilds(rterm);
					}

				}
			}
		} else {
			XSComplexType rtcomp = rfTerm.asElementDecl().getType()
					.asComplexType();
			XSContentType rfxscont = rtcomp.getContentType();
			XSParticle rfparticle = rfxscont.asParticle();
			if (rfparticle != null) {
				XSTerm rsterm = rfparticle.getTerm();
				traverseChilds(rsterm);
			} else {
				childelements.add(rfTerm.asElementDecl());
			}
		}
	}
 
Example #26
Source File: SimpleTypeAnalyzer.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public T modelGroup(XSModelGroup arg0) {
	return null;
}
 
Example #27
Source File: SimpleTypeVisitor.java    From hyperjaxb3 with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void modelGroup(XSModelGroup group) {
	for (XSParticle child : group.getChildren()) {
		child.visit(this);
	}
}
 
Example #28
Source File: DefaultFunctionImpl.java    From jaxb2-basics with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public T modelGroup(XSModelGroup group) {
	return defaultValue(group);
}
 
Example #29
Source File: Axis.java    From jolie with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Iterator<XSModelGroup> modelGroupDecl(XSModelGroupDecl decl) {
    return filter(decl.getModelGroup());
}
 
Example #30
Source File: Axis.java    From jolie with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Iterator<XSComponent> modelGroup(XSModelGroup group) {
    if(visited.add(group))
        return ret(group, new Recursion(group.iterator()));
    else
        return empty();
}