Search in sources :

Example 16 with XSDElementDeclaration

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

the class XSDParser method getStandardLink.

/**
 * Returns an href in Part 1 or Part 2 of the XML specification for the given element.
 *
 * @param xsdElementDeclaration an element declaration in the schema for schema.
 * @return an href.
 */
public String getStandardLink(XSDElementDeclaration xsdElementDeclaration) {
    String result = xsdElementDeclaration.getName();
    XSDElementDeclaration parentElementDeclaration = (XSDElementDeclaration) specialAnchorMap.get(xsdElementDeclaration);
    if (parentElementDeclaration != null) {
        result = // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        "<a target='Part1' href='" + XSDConstants.PART1 + "#element-" + parentElementDeclaration.getName() + "::" + result;
    } else if (part2Anchors.contains(result)) {
        // $NON-NLS-1$ //$NON-NLS-2$
        result = "<a target='Part2' href='" + XSDConstants.PART2 + "#element-" + result;
    } else {
        // $NON-NLS-1$ //$NON-NLS-2$
        result = "<a target='Part1' href='" + XSDConstants.PART1 + "#element-" + result;
    }
    // $NON-NLS-1$
    return result + "'>";
}
Also used : XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration)

Example 17 with XSDElementDeclaration

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

the class XSDUtil method getAllPKXpaths.

public static List<String> getAllPKXpaths(XSDSchema schema) {
    List<String> entity2xpaths = new LinkedList<String>();
    if (schema != null) {
        for (XSDSchemaContent content : schema.getContents()) {
            if (isEntity(content)) {
                XSDElementDeclaration concept = (XSDElementDeclaration) content;
                List<String> keyFields = getKeyFields(concept);
                entity2xpaths.add(0, concept.getName());
                for (String pkfield : keyFields) {
                    // $NON-NLS-1$
                    entity2xpaths.add(concept.getName() + "/" + pkfield);
                }
            }
        }
    }
    return entity2xpaths;
}
Also used : XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDSchemaContent(org.eclipse.xsd.XSDSchemaContent) LinkedList(java.util.LinkedList)

Example 18 with XSDElementDeclaration

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

the class XSDUtil method isSimpleTypeElement.

public static boolean isSimpleTypeElement(XSDParticle particle) {
    XSDTerm term = particle.getTerm();
    if (term instanceof XSDElementDeclaration) {
        XSDElementDeclaration element = ((XSDElementDeclaration) term);
        XSDTypeDefinition type = element.getType();
        if (type instanceof XSDSimpleTypeDefinition) {
            return true;
        }
    }
    return false;
}
Also used : XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XSDSimpleTypeDefinition(org.eclipse.xsd.XSDSimpleTypeDefinition) XSDTerm(org.eclipse.xsd.XSDTerm) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Example 19 with XSDElementDeclaration

use of org.eclipse.xsd.XSDElementDeclaration 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)

Example 20 with XSDElementDeclaration

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

the class Util method getAllObject.

public static Object[] getAllObject(Object elem, List<Object> objList, IStructuredContentProvider provider) {
    Object[] elems = provider.getElements(elem);
    for (Object obj : elems) {
        if (obj == null) {
            continue;
        }
        if (obj instanceof XSDModelGroup || obj instanceof XSDElementDeclaration || obj instanceof XSDParticle || obj instanceof XSDTypeDefinition) {
            if (!objList.contains(obj)) {
                objList.add(obj);
                getAllObject(obj, objList, provider);
            }
        }
    }
    return objList.toArray();
}
Also used : XSDModelGroup(org.eclipse.xsd.XSDModelGroup) XSDElementDeclaration(org.eclipse.xsd.XSDElementDeclaration) XObject(com.sun.org.apache.xpath.internal.objects.XObject) TreeObject(com.amalto.workbench.models.TreeObject) EObject(org.eclipse.emf.ecore.EObject) XSDParticle(org.eclipse.xsd.XSDParticle) XSDTypeDefinition(org.eclipse.xsd.XSDTypeDefinition)

Aggregations

XSDElementDeclaration (org.eclipse.xsd.XSDElementDeclaration)222 XSDParticle (org.eclipse.xsd.XSDParticle)103 XSDComplexTypeDefinition (org.eclipse.xsd.XSDComplexTypeDefinition)93 XSDModelGroup (org.eclipse.xsd.XSDModelGroup)87 ArrayList (java.util.ArrayList)60 XSDTypeDefinition (org.eclipse.xsd.XSDTypeDefinition)57 XSDSchema (org.eclipse.xsd.XSDSchema)48 XSDSimpleTypeDefinition (org.eclipse.xsd.XSDSimpleTypeDefinition)47 Test (org.junit.Test)44 XSDIdentityConstraintDefinition (org.eclipse.xsd.XSDIdentityConstraintDefinition)38 XSDFactory (org.eclipse.xsd.XSDFactory)37 XSDTerm (org.eclipse.xsd.XSDTerm)32 XSDConcreteComponent (org.eclipse.xsd.XSDConcreteComponent)30 EList (org.eclipse.emf.common.util.EList)29 XSDAnnotation (org.eclipse.xsd.XSDAnnotation)28 Iterator (java.util.Iterator)27 XSDAttributeDeclaration (org.eclipse.xsd.XSDAttributeDeclaration)27 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)24 XSDXPathDefinition (org.eclipse.xsd.XSDXPathDefinition)21 Element (org.w3c.dom.Element)21