Package org.atabaque.utils.xml

Examples of org.atabaque.utils.xml.DOMDocument


       
        System.out.println(ConfigFile.getKey("MSG_BUILDING"));
        System.out.println(ConfigFile.getKey("MSG_SOURCE") + inputPath);
        System.out.println(ConfigFile.getKey("MSG_DESTINATION") + outputPath);
       
        DOMDocument doc = new DOMDocument(PROC_PATH + PROCESS_FILENAME);
       
        String processId = doc.getAttributeValue(ELEM_PROCESS, ELEM_ID);
        String processName = doc.getAttributeValue(ELEM_PROCESS, ELEM_NAME);
        String processVersion = doc.getAttributeValue(ELEM_PROCESS, ELEM_VERSION);
       
        // Starts the creation of a Unique
        StringBuffer process = new StringBuffer();
        process.append("<?xml version=\"1.0\" encoding=\"" + ConfigFile.getProperty("CHARSET_ENCODING") + "\"?>\n");
        process.append("<" + ELEM_PROCESS + " " + ELEM_ID + "=\"" + processId + "\" " +
            ELEM_NAME + "=\"" + processName + "\" " + ELEM_VERSION + "=\"" + processVersion + "\">\n");

        NodeList nodeList = doc.selectNodes("*");
        for (int i=0; i<nodeList.getLength(); i++) {
            Element e = (Element) nodeList.item(i);
           
            String id = e.getAttribute(ELEM_ID);
            String name = e.getAttribute(ELEM_NAME);
            String folder = e.getAttribute(ELEM_FOLDER);
            String type = e.getAttribute(ELEM_TYPE);
            String xml = FileUtil.addExt(e.getAttribute(ELEM_XML), XML_EXT);
            String xsl = FileUtil.addExt(e.getAttribute(ELEM_XSL), XSL_EXT);
            String xsl2 = FileUtil.addExt(e.getAttribute(ELEM_XSL2), XSL_EXT);
            String html = FileUtil.addExt(e.getAttribute(ELEM_HTML), HTML_EXT);
            String obs = e.getAttribute(ELEM_OBS);
            String append = e.getAttribute(ELEM_APPEND);
           
            System.out.print("    " + name);
           
            if (type.equals("xml")) {
                String folderName = folder;
                if (folderName.equals("") || folderName.equals("."))
                    folderName = doc.getRoot().getNodeName();
               
                String xmlFileName = (xml.equals("")) ? folderName : xml;
                String xslFileName = (xsl.equals("")) ? xmlFileName : xsl;
                String htmlFileName = (html.equals("")) ? xslFileName : html;
               
                String xmlFile = (i==0?PROC_PATH:XML_PATH) + xmlFileName;
                xmlFile = FileUtil.addExt(xmlFile, XML_EXT);
                String xslFile = XSL_PATH + xslFileName;
                String optionalFolder = "";
                if (!folder.equals("."))
                    optionalFolder = folderName + FILE_SEP;
                String htmlFile = outputPath + optionalFolder + htmlFileName;
               
                FileUtil.createDir(outputPath + folder);
               
                System.out.println(" (" + xml + " -> " + optionalFolder + htmlFileName + ")...");
               
                // Second Transformation
                if (xsl2.equals("")) {
                    if (xmlFile.indexOf("*") > -1) { // It's a wildcard
                        File[] f = FileUtil.listDir(xmlFile);
                        boolean useFileNameAsOutputFolder = false;
                        if (optionalFolder.indexOf("*") > -1) { // Optional Folder is also a wildcard
                            useFileNameAsOutputFolder = true;
                        }
                        for (int index=0; index<f.length; index++) {
                            String filename = f[index].getName();
                            String xmlfile = f[index].getPath().toString();
                            String prefix = "";
                            if (html.indexOf("*") != -1) {
                                prefix = html.substring(0, html.indexOf("*"));
                            }
                            if (useFileNameAsOutputFolder)
                                optionalFolder = filename + FILE_SEP;

                            String htmlfile = outputPath + optionalFolder + prefix + FileUtil.removeExt(filename) + HTML_EXT;

                            System.out.println("      " + filename + " -> " + optionalFolder + prefix + FileUtil.removeExt(filename) + HTML_EXT + "...");

                            XMLUtil.transform(DTD_PATH, xmlfile, xslFile, htmlfile);
                            if (i>0) {
                                if (!append.toLowerCase().equals("false")) {
                                    DOMDocument xmlDoc = new DOMDocument(xmlfile);
                                    if (xmlDoc.isLoaded())
                                        process.append(xmlDoc.getXML());
                                }
                            }
                        }
                    } else {
                        XMLUtil.transform(DTD_PATH, xmlFile, xslFile, htmlFile);
                        if (i>0) {
                            if (!append.toLowerCase().equals("false")) {
                                DOMDocument xmlDoc = new DOMDocument(xmlFile);                               
                                if (xmlDoc.isLoaded())
                                    process.append(xmlDoc.getXML());
                            }
                        }
                    }
                } else {
                    String tempFile = XSL_PATH + xsl2+ TEMP_EXT;
View Full Code Here

TOP

Related Classes of org.atabaque.utils.xml.DOMDocument

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.