Example usage for org.w3c.dom Node getLocalName

List of usage examples for org.w3c.dom Node getLocalName

Introduction

In this page you can find the example usage for org.w3c.dom Node getLocalName.

Prototype

public String getLocalName();

Source Link

Document

Returns the local part of the qualified name of this node.

Usage

From source file:jp.go.nict.langrid.client.soap.io.SoapResponseParser.java

private static Node findFirstChildNamed(Node parent, String localName) {
    Node n = parent.getFirstChild();
    while (n != null && ((n.getNodeType() != Node.ELEMENT_NODE) || !n.getLocalName().equals(localName))) {
        n = n.getNextSibling();//from   w  w w .  j a v a2s  .  c  o m
    }
    return n;
}

From source file:DOM2SAX.java

/**
 * If the DOM was created using a DOM 1.0 API, the local name may be null.
 * If so, get the local name from the qualified name before generating the
 * SAX event.// ww  w  . j a va2 s.  c o m
 */
private static String getLocalName(Node node) {
    final String localName = node.getLocalName();

    if (localName == null) {
        final String qname = node.getNodeName();
        final int col = qname.lastIndexOf(':');
        return (col > 0) ? qname.substring(col + 1) : qname;
    }
    return localName;
}

From source file:Main.java

public static List<Node> getGrandSonElementsByTagName(Element ele, String parentName, String eleName) {

    NodeList nl = ele.getElementsByTagName(parentName);
    if (null == nl) {
        return null;
    }//from  w  w w.ja v  a 2s. c om
    Node item = nl.item(0);
    if (null == item) {
        return null;
    }
    NodeList subNodeList = item.getChildNodes();
    List<Node> childEles = new ArrayList<Node>();
    Node node = null;
    for (int i = 0; i < subNodeList.getLength(); i++) {
        node = subNodeList.item(i);

        if (node != null) {
            if (node instanceof Element && eleName.equals(node.getNodeName())
                    || eleName.equals(node.getLocalName())) {
                childEles.add(node);
            }
        }
    }

    return childEles;
}

From source file:Main.java

@Nullable
public static String getElementName(@Nullable final Node aNode) {
    if (aNode instanceof Document) {
        // Recurse into document element
        return getElementName(((Document) aNode).getDocumentElement());
    }//from  w w  w . ja v  a  2  s.  co m
    if (aNode instanceof Element) {
        String ret = aNode.getLocalName();
        if (ret == null)
            ret = ((Element) aNode).getTagName();
        return ret;
    }
    return null;
}

From source file:Main.java

public static List<String> getGrandSonListValueByTagName(Element element, String parentName, String eleName) {

    NodeList nl = element.getElementsByTagName(parentName);
    if (null == nl) {
        return null;
    }//from ww  w  .j av  a 2 s  .co m
    Node item = nl.item(0);
    if (null == item) {
        return null;
    }
    NodeList subNodeList = item.getChildNodes();
    List<String> childEles = new ArrayList<String>();
    Node node = null;
    for (int i = 0; i < subNodeList.getLength(); i++) {
        node = subNodeList.item(i);

        if (node != null) {
            if (node instanceof Element && eleName.equals(node.getNodeName())
                    || eleName.equals(node.getLocalName())) {
                childEles.add(getTextValue((Element) node));
            }
        }
    }

    return childEles;
}

From source file:com.evolveum.midpoint.util.QNameUtil.java

public static boolean compareQName(QName qname, Node node) {
    return (qname.getNamespaceURI().equals(node.getNamespaceURI())
            && qname.getLocalPart().equals(node.getLocalName()));
}

From source file:com.wso2telco.identity.application.authentication.endpoint.util.TenantDataManager.java

private static void refreshActiveTenantDomainsList() {

    try {/* w w  w  . j  a  v  a2  s . com*/
        String url = "https://" + getPropertyValue(HOST) + ":" + getPropertyValue(PORT)
                + "/services/TenantMgtAdminService/retrieveTenants";

        String xmlString = getServiceResponse(url);

        if (xmlString != null && !"".equals(xmlString)) {

            XPathFactory xpf = XPathFactory.newInstance();
            XPath xpath = xpf.newXPath();

            InputSource inputSource = new InputSource(new StringReader(xmlString));
            String xPathExpression = "/*[local-name() = '" + RETRIEVE_TENANTS_RESPONSE + "']/*[local-name() = '"
                    + RETURN + "']";
            NodeList nodeList = (NodeList) xpath.evaluate(xPathExpression, inputSource, XPathConstants.NODESET);
            tenantDomainList = new ArrayList<String>();

            for (int i = 0; i < nodeList.getLength(); i++) {
                Node node = nodeList.item(i);
                if (node != null && node.getNodeType() == Node.ELEMENT_NODE) {
                    Element element = (Element) node;
                    NodeList tenantData = element.getChildNodes();
                    boolean activeChecked = false;
                    boolean domainChecked = false;
                    boolean isActive = false;
                    String tenantDomain = null;

                    for (int j = 0; j < tenantData.getLength(); j++) {

                        Node dataItem = tenantData.item(j);
                        String localName = dataItem.getLocalName();

                        if (ACTIVE.equals(localName)) {
                            activeChecked = true;
                            if ("true".equals(dataItem.getTextContent())) {
                                isActive = true;
                            }
                        }

                        if (TENANT_DOMAIN.equals(localName)) {
                            domainChecked = true;
                            tenantDomain = dataItem.getTextContent();
                        }

                        if (activeChecked && domainChecked) {
                            if (isActive) {
                                tenantDomainList.add(tenantDomain);
                            }
                            break;
                        }
                    }
                }
            }

            Collections.sort(tenantDomainList);
        }

    } catch (Exception e) {
        if (log.isDebugEnabled()) {
            log.debug("Retrieving Active Tenant Domains Failed. Ignore this if there are no tenants : ", e);
        }
    }
}

From source file:de.openali.odysseus.chart.factory.util.LayerTypeHelper.java

public static ReferencableType getParentNode(final LayerType baseLayerType) {
    final Node node = baseLayerType.getDomNode();
    final Node superiorNode1 = node.getParentNode();
    if (superiorNode1 == null)
        return null;

    final Node superiorNode2 = superiorNode1.getParentNode();
    if (superiorNode2 == null)
        return null;

    final String localName = superiorNode2.getLocalName();
    try {/*from   w  w  w. j a  va2  s  . c  o m*/
        if ("Layer".equals(localName)) //$NON-NLS-1$
        {
            final LayerDocument layerDocument = LayerDocument.Factory.parse(superiorNode2);

            return layerDocument.getLayer();
        } else if ("Chart".equals(localName)) //$NON-NLS-1$
        {
            final ChartDocument document = ChartDocument.Factory.parse(superiorNode2);

            return document.getChart();
        }
    } catch (final XmlException e) {
        OdysseusChartFactory.getDefault().getLog()
                .log(new Status(IStatus.ERROR, OdysseusChartFactory.PLUGIN_ID, e.getLocalizedMessage(), e));
    }

    throw new UnsupportedOperationException();
}

From source file:Main.java

/**
 * Prints a given Node<br>/*from   w ww . jav  a 2s  .  c  o  m*/
 * <p/>
 * For debugging purpose only
 */

public static void printNodeBasics(Node node)

{

    if (node == null)

    {

        System.out.println(" Null node");

        return;

    }

    System.out.println(" Node[Namespace URI=" + node.getNamespaceURI() + " localname=" +

            node.getLocalName() + " name=" +

            node.getNodeName() + " type=" +

            getNodeTypeStr(node.getNodeType()) + " Value=" + node.getNodeValue() +

            "]");

}

From source file:Main.java

/**
 * Builds the node path expression for a node in the DOM tree.
 * @param node in a DOM tree./*from  w ww. j  av  a2s  . c o m*/
 * @param buffer string buffer.
 */
private static void buildNodeName(Node node, StringBuffer buffer) {
    if (node.getParentNode() == null) {
        return;
    }

    buildNodeName(node.getParentNode(), buffer);

    if (node.getParentNode() != null && node.getParentNode().getParentNode() != null) {
        buffer.append(".");
    }

    buffer.append(node.getLocalName());
}