use of com.gargoylesoftware.htmlunit.html.DomText in project htmlunit by HtmlUnit.
the class XSLTProcessor method transform.
private void transform(final Node source, final DomNode parent) {
final Object result = transform(source);
if (result instanceof org.w3c.dom.Node) {
final SgmlPage parentPage = parent.getPage();
final NodeList children = ((org.w3c.dom.Node) result).getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
XmlUtils.appendChild(parentPage, parent, children.item(i), true);
}
} else {
final DomText text = new DomText(parent.getPage(), (String) result);
parent.appendChild(text);
}
}
use of com.gargoylesoftware.htmlunit.html.DomText in project htmlunit by HtmlUnit.
the class HtmlSerializerNormalizedText method appendTitle.
/**
* Process {@link HtmlTitle}.
* @param builder the StringBuilder to add to
* @param htmlTitle the target to process
*/
protected void appendTitle(final HtmlSerializerTextBuilder builder, final HtmlTitle htmlTitle) {
// optimized version
// for the title there is no need to check the visibility
// of the containing dom text;
// this optimization defers the load of the style sheets
final DomNode child = htmlTitle.getFirstChild();
if (child instanceof DomText) {
builder.append(((DomText) child).getData(), Mode.NORMALIZE);
builder.appendBlockSeparator();
}
}
use of com.gargoylesoftware.htmlunit.html.DomText in project htmlunit by HtmlUnit.
the class Document method createTextNode.
/**
* Create a new DOM text node with the given data.
*
* @param newData the string value for the text node
* @return the new text node or NOT_FOUND if there is an error
*/
@JsxFunction
public Object createTextNode(final String newData) {
Object result = NOT_FOUND;
try {
final DomNode domNode = new DomText(getDomNodeOrDie().getPage(), newData);
final Object jsElement = getScriptableFor(domNode);
if (jsElement == NOT_FOUND) {
if (LOG.isDebugEnabled()) {
LOG.debug("createTextNode(" + newData + ") cannot return a result as there isn't a JavaScript object for the DOM node " + domNode.getClass().getName());
}
} else {
result = jsElement;
}
} catch (final ElementNotFoundException e) {
// Just fall through - result is already set to NOT_FOUND
}
return result;
}
Aggregations