Example usage for org.jdom2 Document getRootElement

List of usage examples for org.jdom2 Document getRootElement

Introduction

In this page you can find the example usage for org.jdom2 Document getRootElement.

Prototype

public Element getRootElement() 

Source Link

Document

This will return the root Element for this Document

Usage

From source file:ch.kostceco.tools.kostval.validation.modulesiard.impl.ValidationGtableModuleImpl.java

License:Open Source License

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override/*from  www.j a  va 2 s.  c o m*/
public boolean validate(File valDatei, File directoryOfLogfile) throws ValidationGtableException {
    // Ausgabe SIARD-Modul Ersichtlich das KOST-Val arbeitet
    System.out.print("G   ");
    System.out.print("\r");
    int onWork = 41;

    boolean valid = true;
    try {
        /* Extract the metadata.xml from the temporare work folder and build a jdom document */

        String pathToWorkDir = getConfigurationService().getPathToWorkDir();
        pathToWorkDir = pathToWorkDir + File.separator + "SIARD";
        /* Nicht vergessen in "src/main/resources/config/applicationContext-services.xml" beim
         * entsprechenden Modul die property anzugeben: <property name="configurationService"
         * ref="configurationService" /> */
        File metadataXml = new File(new StringBuilder(pathToWorkDir).append(File.separator).append("header")
                .append(File.separator).append("metadata.xml").toString());

        InputStream fin = new FileInputStream(metadataXml);
        SAXBuilder builder = new SAXBuilder();
        Document document = builder.build(fin);
        fin.close();

        // declare ArrayLists
        List listSchemas = new ArrayList();
        List listTables = new ArrayList();
        List listColumns = new ArrayList();

        /* read the document and for each schema and table entry verify existence in temporary
         * extracted structure */
        Namespace ns = Namespace.getNamespace("http://www.bar.admin.ch/xmlns/siard/1.0/metadata.xsd");

        // select schema elements and loop
        List<Element> schemas = document.getRootElement().getChild("schemas", ns).getChildren("schema", ns);
        for (Element schema : schemas) {
            String schemaName = schema.getChild("name", ns).getText();

            String lsSch = (new StringBuilder().append(schemaName).toString());

            // select table elements and loop
            List<Element> tables = schema.getChild("tables", ns).getChildren("table", ns);
            for (Element table : tables) {
                String tableName = table.getChild("name", ns).getText();

                // Concatenate schema and table
                String lsTab = (new StringBuilder().append(schemaName).append(" / ").append(tableName)
                        .toString());

                // select column elements and loop
                List<Element> columns = table.getChild("columns", ns).getChildren("column", ns);
                for (Element column : columns) {
                    String columnName = column.getChild("name", ns).getText();

                    // Concatenate schema, table and column
                    String lsCol = (new StringBuilder().append(schemaName).append(" / ").append(tableName)
                            .append(" / ").append(columnName).toString());
                    listColumns.add(lsCol);
                    // concatenating Strings
                }
                listTables.add(lsTab);
                // concatenating Strings (table names)
                if (onWork == 41) {
                    onWork = 2;
                    System.out.print("G-   ");
                    System.out.print("\r");
                } else if (onWork == 11) {
                    onWork = 12;
                    System.out.print("G\\   ");
                    System.out.print("\r");
                } else if (onWork == 21) {
                    onWork = 22;
                    System.out.print("G|   ");
                    System.out.print("\r");
                } else if (onWork == 31) {
                    onWork = 32;
                    System.out.print("G/   ");
                    System.out.print("\r");
                } else {
                    onWork = onWork + 1;
                }
            }
            listSchemas.add(lsSch);
            // concatenating Strings (schema names)
        }
        HashSet hashSchemas = new HashSet(); // check for duplicate schemas
        for (Object value : listSchemas)
            if (!hashSchemas.add(value)) {
                valid = false;
                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_G_SIARD)
                        + getTextResourceService().getText(MESSAGE_XML_G_DUPLICATE_SCHEMA, value));
            }
        HashSet hashTables = new HashSet(); // check for duplicate tables
        for (Object value : listTables)
            if (!hashTables.add(value)) {
                valid = false;
                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_G_SIARD)
                        + getTextResourceService().getText(MESSAGE_XML_G_DUPLICATE_TABLE, value));
            }
        HashSet hashColumns = new HashSet(); // check for duplicate columns
        for (Object value : listColumns)
            if (!hashColumns.add(value)) {
                valid = false;
                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_G_SIARD)
                        + getTextResourceService().getText(MESSAGE_XML_G_DUPLICATE_COLUMN, value));
            }

    } catch (java.io.IOException ioe) {
        valid = false;
        getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_G_SIARD)
                + getTextResourceService().getText(ERROR_XML_UNKNOWN, ioe.getMessage() + " (IOException)"));

    } catch (JDOMException e) {
        valid = false;
        getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_G_SIARD)
                + getTextResourceService().getText(ERROR_XML_UNKNOWN, e.getMessage() + " (JDOMException)"));
        return valid;
    }
    return valid;
}

From source file:ch.kostceco.tools.kostval.validation.modulesiard.impl.ValidationHcontentModuleImpl.java

License:Open Source License

@Override
public boolean validate(File valDatei, File directoryOfLogfile) throws ValidationHcontentException {
    // Ausgabe SIARD-Modul Ersichtlich das KOST-Val arbeitet
    System.out.print("H   ");
    System.out.print("\r");
    int onWork = 41;

    boolean valid = true;
    try {/* w w w .  ja  va  2 s  .  co m*/
        /* Extract the metadata.xml from the temporary work folder and build a jdom document */
        String pathToWorkDir = getConfigurationService().getPathToWorkDir();
        pathToWorkDir = pathToWorkDir + File.separator + "SIARD";
        File metadataXml = new File(new StringBuilder(pathToWorkDir).append(File.separator).append("header")
                .append(File.separator).append("metadata.xml").toString());
        InputStream fin = new FileInputStream(metadataXml);
        SAXBuilder builder = new SAXBuilder();
        Document document = builder.build(fin);
        fin.close();

        /* read the document and for each schema and table entry verify existence in temporary
         * extracted structure */
        Namespace ns = Namespace.getNamespace("http://www.bar.admin.ch/xmlns/siard/1.0/metadata.xsd");
        // select schema elements and loop
        List<Element> schemas = document.getRootElement().getChild("schemas", ns).getChildren("schema", ns);
        for (Element schema : schemas) {
            Element schemaFolder = schema.getChild("folder", ns);
            File schemaPath = new File(new StringBuilder(pathToWorkDir).append(File.separator).append("content")
                    .append(File.separator).append(schemaFolder.getText()).toString());
            if (schemaPath.isDirectory()) {
                Element[] tables = schema.getChild("tables", ns).getChildren("table", ns)
                        .toArray(new Element[0]);
                for (Element table : tables) {
                    Element tableFolder = table.getChild("folder", ns);
                    File tablePath = new File(new StringBuilder(schemaPath.getAbsolutePath())
                            .append(File.separator).append(tableFolder.getText()).toString());
                    if (tablePath.isDirectory()) {
                        File tableXml = new File(new StringBuilder(tablePath.getAbsolutePath())
                                .append(File.separator).append(tableFolder.getText() + ".xml").toString());
                        File tableXsd = new File(new StringBuilder(tablePath.getAbsolutePath())
                                .append(File.separator).append(tableFolder.getText() + ".xsd").toString());
                        // TODO: hier erfolgt die Validerung
                        if (verifyRowCount(tableXml, tableXsd)) {

                            // valid = validate1( tableXml, tableXsd ) && valid;

                            // xmllint via cmd
                            // resources\xmllint\xmllint --noout --stream --schema tableXsd tableXml
                            try {
                                // Pfad zum Programm xmllint existiert die Dateien?
                                String pathToxmllintExe = "resources" + File.separator + "xmllint"
                                        + File.separator + "xmllint.exe";
                                String pathToxmllintDll1 = "resources" + File.separator + "xmllint"
                                        + File.separator + "iconv.dll";
                                String pathToxmllintDll2 = "resources" + File.separator + "xmllint"
                                        + File.separator + "libxml2.dll";
                                String pathToxmllintDll3 = "resources" + File.separator + "xmllint"
                                        + File.separator + "zlib1.dll";

                                File fpathToxmllintExe = new File(pathToxmllintExe);
                                File fpathToxmllintDll1 = new File(pathToxmllintDll1);
                                File fpathToxmllintDll2 = new File(pathToxmllintDll2);
                                File fpathToxmllintDll3 = new File(pathToxmllintDll3);
                                if (!fpathToxmllintExe.exists()) {
                                    getMessageService().logError(getTextResourceService()
                                            .getText(MESSAGE_XML_MODUL_H_SIARD)
                                            + getTextResourceService().getText(ERROR_XML_XMLLINT1_MISSING));
                                    valid = false;
                                } else if (!fpathToxmllintDll1.exists()) {
                                    getMessageService().logError(getTextResourceService()
                                            .getText(MESSAGE_XML_MODUL_H_SIARD)
                                            + getTextResourceService().getText(ERROR_XML_XMLLINT2_MISSING));
                                    valid = false;
                                } else if (!fpathToxmllintDll2.exists()) {
                                    getMessageService().logError(getTextResourceService()
                                            .getText(MESSAGE_XML_MODUL_H_SIARD)
                                            + getTextResourceService().getText(ERROR_XML_XMLLINT3_MISSING));
                                    valid = false;
                                } else if (!fpathToxmllintDll3.exists()) {
                                    getMessageService().logError(getTextResourceService()
                                            .getText(MESSAGE_XML_MODUL_H_SIARD)
                                            + getTextResourceService().getText(ERROR_XML_XMLLINT4_MISSING));
                                    valid = false;
                                } else {

                                    StringBuffer command = new StringBuffer("resources" + File.separator
                                            + "xmllint" + File.separator + "xmllint ");
                                    command.append("--noout --stream ");
                                    command.append(" --schema ");
                                    command.append(" ");
                                    command.append("\"");
                                    command.append(tableXsd.getAbsolutePath());
                                    command.append("\"");
                                    command.append(" ");
                                    command.append("\"");
                                    command.append(tableXml.getAbsolutePath());
                                    command.append("\"");

                                    Process proc = null;
                                    Runtime rt = null;

                                    try {
                                        File outTableXml = new File(pathToWorkDir + File.separator + "SIARD_H_"
                                                + tableXml.getName() + ".txt");

                                        Util.switchOffConsoleToTxt(outTableXml);

                                        rt = Runtime.getRuntime();
                                        proc = rt.exec(command.toString().split(" "));
                                        // .split(" ") ist notwendig wenn in einem Pfad ein Doppelleerschlag vorhanden
                                        // ist!

                                        // Fehleroutput holen

                                        StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream(),
                                                "ERROR-" + tableXml.getName());

                                        // Output holen
                                        StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream(),
                                                "OUTPUT-" + tableXml.getName());

                                        // Threads starten
                                        errorGobbler.start();
                                        outputGobbler.start();

                                        // Warte, bis wget fertig ist 0 = Alles io
                                        int exitStatus = proc.waitFor();

                                        // 200ms warten bis die Konsole umgeschaltet wird, damit wirklich alles im
                                        // file landet
                                        Thread.sleep(200);
                                        Util.switchOnConsole();

                                        if (0 != exitStatus) {
                                            // message.xml.h.invalid.xml = <Message>{0} ist invalid zu
                                            // {1}</Message></Error>
                                            getMessageService().logError(
                                                    getTextResourceService().getText(MESSAGE_XML_MODUL_H_SIARD)
                                                            + getTextResourceService().getText(
                                                                    MESSAGE_XML_H_INVALID_XML,
                                                                    tableXml.getName(), tableXsd.getName()));
                                            valid = false;

                                            // Fehlermeldung aus outTableXml auslesen

                                            BufferedReader br = new BufferedReader(new FileReader(outTableXml));
                                            try {
                                                String line = br.readLine();
                                                String linePrev = null;
                                                /* Fehlermeldungen holen, ausser die letzte, die besagt, dass es invalide
                                                 * ist (wurde bereits oben in D, F,E ausgegeben */
                                                while (line != null) {
                                                    if (linePrev != null) {
                                                        getMessageService().logError(getTextResourceService()
                                                                .getText(MESSAGE_XML_MODUL_H_SIARD)
                                                                + getTextResourceService().getText(
                                                                        MESSAGE_XML_H_INVALID_ERROR, linePrev));
                                                    }
                                                    linePrev = line;
                                                    line = br.readLine();
                                                }
                                            } finally {
                                                br.close();

                                                /* Konsole zuerst einmal noch umleiten und die Streams beenden, damit die
                                                 * dateien gelscht werden knnen */
                                                Util.switchOffConsoleToTxtClose(outTableXml);
                                                System.out.println(" . ");
                                                Util.switchOnConsole();
                                                Util.deleteFile(outTableXml);

                                            }
                                        } else {
                                            /* Konsole zuerst einmal noch umleiten und die Streams beenden, damit die
                                             * dateien gelscht werden knnen */
                                            Util.switchOffConsoleToTxtClose(outTableXml);
                                            System.out.println(" . ");
                                            Util.switchOnConsole();
                                            Util.deleteFile(outTableXml);

                                        }
                                        /* Konsole zuerst einmal noch umleiten und die Streams beenden, damit die
                                         * dateien gelscht werden knnen */
                                        Util.switchOffConsoleToTxtClose(outTableXml);
                                        System.out.println(" . ");
                                        Util.switchOnConsole();
                                        Util.deleteFile(outTableXml);

                                    } catch (Exception e) {
                                        getMessageService().logError(
                                                getTextResourceService().getText(MESSAGE_XML_MODUL_H_SIARD)
                                                        + getTextResourceService().getText(ERROR_XML_UNKNOWN,
                                                                e.getMessage()));
                                        return false;
                                    } finally {
                                        if (proc != null) {
                                            closeQuietly(proc.getOutputStream());
                                            closeQuietly(proc.getInputStream());
                                            closeQuietly(proc.getErrorStream());
                                        }
                                    }
                                }
                            } finally {
                            }
                        }
                    }
                    if (onWork == 41) {
                        onWork = 2;
                        System.out.print("H-   ");
                        System.out.print("\r");
                    } else if (onWork == 11) {
                        onWork = 12;
                        System.out.print("H\\   ");
                        System.out.print("\r");
                    } else if (onWork == 21) {
                        onWork = 22;
                        System.out.print("H|   ");
                        System.out.print("\r");
                    } else if (onWork == 31) {
                        onWork = 32;
                        System.out.print("H/   ");
                        System.out.print("\r");
                    } else {
                        onWork = onWork + 1;
                    }
                }
            }
            if (onWork == 41) {
                onWork = 2;
                System.out.print("H-   ");
                System.out.print("\r");
            } else if (onWork == 11) {
                onWork = 12;
                System.out.print("H\\   ");
                System.out.print("\r");
            } else if (onWork == 21) {
                onWork = 22;
                System.out.print("H|   ");
                System.out.print("\r");
            } else if (onWork == 31) {
                onWork = 32;
                System.out.print("H/   ");
                System.out.print("\r");
            } else {
                onWork = onWork + 1;
            }
        }
    } catch (java.io.IOException ioe) {
        valid = false;
        getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_H_SIARD)
                + getTextResourceService().getText(ERROR_XML_UNKNOWN, ioe.getMessage() + " (IOException)"));
    } catch (JDOMException e) {
        valid = false;
        getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_H_SIARD)
                + getTextResourceService().getText(ERROR_XML_UNKNOWN, e.getMessage() + " (JDOMException)"));
    } catch (SAXException e) {
        valid = false;
        getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_H_SIARD)
                + getTextResourceService().getText(ERROR_XML_UNKNOWN, e.getMessage() + " (SAXException)"));
    }

    return valid;
}

From source file:ch.kostceco.tools.siardexcerpt.excerption.moduleexcerpt.impl.ExcerptCGrepModuleImpl.java

License:Open Source License

@Override
public boolean validate(File siardDatei, File outFile, String excerptString) throws ExcerptCGrepException {
    // Ausgabe -> Ersichtlich das SIARDexcerpt arbeitet
    int onWork = 41;

    boolean isValid = true;

    File fGrepExe = new File("resources" + File.separator + "grep" + File.separator + "grep.exe");
    String pathToGrepExe = fGrepExe.getAbsolutePath();
    if (!fGrepExe.exists()) {
        // grep.exe existiert nicht --> Abbruch
        getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_C)
                + getTextResourceService().getText(ERROR_XML_C_MISSINGFILE, fGrepExe.getAbsolutePath()));
        return false;
    } else {//from   w  w w  .ja  v a  2s.  c om
        File fMsys10dll = new File("resources" + File.separator + "grep" + File.separator + "msys-1.0.dll");
        if (!fMsys10dll.exists()) {
            // msys-1.0.dll existiert nicht --> Abbruch
            getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_C)
                    + getTextResourceService().getText(ERROR_XML_C_MISSINGFILE, fMsys10dll.getAbsolutePath()));
            return false;
        }
    }

    File tempOutFile = new File(outFile.getAbsolutePath() + ".tmp");
    String content = "";

    // Record aus Maintable herausholen
    try {
        if (tempOutFile.exists()) {
            Util.deleteDir(tempOutFile);
        }

        /* Nicht vergessen in "src/main/resources/config/applicationContext-services.xml" beim
         * entsprechenden Modul die property anzugeben: <property name="configurationService"
         * ref="configurationService" /> */

        String name = getConfigurationService().getMaintableName();
        String folder = getConfigurationService().getMaintableFolder();
        String cell = getConfigurationService().getMaintablePrimarykeyCell();

        File fMaintable = new File(siardDatei.getAbsolutePath() + File.separator + "content" + File.separator
                + "schema0" + File.separator + folder + File.separator + folder + ".xml");

        try {
            // grep "<c11>7561234567890</c11>" table13.xml >> output.txt
            String command = "cmd /c \"" + pathToGrepExe + " \"<" + cell + ">" + excerptString + "</" + cell
                    + ">\" " + fMaintable.getAbsolutePath() + " >> " + tempOutFile.getAbsolutePath() + "\"";
            /* Das redirect Zeichen verunmglicht eine direkte eingabe. mit dem geschachtellten Befehl
             * gehts: cmd /c\"urspruenlicher Befehl\" */

            // System.out.println( command );

            Process proc = null;
            Runtime rt = null;

            getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_ELEMENT_OPEN, name));

            try {
                Util.switchOffConsole();
                rt = Runtime.getRuntime();
                proc = rt.exec(command.toString().split(" "));
                // .split(" ") ist notwendig wenn in einem Pfad ein Doppelleerschlag vorhanden ist!

                // Fehleroutput holen
                StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream(), "ERROR");

                // Output holen
                StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream(), "OUTPUT");

                // Threads starten
                errorGobbler.start();
                outputGobbler.start();

                // Warte, bis wget fertig ist
                proc.waitFor();

                Util.switchOnConsole();

            } catch (Exception e) {
                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_C)
                        + getTextResourceService().getText(ERROR_XML_UNKNOWN, e.getMessage()));
                return false;
            } finally {
                if (proc != null) {
                    closeQuietly(proc.getOutputStream());
                    closeQuietly(proc.getInputStream());
                    closeQuietly(proc.getErrorStream());
                }
            }

            Scanner scanner = new Scanner(tempOutFile);
            content = "";
            try {
                content = scanner.useDelimiter("\\Z").next();
            } catch (Exception e) {
                // Grep ergab kein treffer Content Null
                content = "";
            }
            scanner.close();

            getMessageService()
                    .logError(getTextResourceService().getText(MESSAGE_XML_ELEMENT_CONTENT, content));
            getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_ELEMENT_CLOSE, name));

            if (tempOutFile.exists()) {
                Util.deleteDir(tempOutFile);
            }
            content = "";

            // Ende Grep

        } catch (Exception e) {
            getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_C)
                    + getTextResourceService().getText(ERROR_XML_UNKNOWN, e.getMessage()));
            return false;
        }

    } catch (Exception e) {
        getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_C)
                + getTextResourceService().getText(ERROR_XML_UNKNOWN, e.getMessage()));
        return false;
    }

    // Ende MainTable

    // grep der SubTables
    try {
        String name = null;
        String folder = null;
        String cell = null;

        InputStream fin = new FileInputStream(
                new File("configuration" + File.separator + "SIARDexcerpt.conf.xml"));
        SAXBuilder builder = new SAXBuilder();
        Document document = builder.build(fin);
        fin.close();

        /* read the document and for each subTable */
        Namespace ns = Namespace.getNamespace("");

        // select schema elements and loop
        List<Element> subtables = document.getRootElement().getChild("subtables", ns).getChildren("subtable",
                ns);
        for (Element subtable : subtables) {
            name = subtable.getChild("name", ns).getText();
            folder = subtable.getChild("folder", ns).getText();
            cell = subtable.getChild("foreignkeycell", ns).getText();

            // System.out.println( name + " - " + folder + " - " + cell );
            File fSubtable = new File(siardDatei.getAbsolutePath() + File.separator + "content" + File.separator
                    + "schema0" + File.separator + folder + File.separator + folder + ".xml");

            try {
                // grep "<c11>7561234567890</c11>" table13.xml >> output.txt
                String command = "cmd /c \"" + pathToGrepExe + " \"<" + cell + ">" + excerptString + "</" + cell
                        + ">\" " + fSubtable.getAbsolutePath() + " >> " + tempOutFile.getAbsolutePath() + "\"";
                /* Das redirect Zeichen verunmglicht eine direkte eingabe. mit dem geschachtellten Befehl
                 * gehts: cmd /c\"urspruenlicher Befehl\" */

                // System.out.println( command );

                Process proc = null;
                Runtime rt = null;

                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_ELEMENT_OPEN, name));

                try {
                    Util.switchOffConsole();
                    rt = Runtime.getRuntime();
                    proc = rt.exec(command.toString().split(" "));
                    // .split(" ") ist notwendig wenn in einem Pfad ein Doppelleerschlag vorhanden ist!

                    // Fehleroutput holen
                    StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream(), "ERROR");

                    // Output holen
                    StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream(), "OUTPUT");

                    // Threads starten
                    errorGobbler.start();
                    outputGobbler.start();

                    // Warte, bis wget fertig ist
                    proc.waitFor();

                    Util.switchOnConsole();

                } catch (Exception e) {
                    getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_C)
                            + getTextResourceService().getText(ERROR_XML_UNKNOWN, e.getMessage()));
                    return false;
                } finally {
                    if (proc != null) {
                        closeQuietly(proc.getOutputStream());
                        closeQuietly(proc.getInputStream());
                        closeQuietly(proc.getErrorStream());
                    }
                }

                Scanner scanner = new Scanner(tempOutFile);
                content = "";
                try {
                    content = scanner.useDelimiter("\\Z").next();
                } catch (Exception e) {
                    // Grep ergab kein treffer Content Null
                    content = "";
                }
                scanner.close();

                getMessageService()
                        .logError(getTextResourceService().getText(MESSAGE_XML_ELEMENT_CONTENT, content));
                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_ELEMENT_CLOSE, name));

                if (tempOutFile.exists()) {
                    Util.deleteDir(tempOutFile);
                }
                content = "";

                // Ende Grep

            } catch (Exception e) {
                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_C)
                        + getTextResourceService().getText(ERROR_XML_UNKNOWN, e.getMessage()));
                return false;
            }

            // Ende SubTables
            if (onWork == 41) {
                onWork = 2;
                System.out.print("-   ");
                System.out.print("\r");
            } else if (onWork == 11) {
                onWork = 12;
                System.out.print("\\   ");
                System.out.print("\r");
            } else if (onWork == 21) {
                onWork = 22;
                System.out.print("|   ");
                System.out.print("\r");
            } else if (onWork == 31) {
                onWork = 32;
                System.out.print("/   ");
                System.out.print("\r");
            } else {
                onWork = onWork + 1;
            }
        }
        System.out.print("   ");
        System.out.print("\r");
    } catch (Exception e) {
        getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_C)
                + getTextResourceService().getText(ERROR_XML_UNKNOWN, e.getMessage()));
        return false;
    }

    return isValid;
}

From source file:ch.kostceco.tools.siardval.validation.module.impl.ValidationFrowModuleImpl.java

License:Open Source License

private boolean prepareXMLAccess(Properties properties, File metadataXML) throws JDOMException, IOException {
    boolean successfullyCommitted = false;
    String me = "[F.0.5] prepareXMLAccess(Properties properties, File metadataXML) ";
    //Initializing validation Logging
    StringBuilder validationLog = new StringBuilder();
    InputStream inputStream = new FileInputStream(metadataXML);
    SAXBuilder builder = new SAXBuilder();
    Document document = builder.build(inputStream);
    //Assigning JDOM Document to the validation context
    this.setMetadataXMLDocument(document);
    String xmlPrefix = properties.getProperty("module.f.metadata.xml.prefix");
    String xsdPrefix = properties.getProperty("module.f.table.xsd.prefix");
    //Setting the namespaces to access metadata.xml and the different table.xsd
    Element rootElement = document.getRootElement();
    String namespaceURI = rootElement.getNamespaceURI();
    Namespace xmlNamespace = Namespace.getNamespace(xmlPrefix, namespaceURI);
    Namespace xsdNamespace = Namespace.getNamespace(xsdPrefix, namespaceURI);
    //Assigning prefix to the validation context
    this.setXmlPrefix(xmlPrefix);
    this.setXsdPrefix(xsdPrefix);
    //Assigning namespace info to the validation context
    this.setXmlNamespace(xmlNamespace);
    this.setXsdNamespace(xsdNamespace);
    if (this.getXmlNamespace() != null && this.getXsdNamespace() != null && this.getXmlPrefix() != null
            && this.getXsdPrefix() != null && this.getMetadataXMLDocument() != null
            && this.getValidationProperties() != null) {
        //Updating the validation log
        String message = properties.getProperty("successfully.executed");
        validationLog.append(me + message);
        successfullyCommitted = true;/*from   w  w  w. j  a  v a 2 s. c  o  m*/
    } else {
        String message = "has failed";
        validationLog.append(me + message);
    }
    this.getValidationLog().append(validationLog);
    return successfullyCommitted;
}

From source file:ch.kostceco.tools.siardval.validation.module.impl.ValidationFrowModuleImpl.java

License:Open Source License

private boolean prepareValidationData(Properties properties, File metadataXML)
        throws JDOMException, IOException {
    boolean successfullyCommitted = false;
    String me = "[F.0.6] prepareValidationData (Properties properties, File metadataXML) ";
    //Initializing validation Logging
    StringBuilder validationLog = new StringBuilder();
    //Gets the tables to be validated
    List<SiardTable> siardTables = new ArrayList<SiardTable>();
    Document document = this.getMetadataXMLDocument();
    Element rootElement = document.getRootElement();
    String workingDirectory = this.getConfigurationService().getPathToWorkDir();
    String siardSchemasElementsName = properties.getProperty("module.f.siard.metadata.xml.schemas.name");
    //Gets the list of <schemas> elements from metadata.xml
    List<Element> siardSchemasElements = rootElement.getChildren(siardSchemasElementsName,
            this.getXmlNamespace());
    for (Element siardSchemasElement : siardSchemasElements) {
        //Gets the list of <schema> elements from metadata.xml
        List<Element> siardSchemaElements = siardSchemasElement.getChildren(
                properties.getProperty("module.f.siard.metadata.xml.schema.name"), this.getXmlNamespace());
        //Iterating over all <schema> elements
        for (Element siardSchemaElement : siardSchemaElements) {
            String schemaFolderName = siardSchemaElement
                    .getChild(properties.getProperty("module.f.siard.metadata.xml.schema.folder.name"),
                            this.getXmlNamespace())
                    .getValue();/*from w  w  w .ja va  2s  . com*/
            Element siardTablesElement = siardSchemaElement.getChild(
                    properties.getProperty("module.f.siard.metadata.xml.tables.name"), this.getXmlNamespace());
            List<Element> siardTableElements = siardTablesElement.getChildren(
                    properties.getProperty("module.f.siard.metadata.xml.table.name"), this.getXmlNamespace());
            //Iterating over all containing table elements
            for (Element siardTableElement : siardTableElements) {
                Element siardColumnsElement = siardTableElement.getChild(
                        properties.getProperty("module.f.siard.metadata.xml.columns.name"),
                        this.getXmlNamespace());
                List<Element> siardColumnElements = siardColumnsElement.getChildren(
                        properties.getProperty("module.f.siard.metadata.xml.column.name"),
                        this.getXmlNamespace());
                String tableName = siardTableElement
                        .getChild(properties.getProperty("module.f.siard.metadata.xml.table.folder.name"),
                                this.getXmlNamespace())
                        .getValue();
                //SiardTable siardTable = new SiardTable();
                //Decoupling dependency to SiardTable Bean by injecting it via Spring
                SiardTable siardTable = this.getSiardTable();
                siardTable.setMetadataXMLElements(siardColumnElements);
                siardTable.setTableName(tableName);
                String siardTableFolderName = siardTableElement
                        .getChild(properties.getProperty("module.f.siard.metadata.xml.table.folder.name"),
                                this.getXmlNamespace())
                        .getValue();
                StringBuilder pathToTableSchema = new StringBuilder();
                StringBuilder pathToTableData = new StringBuilder();
                //Preparing access to the according XML schema file
                pathToTableSchema.append(workingDirectory);
                pathToTableSchema.append(File.separator);
                pathToTableSchema.append(properties.getProperty("module.f.siard.path.to.content"));
                pathToTableSchema.append(File.separator);
                pathToTableSchema.append(schemaFolderName.replaceAll(" ", ""));
                pathToTableSchema.append(File.separator);
                pathToTableSchema.append(siardTableFolderName.replaceAll(" ", ""));
                pathToTableSchema.append(File.separator);
                pathToTableSchema.append(siardTableFolderName.replaceAll(" ", ""));
                pathToTableSchema.append(properties.getProperty("module.f.siard.table.xsd.file.extension"));
                //Preparing access to the table XML data file
                pathToTableData.append(workingDirectory);
                pathToTableData.append(File.separator);
                pathToTableData.append(properties.getProperty("module.f.siard.path.to.content"));
                pathToTableData.append(File.separator);
                pathToTableData.append(schemaFolderName.replaceAll(" ", ""));
                pathToTableData.append(File.separator);
                pathToTableData.append(siardTableFolderName.replaceAll(" ", ""));
                pathToTableData.append(File.separator);
                pathToTableData.append(siardTableFolderName.replaceAll(" ", ""));
                pathToTableData.append(properties.getProperty("module.f.siard.table.xml.file.extension"));
                //Retrieve the according XML schema
                File tableSchema = this.getSiardFiles().get(pathToTableSchema.toString());
                File tableData = this.getSiardFiles().get(pathToTableData.toString());
                SAXBuilder builder = new SAXBuilder();
                Document tableSchemaDocument = builder.build(tableSchema);
                Document tableDataDocument = builder.build(tableData);
                Element tableSchemaRootElement = tableSchemaDocument.getRootElement();
                Element tableDataRootElement = tableDataDocument.getRootElement();
                Namespace xsdNamespace = tableSchemaRootElement.getNamespace();
                Namespace xmlNamespace = tableDataRootElement.getNamespace();
                //Getting the tags from XML schema to be validated
                Element tableSchemaComplexType = tableSchemaRootElement
                        .getChild(properties.getProperty("module.f.siard.table.xsd.complexType"), xsdNamespace);
                Element tableSchemaComplexTypeSequence = tableSchemaComplexType
                        .getChild(properties.getProperty("module.f.siard.table.xsd.sequence"), xsdNamespace);
                Element tableDataComplexType = tableDataRootElement
                        .getChild(properties.getProperty("module.f.siard.table.xml.complexType"), xmlNamespace);
                Element tableDataComplexTypeSequence = tableDataComplexType
                        .getChild(properties.getProperty("module.f.siard.table.xml.sequence"), xmlNamespace);
                List<Element> tableSchemaComplexTypeElements = tableSchemaComplexTypeSequence
                        .getChildren(properties.getProperty("module.f.siard.table.xsd.element"), xsdNamespace);
                List<Element> tableDataComplexTypeElements = tableDataComplexTypeSequence
                        .getChildren(properties.getProperty("module.f.siard.table.xml.element"), xmlNamespace);
                siardTable.setTableXSDElements(tableSchemaComplexTypeElements);
                siardTable.setTableXMLElements(tableDataComplexTypeElements);
                siardTables.add(siardTable);
                //Writing back the List off all SIARD tables to the validation context
                this.setSiardTables(siardTables);
            }
        }
    }
    if (this.getSiardTables() != null && properties != null && metadataXML != null) {
        //Updating the validation log
        String message = properties.getProperty("successfully.executed");
        String newline = properties.getProperty("newline");
        validationLog.append(me + message);
        validationLog.append(newline);
        successfullyCommitted = true;
    } else {
        String message = "has failed";
        validationLog.append(me + message);
        validationLog.append('\n');
    }
    this.getValidationLog().append(validationLog);
    return successfullyCommitted;
}

From source file:ch.kostceco.tools.siardval.validation.module.impl.ValidationDstructureModuleImpl.java

License:Open Source License

@Override
public boolean validate(File siardDatei) throws ValidationDstructureException {
    boolean valid = true;
    try {/*from  ww w . java2  s.co  m*/
        /*
         * Extract the metadata.xml from the temporare work folder and build
         * a jdom document
         */
        String pathToWorkDir = getConfigurationService().getPathToWorkDir();
        File metadataXml = new File(new StringBuilder(pathToWorkDir).append(File.separator).append("header")
                .append(File.separator).append("metadata.xml").toString());
        InputStream fin = new FileInputStream(metadataXml);
        SAXBuilder builder = new SAXBuilder();
        Document document = builder.build(fin);
        fin.close();

        /*
         * read the document and for each schema and table entry verify
         * existence in temporary extracted structure
         */
        Namespace ns = Namespace.getNamespace("http://www.bar.admin.ch/xmlns/siard/1.0/metadata.xsd");
        // select schema elements and loop
        List<Element> schemas = document.getRootElement().getChild("schemas", ns).getChildren("schema", ns);
        for (Element schema : schemas) {
            valid = validateSchema(schema, ns, pathToWorkDir);
        }
    } catch (java.io.IOException ioe) {
        valid = false;
        getMessageService().logError(getTextResourceService().getText(MESSAGE_MODULE_D)
                + getTextResourceService().getText(MESSAGE_DASHES) + "IOException " + ioe.getMessage());
    } catch (JDOMException e) {
        valid = false;
        getMessageService().logError(getTextResourceService().getText(MESSAGE_MODULE_D)
                + getTextResourceService().getText(MESSAGE_DASHES) + "JDOMException " + e.getMessage());
    }

    return valid;
}

From source file:ch.kostceco.tools.siardval.validation.module.impl.ValidationEcolumnModuleImpl.java

License:Open Source License

private boolean prepareXMLAccess(ValidationContext validationContext)
        throws JDOMException, IOException, Exception {
    boolean successfullyCommitted = false;
    Properties properties = validationContext.getValidationProperties();
    File metadataXML = validationContext.getMetadataXML();
    InputStream inputStream = new FileInputStream(metadataXML);
    SAXBuilder builder = new SAXBuilder();
    Document document = builder.build(inputStream);
    // Assigning JDOM Document to the validation context
    validationContext.setMetadataXMLDocument(document);
    String xmlPrefix = properties.getProperty("module.e.metadata.xml.prefix");
    String xsdPrefix = properties.getProperty("module.e.table.xsd.prefix");
    // Setting the namespaces to access metadata.xml and the different
    // table.xsd//from www  . j  ava  2  s  .  c  o  m
    Element rootElement = document.getRootElement();
    String namespaceURI = rootElement.getNamespaceURI();
    Namespace xmlNamespace = Namespace.getNamespace(xmlPrefix, namespaceURI);
    Namespace xsdNamespace = Namespace.getNamespace(xsdPrefix, namespaceURI);
    // Assigning prefix to the validation context
    validationContext.setXmlPrefix(xmlPrefix);
    validationContext.setXsdPrefix(xsdPrefix);
    // Assigning namespace info to the validation context
    validationContext.setXmlNamespace(xmlNamespace);
    validationContext.setXsdNamespace(xsdNamespace);
    if (validationContext.getXmlNamespace() != null && validationContext.getXsdNamespace() != null
            && validationContext.getXmlPrefix() != null && validationContext.getXsdPrefix() != null
            && validationContext.getMetadataXMLDocument() != null
            && validationContext.getValidationProperties() != null) {
        this.setValidationContext(validationContext);
        successfullyCommitted = true;
    } else {
        successfullyCommitted = false;
        this.setValidationContext(null);
        throw new Exception();
    }
    return successfullyCommitted;
}

From source file:ch.kostceco.tools.siardval.validation.module.impl.ValidationEcolumnModuleImpl.java

License:Open Source License

private boolean prepareValidationData(ValidationContext validationContext)
        throws JDOMException, IOException, Exception {
    boolean successfullyCommitted = false;
    Properties properties = validationContext.getValidationProperties();
    // Gets the tables to be validated
    List<SiardTable> siardTables = new ArrayList<SiardTable>();
    Document document = validationContext.getMetadataXMLDocument();
    Element rootElement = document.getRootElement();
    String workingDirectory = validationContext.getConfigurationService().getPathToWorkDir();
    String siardSchemasElementsName = properties.getProperty("module.e.siard.metadata.xml.schemas.name");
    // Gets the list of <schemas> elements from metadata.xml
    List<Element> siardSchemasElements = rootElement.getChildren(siardSchemasElementsName,
            validationContext.getXmlNamespace());
    for (Element siardSchemasElement : siardSchemasElements) {
        // Gets the list of <schema> elements from metadata.xml
        List<Element> siardSchemaElements = siardSchemasElement.getChildren(
                properties.getProperty("module.e.siard.metadata.xml.schema.name"),
                validationContext.getXmlNamespace());
        // Iterating over all <schema> elements
        for (Element siardSchemaElement : siardSchemaElements) {
            String schemaFolderName = siardSchemaElement
                    .getChild(properties.getProperty("module.e.siard.metadata.xml.schema.folder.name"),
                            validationContext.getXmlNamespace())
                    .getValue();/*from  ww w .  j  a va 2 s .  c o m*/
            Element siardTablesElement = siardSchemaElement.getChild(
                    properties.getProperty("module.e.siard.metadata.xml.tables.name"),
                    validationContext.getXmlNamespace());
            List<Element> siardTableElements = siardTablesElement.getChildren(
                    properties.getProperty("module.e.siard.metadata.xml.table.name"),
                    validationContext.getXmlNamespace());
            // Iterating over all containing table elements
            for (Element siardTableElement : siardTableElements) {
                Element siardColumnsElement = siardTableElement.getChild(
                        properties.getProperty("module.e.siard.metadata.xml.columns.name"),
                        validationContext.getXmlNamespace());
                List<Element> siardColumnElements = siardColumnsElement.getChildren(
                        properties.getProperty("module.e.siard.metadata.xml.column.name"),
                        validationContext.getXmlNamespace());
                String tableName = siardTableElement
                        .getChild(properties.getProperty("module.e.siard.metadata.xml.table.folder.name"),
                                validationContext.getXmlNamespace())
                        .getValue();
                SiardTable siardTable = new SiardTable();
                siardTable.setMetadataXMLElements(siardColumnElements);
                siardTable.setTableName(tableName);
                String siardTableFolderName = siardTableElement
                        .getChild(properties.getProperty("module.e.siard.metadata.xml.table.folder.name"),
                                validationContext.getXmlNamespace())
                        .getValue();
                StringBuilder pathToTableSchema = new StringBuilder();
                // Preparing access to the according XML schema file
                pathToTableSchema.append(workingDirectory);
                pathToTableSchema.append(File.separator);
                pathToTableSchema.append(properties.getProperty("module.e.siard.path.to.content"));
                pathToTableSchema.append(File.separator);
                pathToTableSchema.append(schemaFolderName.replaceAll(" ", ""));
                pathToTableSchema.append(File.separator);
                pathToTableSchema.append(siardTableFolderName.replaceAll(" ", ""));
                pathToTableSchema.append(File.separator);
                pathToTableSchema.append(siardTableFolderName.replaceAll(" ", ""));
                pathToTableSchema.append(properties.getProperty("module.e.siard.table.xsd.file.extension"));
                // Retrieve the according XML schema
                File tableSchema = validationContext.getSiardFiles().get(pathToTableSchema.toString());
                SAXBuilder builder = new SAXBuilder();
                Document tableSchemaDocument = builder.build(tableSchema);
                Element tableSchemaRootElement = tableSchemaDocument.getRootElement();
                Namespace namespace = tableSchemaRootElement.getNamespace();
                // Getting the tags from XML schema to be validated
                Element tableSchemaComplexType = tableSchemaRootElement
                        .getChild(properties.getProperty("module.e.siard.table.xsd.complexType"), namespace);
                Element tableSchemaComplexTypeSequence = tableSchemaComplexType
                        .getChild(properties.getProperty("module.e.siard.table.xsd.sequence"), namespace);
                List<Element> tableSchemaComplexTypeElements = tableSchemaComplexTypeSequence
                        .getChildren(properties.getProperty("module.e.siard.table.xsd.element"), namespace);
                siardTable.setTableXSDElements(tableSchemaComplexTypeElements);
                siardTables.add(siardTable);
                // Writing back the List off all SIARD tables to the
                // validation context
                validationContext.setSiardTables(siardTables);
            }
        }
    }
    if (validationContext.getSiardTables().size() > 0) {
        this.setValidationContext(validationContext);
        successfullyCommitted = true;
    } else {
        this.setValidationContext(null);
        successfullyCommitted = false;
        throw new Exception();
    }
    return successfullyCommitted;
}

From source file:ch.kostceco.tools.siardval.validation.module.impl.ValidationFrowModuleImpl.java

License:Open Source License

private boolean prepareXMLAccess(ValidationContext validationContext)
        throws JDOMException, IOException, Exception {
    boolean successfullyCommitted = false;
    Properties properties = validationContext.getValidationProperties();
    File metadataXML = validationContext.getMetadataXML();
    InputStream inputStream = new FileInputStream(metadataXML);
    SAXBuilder builder = new SAXBuilder();
    Document document = builder.build(inputStream);
    // Assigning JDOM Document to the validation context
    validationContext.setMetadataXMLDocument(document);
    String xmlPrefix = properties.getProperty("module.f.metadata.xml.prefix");
    String xsdPrefix = properties.getProperty("module.f.table.xsd.prefix");
    // Setting the namespaces to access metadata.xml and the different
    // table.xsd//w  w w . j  av  a  2 s . com
    Element rootElement = document.getRootElement();
    String namespaceURI = rootElement.getNamespaceURI();
    Namespace xmlNamespace = Namespace.getNamespace(xmlPrefix, namespaceURI);
    Namespace xsdNamespace = Namespace.getNamespace(xsdPrefix, namespaceURI);
    // Assigning prefix to the validation context
    validationContext.setXmlPrefix(xmlPrefix);
    validationContext.setXsdPrefix(xsdPrefix);
    // Assigning namespace info to the validation context
    validationContext.setXmlNamespace(xmlNamespace);
    validationContext.setXsdNamespace(xsdNamespace);
    if (validationContext.getXmlNamespace() != null && validationContext.getXsdNamespace() != null
            && validationContext.getXmlPrefix() != null && validationContext.getXsdPrefix() != null
            && validationContext.getMetadataXMLDocument() != null
            && validationContext.getValidationProperties() != null) {
        this.setValidationContext(validationContext);
        successfullyCommitted = true;
    } else {
        successfullyCommitted = false;
        this.setValidationContext(null);
        throw new Exception();
    }
    return successfullyCommitted;
}

From source file:ch.kostceco.tools.siardval.validation.module.impl.ValidationFrowModuleImpl.java

License:Open Source License

private boolean prepareValidationData(ValidationContext validationContext)
        throws JDOMException, IOException, Exception {
    boolean successfullyCommitted = false;
    Properties properties = validationContext.getValidationProperties();
    // Gets the tables to be validated
    List<SiardTable> siardTables = new ArrayList<SiardTable>();
    Document document = validationContext.getMetadataXMLDocument();
    Element rootElement = document.getRootElement();
    String workingDirectory = validationContext.getConfigurationService().getPathToWorkDir();
    String siardSchemasElementsName = properties.getProperty("module.f.siard.metadata.xml.schemas.name");
    // Gets the list of <schemas> elements from metadata.xml
    List<Element> siardSchemasElements = rootElement.getChildren(siardSchemasElementsName,
            validationContext.getXmlNamespace());
    for (Element siardSchemasElement : siardSchemasElements) {
        // Gets the list of <schema> elements from metadata.xml
        List<Element> siardSchemaElements = siardSchemasElement.getChildren(
                properties.getProperty("module.f.siard.metadata.xml.schema.name"),
                validationContext.getXmlNamespace());
        // Iterating over all <schema> elements
        for (Element siardSchemaElement : siardSchemaElements) {
            String schemaFolderName = siardSchemaElement
                    .getChild(properties.getProperty("module.f.siard.metadata.xml.schema.folder.name"),
                            validationContext.getXmlNamespace())
                    .getValue();//ww  w  . j av a  2s  .  c  om
            Element siardTablesElement = siardSchemaElement.getChild(
                    properties.getProperty("module.f.siard.metadata.xml.tables.name"),
                    validationContext.getXmlNamespace());
            List<Element> siardTableElements = siardTablesElement.getChildren(
                    properties.getProperty("module.f.siard.metadata.xml.table.name"),
                    validationContext.getXmlNamespace());
            // Iterating over all containing table elements
            for (Element siardTableElement : siardTableElements) {
                Element siardColumnsElement = siardTableElement.getChild(
                        properties.getProperty("module.f.siard.metadata.xml.columns.name"),
                        validationContext.getXmlNamespace());
                List<Element> siardColumnElements = siardColumnsElement.getChildren(
                        properties.getProperty("module.f.siard.metadata.xml.column.name"),
                        validationContext.getXmlNamespace());
                String tableName = siardTableElement
                        .getChild(properties.getProperty("module.f.siard.metadata.xml.table.folder.name"),
                                validationContext.getXmlNamespace())
                        .getValue();
                SiardTable siardTable = new SiardTable();
                // Add Table Root Element
                siardTable.setTableRootElement(siardTableElement);
                siardTable.setMetadataXMLElements(siardColumnElements);
                siardTable.setTableName(tableName);
                String siardTableFolderName = siardTableElement
                        .getChild(properties.getProperty("module.f.siard.metadata.xml.table.folder.name"),
                                validationContext.getXmlNamespace())
                        .getValue();
                StringBuilder pathToTableSchema = new StringBuilder();
                // Preparing access to the according XML schema file
                pathToTableSchema.append(workingDirectory);
                pathToTableSchema.append(File.separator);
                pathToTableSchema.append(properties.getProperty("module.f.siard.path.to.content"));
                pathToTableSchema.append(File.separator);
                pathToTableSchema.append(schemaFolderName.replaceAll(" ", ""));
                pathToTableSchema.append(File.separator);
                pathToTableSchema.append(siardTableFolderName.replaceAll(" ", ""));
                pathToTableSchema.append(File.separator);
                pathToTableSchema.append(siardTableFolderName.replaceAll(" ", ""));
                pathToTableSchema.append(properties.getProperty("module.f.siard.table.xsd.file.extension"));
                // Retrieve the according XML schema
                File tableSchema = validationContext.getSiardFiles().get(pathToTableSchema.toString());

                // --> Hier
                StringBuilder pathToTableXML = new StringBuilder();
                pathToTableXML.append(workingDirectory);
                pathToTableXML.append(File.separator);
                pathToTableXML.append(properties.getProperty("module.f.siard.path.to.content"));
                pathToTableXML.append(File.separator);
                pathToTableXML.append(schemaFolderName.replaceAll(" ", ""));
                pathToTableXML.append(File.separator);
                pathToTableXML.append(siardTableFolderName.replaceAll(" ", ""));
                pathToTableXML.append(File.separator);
                pathToTableXML.append(siardTableFolderName.replaceAll(" ", ""));
                pathToTableXML.append(properties.getProperty("module.f.siard.table.xml.file.extension"));
                File tableXML = validationContext.getSiardFiles().get(pathToTableXML.toString());

                SAXBuilder schemaBuilder = new SAXBuilder();
                Document tableSchemaDocument = schemaBuilder.build(tableSchema);
                Element tableSchemaRootElement = tableSchemaDocument.getRootElement();

                // Getting the tags from XML schema to be validated

                siardTable.setTableXSDRootElement(tableSchemaRootElement);

                SAXBuilder xmlBuilder = new SAXBuilder();
                Document tableXMLDocument = xmlBuilder.build(tableXML);
                Element tableXMLRootElement = tableXMLDocument.getRootElement();
                Namespace xMLNamespace = tableXMLRootElement.getNamespace();
                List<Element> tableXMLElements = tableXMLRootElement.getChildren(
                        properties.getProperty("module.f.siard.table.xml.row.element.name"), xMLNamespace);
                siardTable.setTableXMLElements(tableXMLElements);
                siardTables.add(siardTable);
                // Writing back the List off all SIARD tables to the
                // validation context
                validationContext.setSiardTables(siardTables);
            }
        }
    }
    if (validationContext.getSiardTables().size() > 0) {
        this.setValidationContext(validationContext);
        successfullyCommitted = true;
    } else {
        this.setValidationContext(null);
        successfullyCommitted = false;
        throw new Exception();
    }
    return successfullyCommitted;
}