use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument in project webtools.sourceediting by eclipse.
the class PrefixHandler method execute.
/**
* This will use the active editor, and try and retrieve a structured
* model from it. If successful, it setups the namespace edit dialog
* to capture the namespace information.
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
XPathUIPlugin plugin = XPathUIPlugin.getDefault();
IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
// suppress an NPE in the log (shouldn't happen with the enabledWhen rule)
if (activeEditor == null)
return null;
IFile file = (IFile) activeEditor.getEditorInput().getAdapter(IFile.class);
IModelManager modelManager = StructuredModelManager.getModelManager();
IDOMModel model = null;
try {
model = (IDOMModel) modelManager.getModelForRead(file);
IDOMDocument document = model.getDocument();
if (document != null) {
List<NamespaceInfo> info = plugin.getNamespaceInfo(document);
IPathEditorInput editorInput = (IPathEditorInput) activeEditor.getEditorInput();
EditNamespacePrefixDialog dlg = new EditNamespacePrefixDialog(activeEditor.getSite().getShell(), editorInput.getPath());
dlg.setNamespaceInfoList(info);
if (SWT.OK == dlg.open()) {
// Apply changes
}
}
} catch (Exception ex) {
} finally {
if (model != null) {
model.releaseFromRead();
}
}
return null;
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument in project webtools.sourceediting by eclipse.
the class XPathComputer method evaluateXPath.
protected IStatus evaluateXPath(SimpleXPathEngine engine) throws XPathExpressionException {
IDOMDocument doc = null;
if (node.getNodeType() == Node.DOCUMENT_NODE) {
doc = (IDOMDocument) node;
} else {
doc = (IDOMDocument) node.getOwnerDocument();
}
updateNamespaces(engine, doc);
try {
this.nodeList = (NodeList) engine.execute(node);
return Status.OK_STATUS;
} catch (DynamicError de) {
return new Status(IStatus.CANCEL, XPathCorePlugin.PLUGIN_ID, de.getMessage() + " (" + de.code() + ")");
} catch (Throwable t) {
return new Status(IStatus.ERROR, XPathCorePlugin.PLUGIN_ID, t.getMessage());
}
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument in project webtools.sourceediting by eclipse.
the class TestWTPDOMXPath2 method testWTPDOMWithTypes.
public void testWTPDOMWithTypes() throws Exception {
// Test for the fix, for xpathDefaultNamespace
bundle = Platform.getBundle("org.eclipse.wst.xml.xpath2.wtptypes.tests");
URL fileURL = bundle.getEntry("/bugTestFiles/attrNodeTest.xml");
super.domDoc = load(fileURL);
// set up XPath default namespace in Dynamic Context
DynamicContext dc = setupDynamicContext2(new XsdDOMTypeProvider.XsdTypeModel((IDOMDocument) domDoc));
assertXPathTrue("/Example/x[1] instance of element(*, x_Type)", dc, domDoc);
assertXPathTrue("not (/Example/x[1] instance of element(*, y_Type))", dc, domDoc);
assertXPathTrue("/Example/x instance of x_Type+", dc, domDoc);
assertXPathTrue("/Example/x instance of element(x, x_Type)+", dc, domDoc);
assertXPathTrue("not (/Example/x instance of element(z, x_Type)+)", dc, domDoc);
assertXPathTrue("/Example/x[2]/@mesg instance of mesg_Type", dc, domDoc);
assertXPathTrue("/Example/x[2]/@mesg instance of attribute(mesg, mesg_Type)", dc, domDoc);
assertXPathTrue("not (/Example/x[2]/@mesg instance of attribute(mesg, xs:integer))", dc, domDoc);
assertXPathTrue("not (/Example/x[2]/@mesg instance of attribute(cesc, mesg_Type))", dc, domDoc);
assertXPathTrue("/Example/y/@intAttr instance of attribute(intAttr, xs:integer)", dc, domDoc);
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument in project webtools.sourceediting by eclipse.
the class StylesheetBuilder method parseModel.
private Stylesheet parseModel(IDOMModel model, IFile file) {
IDOMDocument document = model.getDocument();
Stylesheet sf = new Stylesheet(file);
StylesheetParser walker = new StylesheetParser(sf);
walker.walkDocument(document);
return sf;
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument in project webtools.sourceediting by eclipse.
the class EditDoctypeAction method createDoctype.
protected DocumentType createDoctype(EditDoctypeDialog dialog, Document document) {
DocumentType result = null;
if (document instanceof DocumentImpl) {
IDOMDocument documentImpl = (IDOMDocument) document;
IDOMDocumentType doctypeImpl = (IDOMDocumentType) documentImpl.createDoctype(dialog.getName());
doctypeImpl.setPublicId(dialog.getPublicId());
doctypeImpl.setSystemId(dialog.getSystemId());
result = doctypeImpl;
}
return result;
}
Aggregations