Search in sources :

Example 16 with XSDWildcard

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>");
    }
}
Also used : XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) Iterator(java.util.Iterator) XSDTerm(org.eclipse.xsd.XSDTerm) XSDWildcard(org.eclipse.xsd.XSDWildcard) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) List(java.util.List) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 17 with XSDWildcard

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]);
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) XSDWildcard(org.eclipse.xsd.XSDWildcard) ArrayList(java.util.ArrayList) List(java.util.List) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) ITreeElement(org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition)

Example 18 with XSDWildcard

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);
    }
}
Also used : XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDWildcard(org.eclipse.xsd.XSDWildcard) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition)

Example 19 with XSDWildcard

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]);
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) XSDComplexTypeContent(org.eclipse.xsd.XSDComplexTypeContent) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) ArrayList(java.util.ArrayList) XSDWildcard(org.eclipse.xsd.XSDWildcard) XSDParticleContent(org.eclipse.xsd.XSDParticleContent) ITreeElement(org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition) XSDEnumerationFacet(org.eclipse.xsd.XSDEnumerationFacet) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 20 with XSDWildcard

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]);
}
Also used : XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) XSDParticleContent(org.eclipse.xsd.XSDParticleContent) XSDWildcard(org.eclipse.xsd.XSDWildcard) ArrayList(java.util.ArrayList) List(java.util.List) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) XSDModelGroupDefinition(org.eclipse.xsd.XSDModelGroupDefinition) ITreeElement(org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement) XSDParticle(org.eclipse.xsd.XSDParticle)

Aggregations

XSDWildcard (org.eclipse.xsd.XSDWildcard)25 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)16 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)15 XSDParticle (org.eclipse.xsd.XSDParticle)13 ArrayList (java.util.ArrayList)10 Iterator (java.util.Iterator)10 EList (org.eclipse.emf.common.util.EList)10 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)9 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)8 XSDAttributeUse (org.eclipse.xsd.XSDAttributeUse)8 XSDTerm (org.eclipse.xsd.XSDTerm)8 List (java.util.List)7 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)7 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)6 XSDModelGroupDefinition (org.eclipse.xsd.XSDModelGroupDefinition)6 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)6 XSDAnnotation (org.eclipse.xsd.XSDAnnotation)5 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)5 TreeObject (com.amalto.workbench.models.TreeObject)4 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)4