Search in sources :

Example 1 with FilterResult

use of com.amalto.workbench.dialogs.datamodel.IXPathSelectionFilter.FilterResult in project tmdm-studio-se by Talend.

the class XSDUtil method iterateParticle.

private static void iterateParticle(XSDParticle particle, IXPathSelectionFilter filter, Set<String> paths, String prefix) {
    XSDTerm term = particle.getTerm();
    if (term instanceof XSDModelGroup) {
        EList<XSDParticle> contents = ((XSDModelGroup) term).getContents();
        for (XSDParticle p : contents) {
            XSDTerm t = p.getTerm();
            if (t instanceof XSDElementDeclaration) {
                XSDElementDeclaration element = ((XSDElementDeclaration) t);
                FilterResult r = filter.check(p);
                if (r == FilterResult.ENABLE) {
                    String path = prefix + element.getName();
                    paths.add(path);
                } else {
                    XSDTypeDefinition type = element.getType();
                    if (type instanceof XSDComplexTypeDefinition) {
                        String nextPrefix = prefix + element.getName() + DIVIDE;
                        XSDParticle cp = type.getComplexType();
                        iterateParticle(cp, filter, paths, nextPrefix);
                    }
                }
            }
        }
    }
}
Also used : XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDTerm(org.eclipse.xsd.XSDTerm) FilterResult(com.amalto.workbench.dialogs.datamodel.IXPathSelectionFilter.FilterResult) XSDComplexTypeDefinition(org.eclipse.xsd.XSDComplexTypeDefinition) XSDParticle(org.eclipse.xsd.XSDParticle) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Aggregations

FilterResult (com.amalto.workbench.dialogs.datamodel.IXPathSelectionFilter.FilterResult)1 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)1 XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)1 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)1 XSDParticle (org.eclipse.xsd.XSDParticle)1 XSDTerm (org.eclipse.xsd.XSDTerm)1 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)1