use of org.w3c.dom.CharacterData in project robovm by robovm.
the class Normalize method testNormalize.
/**
* Runs the test case.
* @throws Throwable Any uncaught exception causes test to fail
*/
public void testNormalize() throws Throwable {
Document doc;
Element root;
NodeList elementList;
Node firstChild;
NodeList textList;
CharacterData textNode;
String data;
doc = (Document) load("staff", builder);
root = doc.getDocumentElement();
root.normalize();
elementList = root.getElementsByTagName("name");
firstChild = elementList.item(2);
textList = firstChild.getChildNodes();
textNode = (CharacterData) textList.item(0);
data = textNode.getData();
assertEquals("data", "Roger\n Jones", data);
}
use of org.w3c.dom.CharacterData in project jabref by JabRef.
the class CitationStyle method createCitationStyleFromSource.
/**
* Creates an CitationStyle instance out of the style string
*/
private static CitationStyle createCitationStyleFromSource(final String source, final String filename) {
try {
DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
InputSource is = new InputSource();
is.setCharacterStream(new StringReader(source));
Document doc = db.parse(is);
NodeList nodes = doc.getElementsByTagName("info");
NodeList titleNode = ((Element) nodes.item(0)).getElementsByTagName("title");
String title = ((CharacterData) titleNode.item(0).getFirstChild()).getData();
return new CitationStyle(filename, title, source);
} catch (ParserConfigurationException | SAXException | IOException e) {
LOGGER.error("Error while parsing source", e);
}
return null;
}
use of org.w3c.dom.CharacterData in project webtools.sourceediting by eclipse.
the class TextTest2 method testModel.
public void testModel() {
IDOMModel model = createXMLModel();
try {
Document document = model.getDocument();
Element a = document.createElement("a");
document.appendChild(a);
CharacterData text = document.createTextNode("text");
a.appendChild(text);
text.setNodeValue("hello <");
printSource(model);
printTree(model);
fOutputWriter.writeln(text.getNodeValue());
saveAndCompareTestResults();
} finally {
model.releaseFromEdit();
}
}
use of org.w3c.dom.CharacterData in project webtools.sourceediting by eclipse.
the class TextTest method testModel.
public void testModel() {
IDOMModel model = createXMLModel();
try {
Document document = model.getDocument();
Element a = document.createElement("a");
document.appendChild(a);
CharacterData text = document.createTextNode("text");
a.appendChild(text);
text.setData("hello <");
printSource(model);
printTree(model);
fOutputWriter.writeln(text.getData());
saveAndCompareTestResults();
} finally {
model.releaseFromEdit();
}
}
use of org.w3c.dom.CharacterData in project aries by apache.
the class SpringOsgiNamespaceHandler method getTextValue.
public static String getTextValue(Element valueEle) {
Assert.notNull(valueEle, "Element must not be null");
StringBuilder sb = new StringBuilder();
NodeList nl = valueEle.getChildNodes();
for (int i = 0, l = nl.getLength(); i < l; ++i) {
Node item = nl.item(i);
if (item instanceof CharacterData && !(item instanceof Comment) || item instanceof EntityReference) {
sb.append(item.getNodeValue());
}
}
return sb.toString();
}
Aggregations