Package de.pdark.decentxml

Examples of de.pdark.decentxml.Element


            // lets detect any drools endpoints...
            List<Node> sessions = nodesByNamespace(doc, droolsNamespace.getURI(), "ksession");
            if (sessions != null) {
                for (Node session: sessions) {
                    if (session instanceof Element) {
                        Element e = (Element) session;
                        String node = e.getAttributeValue("node");
                        String sid = e.getAttributeValue("id");
                        if (node != null && node.length() > 0 && sid != null && sid.length() > 0) {
                            String du = "drools:" + node + "/" + sid;
                            boolean exists = false;
                            for (String uri : uris) {
                                if (uri.startsWith(du)) {
                                    exists = true;
                                }
                            }
                            if (!exists) {
                                uris.add(du);
                            }
                        }
                    }
                }
            }
            return new TreeSet<String>(uris);
        } catch (Exception e) {
          Activator.getLogger().error(e.getMessage(), e);
            return new HashSet<String>();
        }
    }
View Full Code Here


        if (url != null) {
            return parse(new XMLIOSource(url));
        } else {
            Activator.getLogger().warning("Could not find file " + exemplar + " on the class path.");
            Document d = new Document();
            d.addNode(new Element("beans", springNamespace));
            return d;
        }
    }
View Full Code Here

          Activator.getLogger().debug("Property is not supported", e);
        }

        Object value = model.marshalRootElement();
        Document doc = model.getDoc();
        Element docElem = doc.getRootElement();

        // JAXB only seems to do nice whitespace/namespace stuff when writing to stream
        // rather than DOM directly
        // marshaller.marshal(value, docElem);

        StringWriter buffer = new StringWriter();
        marshaller.marshal(value, buffer);

        // now lets parse the XML and insert the root element into the doc
        String xml = buffer.toString();
        if (!model.getNs().equals(springNS)) {
            // !!!
            xml = xml.replaceAll(springNS, model.getNs());
        }
        Document camelDoc = parse(new XMLStringSource(xml));
        Node camelElem = camelDoc.getRootElement();

        // TODO
        //val camelElem = doc.importNode(element, true)

        if (model.isRoutesContext() && camelDoc.getRootElement().getName().equals("camelContext")) {
            camelDoc.getRootElement().setName("routeContext");
        }
        if (model.isJustRoutes()) {
            replaceChild(doc, camelElem, docElem);
        } else {
            if (model.getNode() != null) {
                replaceCamelElement(docElem, camelElem, model.getNode());
            } else {
                docElem.addNode(camelElem);
            }
        }
    }
View Full Code Here

            if (node instanceof Comment) {
                Comment c = (Comment) node;
                Token token = c.getToken();
                if (token != null) {
                    String text = token.getText().trim().replace("<!--", "").replace("-->", "").trim();
                    Element descr = findOrCreateDescriptionOnNextElement(e, idx, root);
                    if (descr == null) {
                        // lets move the comment node to before the root element...
                      Activator.getLogger().warning("No description node found");
                        e.removeNode(c);
                        Parent grandParent = root.getParent();
                        if (grandParent != null) {
                            grandParent.addNode(grandParent.nodeIndexOf(root), c);
                        } else {
                          Activator.getLogger().warning("Cannot save the comment '" + text + "' as there's no parent in the DOM");
                        }
                    } else {
                        if (descr.getNodes().size() > 0) {
                            text = "\n" + text;
                        }
                        descr.addNode(new Text(text));
                    }
                }
            } else if (node instanceof Element) {
                moveCommentsIntoDescriptionElements((Element) node, root);
            }
View Full Code Here

                    return (Element) node;
                }
            }
        }

        Element parent = element.getParentElement();
        if (element == root || parent == null || parent == root) {
            return null;
        } else if (elementsWithDescription.contains(element.getName())) {
            // lets check for a namespace prefix
            String ebn = element.getBeginName();
            int idx = ebn.indexOf(":");
            String name = idx > 0 ? ebn.substring(0, idx + 1) + "description" : "description";
            Element description = new Element(name, element.getNamespace());

            element.addNode(0, description);
            return description;
        } else {
            return findOrCreateDescrptionElement(parent, root);
View Full Code Here

        Exception e = new Exception("Unable to determine route container, no node detected.");
        Activator.getLogger().warning(e);
        throw new RuntimeException(e);
     
      
      Element e = (Element)model.getNode();
      Attribute a = e.getAttribute("id");
      if (a != null) id = a.getValue();
    }
    answer.setId(id);
    answer.addRoutes(routes);
    answer.setBeans(model.beanMap());
View Full Code Here

            if (node instanceof Comment) {
                Comment c = (Comment) node;
                Token token = c.getToken();
                if (token != null) {
                    String text = token.getText().trim().replace("<!--", "").replace("-->", "").trim();
                    Element descr = findOrCreateDescriptionOnNextElement(e, idx, root);
                    if (descr == null) {
                        // lets move the comment node to before the root element...
                        LOG.warn("No description node found");
                        e.removeNode(c);
                        Parent grandParent = root.getParent();
                        if (grandParent != null) {
                            grandParent.addNode(grandParent.nodeIndexOf(root), c);
                        } else {
                            LOG.warn("Cannot save the comment '{}' as there's no parent in the DOM", text);
                        }
                    } else {
                        if (descr.getNodes().size() > 0) {
                            text = "\n" + text;
                        }
                        descr.addNode(new Text(text));
                    }
                }
            } else if (node instanceof Element) {
                moveCommentsIntoDescriptionElements((Element) node, root);
            }
View Full Code Here

                    return (Element) node;
                }
            }
        }

        Element parent = element.getParentElement();
        if (element == root || parent == null || parent == root) {
            return null;
        } else if (elementsWithDescription.contains(element.getName())) {
            // lets check for a namespace prefix
            String ebn = element.getBeginName();
            int idx = ebn.indexOf(":");
            String name = idx > 0 ? ebn.substring(0, idx + 1) + "description" : "description";
            Element description = new Element(name, element.getNamespace());

            element.addNode(0, description);
            return description;
        } else {
            return findOrCreateDescrptionElement(parent, root);
View Full Code Here

            // lets detect any drools endpoints...
            List<Node> sessions = nodesByNamespace(doc, droolsNamespace.getURI(), "ksession");
            if (sessions != null) {
                for (Node session: sessions) {
                    if (session instanceof Element) {
                        Element e = (Element) session;
                        String node = e.getAttributeValue("node");
                        String sid = e.getAttributeValue("id");
                        if (node != null && node.length() > 0 && sid != null && sid.length() > 0) {
                            String du = "drools:" + node + "/" + sid;
                            boolean exists = false;
                            for (String uri : uris) {
                                if (uri.startsWith(du)) {
                                    exists = true;
                                }
                            }
                            if (!exists) {
                                uris.add(du);
                            }
                        }
                    }
                }
            }
            return new TreeSet<String>(uris);
        } catch (Exception e) {
            LOG.error(e.getMessage(), e);
            return new HashSet<String>();
        }
    }
View Full Code Here

        if (url != null) {
            return parse(new XMLIOSource(url));
        } else {
            LOG.warn("Could not find file {} on the class path", exemplar);
            Document d = new Document();
            d.addNode(new Element("beans", springNamespace));
            return d;
        }
    }
View Full Code Here

TOP

Related Classes of de.pdark.decentxml.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.