Here you can find the source of isAppropriateElement(Node iNode, String iNodeName, 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(Node iNode, String iNodeName, String iNamespace)
//package com.java2s; /******************************************************************************* ADL SCORM 2004 4th Edition Sample Run-Time Environment The ADL SCORM 2004 4th Ed. Sample Run-Time Environment is licensed under Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States. The Advanced Distributed Learning Initiative allows you to: * Share - to copy, distribute and transmit the work. * Remix - to adapt the work. /*from w w w .j a v a2 s . c om*/ Under the following conditions: * Attribution. You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). * Noncommercial. You may not use this work for commercial purposes. * Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one. For any reuse or distribution, you must make clear to others the license terms of this work. Any of the above conditions can be waived if you get permission from the ADL Initiative. Nothing in this license impairs or restricts the author's moral rights. *******************************************************************************/ import org.w3c.dom.Node; import org.w3c.dom.Attr; import java.util.logging.Logger; 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(Node iNode, String iNodeName, String iNamespace) { Logger.getLogger("org.adl.util.debug.samplerte").entering( "DOMTreeUtility", "isAppropriateElement()"); Logger.getLogger("org.adl.util.debug.samplerte").finest( "Input Parent Node: " + iNode.getLocalName()); Logger.getLogger("org.adl.util.debug.samplerte").finest( "Input Node being searched for: " + iNodeName); Logger.getLogger("org.adl.util.debug.samplerte") .finest("Input Namespace of node being searched for: " + 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; } }