use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel in project webtools.sourceediting by eclipse.
the class AttrValueTest method testModel.
/* (non-Javadoc)
* @see org.eclipse.wst.html.core.tests.parser.ModelTest#testModel()
*/
public void testModel() {
IDOMModel model = createHTMLModel();
try {
assertNotNull(model);
IStructuredDocument document = model.getStructuredDocument();
assertNotNull(document);
document.setText(this, "<button value=\"" + VALUES[0] + "\"></button><button value=\"" + VALUES[1] + "\"></button><button value=\"" + VALUES[2] + "\"></button>");
IDOMDocument dom = model.getDocument();
NodeList nodes = dom.getElementsByTagName("button");
assertTrue("Must be 3 button elements in the document.", nodes.getLength() == 3);
for (int i = 0; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
Node attr = node.getAttributes().getNamedItem("value");
assertTrue("Attribute 'value' not present.", attr != null && attr.getNodeValue().length() > 0);
assertEquals("Attribute values are not equal", VALUES[i], attr.getNodeValue());
}
} finally {
if (model != null) {
model.releaseFromEdit();
}
}
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel in project webtools.sourceediting by eclipse.
the class CDATASectionTest2 method testModel.
public void testModel() {
IDOMModel model = createXMLModel();
try {
Document document = model.getDocument();
Element a = document.createElement("a");
document.appendChild(a);
CDATASection cdata = document.createCDATASection("contentOfCDATASection");
a.appendChild(cdata);
printSource(model);
printTree(model);
fOutputWriter.writeln(cdata.getData());
cdata.setData("new content");
printSource(model);
printTree(model);
fOutputWriter.writeln(cdata.getData());
cdata.setData("new content");
printSource(model);
printTree(model);
fOutputWriter.writeln(cdata.getData());
saveAndCompareTestResults();
} finally {
model.releaseFromEdit();
}
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel in project webtools.sourceediting by eclipse.
the class EleTest method testModel.
public void testModel() {
IDOMModel model = createHTMLModel();
try {
IStructuredDocument structuredDocument = model.getStructuredDocument();
Document document = model.getDocument();
structuredDocument.replaceText(null, 0, 0, "<html><body><DL>\n\n<DD>Add a \"set top\" rule for the specified parameters1.\n<DD>Add a \"set top\" rule for the specified parameters2.\n<DD>Add a \"set top\" rule for the specified parameters3.\n<DD>Add a \"set top\" rule for the specified parameters4.\n<DD>Add a \"set top\" rule for the specified parameters5.\n<DD>Add a \"set top\" rule for the specified parameters6.\n<DD>Add a \"set top\" rule for the specified parameters7.\n<DD>Add a \"set top\" rule for the specified parameters8.\n<DD>Add a \"set top\" rule for the specified parameters9.\n<DD>Add a \"set top\" rule for the specified parameters10.\n<DD>Add a \"set top\" rule for the specified parameters11.\n<DD>Add a \"set top\" rule for the specified parameters12.\n<DD>Add a \"set top\" rule for the specified parameters.\n<DD>Add a \"set top\" rule for the specified parameters.\n<DD>Add a \"set top\" rule for the specified parameters.\n<DD>Add a \"set top\" rule for the specified parameters.\n<DD>Add a \"set top\" rule for the specified parameters.\n<DD>Add a \"set top\" rule for the specified parameters.\n<DD>Add a \"set top\" rule for the specified parameters.\n<DD>Add a \"set top\" rule for the specified parameters.\n</DL></body></html>");
Node a = document.getElementsByTagName("DL").item(0);
System.out.println(((Element) a).getElementsByTagName("DD").getLength());
} finally {
model.releaseFromEdit();
}
}
use of org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel in project webtools.sourceediting by eclipse.
the class ElementTest2 method testModel.
public void testModel() {
IDOMModel model = createXMLModel();
try {
Document document = model.getDocument();
Element a = document.createElement("a");
Element b = document.createElement("b");
Text t = document.createTextNode("c");
document.appendChild(a);
a.appendChild(b);
b.appendChild(t);
printSource(model);
printTree(model);
a.setPrefix("x");
fOutputWriter.writeln("a.tagName=" + a.getTagName());
printSource(model);
printTree(model);
b.setPrefix("y");
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 EmptyTextTest3 method testModel.
public void testModel() {
IDOMModel model = createXMLModel();
try {
Document document = model.getDocument();
Text text = document.createTextNode("");
document.appendChild(text);
printSource(model);
printTree(model);
Element a = document.createElement("a");
document.insertBefore(a, text);
printSource(model);
printTree(model);
saveAndCompareTestResults();
} finally {
model.releaseFromEdit();
}
}
Aggregations