use of org.eclipse.xsd.XSDParticleContent in project webtools.sourceediting by eclipse.
the class SetMultiplicityCommand method execute.
/* (non-Javadoc)
* @see org.eclipse.wst.xsd.ui.internal.commands.AbstractCommand#run()
*/
public void execute() {
try {
beginRecording(parent.getElement());
if (parent instanceof XSDParticleContent) {
XSDParticleContent xsdParticleContent = (XSDParticleContent) parent;
XSDParticle xsdParticle = (XSDParticle) xsdParticleContent.getContainer();
if (maxOccurs < 0) {
maxOccurs = XSDParticle.UNBOUNDED;
}
xsdParticle.setMaxOccurs(maxOccurs);
xsdParticle.setMinOccurs(minOccurs);
}
} finally {
endRecording();
}
}
use of org.eclipse.xsd.XSDParticleContent in project tmdm-common by Talend.
the class MetadataRepository method visitComplexType.
@Override
public void visitComplexType(XSDComplexTypeDefinition type) {
String typeName = type.getName();
boolean isNonInstantiableType = currentTypeStack.isEmpty();
if (isNonInstantiableType) {
if (nonInstantiableTypes.get(getUserNamespace()) != null) {
if (nonInstantiableTypes.get(getUserNamespace()).containsKey(typeName)) {
// Ignore another definition of type (already processed).
return;
}
}
// There's no current 'entity' type being parsed, this is a complex type not to be used for entity but
// might be referenced by others entities (for fields, inheritance...).
ComplexTypeMetadata nonInstantiableType = new ComplexTypeMetadataImpl(targetNamespace, typeName, false, type.isAbstract());
// Keep line and column of definition
nonInstantiableType.setData(XSD_LINE_NUMBER, XSDParser.getStartLine(type.getElement()));
nonInstantiableType.setData(XSD_COLUMN_NUMBER, XSDParser.getStartColumn(type.getElement()));
nonInstantiableType.setData(XSD_DOM_ELEMENT, type.getElement());
addTypeMetadata(nonInstantiableType);
currentTypeStack.push(nonInstantiableType);
// If type is used, declare usage
List<ComplexTypeMetadata> usages = entityTypeUsage.get(type);
for (ComplexTypeMetadata usage : usages) {
nonInstantiableType.declareUsage(usage);
}
} else {
// Keep track of the complex type used for entity type (especially for inheritance).
if (typeName != null) {
currentTypeStack.peek().setData(MetadataRepository.COMPLEX_TYPE_NAME, typeName);
}
}
XSDComplexTypeContent particle = type.getContent();
if (particle instanceof XSDParticle) {
XSDParticle currentParticle = (XSDParticle) particle;
if (currentParticle.getTerm() instanceof XSDModelGroup) {
XSDModelGroup group = (XSDModelGroup) currentParticle.getTerm();
EList<XSDParticle> particles = group.getContents();
for (XSDParticle p : particles) {
XSDParticleContent particleContent = p.getContent();
XmlSchemaWalker.walk(particleContent, this);
}
}
} else if (particle != null) {
throw new IllegalArgumentException("Not supported XML Schema particle: " + particle.getClass().getName());
}
// Adds the type information about super types.
XSDTypeDefinition contentModel = type.getBaseTypeDefinition();
if (contentModel != null) {
if (!XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(contentModel.getTargetNamespace()) && !Types.ANY_TYPE.equals(contentModel.getName())) {
SoftTypeRef superType = new SoftTypeRef(this, contentModel.getTargetNamespace(), contentModel.getName(), false);
if (currentTypeStack.peek() instanceof ContainedComplexTypeMetadata) {
superType.declareUsage(currentTypeStack.peek());
}
currentTypeStack.peek().addSuperType(superType);
particle = type.getContent();
if (particle instanceof XSDParticle) {
XSDParticle currentParticle = (XSDParticle) particle;
if (currentParticle.getTerm() instanceof XSDModelGroup) {
XSDModelGroup group = (XSDModelGroup) currentParticle.getTerm();
EList<XSDParticle> particles = group.getContents();
for (XSDParticle p : particles) {
XSDParticleContent particleContent = p.getContent();
XmlSchemaWalker.walk(particleContent, this);
}
}
} else if (particle != null) {
throw new IllegalArgumentException("Not supported XML Schema particle: " + particle.getClass().getName());
}
}
}
if (isNonInstantiableType) {
currentTypeStack.pop();
}
}
Aggregations