Example usage for org.w3c.dom Element getNamespaceURI

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

Introduction

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

Prototype

public String getNamespaceURI();

Source Link

Document

The namespace URI of this node, or null if it is unspecified (see ).

Usage

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

void parseAttributes(Object base, Element rootElement) {

    ConvertingWrapDynaBean wrap = new ConvertingWrapDynaBean(base);
    DynaClass danaClass = wrap.getDynaClass();
    NamedNodeMap atts = rootElement.getAttributes();
    String defNamespace = rootElement.getNamespaceURI();
    for (int i = 0; i < atts.getLength(); i++) {
        Node currentAttribute = atts.item(i);
        String ns = currentAttribute.getNamespaceURI();
        if (ns == null) {
            ns = defNamespace;//from w w  w .  ja v  a2s .  c om
        }
        String attrName = currentAttribute.getLocalName();
        //  getNodeName();
        switch (ns) {
        case BPMN2_NS: {
            DynaProperty dynaProperty = danaClass.getDynaProperty(attrName);
            if (dynaProperty != null) {
                Class clazz = dynaProperty.getType();
                if (clazz.isAssignableFrom(Reference.class)) {
                    String value = currentAttribute.getNodeValue();
                    Reference ref = createReference(value);
                    wrap.set(attrName, ref);
                } else if (clazz.isAssignableFrom(QName.class)) {
                    String value = currentAttribute.getNodeValue();
                    QName ret = createQName(value);
                    wrap.set(attrName, ret);
                } else if (clazz.isAssignableFrom(MultiInstanceBehavior.class)) {
                    String value = currentAttribute.getNodeValue();
                    wrap.set(attrName, MultiInstanceBehavior.valueOf(value));
                } else {
                    String value = currentAttribute.getNodeValue();
                    wrap.set(attrName, value);
                }
            }
            break;
        }
        case BPMNDI_NS:
        case DC_NS:
        case DI_NS: {
            DynaProperty dynaProperty = danaClass.getDynaProperty(attrName);
            if (dynaProperty != null) {
                String value = currentAttribute.getNodeValue();
                wrap.set(attrName, value);
            }
            break;
        }
        }
    }
}

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

void parseDataAssociation(DataAssociation dataAssoc, Element rootElement) {
    parseAttributes(dataAssoc, rootElement);
    List<Element> childs = XMLUtil.elements(rootElement);
    for (Element child : childs) {
        String ns = child.getNamespaceURI();
        String nodeName = child.getLocalName();
        //  getNodeName();

        if (ns.equals(BPMN2_NS)) {
            switch (nodeName) {
            case "sourceRef": {
                Reference ref = createReference(child);
                dataAssoc.getSourceRef().add(ref);
                break;
            }//from ww w .ja v a 2s .  c o  m
            case "targetRef": {
                Reference ref = createReference(child);
                dataAssoc.setTargetRef(ref);
                break;
            }
            case "assignment":
                Assignment assignment = pareseAssignment(child);
                dataAssoc.getAssignment().add(assignment);
                break;
            }
        }
    }
}

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

Assignment pareseAssignment(Element root) {
    Assignment assignment = new AssignmentImpl(definitions);
    parseAttributes(assignment, root);//from  w  ww.  ja  va2 s . c  o  m
    List<Element> childs = XMLUtil.elements(root);
    for (Element child : childs) {
        String ns = child.getNamespaceURI();
        String nodeName = child.getLocalName();
        if (ns.equals(BPMN2_NS)) {
            switch (nodeName) {
            case "from": {
                Expression from = parseExpression(child);
                assignment.setFrom(from);
                break;
            }
            case "to": {
                Expression to = parseExpression(child);
                assignment.setTo(to);
                break;
            }
            }
        }
    }
    return assignment;
}

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

void parseMultiInstanceLoopCharacteristics(MultiInstanceLoopCharacteristics multiInstanceLoopCharacteristics,
        Element rootElement) {//from ww  w  .  j av a2s  .  com
    parseAttributes(multiInstanceLoopCharacteristics, rootElement);
    List<Element> childs = XMLUtil.elements(rootElement);
    for (Element child : childs) {
        String ns = child.getNamespaceURI();
        String nodeName = child.getLocalName();
        if (ns.equals(BPMN2_NS)) {
            switch (nodeName) {
            case "loopCardinality": {
                Expression expr = parseExpression(child);
                multiInstanceLoopCharacteristics.setLoopCardinality(expr);
                break;
            }
            default: {
                System.out.println("(MultiInstanceLoopCharacteristics not imp element " + nodeName);
            }
            }
        }
    }
}

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

void parseResourceRoleElement(ResourceRole resourceRole, List<Element> childs) {
    childs.stream().forEach((child) -> {
        String ns = child.getNamespaceURI();
        String nodeName = child.getLocalName();
        if (ns.equals(BPMN2_NS)) {
            if (nodeName.equals("resourceAssignmentExpression")) {
                Element elem = XMLUtil.getFirstChildElement(child);
                ResourceAssignmentExpression resourceAssignmentExpression = new ResourceAssignmentExpressionImpl(
                        definitions);/*from www  .  j  a  va2  s .co m*/

                if (elem != null) {
                    String ns1 = elem.getNamespaceURI();
                    String nodeName1 = elem.getLocalName();
                    if (ns1.equals(BPMN2_NS) && nodeName1.equals("formalExpression")) {
                        String script = XMLUtil.getContentText(elem);
                        FormalExpression formalExpression = new FormalExpressionImpl(definitions);
                        formalExpression.setBody(script);
                        resourceAssignmentExpression.setExpression(formalExpression);
                        resourceRole.setResourceAssignmentExpression(resourceAssignmentExpression);
                    }
                }
            }
        }
    });
}

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

void parseOperation(Operation operation, List<Element> childs) {
    for (Element child : childs) {
        String ns = child.getNamespaceURI();
        String nodeName = child.getLocalName();
        //getNodeName();
        if (ns.equals(BPMN2_NS)) {
            switch (nodeName) {
            case "inMessageRef": {
                Reference ref = createReference(child);
                operation.setInMessageRef(ref);
                break;
            }/*from   w  w  w.  j  a  v  a2  s.c o m*/
            case "outMessageRef": {
                Reference ref = createReference(child);
                operation.setOutMessageRef(ref);
                break;
            }
            }
        }
    }
}

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);
            }/*from   ww  w.  j ava2s  .  c o m*/
        }
            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 ava 2  s  . c  o  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;
            }//w  ww  . j a  v  a2s.c  om
        }
    }
}

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;
            }/* ww w.j  a v a2 s.  c  o m*/
        }
    }
    return null;
}