use of org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo in project webtools.sourceediting by eclipse.
the class NamespaceInfoErrorHelper method computeErrorMessage.
public String computeErrorMessage(List namespaceInfoList, URIResolver idResolver) {
String result = null;
Hashtable prefixTable = new Hashtable();
Hashtable uriTable = new Hashtable();
for (Iterator iterator = namespaceInfoList.iterator(); iterator.hasNext(); ) {
NamespaceInfo nsInfo = (NamespaceInfo) iterator.next();
nsInfo.normalize();
// $NON-NLS-1$
String urikey = nsInfo.uri != null ? nsInfo.uri : "";
NamespaceInfo nsInfo2 = null;
if ((nsInfo2 = (NamespaceInfo) uriTable.get(urikey)) != null) {
if ((nsInfo.uri != null) && nsInfo.uri.equals(nsInfo2.uri)) {
// $NON-NLS-1$ //$NON-NLS-2$
result = XMLUIMessages._UI_WARNING_MORE_THAN_ONE_NS_WITH_NAME + "'" + nsInfo.uri + "'";
} else {
result = XMLUIMessages._UI_WARNING_MORE_THAN_ONE_NS_WITHOUT_NAME;
}
break;
} else {
uriTable.put(urikey, nsInfo);
}
if (nsInfo.uri != null) {
// $NON-NLS-1$
String key = nsInfo.prefix != null ? nsInfo.prefix : "";
if (prefixTable.get(key) != null) {
if (nsInfo.prefix != null) {
// $NON-NLS-1$ //$NON-NLS-2$
result = XMLUIMessages._UI_WARNING_MORE_THAN_ONE_NS_WITH_PREFIX + "'" + nsInfo.prefix + "'";
break;
} else {
result = XMLUIMessages._UI_WARNING_MORE_THAN_ONE_NS_WITHOUT_PREFIX;
break;
}
} else {
prefixTable.put(key, nsInfo);
}
if ((nsInfo.locationHint != null) && (idResolver != null)) {
String grammarURI = idResolver.resolve(null, nsInfo.locationHint, nsInfo.locationHint);
if (!URIHelper.isReadableURI(grammarURI, false)) {
// $NON-NLS-1$ //$NON-NLS-2$
result = XMLUIMessages._UI_WARNING_SCHEMA_CAN_NOT_BE_LOCATED + " '" + nsInfo.locationHint + "'";
break;
}
}
if ((idResolver != null) && (nsInfo.locationHint == null) && !nsInfo.uri.equals(DOMNamespaceInfoManager.XSI_URI)) {
// $NON-NLS-1$ //$NON-NLS-2$
result = XMLUIMessages._UI_WARNING_LOCATION_HINT_NOT_SPECIFIED + " '" + nsInfo.uri + "'";
break;
}
} else {
if (nsInfo.prefix != null) {
// $NON-NLS-1$ //$NON-NLS-2$
result = XMLUIMessages._UI_WARNING_NAMESPACE_NAME_NOT_SPECIFIED + " '" + nsInfo.prefix + "'";
break;
}
}
}
// additional tests
if (result == null) {
for (Iterator iterator = namespaceInfoList.iterator(); iterator.hasNext(); ) {
NamespaceInfo nsInfo = (NamespaceInfo) iterator.next();
nsInfo.normalize();
if ((nsInfo.uri != null) && nsInfo.isPrefixRequired && (nsInfo.prefix == null)) {
// $NON-NLS-1$ //$NON-NLS-2$
result = XMLUIMessages._UI_WARNING_PREFIX_NOT_SPECIFIED + " '" + nsInfo.uri + "'";
break;
}
}
}
return result;
}
use of org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo in project webtools.sourceediting by eclipse.
the class ExcludeResultPrefixesContentAssist method getCompletionProposals.
/**
* (non-Javadoc)
* @see org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest#getCompletionProposals()
*/
@Override
public ArrayList<ICompletionProposal> getCompletionProposals() {
proposals.clear();
IDOMAttr attrNode = (IDOMAttr) ((IDOMElement) getNode()).getAttributeNode(EXCLUDE_RESULT_PREFIXES);
String excludeResultPrefixes = attrNode.getValue();
int offset = getCursorPosition();
if (excludeResultPrefixes == null || excludeResultPrefixes.equals(DEFAULT)) {
return getAllCompletionProposals();
}
// $NON-NLS-1$
tokens = excludeResultPrefixes.split("\\s");
if (tokens[0].equals("")) {
// $NON-NLS-1$
CustomCompletionProposal proposal = new CustomCompletionProposal(DEFAULT, offset, 0, DEFAULT.length(), XSLPluginImageHelper.getInstance().getImage(XSLPluginImages.IMG_PREFIX), DEFAULT, null, null, 0);
addProposal(proposal);
}
Collection<NamespaceInfo> namespaces = this.getNamespaces((IDOMElement) node);
for (NamespaceInfo namespace : namespaces) {
if (includePrefix(namespace)) {
CustomCompletionProposal proposal = new CustomCompletionProposal(namespace.prefix, offset, 0, namespace.prefix.length(), XSLPluginImageHelper.getInstance().getImage(XSLPluginImages.IMG_PREFIX), namespace.prefix, null, namespace.uri, 0);
addProposal(proposal);
}
}
return getAllCompletionProposals();
}
use of org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo in project webtools.sourceediting by eclipse.
the class CommonAddNamespacesDialog method addBuiltInNamespaces.
protected void addBuiltInNamespaces(List list) {
// $NON-NLS-1$
String xsiNamespace = "http://www.w3.org/2001/XMLSchema-instance";
// $NON-NLS-1$
String xsdNamespace = "http://www.w3.org/2001/XMLSchema";
if (!isAlreadyDeclared(xsiNamespace)) {
// $NON-NLS-1$ //$NON-NLS-2$
list.add(new NamespaceInfo("http://www.w3.org/2001/XMLSchema-instance", "xsi", null));
}
if (!isAlreadyDeclared(xsdNamespace)) {
// $NON-NLS-1$ //$NON-NLS-2$
list.add(new NamespaceInfo("http://www.w3.org/2001/XMLSchema", "xsd", null));
}
}
use of org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo in project webtools.sourceediting by eclipse.
the class CommonAddNamespacesDialog method addCatalogMapToList.
protected void addCatalogMapToList(ICatalog catalog, List list) {
ICatalogEntry[] entries = catalog.getCatalogEntries();
for (int i = 0; i < entries.length; i++) {
ICatalogEntry entry = entries[i];
if ((entry.getEntryType() == ICatalogEntry.ENTRY_TYPE_PUBLIC) && entry.getURI().endsWith(".xsd")) {
// $NON-NLS-1$
if (!isAlreadyDeclared(entry.getKey())) {
// $NON-NLS-1$
NamespaceInfo namespaceInfo = new NamespaceInfo(entry.getKey(), "xx", null);
list.add(namespaceInfo);
}
}
}
}
use of org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo in project webtools.sourceediting by eclipse.
the class CommonAddNamespacesDialog method computeAddablePrefixes.
public void computeAddablePrefixes(List addableList, List exisitingList) {
HashMap map = new HashMap();
for (Iterator i = exisitingList.iterator(); i.hasNext(); ) {
NamespaceInfo info = (NamespaceInfo) i.next();
if (info.prefix != null) {
map.put(info.prefix, info);
}
}
for (Iterator i = addableList.iterator(); i.hasNext(); ) {
NamespaceInfo info = (NamespaceInfo) i.next();
if (info.uri != null) {
String prefix = (String) preferredPrefixTable.get(info.uri);
info.prefix = getUniquePrefix(map, prefix, info.uri);
map.put(info.prefix, info);
}
}
}
Aggregations