Example usage for org.w3c.dom Element getLocalName

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

Introduction

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

Prototype

public String getLocalName();

Source Link

Document

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

Usage

From source file:org.xsystem.bpmn2.formats.xml.XMLParser3.java

void parseRoot(Element rootElement) {
    String nodeName = rootElement.getLocalName();
    //getNodeName();
    RootElement root = (RootElement) BPMN2Factory.createBaseElement(nodeName, definitions);
    parseAttributes(root, rootElement);//from  w  w w.j  ava 2s  .c  om
    definitions.getRootElements().add(root);
    if (root instanceof Process) {
        Process process = (Process) root;
        currentProcess = process;
        List<Element> childs = XMLUtil.elements(rootElement);
        parseProcess(process, childs);
    } else if (root instanceof Interface) {
        Interface inter = (Interface) root;
        List<Element> childs = XMLUtil.elements(rootElement);
        parseInterface(inter, childs);
    } else if (root instanceof CorrelationProperty) {
        CorrelationProperty correlationProperty = (CorrelationProperty) root;
        List<Element> childs = XMLUtil.elements(rootElement);
        parseCorrelationProperty(correlationProperty, childs);
    } else if (root instanceof Collaboration) {
        Collaboration collaboration = (Collaboration) root;
        List<Element> childs = XMLUtil.elements(rootElement);
        parseCollaboration(collaboration, childs);
    }
}

From source file:org.xsystem.bpmn2.formats.xml.XMLParser3.java

void parseBPMNShape(BPMNShape shape, Element rootElement) {
    List<Element> childs = XMLUtil.elements(rootElement);
    for (Element child : childs) {
        String ns = child.getNamespaceURI();
        String nodeName = child.getLocalName();
        //     getNodeName();
        switch (ns) {
        case DC_NS: {
            if (BPMNDIFactory.isBounds(nodeName)) {
                Bounds bounds = new Bounds();
                parseAttributes(bounds, child);
                shape.setBounds(bounds);
            }//w  w w .  j  a  v a2s .  c  om
        }
            break;
        case BPMNDI_NS: {
            DiagramElement diagramElement = BPMNDIFactory.createBPMNElement(nodeName);
            parseAttributes(diagramElement, child);
            if (diagramElement instanceof BPMNLabel) {
                BPMNLabel label = (BPMNLabel) diagramElement;
                parseBPMNLabel(label, child);
                shape.setBpmnLabel(label);
            }
        }
            break;
        }
    }
}

From source file:org.xsystem.bpmn2.formats.xml.XMLParser3.java

void parseBPMNEdge(BPMNEdge edge, Element rootElement) {
    List<Element> childs = XMLUtil.elements(rootElement);
    for (Element child : childs) {
        String ns = child.getNamespaceURI();
        String nodeName = child.getLocalName();
        //getNodeName();
        switch (ns) {
        case DI_NS: {
            if (BPMNDIFactory.iswaypoint(nodeName)) {
                Point point = new Point();
                parseAttributes(point, child);
                edge.getWaypoints().add(point);
            }//from www .  j a va 2 s  .  co m
        }
            break;
        case BPMNDI_NS: {
            DiagramElement diagramElement = BPMNDIFactory.createBPMNElement(nodeName);
            parseAttributes(diagramElement, child);
            if (diagramElement instanceof BPMNLabel) {
                BPMNLabel label = (BPMNLabel) diagramElement;
                parseBPMNLabel(label, child);
            }
        }
            break;
        }
    }
}

From source file:org.xsystem.bpmn2.formats.xml.XMLParser3.java

void parseDiagram(Element rootElement) {
    BPMNDiagram diagram = new BPMNDiagram();
    parseAttributes(diagram, rootElement);
    definitions.getBPMNDiagrams().add(diagram);
    List<Element> childs = XMLUtil.elements(rootElement);
    for (Element child : childs) {
        String ns = child.getNamespaceURI();
        String nodeName = child.getLocalName();
        //getNodeName();
        if (ns.equals(BPMNDI_NS)) {
            if (BPMNDIFactory.isBPMNPlane(nodeName)) {
                parseBPMNPlane(diagram, child);
                return;
            }/*from w  ww .j  a v  a 2s .  c  om*/
        }
    }
}

From source file:pl.touk.ode.scopeEvaluator.MockExtVarManager.java

private Map<String, String> elementToMap(Element el) {
    HashMap<String, String> ret = new HashMap<String, String>();
    for (int i = 0; i < el.getChildNodes().getLength(); i++) {
        Node n = el.getChildNodes().item(i);
        if (n instanceof Element) {
            Element el1 = (Element) el;
            ret.put(el1.getLocalName(), el.getTextContent());
        }//ww w. ja v a  2  s  .  c  o m
    }
    return ret;
}

From source file:ru.codeinside.gws.crypto.cryptopro.CryptoProvider.java

private static Element first(final Node parent, final String uri, final String localName) {
    final NodeList nodes = parent.getChildNodes();
    final int n = nodes.getLength();
    for (int i = 0; i < n; i++) {
        final Node node = nodes.item(i);
        if (node instanceof Element) {
            final Element element = (Element) node;
            if (localName.equals(element.getLocalName()) && uri.equals(element.getNamespaceURI())) {
                return element;
            }/*w w  w .j  a v a 2s .c o m*/
        }
    }
    return null;
}

From source file:ru.codeinside.gws.crypto.cryptopro.CryptoProvider.java

private static Element first(final Node parent, final String uri, final String localName, final String attrUri,
        final String attr, final String attrValue) {
    final NodeList nodes = parent.getChildNodes();
    final int n = nodes.getLength();
    for (int i = 0; i < n; i++) {
        final Node node = nodes.item(i);
        if (node instanceof Element) {
            final Element element = (Element) node;
            if (localName.equals(element.getLocalName()) && uri.equals(element.getNamespaceURI())
                    && attrValue.equals(element.getAttributeNS(attrUri, attr))) {
                return element;
            }//  w w  w  . j a  v  a2  s . c  o m
        }
    }
    return null;
}

From source file:ru.codeinside.gws3572c.GMPClientSignTest.java

private static Element first(final Node parent, final String uri, final String localName) {
    final NodeList nodes = parent.getChildNodes();
    final int n = nodes.getLength();
    for (int i = 0; i < n; i++) {
        final Node node = nodes.item(i);
        if (node instanceof Element) {
            final Element element = (Element) node;
            if (localName.equals(element.getLocalName())
                    && (uri == null || uri.equals(element.getNamespaceURI()))) {
                return element;
            }/*from  w w w .  j  a v  a2  s  .  c  o m*/
        }
    }
    return null;
}

From source file:test.unit.be.agiv.security.client.TestUtils.java

/**
 * XMLSEC 1.5 requires us to explicitly mark the Id's within a DOM document.
 * /*  w  ww . j  a va2 s  .  c o  m*/
 * @param document
 */
public static void markAllIdAttributesAsId(Document document) {
    Element nsElement = document.createElement("nsElement");
    nsElement.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:wsu", WSConstants.WS_SECURITY_UTILITY_NAMESPACE);

    NodeList elementsWithIdNodeList;
    try {
        elementsWithIdNodeList = XPathAPI.selectNodeList(document, "//*[@Id or @wsu:Id]", nsElement);
    } catch (TransformerException e) {
        throw new RuntimeException(e);
    }

    for (int nodeIdx = 0; nodeIdx < elementsWithIdNodeList.getLength(); nodeIdx++) {
        Element elementWithId = (Element) elementsWithIdNodeList.item(nodeIdx);
        LOG.debug("element with Id: " + elementWithId.getLocalName());
        Attr attributeNode = elementWithId.getAttributeNode("Id");
        if (null == attributeNode) {
            attributeNode = elementWithId.getAttributeNodeNS(WSConstants.WS_SECURITY_UTILITY_NAMESPACE, "Id");
        }
        elementWithId.setIdAttributeNode(attributeNode, true);
    }
}

From source file:ubic.gemma.web.services.AbstractGemmaEndpoint.java

/**
 * @param requestElement erquest element
 * @param tagName        tag name//ww  w. j a  va  2s. c  om
 * @return A method written for array input from MATLAB clients. A more generic method to use is getNodeValues(). Column
 * Arrays and Horizontal Arrays from MATLAB both work, but it must be passed in directly (i.e. EEArray.ee_ids)
 */
protected Collection<String> getArrayValues(Element requestElement, String tagName) {
    Assert.isTrue(AbstractGemmaEndpoint.NAMESPACE_URI.equals(requestElement.getNamespaceURI()),
            "Invalid namespace");
    Assert.isTrue(localName.equals(requestElement.getLocalName()), "Invalid local name");
    this.authenticate();

    Collection<String> value = new HashSet<>();
    String node;
    NodeList children = requestElement.getElementsByTagName(tagName).item(0).getChildNodes();

    // generic clients
    // iterate over the child nodes
    for (int i = 0; i < children.getLength(); i++) {
        // need to go one more level down into the great-grandchildren
        Node child = children.item(i).getChildNodes().item(0);
        // new check to see if the request is a Matlab one
        // Matlab seems to package the xml such that values are found in every odd (ie. 1, 3, 5, 7, etc)
        // great-grandchild. If at i=0, there is no value, then it IS a Matlab request.
        if (i == 0 && child == null)
            break;
        if (child.getNodeType() == Node.TEXT_NODE) {
            node = child.getNodeValue();
            value.add(node);
        }
    }

    if (!value.isEmpty())
        return value;

    // MATLAB specific
    // but it appears that MATLAB encodes it so that every odd (ie. 1, 3, 5, 7, etc) great-grandchild holds the
    // array value
    value = new HashSet<>();

    for (int i = 1; i < children.getLength(); i = i + 2) {

        // need to go one more level down into the great-grandchildren
        Node child = children.item(i).getChildNodes().item(0);
        // Node child = children.item(i).getFirstChild();

        if (child.getNodeType() == Node.TEXT_NODE) {
            node = child.getNodeValue();
            value.add(node);
        }
    }

    if (value.isEmpty()) {
        throw new IllegalArgumentException("Could not find request text node");
    }

    return value;

}