Package org.dom4j

Examples of org.dom4j.Document


        }
        try {
            File componentConfig = new File(componentDir, "component.xml");
            if (componentConfig.exists()) {
                SAXReader saxReader = new SAXReader();
                Document componentXML = saxReader.read(componentConfig);
                Element element = (Element)componentXML.selectSingleNode(xpath);
                if (element != null) {
                    return element.getTextTrim();
                }
            }
        }
View Full Code Here


            // Make the reader non-validating so that it doesn't try to resolve external
            // DTD's. Trying to resolve external DTD's can break on some firewall configurations.
            SAXReader saxReader = new SAXReader(false);
            saxReader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd",
                    false);
            Document doc = saxReader.read(webXML);
            // Find all <servlet> entries to discover name to class mapping.
            List classes = doc.selectNodes("//servlet");
            Map<String, Class> classMap = new HashMap<String, Class>();
            for (int i = 0; i < classes.size(); i++) {
                Element servletElement = (Element)classes.get(i);
                String name = servletElement.element("servlet-name").getTextTrim();
                String className = servletElement.element("servlet-class").getTextTrim();
                classMap.put(name, finder.loadClass(className, component));
            }
            // Find all <servelt-mapping> entries to discover name to URL mapping.
            List names = doc.selectNodes("//servlet-mapping");
            for (int i = 0; i < names.size(); i++) {
                Element nameElement = (Element)names.get(i);
                String name = nameElement.element("servlet-name").getTextTrim();
                String url = nameElement.element("url-pattern").getTextTrim();
                // Register the servlet for the URL.
View Full Code Here

        String pluginName = webXML.getParentFile().getParentFile().getName();
        try {
            SAXReader saxReader = new SAXReader(false);
            saxReader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd",
                    false);
            Document doc = saxReader.read(webXML);
            // Find all <servelt-mapping> entries to discover name to URL mapping.
            List names = doc.selectNodes("//servlet-mapping");
            for (int i = 0; i < names.size(); i++) {
                Element nameElement = (Element)names.get(i);
                String url = nameElement.element("url-pattern").getTextTrim();
                // Destroy the servlet than remove from servlets map.
                HttpServlet servlet = servlets.get(pluginName + url);
View Full Code Here

    private static final String SAMPLE_NAME_2 = "jack";
    private static final String SAMPLE_NAME_3 = "bob";

    @Override
    protected void setUp() throws Exception {
        Document document = DocumentHelper.createDocument();
        rootElement = document.addElement("root");
        rootNode = new DOM4JSettingsNode(rootElement);
    }
View Full Code Here

        }

        try {
            XMLWriter xmlWriter = new XMLWriter(fileOutputStream, OutputFormat.createPrettyPrint());

            Document document = DocumentHelper.createDocument();
            Element rootElement = document.addElement(rootElementTag);
            DOM4JSettingsNode settingsNode = new DOM4JSettingsNode(rootElement);
            for (int index = 0; index < serializables.length; index++) {
                SettingsSerializable serializable = serializables[index];
                try //don't let a single serializer stop the entire thing from being written in.
                    serializable.serializeOut(settingsNode);
View Full Code Here

        try {
            XMLWriter xmlWriter = new XMLWriter(fileOutputStream, OutputFormat.createPrettyPrint());
            Element rootElement = settingsNode.getElement();
            rootElement.detach();

            Document document = DocumentHelper.createDocument(rootElement);

            xmlWriter.write(document);
        } catch (Throwable t) {
            LOGGER.error("Internal error. Failed to save.", t);
            exportInteraction.reportError("Internal error. Failed to save.");
View Full Code Here

            return null//we should really sit in a loop until they cancel or give us a valid file.
        }

        try {
            SAXReader reader = new SAXReader();
            Document document = reader.read(file);

            return new DOM4JSettingsNode(document.getRootElement());
        } catch (Throwable t) {
            LOGGER.error("Unable to read file: " + file.getAbsolutePath(), t);
            importInteraction.reportError("Unable to read file: " + file.getAbsolutePath());
            return null;
        }
View Full Code Here

        return file;   //it already ends with the correct extension.
    }

    public static DOM4JSettingsNode createBlankSettings() {
        Document document = DocumentHelper.createDocument();
        Element rootElement = document.addElement("root");
        DOM4JSettingsNode settings = new DOM4JSettingsNode(rootElement);
        return settings;
    }
View Full Code Here

   
  public void testWSDLGeneration() throws Exception
  {
        addNamespace("wsdl", "http://schemas.xmlsoap.org/wsdl/");
       
        Document doc = getWSDL("Version");
       
        assertValid("/wsdl:definitions/wsdl:message[@name='getVersionResponse']", doc );
  }
View Full Code Here

   
    public void testListSerialization() throws Exception
    {
      addNamespace("wsdl", "http://schemas.xmlsoap.org/wsdl/");
       
        Document doc = getWSDL("ListService");
       
        assertInvalid("/wsdl:definitions/wsdl:message[@name='secretMethodResponse']", doc );
        assertValid("/wsdl:definitions/wsdl:message[@name='getDevelopersResponse']", doc );
        assertValid("/wsdl:definitions/wsdl:message[@name='getDevelopersResponse']/wsdl:part[@type='impl:ArrayOf_xsd_string']", doc );
View Full Code Here

TOP

Related Classes of org.dom4j.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.