Here you can find the source of isAppropriateElement(final Node iNode, final String iNodeName, final String iNamespace)
(iNode)
is the node we are looking for.
Parameter | Description |
---|---|
iNode | The Node we are trying to determine if it is the correct node |
iNodeName | The name of the node we are looking for. |
iNamespace | The namespace of the node we are looking for. |
public static boolean isAppropriateElement(final Node iNode, final String iNodeName, final String iNamespace)
//package com.java2s; /*// w w w .j a va 2s . c o m * Copyright (c) [yyyy] [TITULAR] * This file is part of [SSSSS]. * * [SSSS] is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details, currently published * at http://www.gnu.org/copyleft/gpl.html or in the gpl.txt in * the root folder of this distribution. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. */ import org.w3c.dom.*; public class Main { /** * This method determins if a node in the DOM Tree <code>(iNode)</code> is * the node we are looking for. This is done by comparing the node's * local name and namespace with a given node name <code>(iNodeName)</code> * and namespace <code>(iNamespace)</code>. * * @param iNode The Node we are trying to determine if it is the correct * node * @param iNodeName The name of the node we are looking for. * @param iNamespace The namespace of the node we are looking for. * * @return A boolean value indicating whether or not this is the * correct node we are looking for */ public static boolean isAppropriateElement(final Node iNode, final String iNodeName, final String iNamespace) { boolean result = false; if (iNode.getNodeType() == Node.ATTRIBUTE_NODE) { if (iNode.getNamespaceURI() == null) { // Attribute has been passed in and its namepsace is null, get the // attributes parent's namespace String parentsNamespace = ((Attr) iNode).getOwnerElement().getNamespaceURI(); if ((iNode.getLocalName().equals(iNodeName)) && (parentsNamespace.equals(iNamespace))) { result = true; } } else { if ((iNode.getLocalName().equals(iNodeName)) && (iNode.getNamespaceURI().equals(iNamespace))) { result = true; } } } else if ((iNode.getLocalName().equals(iNodeName)) && (iNode.getNamespaceURI().equals(iNamespace))) { result = true; } return result; } }