List of usage examples for org.w3c.dom DocumentFragment getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:com.gargoylesoftware.htmlunit.javascript.host.XSLTProcessor.java
/** * Transforms the node source applying the stylesheet given by the importStylesheet() function. * The owner document of the output node owns the returned document fragment. * @param source the node to be transformed * @param output This document is used to generate the output * @return the result of the transformation *//*from w ww . j av a2 s .com*/ @JsxFunction(@WebBrowser(FF)) public DocumentFragment transformToFragment(final Node source, final Object output) { final SgmlPage page = ((Document) output).getDomNodeOrDie(); final DomDocumentFragment fragment = page.createDomDocumentFragment(); final DocumentFragment rv = new DocumentFragment(); rv.setPrototype(getPrototype(rv.getClass())); rv.setParentScope(getParentScope()); rv.setDomNode(fragment); transform(source, fragment); return rv; }
From source file:com.gargoylesoftware.htmlunit.javascript.host.XSLTProcessor.java
/** * Starts the transformation process or resumes a previously failed transformation. *///w w w.ja v a 2 s.com @JsxFunction(@WebBrowser(IE)) public void transform() { final Node input = input_; final SgmlPage page = input.getDomNodeOrDie().getPage(); if (output_ == null || !(output_ instanceof Node)) { final DomDocumentFragment fragment = page.createDomDocumentFragment(); final DocumentFragment node = new DocumentFragment(); node.setParentScope(getParentScope()); node.setPrototype(getPrototype(node.getClass())); node.setDomNode(fragment); output_ = fragment.getScriptObject(); } transform(input_, ((Node) output_).getDomNodeOrDie()); final XMLSerializer serializer = new XMLSerializer(); serializer.setParentScope(getParentScope()); final StringBuilder output = new StringBuilder(); for (final DomNode child : ((Node) output_).getDomNodeOrDie().getChildren()) { if (child instanceof DomText) { //IE: XmlPage ignores all empty text nodes (if 'xml:space' is 'default') //Maybe this should be changed for 'xml:space' = preserve //See XMLDocumentTest.testLoadXML_XMLSpaceAttribute() if (StringUtils.isNotBlank(((DomText) child).getData())) { output.append(((DomText) child).getData()); } } else { //remove trailing "\r\n" final String serializedString = serializer.serializeToString((Node) child.getScriptObject()); output.append(serializedString.substring(0, serializedString.length() - 2)); } } output_ = output.toString(); }