Package org.w3c.dom

Examples of org.w3c.dom.Document


  {
    Node root = null;
    if (_type == Node.DOCUMENT_NODE) {
      root = ((Document)_node).getDocumentElement();
    } else {
      Document doc = _node.getOwnerDocument();
      if (doc != null) {
        root = doc.getDocumentElement();
      }
    }
    return (root != null) ? new AnyNode(root) : NULL;
  }
View Full Code Here


    /**
     * @return
     */
    private Document generateCapabilitiesDocument() {
       
        Document doc;
       
        try {
            DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
           
            DOMImplementation impl = builder.getDOMImplementation();
            DocumentType doctype = impl.createDocumentType("wms", "WMT_MS_Capabilities",
                    "http://schemas.opengis.net/wms/1.1.1/WMS_MS_Capabilities.dtd");
            doc = impl.createDocument(null, "WMT_MS_Capabilities", doctype);
        } catch (javax.xml.parsers.ParserConfigurationException ex) {
            throw new RuntimeException("Cannot create new Xml Document:" + ex.getMessage());
        }
       
        Element root = doc.getDocumentElement();
        root.setAttribute("version", "1.1.1");
        root.setAttribute("updateSequence", Integer.toString(updateSequence));

        Element service = doc.createElement("Service");
        service.appendChild(textnode(doc, "Name", "OGC:WMS"));
        service.appendChild(textnode(doc, "Title", wmsTitle));
        service.appendChild(textnode(doc, "Abstract", wmsAbstract));

        if (!keywordsList.isEmpty()) {
            Element keywordListElement = doc.createElement("KeywordList");
            for (int i = 0; i < keywordsList.size(); i++) {
                keywordListElement.appendChild(textnode(doc, "Keyword", (String) keywordsList.get(i)));
            }
            service.appendChild(keywordListElement);
        }

        Element onlineResource = doc.createElement("OnlineResource");
        onlineResource.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
        onlineResource.setAttribute("xlink:type", "simple");
        onlineResource.setAttribute("xlink:href", onlineResourcesList[FMT_MAIN]);
        service.appendChild(onlineResource);

        service.appendChild(textnode(doc, "Fees", "none"));
        service.appendChild(textnode(doc, "AccessConstraints", "none"));
        root.appendChild(service);

        Node capability = doc.createElement("Capability");
        Element request = doc.createElement("Request");

        request.appendChild(requestcap(doc, WMTConstants.GETCAPABILITIES, formatsList[FMT_GETCAPS], "Get",
                onlineResourcesList[FMT_GETCAPS]));
        request.appendChild(requestcap(doc, WMTConstants.GETMAP, formatsList[FMT_GETMAP], "Get",
                onlineResourcesList[FMT_GETMAP]));
        request.appendChild(requestcap(doc, WMTConstants.GETFEATUREINFO, formatsList[FMT_GETFEATUREINFO],
                "Get", onlineResourcesList[FMT_GETFEATUREINFO]));
        capability.appendChild(request);

        Element exceptionElement = doc.createElement("Exception");
        for (int i = 0; i < formatsList[FMT_EXCEPTIONS].size(); i++) {
            exceptionElement.appendChild(textnode(doc, "Format", (String) formatsList[FMT_EXCEPTIONS].get(i)));
        }
        capability.appendChild(exceptionElement);

View Full Code Here

        tr.setOutputProperty(OutputKeys.METHOD, "xml");
        tr.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
        tr.setOutputProperty(OutputKeys.VERSION, "1.0");
        tr.setOutputProperty(OutputKeys.ENCODING, "UTF-8");

        Document document = generateCapabilitiesDocument();
       
        // system id not transformed by default transformer
        tr.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, document.getDoctype().getSystemId());
       
        // Serialize XML Document
        tr.transform(new DOMSource(document), new StreamResult(strWriter));
        return strWriter.toString();
    }
View Full Code Here

        Message = message;
        Code = code;

        try {
            DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
            Document doc = builder.newDocument();

//            Document doc = new DocumentImpl();
        Element root = doc.createElement("ServiceExceptionReport");
        root.setAttribute("version", "1.1.0");
        Element ex = doc.createElement("ServiceException");
        ex.appendChild(doc.createTextNode(Message));
        if (Code != null)
            ex.setAttribute("code", Code);

        root.appendChild(ex);
        doc.appendChild(root);

        StringWriter strWriter = new StringWriter();
//        XMLSerializer serializer = null;
//        OutputFormat outFormat = null;
        Transformer tr = TransformerFactory.newInstance().newTransformer();
View Full Code Here

        String extendedPath;
        String currentDir;
        CollectionStorage colStorage;
        NodeList childNodes;

        Document doc = getDocument();
        if (doc == null) {
            return;
        }

        NodeList nodeList = doc.getElementsByTagName(COLLECTION);
        if (nodeList.getLength() == 0) {
            return;
        }
        for (int i = 0; i < nodeList.getLength(); i++) {
View Full Code Here

    private Document getDocument() {
        if (!fileExists()) {
            return null;
        }

        Document doc = null;
        try {
            InputSource input = new InputSource(new FileInputStream(storageMetaFile));
            DOMParser parser = new DOMParser();
            parser.parse(input);
            doc = parser.getDocument();
View Full Code Here

        return null;
    }
   
    private void add() throws Exception {
        Document document = read(add);
       
        Element element = document.getDocumentElement();
        NodeList nodes = element.getElementsByTagName("module");
       
        for (int i = 0; i < nodes.getLength(); i++) {
            Element module = (Element) nodes.item(i);
            String jarfile = XMLParser.getString(module, "module-jar");
View Full Code Here

            save(xmlModule, jarfile);
        }
    }

    private void alter() throws Exception {
        Document document = read(alter);
       
        Element element = document.getDocumentElement();
        NodeList nodes = element.getElementsByTagName("module");
       
        for (int i = 0; i < nodes.getLength(); i++) {
            Element module = (Element) nodes.item(i);
            String jarfile = XMLParser.getString(module, "module-jar");
View Full Code Here

            save(xmlModule, jarfile);
        }       
    }

    private void remove() throws Exception {
        Document document = read(remove);
       
        Element element = document.getDocumentElement();
        NodeList nodes = element.getElementsByTagName("module");
       
        for (int i = 0; i < nodes.getLength(); i++) {
            Element module = (Element) nodes.item(i);
            String jarfile = XMLParser.getString(module, "module-jar");
View Full Code Here

//        if (logger.isDebugEnabled()) {
//            Utilities.writeToFile(html.getBytes(), "online_service_document.xml");
//        }
       
        Reader reader = new InputStreamReader(in);
        Document document = builder.newDocument();
       
        try {
            HtmlParser parser = new HtmlParser(new SimpleUserAgentContext(), document);
            parser.parse(reader);
        } catch (Exception e) {
View Full Code Here

TOP

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