use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel in project webtools.sourceediting by eclipse.
the class EntityTest8 method testModel.
public void testModel() {
IDOMModel model = createXMLModel();
try {
// Document document = model.getDocument();
IStructuredDocument structuredDocument = model.getStructuredDocument();
structuredDocument.setText(this, "&ibm;&rtp;");
printSource(model);
printTree(model);
saveAndCompareTestResults();
} finally {
model.releaseFromEdit();
}
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel in project webtools.sourceediting by eclipse.
the class ModelTest method createHTMLModel.
public static IDOMModel createHTMLModel() {
// return new XMLModelImpl();
IStructuredModel model = null;
try {
IModelManager modelManager = StructuredModelManager.getModelManager();
model = modelManager.getModelForEdit("test.html", new NullInputStream(), null);
// always use the same line delimiter for these tests, regardless
// of
// plaform or preference settings
model.getStructuredDocument().setLineDelimiter(TestWriter.commonEOL);
} catch (Exception e) {
e.printStackTrace();
}
// null);
return (IDOMModel) model;
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel in project webtools.sourceediting by eclipse.
the class ParserTest2 method testModel.
public void testModel() {
IDOMModel model = createXMLModel();
try {
IStructuredDocument structuredDocument = model.getStructuredDocument();
Document document = model.getDocument();
structuredDocument.replaceText(null, 0, 0, "<a b=\"\" c=\"c\">");
printSource(model);
printTree(model);
Element a = (Element) document.getFirstChild();
NamedNodeMap attributes = a.getAttributes();
for (int i = 0; i < attributes.getLength(); i++) {
Node attr = attributes.item(i);
String name = attr.getNodeName();
String value = attr.getNodeValue();
fOutputWriter.writeln(name + "=[" + value + "]");
}
structuredDocument.replaceText(null, 8, 0, "d");
printSource(model);
printTree(model);
a = (Element) document.getFirstChild();
attributes = a.getAttributes();
for (int i = 0; i < attributes.getLength(); i++) {
Node attr = attributes.item(i);
String name = attr.getNodeName();
String value = attr.getNodeValue();
fOutputWriter.writeln(name + "=[" + value + "]");
}
structuredDocument.replaceText(null, 8, 1, "");
printSource(model);
printTree(model);
a = (Element) document.getFirstChild();
attributes = a.getAttributes();
for (int i = 0; i < attributes.getLength(); i++) {
Node attr = attributes.item(i);
String name = attr.getNodeName();
String value = attr.getNodeValue();
fOutputWriter.writeln(name + "=[" + value + "]");
}
saveAndCompareTestResults();
} finally {
model.releaseFromEdit();
}
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel in project webtools.sourceediting by eclipse.
the class ParserTest4 method testModel.
public void testModel() {
IDOMModel model = createXMLModel();
try {
IStructuredDocument structuredDocument = model.getStructuredDocument();
// Document document = model.getDocument();
structuredDocument.replaceText(null, 0, 0, "<a>\n\n<% a %>\n<% b %>\n</a>");
printSource(model);
printTree(model);
structuredDocument.replaceText(null, 4, 0, "<");
printSource(model);
printTree(model);
structuredDocument.replaceText(null, 5, 0, "b");
printSource(model);
printTree(model);
structuredDocument.replaceText(null, 6, 0, "c");
printSource(model);
printTree(model);
structuredDocument.replaceText(null, 7, 0, "d");
printSource(model);
printTree(model);
structuredDocument.replaceText(null, 8, 0, "e");
printSource(model);
printTree(model);
structuredDocument.replaceText(null, 9, 0, ">");
printSource(model);
printTree(model);
saveAndCompareTestResults();
} finally {
model.releaseFromEdit();
}
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel in project webtools.sourceediting by eclipse.
the class SplitTextTest3 method testModel.
public void testModel() {
IDOMModel model = createHTMLModel();
try {
Document document = model.getDocument();
Element p = document.createElement("P");
document.appendChild(p);
Text text = document.createTextNode("aa");
p.appendChild(text);
printSource(model);
printTree(model);
Element b = document.createElement("B");
Text text2 = document.createTextNode("bbbb");
b.appendChild(text2);
p.appendChild(b);
printSource(model);
printTree(model);
Text text3 = document.createTextNode("ccc");
p.appendChild(text3);
printSource(model);
printTree(model);
p.removeChild(b);
printSource(model);
printTree(model);
p.insertBefore(b, text3);
printSource(model);
printTree(model);
saveAndCompareTestResults();
} finally {
model.releaseFromEdit();
}
}
Aggregations