/** * Creates a new document fragment. * @return a newly created document fragment */ @JsxFunction public Object createDocumentFragment() { final DomDocumentFragment fragment = getDomNodeOrDie().getPage().createDocumentFragment(); final DocumentFragment node = new DocumentFragment(); node.setParentScope(getParentScope()); node.setPrototype(getPrototype(node.getClass())); node.setDomNode(fragment); return getScriptableFor(fragment); }
/** * Creates a new document fragment. * @return a newly created document fragment */ @JsxFunction public Object createDocumentFragment() { final DomDocumentFragment fragment = getDomNodeOrDie().getPage().createDocumentFragment(); final DocumentFragment node = new DocumentFragment(); node.setParentScope(getParentScope()); node.setPrototype(getPrototype(node.getClass())); node.setDomNode(fragment); return getScriptableFor(fragment); }
/** * 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 */ @JsxFunction public DocumentFragment transformToFragment(final Node source, final Object output) { final SgmlPage page = (SgmlPage) ((Document) output).getDomNodeOrDie(); final DomDocumentFragment fragment = page.createDocumentFragment(); final DocumentFragment rv = new DocumentFragment(); rv.setPrototype(getPrototype(rv.getClass())); rv.setParentScope(getParentScope()); rv.setDomNode(fragment); transform(source, fragment); return rv; }
/** * Appends a new child as the last child of the node. * @param newChild the new child node to be appended at the end of the list of children belonging to this node * @return the new child node successfully appended to the list */ @JsxFunction public Object appendChild(final Object newChild) { if (newChild == null || "null".equals(newChild)) { throw Context.reportRuntimeError("Type mismatch."); } Object appendedChild = null; if (newChild instanceof XMLDOMNode) { final XMLDOMNode childNode = (XMLDOMNode) newChild; // Get XML node for the DOM node passed in final DomNode childDomNode = childNode.getDomNodeOrDie(); // Get the parent XML node that the child should be added to. final DomNode parentNode = getDomNodeOrDie(); // Append the child to the parent node parentNode.appendChild(childDomNode); appendedChild = newChild; // if the parentNode has null parentNode in IE, // create a DocumentFragment to be the parentNode's parentNode. if (!(parentNode instanceof SgmlPage) && !(this instanceof XMLDOMDocumentFragment) && parentNode.getParentNode() == null) { final DomDocumentFragment fragment = parentNode.getPage().createDocumentFragment(); fragment.appendChild(parentNode); } } return appendedChild; }
final DomDocumentFragment fragment = page.createDocumentFragment(); final XMLDOMDocumentFragment node = new XMLDOMDocumentFragment(); node.setParentScope(getParentScope());
/** * 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 */ @JsxFunction public DocumentFragment transformToFragment(final Node source, final Object output) { final SgmlPage page = (SgmlPage) ((Document) output).getDomNodeOrDie(); final DomDocumentFragment fragment = page.createDocumentFragment(); final DocumentFragment rv = new DocumentFragment(); rv.setPrototype(getPrototype(rv.getClass())); rv.setParentScope(getParentScope()); rv.setDomNode(fragment); transform(source, fragment); return rv; }
final DomDocumentFragment fragment = page.createDocumentFragment(); final XMLDOMDocumentFragment node = new XMLDOMDocumentFragment(); node.setParentScope(getParentScope());
/** * Appends a new child as the last child of the node. * @param newChild the new child node to be appended at the end of the list of children belonging to this node * @return the new child node successfully appended to the list */ @JsxFunction public Object appendChild(final Object newChild) { if (newChild == null || "null".equals(newChild)) { throw Context.reportRuntimeError("Type mismatch."); } Object appendedChild = null; if (newChild instanceof XMLDOMNode) { final XMLDOMNode childNode = (XMLDOMNode) newChild; // Get XML node for the DOM node passed in final DomNode childDomNode = childNode.getDomNodeOrDie(); // Get the parent XML node that the child should be added to. final DomNode parentNode = getDomNodeOrDie(); // Append the child to the parent node parentNode.appendChild(childDomNode); appendedChild = newChild; // if the parentNode has null parentNode in IE, // create a DocumentFragment to be the parentNode's parentNode. if (!(parentNode instanceof SgmlPage) && !(this instanceof XMLDOMDocumentFragment) && parentNode.getParentNode() == null) { final DomDocumentFragment fragment = parentNode.getPage().createDocumentFragment(); fragment.appendChild(parentNode); } } return appendedChild; }
final DomDocumentFragment fragment = domNode.getPage().createDocumentFragment(); fragment.appendChild(domNode);
final DomDocumentFragment fragment = domNode.getPage().createDocumentFragment(); fragment.appendChild(domNode);