|
Lines 19-24
Link Here
|
| 19 |
import org.eclipse.core.resources.ResourcesPlugin; |
19 |
import org.eclipse.core.resources.ResourcesPlugin; |
| 20 |
import org.eclipse.core.runtime.IPath; |
20 |
import org.eclipse.core.runtime.IPath; |
| 21 |
import org.eclipse.core.runtime.Path; |
21 |
import org.eclipse.core.runtime.Path; |
|
|
22 |
import org.eclipse.jface.text.BadLocationException; |
| 22 |
import org.eclipse.jface.text.IDocument; |
23 |
import org.eclipse.jface.text.IDocument; |
| 23 |
import org.eclipse.jface.text.IRegion; |
24 |
import org.eclipse.jface.text.IRegion; |
| 24 |
import org.eclipse.jface.text.ITextViewer; |
25 |
import org.eclipse.jface.text.ITextViewer; |
|
Lines 43-51
Link Here
|
| 43 |
import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl; |
44 |
import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl; |
| 44 |
import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery; |
45 |
import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery; |
| 45 |
import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper; |
46 |
import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper; |
|
|
47 |
import org.eclipse.wst.xml.core.internal.document.AttrImpl; |
| 46 |
import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil; |
48 |
import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil; |
| 47 |
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr; |
49 |
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr; |
| 48 |
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; |
50 |
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; |
|
|
51 |
import org.eclipse.wst.xml.ui.internal.Logger; |
| 49 |
import org.w3c.dom.Attr; |
52 |
import org.w3c.dom.Attr; |
| 50 |
import org.w3c.dom.DocumentType; |
53 |
import org.w3c.dom.DocumentType; |
| 51 |
import org.w3c.dom.Element; |
54 |
import org.w3c.dom.Element; |
|
Lines 112-118
Link Here
|
| 112 |
String uriString = null; |
115 |
String uriString = null; |
| 113 |
if (currentNode.getNodeType() == Node.DOCUMENT_TYPE_NODE) { |
116 |
if (currentNode.getNodeType() == Node.DOCUMENT_TYPE_NODE) { |
| 114 |
// doctype nodes |
117 |
// doctype nodes |
| 115 |
uriString = getURIString(currentNode, document); |
118 |
uriString = getURIString(currentNode, document, region); |
| 116 |
} |
119 |
} |
| 117 |
else if (currentNode.getNodeType() == Node.ELEMENT_NODE) { |
120 |
else if (currentNode.getNodeType() == Node.ELEMENT_NODE) { |
| 118 |
// element nodes |
121 |
// element nodes |
|
Lines 120-126
Link Here
|
| 120 |
if (currentAttr != null) { |
123 |
if (currentAttr != null) { |
| 121 |
// try to find link for current attribute |
124 |
// try to find link for current attribute |
| 122 |
// resolve attribute value |
125 |
// resolve attribute value |
| 123 |
uriString = getURIString(currentAttr, document); |
126 |
uriString = getURIString(currentAttr, document, region); |
| 124 |
// verify validity of uri string |
127 |
// verify validity of uri string |
| 125 |
if ((uriString == null) || !isValidURI(uriString)) { |
128 |
if ((uriString == null) || !isValidURI(uriString)) { |
| 126 |
// reset current attribute |
129 |
// reset current attribute |
|
Lines 131-137
Link Here
|
| 131 |
// try to find a linkable attribute within element |
134 |
// try to find a linkable attribute within element |
| 132 |
currentAttr = getLinkableAttr((Element) currentNode); |
135 |
currentAttr = getLinkableAttr((Element) currentNode); |
| 133 |
if (currentAttr != null) { |
136 |
if (currentAttr != null) { |
| 134 |
uriString = getURIString(currentAttr, document); |
137 |
uriString = getURIString(currentAttr, document, region); |
| 135 |
} |
138 |
} |
| 136 |
} |
139 |
} |
| 137 |
currentNode = currentAttr; |
140 |
currentNode = currentAttr; |
|
Lines 400-406
Link Here
|
| 400 |
* @param node - |
403 |
* @param node - |
| 401 |
* assumes not null |
404 |
* assumes not null |
| 402 |
*/ |
405 |
*/ |
| 403 |
private String getURIString(Node node, IDocument document) { |
406 |
private String getURIString(Node node, IDocument document, IRegion region) { |
| 404 |
String resolvedURI = null; |
407 |
String resolvedURI = null; |
| 405 |
// need the base location, publicId, and systemId for URIResolver |
408 |
// need the base location, publicId, and systemId for URIResolver |
| 406 |
String baseLoc = null; |
409 |
String baseLoc = null; |
|
Lines 436-445
Link Here
|
| 436 |
else if ((XSI_NAMESPACE_URI.equals(DOMNamespaceHelper.getNamespaceURI(attrNode))) && (SCHEMA_LOCATION.equals(unprefixedName))) { |
439 |
else if ((XSI_NAMESPACE_URI.equals(DOMNamespaceHelper.getNamespaceURI(attrNode))) && (SCHEMA_LOCATION.equals(unprefixedName))) { |
| 437 |
// for now just use the first pair |
440 |
// for now just use the first pair |
| 438 |
// need to look into being more precise |
441 |
// need to look into being more precise |
|
|
442 |
|
| 443 |
//Being precise now |
| 444 |
String attrText = ""; //$NON-NLS-1$ |
| 445 |
int relativeOffset = -1; |
| 446 |
if (node instanceof AttrImpl) { |
| 447 |
relativeOffset = region.getOffset() - ((AttrImpl)node).getStartOffset(); |
| 448 |
try { |
| 449 |
attrText = document.get(((AttrImpl)node).getStartOffset(), ((AttrImpl)node).getLength()); |
| 450 |
} catch (BadLocationException e) { |
| 451 |
Logger.logException(e); |
| 452 |
} |
| 453 |
} |
| 439 |
StringTokenizer st = new StringTokenizer(attrValue); |
454 |
StringTokenizer st = new StringTokenizer(attrValue); |
| 440 |
publicId = st.hasMoreTokens() ? st.nextToken() : null; |
455 |
while (st.hasMoreElements()) { |
| 441 |
systemId = st.hasMoreTokens() ? st.nextToken() : null; |
456 |
publicId = st.hasMoreTokens() ? st.nextToken() : null; |
|
|
457 |
systemId = st.hasMoreTokens() ? st.nextToken() : null; |
| 458 |
int startOffset = -1; |
| 459 |
int endOffset = -1; |
| 460 |
if (publicId != null) { |
| 461 |
startOffset = attrText.indexOf(publicId); |
| 462 |
if (systemId != null) { |
| 463 |
endOffset = attrText.indexOf(systemId) + systemId.length(); |
| 464 |
} |
| 465 |
else { |
| 466 |
endOffset = attrText.indexOf(publicId) + publicId.length(); |
| 467 |
} |
| 468 |
} |
| 469 |
if (startOffset <= relativeOffset && relativeOffset <= endOffset) |
| 470 |
break; |
| 442 |
// else check if xmlns publicId = value |
471 |
// else check if xmlns publicId = value |
|
|
472 |
} |
| 443 |
} |
473 |
} |
| 444 |
else { |
474 |
else { |
| 445 |
systemId = attrValue; |
475 |
systemId = attrValue; |