Package writer2latex.xmerge

Examples of writer2latex.xmerge.NewDOMDocument


        if (f.exists()) read(sUserConfig);
        else if (createUserConfig()) write(sUserConfig);
    }
 
    public void read(String sFileName) {
        NewDOMDocument doc = new NewDOMDocument(sFileName,".xml");
        try {
            doc.read(new FileInputStream(sFileName));
        } catch(IOException e) {
            System.out.println("Oops - I cannot read the configuration file "+sFileName);
            e.printStackTrace();
            return; // give up and continue without the configuration
        }
        Document dom = doc.getContentDOM();
        if (dom==null) {
            System.out.println("Oops - I cannot understand the contents of the configuration file "+sFileName);
            return; // give up and continue without the configuration
        }
        Node root = dom.getDocumentElement();
View Full Code Here


            }
        }
    }
   
    public void write(String sFileName) {
        NewDOMDocument doc = new NewDOMDocument(sFileName,".xml");
        Document dom = null;
        try {
            DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder builder = builderFactory.newDocumentBuilder();
            DOMImplementation domImpl = builder.getDOMImplementation();
            dom = domImpl.createDocument("","config",null);
        }
        catch (Throwable t) {
            t.printStackTrace();
        }
        Element rootElement = dom.getDocumentElement();

        for (int i=0; i<OPTION_COUNT; i++) {
            Element optionNode = dom.createElement("option");
            optionNode.setAttribute("name",options[i].getName());
            optionNode.setAttribute("value",options[i].getString());
            rootElement.appendChild(optionNode);
        }

        // Write math symbol map
        Enumeration msEnum = mathSymbols.keys();
        while (msEnum.hasMoreElements()) {
            String sName = (String) msEnum.nextElement();
            String sLatex = (String) mathSymbols.get(sName);
            Element msNode = dom.createElement("math-symbol-map");
            msNode.setAttribute("name",sName);
          msNode.setAttribute("latex",sLatex);
            rootElement.appendChild(msNode);
        }

        writeStyleMap(dom,par,"paragraph");
        writeStyleMap(dom,parBlock,"paragraph-block");
        writeStyleMap(dom,text,"text");
        writeStyleMap(dom,list,"list");
        writeStyleMap(dom,listItem,"listitem");

        Element hmNode = dom.createElement("heading-map");
        hmNode.setAttribute("max-level",Integer.toString(headingMap.getMaxLevel()));
        rootElement.appendChild(hmNode);
        for (int i=1; i<=headingMap.getMaxLevel(); i++) {
            Element hlmNode = dom.createElement("heading-level-map");
            hlmNode.setAttribute("writer-level",Integer.toString(i));
            hlmNode.setAttribute("name",headingMap.getName(i));
            hlmNode.setAttribute("level",Integer.toString(headingMap.getLevel(i)));
            hmNode.appendChild(hlmNode);
        }

   
//        writeXStyleMap(dom,xpar,"paragraph");
//        writeXStyleMap(dom,xtext,"text");
//        writeXStyleMap(dom,xlist,"list");
//        writeXStyleMap(dom,xframe,"frame");
//        writeXStyleMap(dom,xframe,"attribute");

        writeContent(dom,customPreamble,"custom-preamble");

        doc.setContentDOM(dom);
        try {
            doc.write(new FileOutputStream(sFileName));
        } catch(IOException e) {
            System.out.println("Oops - problem writing the configuration");
            e.printStackTrace();
        }
    }
View Full Code Here

TOP

Related Classes of writer2latex.xmerge.NewDOMDocument

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.