Search in sources :

Example 71 with XSDTypeDefinition

use of org.eclipse.xsd.XSDTypeDefinition in project tmdm-studio-se by Talend.

the class XSDTreeContentProvider method getChildren.

public Object[] getChildren(Object parent) {
    if (parent instanceof XSDSchema) {
        EList xsdElementDeclarations = xsdSchema.getElementDeclarations();
        List<XSDElementDeclaration> list = new ArrayList<XSDElementDeclaration>();
        if (filter != null && !filter.isAll()) {
            for (XSDElementDeclaration el : (XSDElementDeclaration[]) xsdElementDeclarations.toArray(new XSDElementDeclaration[xsdElementDeclarations.size()])) {
                if (isInclude(el.getAnnotation())) {
                    list.add(el);
                }
            }
            return filterOutDuplicatedElems(list);
        }
        return filterOutDuplicatedElems(xsdElementDeclarations);
    }
    if (parent instanceof XSDAttributeGroupDefinition) {
        XSDAttributeGroupDefinition attributeGroupDefinition = (XSDAttributeGroupDefinition) parent;
        if (// a ref
        attributeGroupDefinition.getContents().size() == 0)
            attributeGroupDefinition = attributeGroupDefinition.getResolvedAttributeGroupDefinition();
        return attributeGroupDefinition.getContents().toArray(new Object[attributeGroupDefinition.getContents().size()]);
    }
    if (parent instanceof XSDParticle) {
        // a particle inside a choice or sequence or whatever
        XSDParticle xsdParticle = (XSDParticle) parent;
        return getXSDParticleChildren(xsdParticle);
    }
    if (parent instanceof XSDModelGroup) {
        XSDModelGroup modelGroup = ((XSDModelGroup) parent);
        EList list = modelGroup.getContents();
        List<XSDParticle> ls = new ArrayList<XSDParticle>();
        if (filter != null && !filter.isAll()) {
            for (XSDParticle el : (XSDParticle[]) list.toArray(new XSDParticle[list.size()])) {
                XSDTerm tm = el.getTerm();
                if (tm instanceof XSDElementDeclaration) {
                    XSDAnnotation annotation = ((XSDElementDeclaration) tm).getAnnotation();
                    if (isInclude(annotation)) {
                        ls.add(el);
                    }
                }
            }
            return ls.toArray(new XSDParticle[ls.size()]);
        }
        return list.toArray(new Object[list.size()]);
    }
    if (parent instanceof XSDSimpleTypeDefinition) {
        XSDSimpleTypeDefinition std = (XSDSimpleTypeDefinition) parent;
        if (std.getVariety().equals(XSDVariety.ATOMIC_LITERAL)) {
            ArrayList list = new ArrayList();
            // add Base Type if not a pre-defined type
            if (std != null && std.getSchema() != null && std.getSchema().getSchemaForSchema() != null)
                if (!std.getSchema().getSchemaForSchema().getTypeDefinitions().contains(std))
                    list.add(std.getBaseTypeDefinition());
            list.addAll(std.getFacetContents());
            return list.toArray(new Object[list.size()]);
        }
        if (std.getVariety().equals(XSDVariety.LIST_LITERAL)) {
            // FIXME: How do we indicate it is a LIST?
            return new XSDSimpleTypeDefinition[] { std.getBaseTypeDefinition() };
        }
        if (std.getVariety().equals(XSDVariety.UNION_LITERAL))
            return std.getMemberTypeDefinitions().toArray(new XSDSimpleTypeDefinition[std.getMemberTypeDefinitions().size()]);
    // return new Object[]{std.getBaseTypeDefinition()};
    }
    if (parent instanceof XSDElementDeclaration) {
        // abstract elements do not have children
        if (((XSDElementDeclaration) parent).isAbstract())
            return new Object[0];
        ArrayList<Object> list = new ArrayList<Object>();
        // handle extensions and restrictions directly
        XSDTypeDefinition typeDefinition = ((XSDElementDeclaration) parent).getTypeDefinition();
        if (typeDefinition instanceof XSDComplexTypeDefinition) {
            list.addAll(Util.getComplexTypeDefinitionChildren((XSDComplexTypeDefinition) typeDefinition));
        } else {
            list.add(((XSDElementDeclaration) parent).getTypeDefinition());
        }
        // the keys
        if (filter != null && !filter.isAll()) {
        } else {
            list.addAll(((XSDElementDeclaration) parent).getIdentityConstraintDefinitions());
        }
        // the annotations
        XSDAnnotation annotation = ((XSDElementDeclaration) parent).getAnnotation();
        if (filter != null && !filter.isAll()) {
        } else {
            if (annotation != null) {
                list.add(annotation);
            }
        }
        return list.toArray(new Object[list.size()]);
    }
    if (parent instanceof XSDIdentityConstraintDefinition) {
        ArrayList list = new ArrayList();
        if (filter != null && !filter.isAll()) {
        } else {
            list.add(((XSDIdentityConstraintDefinition) parent).getSelector());
            list.addAll(((XSDIdentityConstraintDefinition) parent).getFields());
        }
        return list.toArray(new Object[list.size()]);
    }
    if (parent instanceof XSDAnnotation) {
        ArrayList list = new ArrayList();
        if (filter != null && !filter.isAll()) {
        } else {
            XSDAnnotation annotation = (XSDAnnotation) parent;
            list.addAll(annotation.getUserInformation());
            list.addAll(annotation.getApplicationInformation());
        }
        return list.size() == 0 ? new Object[0] : list.toArray(new Object[list.size()]);
    }
    if (parent instanceof Element) {
        // appinfos
        return new Object[0];
    }
    return new Object[0];
}
Also used : XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition) EList(org.eclipse.emf.common.util.EList) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDTerm(org.eclipse.xsd.XSDTerm) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) TreeObject(com.amalto.workbench.models.TreeObject) XSDAnnotation(org.eclipse.xsd.XSDAnnotation) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDParticle(org.eclipse.xsd.XSDParticle) XSDSchema(org.eclipse.xsd.XSDSchema)

Example 72 with XSDTypeDefinition

use of org.eclipse.xsd.XSDTypeDefinition in project tmdm-studio-se by Talend.

the class TypesContentProvider method getXSDParticleChildren.

private Object[] getXSDParticleChildren(XSDParticle particle) {
    // System.out.println("getXSDParticleChildren() CLASS "+particle.getClass().getName());
    // System.out.println("getXSDParticleChildren() TERM "+particle.getTerm().getClass().getName()+": "+particle.getTerm());
    XSDTerm term = particle.getTerm();
    if (term instanceof XSDElementDeclaration) {
        XSDTypeDefinition typeDef = ((XSDElementDeclaration) term).getTypeDefinition();
        if (typeDef == null)
            // elements with not type declaration (allowed)
            return new Object[0];
        ArrayList<Object> list = new ArrayList<Object>();
        if (typeDef instanceof XSDComplexTypeDefinition) {
            list.addAll(getComplexTypeDefinitionChildren((XSDComplexTypeDefinition) typeDef));
        } else {
            list.add(typeDef);
        }
        list.addAll(((XSDElementDeclaration) term).getIdentityConstraintDefinitions());
        XSDAnnotation annotation = ((XSDElementDeclaration) term).getAnnotation();
        if (filter != null && !filter.isAll()) {
        } else {
            if (annotation != null) {
                list.add(annotation);
            }
        }
        return list.toArray(new Object[list.size()]);
    }
    if (term instanceof XSDModelGroup) {
        // a ModelGroup skip it and get children directtly
        EList list = ((XSDModelGroup) term).getContents();
        return list.toArray(new XSDParticle[list.size()]);
    }
    if (term instanceof XSDWildcard) {
    }
    return new Object[] {};
}
Also used : EList(org.eclipse.emf.common.util.EList) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) ArrayList(java.util.ArrayList) XSDTerm(org.eclipse.xsd.XSDTerm) XSDWildcard(org.eclipse.xsd.XSDWildcard) TreeObject(com.amalto.workbench.models.TreeObject) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDAnnotation(org.eclipse.xsd.XSDAnnotation) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 73 with XSDTypeDefinition

use of org.eclipse.xsd.XSDTypeDefinition in project tmdm-studio-se by Talend.

the class TypesContentProvider method getComplexTypeDefinitionChildren.

private ArrayList<Object> getComplexTypeDefinitionChildren(XSDComplexTypeDefinition complexTypeDefinition) {
    // System.out.println("getComplexTypeDefinitionChildren "+complexTypeDefinition+": "+complexTypeDefinition.getContent());
    // System.out.println(
    // "getComplexTypeDefinitionChildren BASE TYPE "+
    // complexTypeDefinition.getBaseTypeDefinition().getName()+" : "+
    // complexTypeDefinition.getDerivationMethod().getName()
    // );
    XSDComplexTypeContent xsdComplexTypeContent = complexTypeDefinition.getContent();
    ArrayList<Object> list = new ArrayList<Object>();
    // Now determine whether ref. If ref look at the base Type definition
    if (xsdComplexTypeContent == null) {
        XSDTypeDefinition typeDefinition = complexTypeDefinition.getBaseTypeDefinition();
        // if a simple type return the simple type
        if (typeDefinition instanceof XSDSimpleTypeDefinition) {
            list.add(typeDefinition);
            return list;
        } else {
        }
        // it is a complex Type
        xsdComplexTypeContent = ((XSDComplexTypeDefinition) typeDefinition).getContent();
    }
    // check if we are extending a complex Definition
    if ("extension".equals(complexTypeDefinition.getDerivationMethod().getName())) {
        // $NON-NLS-1$
        if (complexTypeDefinition.getBaseTypeDefinition() instanceof XSDComplexTypeDefinition) {
            list.addAll(getComplexTypeDefinitionChildren((XSDComplexTypeDefinition) complexTypeDefinition.getBaseTypeDefinition()));
        }
    }
    // Attributes
    if (complexTypeDefinition.getAttributeContents() != null)
        list.addAll(complexTypeDefinition.getAttributeContents());
    // Annotations
    if (complexTypeDefinition.getAnnotations() != null)
        list.addAll(complexTypeDefinition.getAnnotations());
    // simple type return the simple type
    if (xsdComplexTypeContent instanceof XSDSimpleTypeDefinition) {
        list.add(xsdComplexTypeContent);
        return list;
    }
    // xsd Particle: we have a model group
    if (xsdComplexTypeContent instanceof XSDParticle) {
        // System.out.println("Model Group?: "+((XSDParticle)xsdComplexTypeContent).getTerm());
        if (((XSDParticle) xsdComplexTypeContent).getTerm() instanceof XSDModelGroup) {
            // return the model group
            list.add(((XSDParticle) xsdComplexTypeContent).getTerm());
            return list;
        } else {
            // wild card or element declaration '?)
            list.add(((XSDParticle) xsdComplexTypeContent).getTerm());
            return list;
        }
    }
    // what else could it be ?
    list.add(xsdComplexTypeContent);
    return list;
}
Also used : XSDComplexTypeContent(org.eclipse.xsd.XSDComplexTypeContent) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) ArrayList(java.util.ArrayList) TreeObject(com.amalto.workbench.models.TreeObject) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDParticle(org.eclipse.xsd.XSDParticle) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 74 with XSDTypeDefinition

use of org.eclipse.xsd.XSDTypeDefinition in project tmdm-studio-se by Talend.

the class TypesLabelProvider method getText.

@Override
public String getText(Object obj) {
    if (obj instanceof XSDElementDeclaration) {
        String name = ((XSDElementDeclaration) obj).getName();
        if (((XSDElementDeclaration) obj).isAbstract()) {
            name += Messages.TypesLabelProvider_0;
        }
        String tail = ((XSDElementDeclaration) obj).getTargetNamespace() == null ? "" : // $NON-NLS-1$//$NON-NLS-2$
        " : " + ((XSDElementDeclaration) obj).getTargetNamespace();
        return name + tail;
    }
    if (obj instanceof XSDParticle) {
        XSDParticle xsdParticle = (XSDParticle) obj;
        XSDParticleContent content = xsdParticle.getContent();
        XSDTerm xsdTerm = xsdParticle.getTerm();
        // $NON-NLS-1$
        String name = "";
        if (content instanceof XSDElementDeclaration) {
            XSDElementDeclaration decl = (XSDElementDeclaration) content;
            // $NON-NLS-1$
            name += (decl.getName() == null ? "" : decl.getName());
            if (decl.getTypeDefinition() == null) {
                // $NON-NLS-1$//$NON-NLS-2$
                name += " [" + ((XSDElementDeclaration) xsdTerm).getName() + "]";
            }
        } else if (content instanceof XSDModelGroup) {
            // System.out.println("SHOULD NOT HAPPEN????");
            if (xsdParticle.getContainer() instanceof XSDComplexTypeDefinition) {
                String ctdName = ((XSDComplexTypeDefinition) xsdParticle.getContainer()).getName();
                // $NON-NLS-1$
                name = (ctdName != null ? ctdName : "");
            }
        /*
                 * int type = ((XSDModelGroup)xsdTerm).getCompositor().getValue(); switch (type) { case
                 * XSDCompositor.ALL: name= ""; break; case XSDCompositor.CHOICE: name= ""; break; case
                 * XSDCompositor.SEQUENCE: name= ""; break; }
                 */
        } else {
            // $NON-NLS-1$
            name = "[Any]";
        }
        if (!((xsdParticle.getMinOccurs() == 1) && (xsdParticle.getMaxOccurs() == 1))) {
            // $NON-NLS-1$
            name += "  [";
            name += xsdParticle.getMinOccurs();
            // $NON-NLS-1$
            name += "...";
            // $NON-NLS-1$//$NON-NLS-2$
            name += (xsdParticle.getMaxOccurs() == -1) ? "many" : "" + xsdParticle.getMaxOccurs();
            // $NON-NLS-1$
            name += "]";
        }
        return name;
    }
    if (obj instanceof XSDSimpleTypeDefinition) {
        return getSimpleTypeDefinition((XSDSimpleTypeDefinition) obj);
    }
    if (obj instanceof XSDComplexTypeDefinition) {
        return getComplexTypeDefinition((XSDComplexTypeDefinition) obj);
    }
    if (obj instanceof XSDModelGroup) {
        // return the name of the complex type definition
        XSDParticle particle = (XSDParticle) (((XSDModelGroup) obj).getContainer());
        XSDComplexTypeDefinition complexTypeDefinition = (XSDComplexTypeDefinition) particle.getContainer();
        String name = complexTypeDefinition.getName();
        if (name == null) {
            // $NON-NLS-1$
            name = "";
        }
        // return the occurrence
        if (!((particle.getMinOccurs() == 1) && (particle.getMaxOccurs() == 1))) {
            // $NON-NLS-1$
            name += "  [";
            name += particle.getMinOccurs();
            // $NON-NLS-1$
            name += "...";
            // $NON-NLS-1$//$NON-NLS-2$
            name += (particle.getMaxOccurs() == -1) ? "many" : "" + particle.getMaxOccurs();
            // $NON-NLS-1$
            name += "]";
        }
        XSDTypeDefinition extendType = complexTypeDefinition.getBaseTypeDefinition();
        // $NON-NLS-1$
        String extendTypeName = "";
        if (extendType != null && extendType != complexTypeDefinition && !"anyType".equals(extendType.getName())) {
            // $NON-NLS-1$
            // $NON-NLS-1$
            extendTypeName = ":" + extendType.getName();
        }
        return name + extendTypeName;
    }
    if (obj instanceof XSDFacet) {
        // $NON-NLS-1$
        return ((XSDFacet) obj).getFacetName() + ": " + ((XSDFacet) obj).getLexicalValue();
    }
    if (obj instanceof XSDIdentityConstraintDefinition) {
        return ((XSDIdentityConstraintDefinition) obj).getName();
    }
    if (obj instanceof XSDXPathDefinition) {
        XSDXPathDefinition xpath = (XSDXPathDefinition) obj;
        return xpath.getValue();
    }
    if (obj instanceof XSDAttributeGroupDefinition) {
        XSDAttributeGroupDefinition attributeGroupDefinition = (XSDAttributeGroupDefinition) obj;
        // $NON-NLS-1$
        String name = (attributeGroupDefinition.getName() == null ? "" : attributeGroupDefinition.getName());
        if (attributeGroupDefinition.getContents().size() == 0) {
            // $NON-NLS-1$//$NON-NLS-2$
            name += " [" + attributeGroupDefinition.getResolvedAttributeGroupDefinition().getName() + "]";
        }
        return name;
    }
    if (obj instanceof XSDAttributeUse) {
        XSDAttributeUse attributeUse = (XSDAttributeUse) obj;
        String name = attributeUse.getAttributeDeclaration().getName();
        if (name == null) {
            // $NON-NLS-1$//$NON-NLS-2$
            name = " [" + attributeUse.getAttributeDeclaration().getResolvedAttributeDeclaration().getName() + "]";
        }
        return name;
    }
    if (obj instanceof XSDAnnotation) {
        // $NON-NLS-1$
        return "Annotations";
    }
    if (obj instanceof Element) {
        try {
            Element e = (Element) obj;
            if (e.getLocalName().equals("documentation")) {
                // $NON-NLS-1$
                return Messages.TypesLabelProvider_1 + e.getChildNodes().item(0).getNodeValue();
            } else if (e.getLocalName().equals("appinfo")) {
                // $NON-NLS-1$
                // $NON-NLS-1$
                String source = e.getAttribute("source");
                if (source != null) {
                    if (source.startsWith("X_Label_")) {
                        // $NON-NLS-1$
                        return Util.iso2lang.get(source.substring(8).toLowerCase()) + Messages.TypesLabelProvider_2 + e.getChildNodes().item(0).getNodeValue();
                    } else if (source.equals("X_ForeignKey")) {
                        // $NON-NLS-1$
                        return Messages.TypesLabelProvider_3 + e.getChildNodes().item(0).getNodeValue();
                    } else if (source.equals("X_ForeignKey_NotSep")) {
                        // $NON-NLS-1$
                        Boolean v = Boolean.valueOf(e.getChildNodes().item(0).getNodeValue());
                        return Messages.SimpleXpathInputDialog_sepFkTabPanel + Messages.TypesLabelProvider_4 + v;
                    } else if (source.equals("X_ForeignKeyInfo")) {
                        // $NON-NLS-1$
                        return Messages.TypesLabelProvider_5 + e.getChildNodes().item(0).getNodeValue();
                    } else if (source.equals("X_ForeignKey_Filter")) {
                        // $NON-NLS-1$
                        return Messages.TypesLabelProvider_6 + e.getChildNodes().item(0).getNodeValue();
                    } else if (source.equals("X_SourceSystem")) {
                        // $NON-NLS-1$
                        return Messages.TypesLabelProvider_7 + e.getChildNodes().item(0).getNodeValue();
                    } else if (source.equals("X_TargetSystem")) {
                        // $NON-NLS-1$
                        return Messages.TypesLabelProvider_8 + e.getChildNodes().item(0).getNodeValue();
                    } else if (source.startsWith("X_Description_")) {
                        // $NON-NLS-1$
                        return Util.iso2lang.get(source.substring(14).toLowerCase()) + Messages.TypesLabelProvider_9 + e.getChildNodes().item(0).getNodeValue();
                    } else if (source.equals("X_Write")) {
                        // $NON-NLS-1$
                        return Messages.TypesLabelProvider_10 + e.getChildNodes().item(0).getNodeValue();
                    } else if (source.equals("X_Deny_Create")) {
                        // $NON-NLS-1$
                        return Messages.TypesLabelProvider_11 + e.getChildNodes().item(0).getNodeValue();
                    } else if (source.equals("X_Deny_LogicalDelete")) {
                        // $NON-NLS-1$
                        return Messages.TypesLabelProvider_12 + e.getChildNodes().item(0).getNodeValue();
                    } else if (source.equals("X_Deny_PhysicalDelete")) {
                        // $NON-NLS-1$
                        return Messages.TypesLabelProvider_13 + e.getChildNodes().item(0).getNodeValue();
                    } else if (source.equals("X_Hide")) {
                        // $NON-NLS-1$
                        return Messages.TypesLabelProvider_14 + e.getChildNodes().item(0).getNodeValue();
                    } else if (source.equals("X_AutoExpand")) {
                        // $NON-NLS-1$
                        return Messages.TypesLabelProvider_15 + e.getChildNodes().item(0).getNodeValue();
                    } else if (source.equals("X_Retrieve_FKinfos")) {
                        // $NON-NLS-1$
                        return Messages.bind(Messages.XSDTreeLabelProvider_23, e.getChildNodes().item(0).getNodeValue());
                    } else if (source.equals("X_FKIntegrity")) {
                        // $NON-NLS-1$
                        return Messages.bind(Messages.XSDTreeLabelProvider_24, e.getChildNodes().item(0).getNodeValue());
                    } else if (source.equals("X_FKIntegrity_Override")) {
                        // $NON-NLS-1$
                        return Messages.bind(Messages.XSDTreeLabelProvider_25, e.getChildNodes().item(0).getNodeValue());
                    } else if (source.equals("X_Workflow")) {
                        // $NON-NLS-1$
                        return Messages.bind(Messages.XSDTreeLabelProvider_16, e.getChildNodes().item(0).getNodeValue());
                    }
                    if (source.equals("X_ForeignKey_Filter")) {
                        // $NON-NLS-1$
                        String nodeValue = e.getChildNodes().item(0).getNodeValue();
                        if (nodeValue.startsWith("$CFFP:")) {
                            // $NON-NLS-1$
                            nodeValue = StringEscapeUtils.unescapeXml(nodeValue).substring(6);
                        }
                        return Messages.bind(Messages.XSDTreeLabelProvider_26, nodeValue);
                    } else {
                        // $NON-NLS-1$
                        return source + ": " + Util.nodeToString((Element) obj);
                    }
                } else {
                    return Util.nodeToString((Element) obj);
                }
            } else {
                return Util.nodeToString((Element) obj);
            }
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }
    if (obj == null) {
        // $NON-NLS-1$
        return "NULL";
    }
    // $NON-NLS-1$//$NON-NLS-2$
    return "?? " + obj.getClass().getName() + " : " + obj.toString();
}
Also used : XSDAttributeUse(org.eclipse.xsd.XSDAttributeUse) XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) Element(org.w3c.dom.Element) XSDParticleContent(org.eclipse.xsd.XSDParticleContent) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition) XSDAttributeGroupDefinition(org.eclipse.xsd.XSDAttributeGroupDefinition) XSDFacet(org.eclipse.xsd.XSDFacet) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDTerm(org.eclipse.xsd.XSDTerm) XSDIdentityConstraintDefinition(org.eclipse.xsd.XSDIdentityConstraintDefinition) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDXPathDefinition(org.eclipse.xsd.XSDXPathDefinition) XSDAnnotation(org.eclipse.xsd.XSDAnnotation) XSDParticle(org.eclipse.xsd.XSDParticle)

Example 75 with XSDTypeDefinition

use of org.eclipse.xsd.XSDTypeDefinition in project tmdm-studio-se by Talend.

the class Util method getChildElements.

/**
 * onlyTopLevel indicates whether return decl's direct subelements(true) or all the subelements(false).
 */
public static Map<String, XSDParticle> getChildElements(String parentxpath, XSDElementDeclaration decl, boolean onlyTopLevel, final Set<Object> visited) throws Exception {
    Map<String, XSDParticle> childElements = new HashMap<String, XSDParticle>();
    XSDTypeDefinition baseType = decl.getTypeDefinition();
    if (baseType instanceof XSDComplexTypeDefinition) {
        XSDComplexTypeDefinition cmpType = (XSDComplexTypeDefinition) baseType;
        Map<String, XSDParticle> childs = getChildElements(parentxpath, cmpType, onlyTopLevel, visited);
        for (String xsdDecl : childs.keySet()) {
            if (!childElements.containsKey(xsdDecl)) {
                childElements.put(xsdDecl, childs.get(xsdDecl));
            }
        }
    }
    return childElements;
}
Also used : LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDParticle(org.eclipse.xsd.XSDParticle) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Aggregations

XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)119 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)66 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)57 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)46 ArrayList (java.util.ArrayList)39 XSDParticle (org.eclipse.xsd.XSDParticle)36 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)32 Iterator (java.util.Iterator)26 XSDSchema (org.eclipse.xsd.XSDSchema)26 List (java.util.List)22 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)17 EList (org.eclipse.emf.common.util.EList)16 TreeObject (com.amalto.workbench.models.TreeObject)14 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)14 XSDAttributeGroupDefinition (org.eclipse.xsd.XSDAttributeGroupDefinition)13 XSDTerm (org.eclipse.xsd.XSDTerm)13 XSDFactory (org.eclipse.xsd.XSDFactory)12 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)11 XSDAnnotation (org.eclipse.xsd.XSDAnnotation)10 XSDComplexTypeContent (org.eclipse.xsd.XSDComplexTypeContent)10