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 + "'>";
}
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;
}
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;
}
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);
}
}
}
}
}
}
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();
}
Aggregations