本文整理汇总了Java中mf.org.w3c.dom.Node.getNodeType方法的典型用法代码示例。如果您正苦于以下问题:Java Node.getNodeType方法的具体用法?Java Node.getNodeType怎么用?Java Node.getNodeType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mf.org.w3c.dom.Node
的用法示例。
在下文中一共展示了Node.getNodeType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFirstChildElementNS
import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/** Finds and returns the first child node with the given qualified name. */
public static Element getFirstChildElementNS(Node parent,
String[][] elemNames) {
// search for node
Node child = parent.getFirstChild();
while (child != null) {
if (child.getNodeType() == Node.ELEMENT_NODE) {
for (int i = 0; i < elemNames.length; i++) {
String uri = child.getNamespaceURI();
if (uri != null && uri.equals(elemNames[i][0]) &&
child.getLocalName().equals(elemNames[i][1])) {
return (Element)child;
}
}
}
child = child.getNextSibling();
}
// not found
return null;
}
示例2: getNextElementSibling
import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/**
* @see <a href="http://www.w3.org/TR/2008/REC-ElementTraversal-20081222/#attribute-nextElementSibling">
* Element Traversal Specification</a>
*/
public final Element getNextElementSibling() {
Node n = getNextLogicalSibling(this);
while (n != null) {
switch (n.getNodeType()) {
case Node.ELEMENT_NODE:
return (Element) n;
case Node.ENTITY_REFERENCE_NODE:
final Element e = getFirstElementChild(n);
if (e != null) {
return e;
}
break;
}
n = getNextLogicalSibling(n);
}
return null;
}
示例3: getFirstElementChild
import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
private Element getFirstElementChild(Node n) {
final Node top = n;
while (n != null) {
if (n.getNodeType() == Node.ELEMENT_NODE) {
return (Element) n;
}
Node next = n.getFirstChild();
while (next == null) {
if (top == n) {
break;
}
next = n.getNextSibling();
if (next == null) {
n = n.getParentNode();
if (n == null || top == n) {
return null;
}
}
}
n = next;
}
return null;
}
示例4: getPreviousLogicalSibling
import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
private Node getPreviousLogicalSibling(Node n) {
Node prev = n.getPreviousSibling();
// If "n" has no previous sibling and its parent is an entity reference node we
// need to continue the search through the previous siblings of the entity
// reference as these are logically siblings of the given node.
if (prev == null) {
Node parent = n.getParentNode();
while (parent != null && parent.getNodeType() == Node.ENTITY_REFERENCE_NODE) {
prev = parent.getPreviousSibling();
if (prev != null) {
break;
}
parent = parent.getParentNode();
}
}
return prev;
}
示例5: getChildText
import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/**
* Returns the concatenated child text of the specified node.
* This method only looks at the immediate children of type
* <code>Node.TEXT_NODE</code> or the children of any child
* node that is of type <code>Node.CDATA_SECTION_NODE</code>
* for the concatenation.
*
* @param node The node to look at.
*/
public static String getChildText(Node node) {
// is there anything to do?
if (node == null) {
return null;
}
// concatenate children text
StringBuffer str = new StringBuffer();
Node child = node.getFirstChild();
while (child != null) {
short type = child.getNodeType();
if (type == Node.TEXT_NODE) {
str.append(child.getNodeValue());
}
else if (type == Node.CDATA_SECTION_NODE) {
str.append(getChildText(child));
}
child = child.getNextSibling();
}
// return text value
return str.toString();
}
示例6: getNextVisibleSiblingElement
import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
public static Element getNextVisibleSiblingElement(Node node, Hashtable hiddenNodes) {
// search for node
Node sibling = node.getNextSibling();
while (sibling != null) {
if (sibling.getNodeType() == Node.ELEMENT_NODE &&
!isHidden(sibling, hiddenNodes)) {
return (Element)sibling;
}
sibling = sibling.getNextSibling();
}
// not found
return null;
}
示例7: getLastChildElementNS
import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/** Finds and returns the last child node with the given qualified name. */
public static Element getLastChildElementNS(Node parent,
String[][] elemNames) {
// search for node
Node child = parent.getLastChild();
while (child != null) {
if (child.getNodeType() == Node.ELEMENT_NODE) {
for (int i = 0; i < elemNames.length; i++) {
String uri = child.getNamespaceURI();
if (uri != null && uri.equals(elemNames[i][0]) &&
child.getLocalName().equals(elemNames[i][1])) {
return (Element)child;
}
}
}
child = child.getPreviousSibling();
}
// not found
return null;
}
示例8: append
import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
private void append(Node node) throws XNIException {
if (fCurrentNode != null) {
fCurrentNode.appendChild(node);
}
else {
/** Check if this node can be attached to the target. */
if ((kidOK[fTarget.getNodeType()] & (1 << node.getNodeType())) == 0) {
String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "HIERARCHY_REQUEST_ERR", null);
throw new XNIException(msg);
}
fTargetChildren.add(node);
}
}
示例9: checkIndex
import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
void checkIndex(Node refNode, int offset) throws DOMException
{
if (offset < 0) {
throw new DOMException(
DOMException.INDEX_SIZE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INDEX_SIZE_ERR", null));
}
int type = refNode.getNodeType();
// If the node contains text, ensure that the
// offset of the range is <= to the length of the text
if (type == Node.TEXT_NODE
|| type == Node.CDATA_SECTION_NODE
|| type == Node.COMMENT_NODE
|| type == Node.PROCESSING_INSTRUCTION_NODE) {
if (offset > refNode.getNodeValue().length()) {
throw new DOMException(DOMException.INDEX_SIZE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INDEX_SIZE_ERR", null));
}
}
else {
// Since the node is not text, ensure that the offset
// is valid with respect to the number of child nodes
if (offset > refNode.getChildNodes().getLength()) {
throw new DOMException(DOMException.INDEX_SIZE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INDEX_SIZE_ERR", null));
}
}
}
示例10: fillNamespaceContext
import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
private void fillNamespaceContext() {
if (fRoot != null) {
Node currentNode = fRoot.getParentNode();
while (currentNode != null) {
if (Node.ELEMENT_NODE == currentNode.getNodeType()) {
NamedNodeMap attributes = currentNode.getAttributes();
final int attrCount = attributes.getLength();
for (int i = 0; i < attrCount; ++i) {
Attr attr = (Attr) attributes.item(i);
String value = attr.getValue();
if (value == null) {
value = XMLSymbols.EMPTY_STRING;
}
fillQName(fAttributeQName, attr);
// REVISIT: Should we be looking at non-namespace attributes
// for additional mappings? Should we detect illegal namespace
// declarations and exclude them from the context? -- mrglavas
if (fAttributeQName.uri == NamespaceContext.XMLNS_URI) {
// process namespace attribute
if (fAttributeQName.prefix == XMLSymbols.PREFIX_XMLNS) {
declarePrefix0(fAttributeQName.localpart, value.length() != 0 ? fSymbolTable.addSymbol(value) : null);
}
else {
declarePrefix0(XMLSymbols.EMPTY_STRING, value.length() != 0 ? fSymbolTable.addSymbol(value) : null);
}
}
}
}
currentNode = currentNode.getParentNode();
}
}
}
示例11: setDOMResult
import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
public void setDOMResult(DOMResult result) {
fIgnoreChars = false;
if (result != null) {
//MF - Renamed - Resourced
final Node target = (Node) result.getNode();
fDocument = (target.getNodeType() == Node.DOCUMENT_NODE) ? (Document) target : target.getOwnerDocument();
fDocumentImpl = (fDocument instanceof CoreDocumentImpl) ? (CoreDocumentImpl) fDocument : null;
fStorePSVI = (fDocument instanceof PSVIDocumentImpl);
return;
}
fDocument = null;
fDocumentImpl = null;
fStorePSVI = false;
}
示例12: fillNamespaceContext
import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
void fillNamespaceContext() {
if (fSchemaRoot != null) {
Node currentNode = fSchemaRoot.getParentNode();
while (currentNode != null) {
if (Node.ELEMENT_NODE == currentNode.getNodeType()) {
NamedNodeMap attributes = currentNode.getAttributes();
final int attrCount = attributes.getLength();
for (int i = 0; i < attrCount; ++i) {
Attr attr = (Attr) attributes.item(i);
String value = attr.getValue();
if (value == null) {
value = XMLSymbols.EMPTY_STRING;
}
fillQName(fAttributeQName, attr);
// REVISIT: Should we be looking at non-namespace attributes
// for additional mappings? Should we detect illegal namespace
// declarations and exclude them from the context? -- mrglavas
if (fAttributeQName.uri == NamespaceContext.XMLNS_URI) {
// process namespace attribute
if (fAttributeQName.prefix == XMLSymbols.PREFIX_XMLNS) {
declarePrefix(fAttributeQName.localpart, value.length() != 0 ? fSymbolTable.addSymbol(value) : null);
}
else {
declarePrefix(XMLSymbols.EMPTY_STRING, value.length() != 0 ? fSymbolTable.addSymbol(value) : null);
}
}
}
}
currentNode = currentNode.getParentNode();
}
}
}
示例13: getLastChild
import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/** Internal function.
* Return the last child Node, from the input node
* after applying filter, whatToshow.
* The current node is not consulted or set.
*/
Node getLastChild(Node node) {
if (node == null) return null;
if ( !fEntityReferenceExpansion
&& node.getNodeType() == Node.ENTITY_REFERENCE_NODE)
return null;
Node newNode = node.getLastChild();
if (newNode == null) return null;
int accept = acceptNode(newNode);
if (accept == NodeFilter.FILTER_ACCEPT)
return newNode;
else
if (accept == NodeFilter.FILTER_SKIP
&& newNode.hasChildNodes())
{
Node lChild = getLastChild(newNode);
if (lChild == null) {
return getPreviousSibling(newNode, node);
}
return lChild;
}
else
//if (accept == NodeFilter.REJECT_NODE)
{
return getPreviousSibling(newNode, node);
}
}
示例14: finishNode
import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/** Do processing for the end of a node. */
private void finishNode(Node node) {
if (node.getNodeType() == Node.ELEMENT_NODE) {
fCurrentElement = node;
// end element
fillQName(fElementQName, node);
fSchemaValidator.endElement(fElementQName, null);
// pop namespace context
fNamespaceContext.popContext();
}
}
示例15: isKidOK
import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/**
* Uses the kidOK lookup table to check whether the proposed
* tree structure is legal.
*/
protected boolean isKidOK(Node parent, Node child) {
if (allowGrammarAccess &&
parent.getNodeType() == Node.DOCUMENT_TYPE_NODE) {
return child.getNodeType() == Node.ELEMENT_NODE;
}
return 0 != (kidOK[parent.getNodeType()] & 1 << child.getNodeType());
}