Examples of DocumentBuilder


Examples of javax.xml.parsers.DocumentBuilder

       
        @Override
        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);

Examples of javax.xml.parsers.DocumentBuilder

   */
  public static Document parseInputStream(final InputStream instream)
      throws ParserConfigurationException, SAXException, IOException
  {
    final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    final DocumentBuilder db = dbf.newDocumentBuilder();
    return db.parse(new InputSource(instream));
  }

Examples of javax.xml.parsers.DocumentBuilder

  }

  private void compile(File inDir, File outDir, File mapFile, String locale) throws HelpException {
    String xmlFiles[] = inDir.list(new DialogUtils.ExtensionFilter("xml", false));
    Transformer transformer = null;
    DocumentBuilder db = null;
    PrintWriter mapPrinter = null;

    log.debug("generating help file with locale [" + locale + "]");
    try {
      log.debug("loading xml parser ..");
      db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    } catch (Exception e) {
      throw new HelpException("Error while loading an XML parser", e);
    }

    try {
      log.debug("creating map file [" + mapFile.getPath() + "] ..");
      mapPrinter = new PrintWriter(new BufferedOutputStream(new FileOutputStream(mapFile)));
      mapPrinter.println("<?xml version='1.0' encoding='ISO-8859-1' ?>");
      mapPrinter.println(
        "<!DOCTYPE map PUBLIC \"-//Sun Microsystems Inc.//DTD JavaHelp Map Version 1.0//EN\""
          + " \"http://java.sun.com/products/javahelp/map_1_0.dtd\">\n");
      mapPrinter.println("<!-- Do not change, this file is automatically generated -->");
      mapPrinter.println("<map version=\"1.0\">");
    } catch (Exception e) {
      throw new HelpException("Error while creating the map file", e);
    }

    try {
      log.debug("loading transformer ..");
      URL xslFile = getClass().getResource("/resources/xmlgui/help.xsl");
      transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(xslFile.openStream()));
      transformer.setParameter("locale", locale);
    } catch (Exception e) {
      throw new HelpException("Error while constructing the transformer", e);
    }

    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()

Examples of javax.xml.parsers.DocumentBuilder

      fout.close();
     
      //修改配置的配置文件,在其中增加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");

Examples of javax.xml.parsers.DocumentBuilder

        final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);
        dbf.setExpandEntityReferences(true);
        final Document doc;
        try {
            DocumentBuilder db = dbf.newDocumentBuilder();
            doc = db.parse(is);
        } catch (Exception e) {
            throw new IllegalStateException("buildDocument failed", e);
        }
        return doc;
    }

Examples of javax.xml.parsers.DocumentBuilder

        dbf.setNamespaceAware(true);
        dbf.setExpandEntityReferences(true);
        String input = "<doc>" + frag + "</doc>";
        final Document doc;
        try {
            DocumentBuilder db = dbf.newDocumentBuilder();
            doc = db.parse(new ByteArrayInputStream(input.getBytes("UTF-8")));
        } catch (Exception e) {
            throw new IllegalStateException("buildDocument failed", e);
        }
        return doc;
    }

Examples of javax.xml.parsers.DocumentBuilder

    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());

Examples of javax.xml.parsers.DocumentBuilder

        super();
        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");

Examples of javax.xml.parsers.DocumentBuilder

        return fields;
    }   
   
    private Document read(File file) throws Exception {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        FileInputStream bis = new FileInputStream(file);
        return db.parse(bis);
    }

Examples of javax.xml.parsers.DocumentBuilder

     * @throws InvalidModuleXmlException
     */
    private void initialize(byte[] xml) throws InvalidModuleXmlException {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        try {
            DocumentBuilder db = dbf.newDocumentBuilder();
            ByteArrayInputStream bis = new ByteArrayInputStream(xml);
            document = db.parse(bis);
            load();
        } catch(Exception e) {
            throw new InvalidModuleXmlException(getName(), e);
        }
    }
TOP
Copyright © 2018 www.massapi.com. 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.