use of org.htmlcleaner.CommentToken in project stanbol by apache.
the class DomSerializer2 method createSubnodes.
private void createSubnodes(Document document, Element element, List tagChildren) {
if (tagChildren != null) {
Iterator it = tagChildren.iterator();
while (it.hasNext()) {
Object item = it.next();
if (item instanceof CommentToken) {
CommentToken commentNode = (CommentToken) item;
Comment comment = document.createComment(commentNode.getContent().toString());
element.appendChild(comment);
} else if (item instanceof ContentToken) {
ContentToken contentToken = (ContentToken) item;
String content = contentToken.getContent();
String nodeName = element.getNodeName();
boolean specialCase = props.isUseCdataForScriptAndStyle() && ("script".equalsIgnoreCase(nodeName) || "style".equalsIgnoreCase(nodeName));
if (escapeXml && !specialCase) {
content = escapeXml(content, props, true);
}
element.appendChild(specialCase ? document.createCDATASection(content) : document.createTextNode(content));
} else if (item instanceof TagNode) {
TagNode subTagNode = (TagNode) item;
Element subelement = document.createElement(subTagNode.getName());
;
setAttributes(subTagNode, subelement);
// recursively create subnodes
createSubnodes(document, subelement, subTagNode.getChildren());
element.appendChild(subelement);
} else if (item instanceof List) {
List sublist = (List) item;
createSubnodes(document, element, sublist);
}
}
}
}
Aggregations