Package org.w3c.dom

Examples of org.w3c.dom.Document


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

        Document doc;
        try {
            InputSource input = new InputSource(new FileInputStream(controlFilePath));
            doc = SafeUpdateUtils.parse(input);
        } catch (Exception e) {
            logger.error(e);
View Full Code Here


     * @param rootTag parents tag to find the node.
     * @param visitor
     * @return false if can't get root tag.
     */
    protected boolean readState(String rootTag, NodeVisitor visitor) {
        Document doc = getDocument();
        if (doc == null) {
            return false;
        }
        NodeList nodeList = doc.getElementsByTagName(rootTag);
        if (nodeList.getLength() == 0) {
            return false;
        }
        nodeList = nodeList.item(0).getChildNodes();
        for (int i = 0; i < nodeList.getLength(); i++) {
View Full Code Here

    String widgetName,
    GUIEventListener listener,
    MapDataModel dataModel,
    Widget parentWidget)
    throws GUIException {
    Document document = null;
    try {
      document = (Document) documentCache.get(url.toString());
      if (document == null) {
        document = dbf.newDocumentBuilder().parse(url.openStream());
        documentCache.put(url.toString(), document);
View Full Code Here

        public void run() {
            try {
              DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                DocumentBuilder db = dbf.newDocumentBuilder();
                FileInputStream fis = new FileInputStream(file);
                Document document = db.parse(fis);
               
                Element eTop = document.getDocumentElement();
               
                String name = Converter.getValidXmlTag(module.getSystemObjectName());
                NodeList nlItems = eTop.getElementsByTagName(name);
   
                listener.notifyStarted(nlItems != null ? nlItems.getLength() : 0);
View Full Code Here

    for (int i = 0; i < xmlFiles.length; i++) {
      String xmlFile = xmlFiles[i];
      String idName = xmlFile.substring(0, xmlFile.length() - 4);
      File sourceFile = new File(inDir.getPath() + "/" + xmlFile);
      File outputFile = new File(outDir.getPath() + "/" + idName + "." + locale + ".html");
      Document document = null;

      log.debug("loading help file [" + xmlFile + "]");
      try {
        document = db.parse(sourceFile);
        mapPrinter.println(
          "  <mapID target=\""
            + document.getDocumentElement().getAttribute("id")
            + "\" url=\""
            + outputFile.getName()
            + "\" />");
      } catch (Exception e) {
        throw new HelpException("Error while loading [" + xmlFile + "]", e);
View Full Code Here

     * @return java.awt.Graphics object to use.
     */
    public Graphics getGraphics(int width, int height) {
        if (svgGenerator == null) {
            DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation();
            Document document = domImpl.createDocument(null, "svg", null);
            svgGenerator = new SVGGraphics2D(document);
            svgGenerator.setClip(0, 0, width, height);
        }
        return svgGenerator;
    }
View Full Code Here

      //修改配置的配置文件,在其中增加sqlMap元素
      DocumentBuilderFactory factory = DocumentBuilderFactory
      .newInstance();
      DocumentBuilder ibatisConfigBuilder = factory.newDocumentBuilder();
      InputStream inputStream = Resources.getResourceAsStream("SqlMapConfig.xml");
      Document doc = ibatisConfigBuilder.parse(inputStream);
     
      NodeList sqlMapElem = doc.getElementsByTagName("sqlMapConfig");
     
      Element elem = doc.createElement("sqlMap");
      elem.setAttribute("resource", "sqlMap.xml");
      sqlMapElem.item(0).appendChild(elem);
     
      Transformer trans = TransformerFactory.newInstance().newTransformer();
      File tempFile = File.createTempFile("sqlMapConfig", ".xml");
View Full Code Here

            return node;
        }

        public Element asElement() {
            if (element == null) {
                Document document;
                try {
                    document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(toString())));
                } catch (Exception e) {
                    throw UncheckedException.asUncheckedException(e);
                }
                element = document.getDocumentElement();
                builder = null;
                node = null;
            }
            return element;
        }
View Full Code Here

        if(actual.length() == 0) {
            Assert.assertEquals(expected, actual);
        }
        actual = "<doc>" + actual + "</doc>";
        expected = "<doc>" + expected + "</doc>";
        Document actualDoc = buildDocument(new ByteArrayInputStream(actual.getBytes("UTF-8")));
        Document expectedDoc = buildDocument(new ByteArrayInputStream(expected.getBytes("UTF-8")));
        XMLAssert.assertXMLEqual(expectedDoc, actualDoc);
    }
View Full Code Here

        XMLAssert.assertXMLEqual(expectedDoc, actualDoc);
    }

    private static Document buildDocument(InputStream is) {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        final Document doc;
        try {
            DocumentBuilder db = dbf.newDocumentBuilder();
            doc = db.parse(is);
        } catch (Exception e) {
            throw new IllegalStateException("buildDocument failed!", 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.