Tabnine Logo
Node.getOwnerDocument
Code IndexAdd Tabnine to your IDE (free)

How to use
getOwnerDocument
method
in
org.w3c.dom.Node

Best Java code snippets using org.w3c.dom.Node.getOwnerDocument (Showing top 20 results out of 3,726)

Refine searchRefine arrow

  • Node.getNodeType
  • Node.appendChild
origin: libgdx/libgdx

/** If the child node doesn't exist, it is created. */
private static Node getFirstChildNodeByName (Node parent, String child) {
  NodeList childNodes = parent.getChildNodes();
  for (int i = 0; i < childNodes.getLength(); i++) {
    if (childNodes.item(i).getNodeName().equals(child)) {
      return childNodes.item(i);
    }
  }
  Node newNode = parent.getOwnerDocument().createElement(child);
  if (childNodes.item(0) != null)
    return parent.insertBefore(newNode, childNodes.item(0));
  else
    return parent.appendChild(newNode);
}
origin: robovm/robovm

/**
 * Get the root node of the document tree, regardless of
 * whether or not the node passed in is a document node.
 * <p>
 * TODO: This doesn't handle DocumentFragments or "orphaned" subtrees
 * -- it's currently returning ownerDocument even when the tree is
 * not actually part of the main Document tree. We should either
 * rewrite the description to say that it finds the Document node,
 * or change the code to walk up the ancestor chain.
 *
 * @param n Node to be examined
 *
 * @return the Document node. Note that this is not the correct answer
 * if n was (or was a child of) a DocumentFragment or an orphaned node,
 * as can arise if the DOM has been edited rather than being generated
 * by a parser.
 */
public Node getRootNode(Node n)
{
 int nt = n.getNodeType();
 return ( (Node.DOCUMENT_NODE == nt) || (Node.DOCUMENT_FRAGMENT_NODE == nt) ) 
     ? n : n.getOwnerDocument();
}
origin: plutext/docx4j

static class LoggingErrorListener implements ErrorListener {
    // See http://www.cafeconleche.org/slides/sd2003west/xmlandjava/346.html
  
  boolean strict;
    public LoggingErrorListener(boolean strict) {
  }
  
  public void warning(TransformerException exception) {
      log.warn(exception.getMessage(), exception);
      // Don't throw an exception and stop the processor
   // just for a warning; but do log the problem
  }
  
  public void error(TransformerException exception)
   throws TransformerException {
   
    log.error(exception.getMessage(), exception);
   
    // XSLT is not as draconian as XML. There are numerous errors
   // which the processor may but does not have to recover from; 
   // e.g. multiple templates that match a node with the same
   // priority. If I do not want to allow that,  I'd throw this 
   // exception here.
    if (strict) {
      throw exception;
    }
origin: xalan/xalan

/**
 * Get the root node of the document tree, regardless of
 * whether or not the node passed in is a document node.
 * <p>
 * TODO: This doesn't handle DocumentFragments or "orphaned" subtrees
 * -- it's currently returning ownerDocument even when the tree is
 * not actually part of the main Document tree. We should either
 * rewrite the description to say that it finds the Document node,
 * or change the code to walk up the ancestor chain.
 *
 * @param n Node to be examined
 *
 * @return the Document node. Note that this is not the correct answer
 * if n was (or was a child of) a DocumentFragment or an orphaned node,
 * as can arise if the DOM has been edited rather than being generated
 * by a parser.
 */
public Node getRootNode(Node n)
{
 int nt = n.getNodeType();
 return ( (Node.DOCUMENT_NODE == nt) || (Node.DOCUMENT_FRAGMENT_NODE == nt) ) 
     ? n : n.getOwnerDocument();
}
origin: org.apache.tuscany.sca/tuscany-databinding

public void setChild(Node wrapper, int i, ElementInfo childElement, Object value) {
  Node node = (Node)value;
  if (node.getNodeType() == Node.DOCUMENT_NODE) {
    node = ((Document)node).getDocumentElement();
  }
  wrapper.appendChild(wrapper.getOwnerDocument().importNode(node, true));
}
origin: libgdx/libgdx

/** If the child node doesn't exist, it is created. */
private static Node getFirstChildNodeByName (Node parent, String child) {
  NodeList childNodes = parent.getChildNodes();
  for (int i = 0; i < childNodes.getLength(); i++) {
    if (childNodes.item(i).getNodeName().equals(child)) {
      return childNodes.item(i);
    }
  }
  Node newNode = parent.getOwnerDocument().createElement(child);
  if (childNodes.item(0) != null)
    return parent.insertBefore(newNode, childNodes.item(0));
  else
    return parent.appendChild(newNode);
}
origin: marytts/marytts

public static TreeWalker createTreeWalker(Node root, String... tagNames) {
  return createTreeWalker(root.getNodeType() == Node.DOCUMENT_NODE ? (Document) root : root.getOwnerDocument(), root,
      tagNames);
}
origin: org.apache.tuscany.sca/tuscany-base-runtime

public void setChild(Node wrapper, int i, ElementInfo childElement, Object value) {
  Node node = (Node)value;
  if (node.getNodeType() == Node.DOCUMENT_NODE) {
    node = ((Document)node).getDocumentElement();
  }
  wrapper.appendChild(wrapper.getOwnerDocument().importNode(node, true));
}
origin: looly/hutool

/**
 * 在已有节点上创建子节点
 * 
 * @param node 节点
 * @param tagName 标签名
 * @return 子节点
 * @since 4.0.9
 */
public static Element appendChild(Node node, String tagName) {
  Document doc = (node instanceof Document) ? (Document) node : node.getOwnerDocument();
  Element child = doc.createElement(tagName);
  node.appendChild(child);
  return child;
}
origin: marytts/marytts

public static NodeIterator createNodeIterator(Node root, String... tagNames) {
  return createNodeIterator(root.getNodeType() == Node.DOCUMENT_NODE ? (Document) root : root.getOwnerDocument(), root,
      tagNames);
}
origin: org.codehaus.castor/castor-xml

@Override
public void characters(final char[] chars, final int offset, final int length) {
 String data = new String(chars, offset, length);
 Node parent = !_parents.isEmpty() ? _parents.peek() : _node;
 Node last = parent.getLastChild();
 if ((last != null) && (last.getNodeType() == Node.TEXT_NODE)) {
  ((Text) last).appendData(data);
 } else {
  Text text = parent.getOwnerDocument().createTextNode(data);
  parent.appendChild(text);
 }
}
origin: looly/hutool

/**
 * 在已有节点上创建子节点
 * 
 * @param node 节点
 * @param tagName 标签名
 * @return 子节点
 * @since 4.0.9
 */
public static Element appendChild(Node node, String tagName) {
  Document doc = (node instanceof Document) ? (Document) node : node.getOwnerDocument();
  Element child = doc.createElement(tagName);
  node.appendChild(child);
  return child;
}
origin: marytts/marytts

public static NodeIterator createNodeIterator(Node root, String... tagNames) {
  return createNodeIterator(root.getNodeType() == Node.DOCUMENT_NODE ? (Document) root : root.getOwnerDocument(), root,
      tagNames);
}
origin: org.codehaus.castor/com.springsource.org.castor

public void characters(final char[] chars, final int offset, final int length) {
  String data = new String(chars, offset, length);
  Node parent = (_parents.size() > 0) ? (Node) _parents.peek() : _document;
  Node last = parent.getLastChild();
  if ((last != null) && (last.getNodeType() == Node.TEXT_NODE)) {
    ((Text)last).appendData(data);
  } else {
    Text text = parent.getOwnerDocument().createTextNode(data);
    parent.appendChild(text);
  }
}
origin: libgdx/libgdx

/** If the child node or attribute doesn't exist, it is created. Usage example: Node property =
 * getFirstChildByAttrValue(properties, "property", "name"); */
private static Node getFirstChildByNameAttrValue (Node node, String childName, String attr, String value) {
  NodeList childNodes = node.getChildNodes();
  for (int i = 0; i < childNodes.getLength(); i++) {
    if (childNodes.item(i).getNodeName().equals(childName)) {
      NamedNodeMap attributes = childNodes.item(i).getAttributes();
      Node attribute = attributes.getNamedItem(attr);
      if (attribute.getNodeValue().equals(value)) return childNodes.item(i);
    }
  }
  Node newNode = node.getOwnerDocument().createElement(childName);
  NamedNodeMap attributes = newNode.getAttributes();
  Attr nodeAttr = node.getOwnerDocument().createAttribute(attr);
  nodeAttr.setNodeValue(value);
  attributes.setNamedItem(nodeAttr);
  if (childNodes.item(0) != null) {
    return node.insertBefore(newNode, childNodes.item(0));
  } else {
    return node.appendChild(newNode);
  }
}
origin: marytts/marytts

public static TreeWalker createTreeWalker(Node root, String... tagNames) {
  return createTreeWalker(root.getNodeType() == Node.DOCUMENT_NODE ? (Document) root : root.getOwnerDocument(), root,
      tagNames);
}
origin: org.springframework.ws/spring-oxm

protected final void marshalDomNode(Object graph, Node node) throws XmlMappingException {
  Document document = node.getNodeType() == Node.DOCUMENT_NODE ? (Document) node : node.getOwnerDocument();
  Node xmlBeansNode = ((XmlObject) graph).newDomNode(getXmlOptions());
  NodeList xmlBeansChildNodes = xmlBeansNode.getChildNodes();
  for (int i = 0; i < xmlBeansChildNodes.getLength(); i++) {
    Node xmlBeansChildNode = xmlBeansChildNodes.item(i);
    Node importedNode = document.importNode(xmlBeansChildNode, true);
    node.appendChild(importedNode);
  }
}
origin: libgdx/libgdx

/** If the child node or attribute doesn't exist, it is created. Usage example: Node property =
 * getFirstChildByAttrValue(properties, "property", "name"); */
private static Node getFirstChildByNameAttrValue (Node node, String childName, String attr, String value) {
  NodeList childNodes = node.getChildNodes();
  for (int i = 0; i < childNodes.getLength(); i++) {
    if (childNodes.item(i).getNodeName().equals(childName)) {
      NamedNodeMap attributes = childNodes.item(i).getAttributes();
      Node attribute = attributes.getNamedItem(attr);
      if (attribute.getNodeValue().equals(value)) return childNodes.item(i);
    }
  }
  Node newNode = node.getOwnerDocument().createElement(childName);
  NamedNodeMap attributes = newNode.getAttributes();
  Attr nodeAttr = node.getOwnerDocument().createAttribute(attr);
  nodeAttr.setNodeValue(value);
  attributes.setNamedItem(nodeAttr);
  if (childNodes.item(0) != null) {
    return node.insertBefore(newNode, childNodes.item(0));
  } else {
    return node.appendChild(newNode);
  }
}
origin: plutext/docx4j

/**
 * This method returns the owner document of a particular node.
 * This method is necessary because it <I>always</I> returns a
 * {@link Document}. {@link Node#getOwnerDocument} returns <CODE>null</CODE>
 * if the {@link Node} is a {@link Document}.
 *
 * @param node
 * @return the owner document of the node
 */
public static Document getOwnerDocument(Node node) {
  if (node.getNodeType() == Node.DOCUMENT_NODE) {
    return (Document) node;
  } 
  try {
    return node.getOwnerDocument();
  } catch (NullPointerException npe) {
    throw new NullPointerException(I18n.translate("endorsed.jdk1.4.0")
                    + " Original message was \""
                    + npe.getMessage() + "\"");
  }
}
origin: marytts/marytts

public static Element appendChildElement(Node node, String childName) {
  if (node == null)
    throw new NullPointerException("Received null node");
  return (Element) node.appendChild(createElement(node.getOwnerDocument(), childName));
}
org.w3c.domNodegetOwnerDocument

Javadoc

The Document object associated with this node. This is also the Document object used to create new nodes. When this node is a Document or a DocumentType which is not used with any Document yet, this is null.

Popular methods of Node

  • getNodeName
    The name of this node, depending on its type; see the table above.
  • getNodeValue
    The value of this node, depending on its type; see the table above. When it is defined to be null, s
  • getNodeType
    A code representing the type of the underlying object, as defined above.
  • getChildNodes
    A NodeList that contains all children of this node. If there are no children, this is a NodeList con
  • getTextContent
    This attribute returns the text content of this node and its descendants. When it is defined to be n
  • getAttributes
    A NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.
  • getFirstChild
    The first child of this node. If there is no such node, this returnsnull.
  • getLocalName
    Returns the local part of the qualified name of this node. For nodes of any type other than ELEMENT_
  • getParentNode
    The parent of this node. All nodes, except Attr,Document, DocumentFragment, Entity, and Notation may
  • getNextSibling
    The node immediately following this node. If there is no such node, this returns null.
  • appendChild
    Adds the node newChild to the end of the list of children of this node. If the newChild is already
  • getNamespaceURI
    The namespace URI of this node, or null if it is unspecified. This is not a computed value that is t
  • appendChild,
  • getNamespaceURI,
  • removeChild,
  • hasChildNodes,
  • getPrefix,
  • setNodeValue,
  • getPreviousSibling,
  • insertBefore,
  • cloneNode

Popular in Java

  • Making http post requests using okhttp
  • onCreateOptionsMenu (Activity)
  • getExternalFilesDir (Context)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Menu (java.awt)
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • Notification (javax.management)
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now