use of org.eclipse.xsd.XSDWildcard in project tmdm-studio-se by Talend.
the class XSDParser method processParticle.
public void processParticle(XSDParticle xsdParticle, String ident) {
int minOccurs = xsdParticle.getMinOccurs();
int maxOccurs = xsdParticle.getMaxOccurs();
XSDTerm xsdTerm = xsdParticle.getTerm();
if (xsdTerm instanceof XSDElementDeclaration) {
XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration) xsdTerm;
String elementDeclarationName = xsdElementDeclaration.getName();
System.out.print(elementDeclarationName);
if (minOccurs == 0) {
if (maxOccurs == 1) {
// $NON-NLS-1$
System.out.print("?");
} else {
// $NON-NLS-1$
System.out.print("*");
}
} else if (maxOccurs == -1) {
// $NON-NLS-1$
System.out.print("+");
}
System.out.println(// $NON-NLS-1$
" -- root Container: " + ((XSDParticle) xsdElementDeclaration.getContainer()).getTerm().getClass().getName());
} else if (xsdTerm instanceof XSDModelGroup) {
XSDModelGroup xsdModelGroup = (XSDModelGroup) xsdTerm;
List particles = xsdModelGroup.getParticles();
String separator = // $NON-NLS-1$
XSDCompositor.CHOICE_LITERAL == xsdModelGroup.getCompositor() ? // $NON-NLS-1$
"|" : // $NON-NLS-1$ //$NON-NLS-2$
XSDCompositor.SEQUENCE_LITERAL == xsdModelGroup.getCompositor() ? "&" : "a";
for (Iterator it = particles.iterator(); it.hasNext(); ) {
XSDParticle childParticle = (XSDParticle) it.next();
// $NON-NLS-1$ //$NON-NLS-2$
System.out.print(ident + "[" + separator + "]");
// $NON-NLS-1$
processParticle(childParticle, ident + " ");
}
if (minOccurs == 0) {
if (maxOccurs == 1) {
// $NON-NLS-1$
System.out.print("?");
} else {
// $NON-NLS-1$
System.out.print("*");
}
} else if (maxOccurs == -1) {
// $NON-NLS-1$
System.out.print("+");
}
System.out.println();
} else if (xsdTerm instanceof XSDWildcard) {
// $NON-NLS-1$
System.out.print("<em>{any}</em>");
}
}
use of org.eclipse.xsd.XSDWildcard in project webtools.sourceediting by eclipse.
the class XSDAttributeGroupDefinitionAdapter method getChildren.
public ITreeElement[] getChildren() {
XSDAttributeGroupDefinition xsdAttributeGroup = (XSDAttributeGroupDefinition) target;
List list = new ArrayList();
Iterator iterator = xsdAttributeGroup.getContents().iterator();
while (iterator.hasNext()) {
Object o = iterator.next();
if (o instanceof XSDAttributeUse) {
list.add(((XSDAttributeUse) o).getAttributeDeclaration());
} else {
list.add(o);
}
}
XSDWildcard wildcard = xsdAttributeGroup.getAttributeWildcardContent();
if (wildcard != null) {
list.add(wildcard);
}
List adapterList = new ArrayList();
populateAdapterList(list, adapterList);
return (ITreeElement[]) adapterList.toArray(new ITreeElement[0]);
}
use of org.eclipse.xsd.XSDWildcard in project webtools.sourceediting by eclipse.
the class XSDVisitor method visitParticleContent.
public void visitParticleContent(XSDParticleContent particleContent) {
if (particleContent instanceof XSDModelGroupDefinition) {
XSDModelGroupDefinition modelGroupDef = (XSDModelGroupDefinition) particleContent;
if (particleStack.contains(modelGroupDef)) {
return;
}
particleStack.push(modelGroupDef);
visitModelGroupDefinition(modelGroupDef);
particleStack.pop();
} else if (particleContent instanceof XSDModelGroup) {
visitModelGroup((XSDModelGroup) particleContent);
} else if (particleContent instanceof XSDElementDeclaration) {
visitElementDeclaration((XSDElementDeclaration) particleContent);
} else if (particleContent instanceof XSDWildcard) {
visitWildcard((XSDWildcard) particleContent);
}
}
use of org.eclipse.xsd.XSDWildcard in project webtools.sourceediting by eclipse.
the class XSDComplexTypeDefinitionAdapter method getChildren.
public ITreeElement[] getChildren() {
XSDComplexTypeDefinition xsdComplexTypeDefinition = getXSDComplexTypeDefinition();
List list = new ArrayList();
// Add attributes
for (Iterator i = xsdComplexTypeDefinition.getAttributeContents().iterator(); i.hasNext(); ) {
Object obj = i.next();
if (obj instanceof XSDAttributeUse) {
list.add(((XSDAttributeUse) obj).getAttributeDeclaration());
} else if (obj instanceof XSDAttributeGroupDefinition) {
getAttributeUses((XSDAttributeGroupDefinition) obj, list);
}
}
// Add enumerations
boolean canHaveEnumerations = xsdComplexTypeDefinition.getContentType() instanceof XSDSimpleTypeDefinition && XSDDerivationMethod.RESTRICTION_LITERAL.equals(xsdComplexTypeDefinition.getDerivationMethod());
if (canHaveEnumerations) {
Object contentType = getContentType();
if (contentType != null) {
for (Iterator iterator = ((XSDSimpleTypeDefinition) contentType).getEnumerationFacets().iterator(); iterator.hasNext(); ) {
XSDEnumerationFacet enumerationFacet = (XSDEnumerationFacet) iterator.next();
list.add(enumerationFacet);
}
}
}
XSDWildcard anyAttr = xsdComplexTypeDefinition.getAttributeWildcard();
if (anyAttr != null)
list.add(anyAttr);
// get immediate XSD Model Group of this complex type
if (xsdComplexTypeDefinition.getContent() != null) {
XSDComplexTypeContent xsdComplexTypeContent = xsdComplexTypeDefinition.getContent();
if (xsdComplexTypeContent instanceof XSDParticle) {
XSDParticleContent particleContent = ((XSDParticle) xsdComplexTypeContent).getContent();
if (particleContent instanceof XSDModelGroup) {
list.add(particleContent);
}
}
}
// get inherited XSD Model Group of this complex type
boolean showInheritedContent = XSDEditorPlugin.getPlugin().getShowInheritedContent();
if (showInheritedContent) {
XSDTypeDefinition typeDef = xsdComplexTypeDefinition.getBaseTypeDefinition();
if (typeDef instanceof XSDComplexTypeDefinition) {
XSDComplexTypeDefinition baseCT = (XSDComplexTypeDefinition) typeDef;
if (baseCT.getTargetNamespace() != null && !baseCT.getTargetNamespace().equals(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001)) {
if (baseCT.getContent() != null) {
XSDComplexTypeContent xsdComplexTypeContent = baseCT.getContent();
if (xsdComplexTypeContent instanceof XSDParticle) {
XSDParticleContent particleContent = ((XSDParticle) xsdComplexTypeContent).getContent();
if (particleContent instanceof XSDModelGroup) {
list.add(particleContent);
}
}
}
}
}
}
List adapterList = new ArrayList();
populateAdapterList(list, adapterList);
return (ITreeElement[]) adapterList.toArray(new ITreeElement[0]);
}
use of org.eclipse.xsd.XSDWildcard in project webtools.sourceediting by eclipse.
the class XSDModelGroupAdapter method getChildren.
public ITreeElement[] getChildren() {
XSDModelGroup xsdModelGroup = getXSDModelGroup();
List list = new ArrayList();
for (Iterator i = xsdModelGroup.getContents().iterator(); i.hasNext(); ) {
Object object = i.next();
XSDParticleContent particle = ((XSDParticle) object).getContent();
if (particle instanceof XSDElementDeclaration) {
list.add(particle);
} else if (particle instanceof XSDWildcard) {
list.add(particle);
} else if (particle instanceof XSDModelGroup) {
list.add(particle);
} else if (particle instanceof XSDModelGroupDefinition) {
// list.add(((XSDModelGroupDefinition)particle).getResolvedModelGroupDefinition());
list.add(particle);
}
}
List adapterList = new ArrayList();
populateAdapterList(list, adapterList);
return (ITreeElement[]) adapterList.toArray(new ITreeElement[0]);
}
Aggregations