// Allow SELECT DISTINCT, which is ignored. It is meaningless except for
// self-entity relation using relate() functionality
List elements = select.getSymbols();
for (int i = 0; i < elements.size(); i++) {
SelectSymbol ss = (SelectSymbol) elements.get(i);
if (ss instanceof ElementSymbol) {
// Here we make an assumption that: all elements named with "xml" must use qualified name
// rather than a simple "xml" in order to distinguish it from "SELECT xml" and
// "SELECT model.document.xml" case, both of whom stand for selecting the whole document.
// Then "SELECT xml" or "SELECT model.document.xml" can only stand for one meaning with two cases:
// 1) whole document
// 2) whole document, root name = "xml", too
// There are other cases of "xml", such as, element name = "xml",
// but those are ok because those will be resolved later as normal elements
String symbolName = ss.getName();
if(symbolName.equalsIgnoreCase("xml") || symbolName.equalsIgnoreCase(group.getName() + ".xml")) { //$NON-NLS-1$ //$NON-NLS-2$
if(elements.size() != 1) {
throw new QueryResolverException(QueryPlugin.Util.getString("XMLQueryResolver.xml_only_valid_alone")); //$NON-NLS-1$
}
select.clearSymbols();
AllSymbol all = new AllSymbol();
all.setElementSymbols(validElements);
select.addSymbol(all);
query.setSelect(select);
return;
}
// normal elements
resolveElement((ElementSymbol)ss, validElements, externalGroups, metadata);
} else if (ss instanceof AllInGroupSymbol) {
// Resolve the element with "*" case. such as "A.*"
// by stripping off the ".*" part,
String symbolName = ss.getName();
int index = symbolName.indexOf("*"); //$NON-NLS-1$
String elementPart = symbolName.substring(0, index-1);
// Check for case where we have model.doc.*
if(elementPart.equalsIgnoreCase(group.getName())) {