Package org.w3c.dom

Examples of org.w3c.dom.Element


    return new Definitions();
  }

  public Object end(final String uri, final String localName,
                final ExtensibleXmlParser parser) throws SAXException {
    final Element element = parser.endElementBuilder();
    Definitions definitions = (Definitions) parser.getCurrent();
        String namespace = element.getAttribute("targetNamespace");
        List<Process> processes = ((ProcessBuildData) parser.getData()).getProcesses();
        for (Process process : processes) {
            RuleFlowProcess ruleFlowProcess = (RuleFlowProcess)process;
            ruleFlowProcess.setMetaData("TargetNamespace", namespace);
        }
View Full Code Here


        return EventNode.class;
    }

    public Object end(final String uri, final String localName,
                      final ExtensibleXmlParser parser) throws SAXException {
        final Element element = parser.endElementBuilder();
        Node node = (Node) parser.getCurrent();
        String attachedTo = element.getAttribute("attachedToRef");
        String cancelActivityString = element.getAttribute("cancelActivity");
        boolean cancelActivity = true;
        if ("false".equals(cancelActivityString)) {
            cancelActivity = false;
        }
        // determine type of event definition, so the correct type of node
        // can be generated
        org.w3c.dom.Node xmlNode = element.getFirstChild();
        while (xmlNode != null) {
            String nodeName = xmlNode.getNodeName();
            if ("escalationEventDefinition".equals(nodeName)) {
                // reuse already created EventNode
                handleEscalationNode(node, element, uri, localName, parser, attachedTo, cancelActivity);
View Full Code Here

    reader = new SimpleElementReader();
  }

  @Test
  public void testGetAttribute() {
    Element element = mock(Element.class);
    when(element.getAttribute("A")).thenReturn(" B ");

    String result = reader.getAttribute(element, "A");

    assertEquals("B", result);
  }
View Full Code Here

    assertEquals("B", result);
  }

  @Test
  public void testGetNodeValue() {
    Element element = mock(Element.class);
    Node node = mock(Node.class);
    when(node.getNodeValue()).thenReturn(" B ");
    when(element.getFirstChild()).thenReturn(node);

    String result = reader.getNodeValue(element);

    assertEquals("B", result);
  }
View Full Code Here

    assertEquals("B", result);
  }

  @Test
  public void testNodeValueIsNull() {
    Element element = mock(Element.class);
    Node node = mock(Node.class);
    when(node.getNodeValue()).thenReturn(null);
    when(element.getFirstChild()).thenReturn(node);

    assertEquals("", reader.getNodeValue(element));
  }
View Full Code Here

    }   
   
    public Object end(final String uri,
                      final String localName,
                      final ExtensibleXmlParser parser) throws SAXException {
        final Element element = parser.endElementBuilder();
         
      Constrainable parent = (Constrainable) parser.getParent();
        Constraint constraint = new ConstraintImpl();

        final String toNodeIdString = element.getAttribute("toNodeId");
        String toType = element.getAttribute("toType");
        ConnectionRef connectionRef = null;
        if (toNodeIdString != null && toNodeIdString.trim().length() > 0) {
          int toNodeId = new Integer(toNodeIdString);
          if (toType == null || toType.trim().length() == 0) {
            toType = NodeImpl.CONNECTION_DEFAULT_TYPE;
          }
          connectionRef = new ConnectionRef(toNodeId, toType);
        }

        final String name = element.getAttribute("name");
        constraint.setName(name);
        final String priority = element.getAttribute("priority");
        if (priority != null && priority.length() != 0) {
            constraint.setPriority(new Integer(priority));
        }

        final String type = element.getAttribute("type");
        constraint.setType(type);
        final String dialect = element.getAttribute("dialect");
        constraint.setDialect(dialect);
         
        String text = ((Text)element.getChildNodes().item( 0 )).getWholeText();
        if (text != null) {
            text = text.trim();
            if ("".equals(text)) {
                text = null;
            }
View Full Code Here

            }
        }
    }

    public void fillDependencies(Collection<File> files, Document doc) {
        Element rootElement = Helper.getFirstElement(doc.getElementsByTagName("dependencies"));
        NodeList nodeList = rootElement.getElementsByTagName("dependency");
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node n = nodeList.item(i);
            if (n.getNodeType() != Node.ELEMENT_NODE) {
                continue;
            }
            Element element = (Element) n;
            boolean include = true;
            StringBuilder path = new StringBuilder(mavenRepoPath);
            StringBuilder jarName = new StringBuilder();

            String groupId = Helper.getFirstElement(element.getElementsByTagName("groupId")).getTextContent();
            for (String str : groupId.split("\\.")) {
                path.append('/');
                path.append(str);
            }
            String artifactId = Helper.getFirstElement(element.getElementsByTagName("artifactId")).getTextContent();
            path.append('/');
            path.append(artifactId);
            jarName.append(artifactId);
            jarName.append('-');

            // if version is not explicitely set => NPE!
            Element versionElement = Helper.getFirstElement(element.getElementsByTagName("version"));
            String versionString = replaceProperty(versionElement.getTextContent());

            path.append('/');
            path.append(versionString);

            jarName.append(versionString);
            jarName.append(".jar");

            Element scopeElement = Helper.getFirstElement(element.getElementsByTagName("scope"));
            if (scopeElement != null) {
                if (!"compile".equals(scopeElement.getTextContent()) && !"system".equals(scopeElement.getTextContent())) {
                    include = false;
                }

                if ("system".equals(scopeElement.getTextContent())) {
                    Element sysPath = Helper.getFirstElement(element.getElementsByTagName("systemPath"));
                    if (sysPath != null) {
                        path.setLength(0);
                        jarName.setLength(0);
                        path.append(replaceProperty(sysPath.getTextContent()));
                    }
                }
            }

            if (include) {
View Full Code Here

            }
        }
    }

    public void fillProperties(Document doc) {
        Element rootElement = Helper.getFirstElement(doc.getElementsByTagName("properties"));
        if (rootElement == null) {
            return;
        }

        NodeList nodeList = rootElement.getChildNodes();
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node n = nodeList.item(i);
            if (n.getNodeType() != Node.ELEMENT_NODE) {
                continue;
            }
            Element element = (Element) n;
            properties.put(element.getNodeName(), element.getTextContent());
        }
    }
View Full Code Here

    protected abstract Node createNode(Attributes attrs);

    public Object end(final String uri, final String localName,
                      final ExtensibleXmlParser parser) throws SAXException {
        final Element element = parser.endElementBuilder();
        Node node = (Node) parser.getCurrent();
        handleNode(node, element, uri, localName, parser);
        NodeContainer nodeContainer = (NodeContainer) parser.getParent();
        nodeContainer.addNode(node);
        return node;
View Full Code Here

   
    protected void handleScript(final ExtendedNodeImpl node, final Element element, String type) {
        NodeList nodeList = element.getChildNodes();
        for (int i = 0; i < nodeList.getLength(); i++) {
          if (nodeList.item(i) instanceof Element) {
            Element xmlNode = (Element) nodeList.item(i);
            String nodeName = xmlNode.getNodeName();
            if (nodeName.equals("extensionElements")) {
                  NodeList subNodeList = xmlNode.getChildNodes();
                  for (int j = 0; j < subNodeList.getLength(); j++) {
                    org.w3c.dom.Node subXmlNode = subNodeList.item(j);
                    if ((type + "-script").equals(subXmlNode.getNodeName())) {
                List<DroolsAction> actions = node.getActions(type);
                if (actions == null) {
View Full Code Here

TOP

Related Classes of org.w3c.dom.Element

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.