Package de.pdark.decentxml

Examples of de.pdark.decentxml.Document


        return unmarshal(doc, "XML File " + file);
    }

    public XmlModel unmarshal(String text) throws Exception {
        Document doc;
        if (text != null && text.trim().length() > 0) {
            doc = parse(new XMLStringSource(text));
        } else {
            doc = createExemplarDoc();
        }
View Full Code Here


        } catch (Exception e) {
            LOG.debug("Property 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) {
View Full Code Here

      resourcesPrefix = null;
    }
   
    InputStream is = getResource(resourcesPrefix, tplXml);
    String xmlText = readStreamToString(is, true, tplXml, tplVars);
    Document doc = XMLParser.parse(xmlText);
    Element root = doc.getRootElement();
    Resource project = processResource(resourcesPrefix, root, tplVars, null);
    return project;
  }
View Full Code Here

 
 
  public static Resource read(String tplXml, Map<String, Object> tplVars) throws IOException {
    InputStream is = getResource(tplXml);
    String xmlText = readStreamToString(is, true, tplXml, tplVars);
    Document doc = XMLParser.parse(xmlText);
    Element root = doc.getRootElement();
    Resource project = processResource(root, tplVars, null);
    return project;
  }
View Full Code Here

TOP

Related Classes of de.pdark.decentxml.Document

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.