src/main/java/fr/insee/eno/params/validation/ValidationMessage.java
public class ValidationMessage {
	
	public ValidationMessage(String message, boolean valid) {
		super();
		this.message = message;
		this.valid = valid;
	}
	private String message;
	private boolean valid;
	
	
	
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public boolean isValid() {
		return valid;
	}
	public void setValid(boolean valid) {
		this.valid = valid;
	}

}
src/main/java/fr/insee/eno/params/pipeline/PipeLineGeneratorImpl.java
public class PipeLineGeneratorImpl implements PipelineGenerator {
	
	private static final Logger LOGGER = LoggerFactory.getLogger(PipeLineGeneratorImpl.class);
	
	// In2Out Generator
	private IdentityGenerator identityGenerator = new IdentityGenerator();
	
	private DDI2XFORMSGenerator ddi2xformsGenerator = new DDI2XFORMSGenerator();

	private DDI2LunaticXMLGenerator ddi2lunaticXmlGenerator = new DDI2LunaticXMLGenerator();

	private DDI2FODTGenerator ddi2fodtGenerator = new DDI2FODTGenerator();

	private DDI2FOGenerator ddi2foGenerator = new DDI2FOGenerator();

	private PoguesXML2DDIGenerator poguesXml2ddiGenerator = new PoguesXML2DDIGenerator();
	
	// PreProcessing
	
	private NoopPreprocessor noopPreprocessor = new NoopPreprocessor();
	
	private DDIDereferencingPreprocessor ddiDereferencing = new DDIDereferencingPreprocessor();

	private DDICleaningPreprocessor ddiCleaning = new DDICleaningPreprocessor();

	private DDITitlingPreprocessor ddiTitling = new DDITitlingPreprocessor();

	private DDIMappingPreprocessor ddiMapping = new DDIMappingPreprocessor();
	
	private DDIMultimodalSelectionPreprocessor ddiMultimodal = new DDIMultimodalSelectionPreprocessor();
	
	private DDIMarkdown2XhtmlPreprocessor ddiMW2XHTML = new DDIMarkdown2XhtmlPreprocessor();

	private PoguesXMLPreprocessorGoToTreatment poguesXmlGoTo = new PoguesXMLPreprocessorGoToTreatment();
	
	private PoguesXmlInsertFilterLoopIntoQuestionTree poguesXmlFilterLoopIntoQuestionTree = new PoguesXmlInsertFilterLoopIntoQuestionTree();
	
	private DDI32ToDDI33Preprocessor ddi32ToDDI33Preprocessor = new DDI32ToDDI33Preprocessor();
	
	// PostProcessing
	private XFORMSBrowsingPostprocessor xformsBrowsing = new XFORMSBrowsingPostprocessor();

	private XFORMSInseePatternPostprocessor xformsInseePattern = new XFORMSInseePatternPostprocessor();

	private XFORMSFixAdherencePostprocessor xformsFixAdherence = new XFORMSFixAdherencePostprocessor();

	private XFORMSIdentificationPostprocessor xformsIdentification = new XFORMSIdentificationPostprocessor();

	private XFORMSInsertEndPostprocessor xformsInsertEnd = new XFORMSInsertEndPostprocessor();

	private XFORMSInsertGenericQuestionsPostprocessor xformsInsertGenericQuestions = new XFORMSInsertGenericQuestionsPostprocessor();

	private XFORMSInsertWelcomePostprocessor xformsInsertWelcome = new XFORMSInsertWelcomePostprocessor();

	private XFORMSInseeModelPostprocessor xformsInseeModel = new XFORMSInseeModelPostprocessor();

	private XFORMSSpecificTreatmentPostprocessor xformsSpecificTreatment = new XFORMSSpecificTreatmentPostprocessor();

	private FOEditStructurePagesPostprocessor foEditStructurePages = new FOEditStructurePagesPostprocessor();

	private FOInsertAccompanyingMailsPostprocessor foInsertAccompanyingMails = new FOInsertAccompanyingMailsPostprocessor();

	private FOInsertCoverPagePostprocessor foInsertCoverPage = new FOInsertCoverPagePostprocessor();

	private FOInsertEndQuestionPostprocessor foInsertEndQuestion = new FOInsertEndQuestionPostprocessor();
	
	private FOMailingPostprocessor foMailing = new FOMailingPostprocessor();
	
	private FOSpecificTreatmentPostprocessor foSpecificTreatment = new FOSpecificTreatmentPostprocessor();
	
	private FOTableColumnPostprocessorFake foTableColumn = new FOTableColumnPostprocessorFake();
	
	private LunaticXMLSpecificTreatmentPostprocessor lunaticXmlSpecificTreatment = new LunaticXMLSpecificTreatmentPostprocessor();
	
	private LunaticXMLInsertGenericQuestionsPostprocessor lunaticXmlInsertGenericQuestions = new LunaticXMLInsertGenericQuestionsPostprocessor();

	private LunaticXMLPaginationPostprocessor lunaticXMLPaginationPostprocessor = new LunaticXMLPaginationPostprocessor();
	
	private LunaticXMLExternalizeVariablesAndDependenciesPostprocessor lunaticXMLExternalizeVariablesAndDependencies = new LunaticXMLExternalizeVariablesAndDependenciesPostprocessor();
	
	private LunaticXMLSortComponentsPostprocessor lunaticXmlSortComponents = new LunaticXMLSortComponentsPostprocessor();
	
	private LunaticXMLVTLParserPostprocessor lunaticXmlvtlParser = new LunaticXMLVTLParserPostprocessor();
	
	private NoopPostprocessor noop = new NoopPostprocessor();
	

	@Override
	public GenerationService setPipeLine(Pipeline pipeline) throws Exception {
		LOGGER.info("Creating new pipeline...");
		Preprocessor[] preprocessors = setPreProcessors(pipeline.getPreProcessing());
		Generator generator = setGenerator(pipeline.getInFormat(), pipeline.getOutFormat());
		Postprocessor[] postprocessors = setPostProcessors(pipeline.getPostProcessing());
		
		LOGGER.info("PreProccesings : "+Arrays.toString(preprocessors));
		LOGGER.info("Core generation : "+generator.in2out());
		LOGGER.info("PostProccesings : "+Arrays.toString(postprocessors));
		return new GenerationService(preprocessors, generator, postprocessors);
	}

	@Override
	public Postprocessor[] setPostProcessors(List<PostProcessing> postProcessings) {
		List<Postprocessor> postprocessors = new ArrayList<Postprocessor>();
		if(!postProcessings.isEmpty()) {
			for(PostProcessing postProcessing : postProcessings) {
				postprocessors.add(getPostPorcessor(postProcessing));
			}
		}
		else {
			postprocessors.add(new NoopPostprocessor());
		}
		
		return postprocessors.toArray(new Postprocessor[postprocessors.size()]);
	}

	@Override
	public Preprocessor[] setPreProcessors(List<PreProcessing> preProcessings) {
		List<Preprocessor> preprocessors = new ArrayList<Preprocessor>();
		if(preProcessings.isEmpty()) {preprocessors.add(noopPreprocessor);}
		else {
		for(PreProcessing preProcessing : preProcessings) {
			preprocessors.add(getPreProcessor(preProcessing));
		} }
		return preprocessors.toArray(new Preprocessor[preprocessors.size()]);
	}
	
	@Override
	public Generator setGenerator(InFormat inFormat, OutFormat outFormat) {
		Generator generator=null;
		
		switch (inFormat) {
		case DDI:
			switch (outFormat) {
			case DDI:
				generator = identityGenerator;
				break;
			case XFORMS:
				generator = ddi2xformsGenerator;
				break;
			case LUNATIC_XML:
				generator = ddi2lunaticXmlGenerator;
				break;
			case FODT:
				generator = ddi2fodtGenerator;
				break;
			case FO:
				generator = ddi2foGenerator;
				break;
//			case POGUES_XML:
//				generator = ddi2poguesXmlGenerator;
//				break;
			}
			break;
		case POGUES_XML:
			switch (outFormat) {
			case DDI:
				generator = poguesXml2ddiGenerator;
				break;
			default:
				generator = identityGenerator;
				break;
			}
			break;
		case XFORMS:
			generator = identityGenerator;
			break;
		}
		return generator;
	}

	@Override
	public Postprocessor getPostPorcessor(PostProcessing postProcessing) {
		Postprocessor postprocessor = null;
		switch (postProcessing) {
		case XFORMS_BROWSING:
			postprocessor = xformsBrowsing;
			break;
		case XFORMS_INSEE_PATTERN:
			postprocessor = xformsInseePattern;
			break;
		case XFORMS_FIX_ADHERENCE:
			postprocessor = xformsFixAdherence;
			break;
		case XFORMS_IDENTIFICATION:
			postprocessor = xformsIdentification;
			break;
		case XFORMS_INSERT_END:
			postprocessor = xformsInsertEnd;
			break;
		case XFORMS_INSERT_GENERIC_QUESTIONS:
			postprocessor = xformsInsertGenericQuestions;
			break;
		case XFORMS_INSERT_WELCOME:
			postprocessor = xformsInsertWelcome;
			break;
		case XFORMS_INSEE_MODEL:
			postprocessor = xformsInseeModel;
			break;
		case XFORMS_SPECIFIC_TREATMENT:
			postprocessor = xformsSpecificTreatment;
			break;
		case FO_EDIT_STRUCTURE_PAGES:
			postprocessor = foEditStructurePages;
			break;
		case FO_INSERT_ACCOMPANYING_MAILS:
			postprocessor = foInsertAccompanyingMails;
			break;
		case FO_INSERT_COVER_PAGE:
			postprocessor = foInsertCoverPage;
			break;
		case FO_INSERT_END_QUESTION:
			postprocessor = foInsertEndQuestion;
			break;
		case FO_MAILING:
			postprocessor = foMailing;
			break;
		case FO_SPECIFIC_TREATMENT:
			postprocessor = foSpecificTreatment;
			break;
		case FO_TABLE_COLUMN:
			postprocessor = foTableColumn;
			break;
		case LUNATIC_XML_PAGINATION:
			postprocessor = lunaticXMLPaginationPostprocessor;
			break;
		case LUNATIC_XML_EXTERNALIZE_VARIABLES:
			postprocessor = lunaticXMLExternalizeVariablesAndDependencies;
			break;
		case LUNATIC_XML_INSERT_GENERIC_QUESTIONS:
			postprocessor= lunaticXmlInsertGenericQuestions;
			break;
		case LUNATIC_XML_SORT_COMPONENTS:
			postprocessor = lunaticXmlSortComponents;
			break;
		case LUNATIC_XML_VTL_PARSER:
			postprocessor = lunaticXmlvtlParser;
			break;
		case LUNATIC_XML_SPECIFIC_TREATMENT:
			postprocessor = lunaticXmlSpecificTreatment;
			break;
		case DDI_SPECIFIC_TREATMENT:
			postprocessor = noop;
			break;
		case FODT_SPECIFIC_TREATMENT:
			postprocessor = noop;
			break;
		}
		return postprocessor;
	}

	@Override
	public Preprocessor getPreProcessor(PreProcessing preProcessing) {
		Preprocessor preprocessor = null;
		
		if(preProcessing==null) {
			preprocessor = noopPreprocessor;
			}
		else {
		switch (preProcessing) {
		case DDI_32_TO_DDI_33:
			preprocessor = ddi32ToDDI33Preprocessor;
			break;
		case DDI_MARKDOWN_TO_XHTML:
			preprocessor = ddiMW2XHTML;
			break;
		case DDI_DEREFERENCING:
			preprocessor = ddiDereferencing;
			break;
		case DDI_CLEANING:
			preprocessor = ddiCleaning;
			break;
		case DDI_TITLING:
			preprocessor = ddiTitling;
			break;
		case DDI_MAPPING:
			preprocessor = ddiMapping;
			break;
		case DDI_MULTIMODAL_SELECTION:
			preprocessor = ddiMultimodal;
			break;
		case POGUES_XML_INSERT_FILTER_LOOP_INTO_QUESTION_TREE:
			preprocessor = poguesXmlFilterLoopIntoQuestionTree;
			break;
		case POGUES_XML_GOTO_2_ITE:
			preprocessor = poguesXmlGoTo;
			break;
			case POGUES_XML_SUPPRESSION_GOTO:
			break;
		case POGUES_XML_TWEAK_TO_MERGE_EQUIVALENT_ITE:
			break;
		}}
		return preprocessor;
	}
	

}
src/main/java/fr/insee/eno/utils/FolderCleaner.java
public class FolderCleaner {

	private final static Logger logger = LoggerFactory.getLogger(FolderCleaner.class);

	/**
	 * Method representing the Clean ant target : Cleaning the current
	 * questionnaireFolder (with the created survey name) Cleaning the temp folder
	 * Cleaning the test folder
	 * 
	 * @param questionnaireFolder : the folder that has to be either created or
	 *                            cleaned (having the survey's name)
	 * @throws Exception : FileNotfound / NoAccess mainly
	 */
	public void cleanTarget(String questionnaireFolder) throws Exception {

		String tempFolder = Constants.TEMP_FOLDER_PATH + "/temp";
		String testFolder = Constants.TEMP_FOLDER_PATH + "/test";

		logger.debug("Cleaning directories : " + tempFolder + " | " + testFolder + " | " + questionnaireFolder);

		FileUtils.forceMkdir(new File(tempFolder));
		FileUtils.cleanDirectory(new File(tempFolder));

		FileUtils.forceMkdir(new File(testFolder));
		FileUtils.cleanDirectory(new File(testFolder));

		FileUtils.forceMkdir(new File(questionnaireFolder));
		FileUtils.cleanDirectory(new File(questionnaireFolder));

	}

	/**
	 * Generic method to clean one folder
	 * 
	 * @param folder : the folder to be cleaned
	 * @throws IOException : FileNotfound / NoAccess mainly
	 */
	public void cleanOneFolder(File folder) throws IOException {
		logger.debug("Cleaning " + folder);
		if (folder.exists() && Files.isDirectory(folder.toPath())) {
			FileUtils.cleanDirectory(folder);
		}
	}

	/**
	 * Method to clean all files in folder except one
	 * 
	 * @param folder : the folder to be cleaned
	 * @param generatedFile : the file to not delete
	 * @throws IOException : FileNotfound / NoAccess mainly
	 */
	public void cleanOneFolderExceptGeneratedFile(File folder, File generatedFile) throws IOException  {
		logger.debug("Special cleaning into : " + folder+" (deleting all files except : "+generatedFile.getName() +")");
		if (folder.exists() && Files.isDirectory(folder.toPath())) {
			File[] matchCleaningInput = folder.listFiles(new FilenameFilter() {
				@Override
				public boolean accept(File dir, String name) {
					if(Files.isDirectory(Paths.get(dir+"/"+name))){
						try {
							cleanOneFolderExceptGeneratedFile(Paths.get(dir+"/"+name).toFile(),generatedFile);
						} catch (IOException e) {
							logger.error(e.getMessage());
						}
					}
					return !name.equals(generatedFile.getName());
				}
			});
			for(File file : matchCleaningInput) {
				if(Files.isDirectory(file.toPath())) {
					if(file.list().length==0) {
						FileUtils.forceDelete(file);
					}
				}
				else {
					FileUtils.forceDelete(file);
				}
			}		
		}
	}
}
src/main/java/fr/insee/eno/params/ValorizatorParametersImpl.java
public class ValorizatorParametersImpl implements ValorizatorParameters {

	private static final Logger LOGGER = LoggerFactory.getLogger(ValorizatorParametersImpl.class);
	
	private XslTransformation saxonService = new XslTransformation();

	private static final String styleSheetPath = Constants.MERGE_PARAMETERS_XSL;


	@Override
	public ByteArrayOutputStream mergeParameters(ENOParameters enoParameters) throws JAXBException, IllegalArgumentException, IllegalAccessException, IOException   {
		
		ByteArrayOutputStream tempByteArrayOutputStream = new ByteArrayOutputStream();
		
		JAXBContext context = JAXBContext.newInstance(ENOParameters.class);
		Marshaller jaxbMarshaller =  context.createMarshaller();
		jaxbMarshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
		jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
		jaxbMarshaller.marshal(enoParameters, tempByteArrayOutputStream);
		
		InputStream PARAM_XSL = Constants.getInputStreamFromPath(styleSheetPath);
		InputStream inputStream = new ByteArrayInputStream(tempByteArrayOutputStream.toByteArray());
		ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
		
		try {
			saxonService.mergeEnoParameters(inputStream, outputStream, PARAM_XSL);
		}catch(Exception e) {
			String errorMessage = "An error was occured during the valorisation of parameters. "+e.getMessage();
			LOGGER.error(errorMessage);
			throw new EnoGenerationException(errorMessage);
		}
		
		tempByteArrayOutputStream.close();
		inputStream.close();
		PARAM_XSL.close();

		return outputStream;
	}
	
	@Override
	public File mergeParameters(File enoParameters) throws JAXBException, IllegalArgumentException, IllegalAccessException, IOException   {
		File finalParam = Constants.TEMP_FILE_PARAMS("new-params.xml");
		
		InputStream PARAM_XSL = Constants.getInputStreamFromPath(styleSheetPath);
		InputStream inputStream = FileUtils.openInputStream(enoParameters);
		OutputStream outputStream = FileUtils.openOutputStream(finalParam);
		
		try {
			saxonService.mergeEnoParameters(inputStream, outputStream, PARAM_XSL);
		}catch(Exception e) {
			String errorMessage = String.format("An error was occured during the valorisation of parameters. %s : %s",
					e.getMessage(),
					Utils.getErrorLocation(styleSheetPath,e));
			LOGGER.error(errorMessage);
			throw new EnoGenerationException(errorMessage);
		}
		
		inputStream.close();
		outputStream.close();
		PARAM_XSL.close();
		
		return finalParam;
	}

	@Override
	public ENOParameters mergeEnoParameters(ENOParameters enoParameters) throws JAXBException, IOException, IllegalArgumentException, IllegalAccessException  {
		LOGGER.info("Merging eno Parameters");
		ByteArrayOutputStream outputStream = this.mergeParameters(enoParameters);
		ENOParameters finalEnoParam = this.getParameters(new ByteArrayInputStream(outputStream.toByteArray()));
		outputStream.close();
		return finalEnoParam;
	}

	


	/**
	 * 
	 * @return the java object representing parameters of default parameters xml file
	 * @throws JAXBException
	 * @throws IOException
	 */
	public ENOParameters getDefaultParameters() throws JAXBException, IOException {
		InputStream xmlParameters = Constants.getInputStreamFromPath(Constants.PARAMETERS_DEFAULT_XML);
		StreamSource xml = new StreamSource(xmlParameters);
		return this.getParameters(xml);
	}

	
	@Override
	public ENOParameters getParameters(InputStream inputStream) throws JAXBException, UnsupportedEncodingException {

		if (inputStream == null)
			return null;

		LOGGER.debug("Preparing to translate from XML to java");
		
		

		JAXBContext context = JAXBContext.newInstance(ENOParameters.class);
		Unmarshaller unmarshaller = context.createUnmarshaller();
		unmarshaller.setListener(new UnmarshallLogger());

		ENOParameters enoParameters = (ENOParameters) unmarshaller.unmarshal(inputStream);

		return enoParameters;
	}

	public ENOParameters getParameters(StreamSource xmlStream) throws JAXBException, UnsupportedEncodingException {

		if (xmlStream == null)
			return null;

		LOGGER.debug("Preparing to translate from XML to java");

		JAXBContext context = JAXBContext.newInstance(ENOParameters.class);
		Unmarshaller unmarshaller = context.createUnmarshaller();
		unmarshaller.setListener(new UnmarshallLogger());

		ENOParameters enoParameters = (ENOParameters) unmarshaller.unmarshal(xmlStream);

		return enoParameters;
	}

	private class UnmarshallLogger extends Unmarshaller.Listener {

		@Override
		public void beforeUnmarshal(Object target, Object parent) {
			LOGGER.debug("Before unmarshalling object " + target);
		}

		@Override
		public void afterUnmarshal(Object target, Object parent) {
			LOGGER.debug("After unmarshalling object " + target);
		}
	}

	public List<Field> getAllFields(List<Field> fields, Class<?> type) {
		fields.addAll(Arrays.asList(type.getDeclaredFields()));
		if (type.getSuperclass() != null) {
			getAllFields(fields, type.getSuperclass());
		}

		return fields;
	}
}
src/main/java/fr/insee/eno/exception/EnoParametersException.java
public class EnoParametersException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    public EnoParametersException(String message) {
        super(message);
    }
}
src/main/java/fr/insee/eno/params/validation/SchemaValidator.java
public interface SchemaValidator {
	
	/**
	 * 
	 * @param paramsIS
	 * @return
	 */
	ValidationMessage validate(InputStream paramsIS);
	

}
src/main/java/fr/insee/eno/params/pipeline/PipelineGenerator.java
public interface PipelineGenerator {
	
	/**
	 * 
	 * @param pipeline
	 * @return a GenerationService with the Eno transformation (PreProcessor, Generator and PostProcessor) according to the param.
	 * @throws Exception
	 */
	public GenerationService setPipeLine(Pipeline pipeline) throws Exception;
	
	/**
	 * 
	 * @param postProcessings
	 * @return a list of Postprocessor (Java class) according to a List of PostProcessing (Enum)
	 */
	public Postprocessor[] setPostProcessors(List<PostProcessing> postProcessings);
	
	/**
	 * 
	 * @param preProcessings : a list of Preprocessor (Java class) according to a List of PreProcessing (Enum)
	 * @return
	 */
	public Preprocessor[] setPreProcessors(List<PreProcessing> preProcessings);
	
	/**
	 * 
	 * @param inFormat
	 * @param outFormat
	 * @return the Generator according to the inFormat(Enum) and outFormat(Enum)
	 */
	public Generator setGenerator(InFormat inFormat, OutFormat outFormat);
	
	/**
	 * Linking function : Postprocessor with PostProcessing
	 * @param postProcessing
	 * @return the Postprocessor java class according to PostProcessing(Enum)
	 */
	public Postprocessor getPostPorcessor(PostProcessing postProcessing);
	
	/**
	 * Linking function : Preprocessor with PreProcessing
	 * @param preProcessing
	 * @return the Preprocessor java class according to PreProcessing(Enum)
	 */
	public Preprocessor getPreProcessor(PreProcessing preProcessing);

}
src/main/java/fr/insee/eno/Constants.java
public final class Constants {


	private static final Logger logger = LoggerFactory.getLogger(Constants.class);

	private Constants() {
	}

	// ---------- Core resources: references to XSL, XML, etc. resources used to generate a questionnaire

	// ----- Folders
	public static final String UTIL_FOLDER_PATH = "/xslt/util";
	public static final String PARAMS_DEFAULT_FOLDER_PATH = "/params/default";
	public static final String PARAMS_SCHEMAS_FOLDER_PATH = "/params/schemas";
	public static final String TRANSFORMATIONS_FOLDER = "/xslt/transformations";
	public static final String CONFIG_FOLDER = "/config";
	public static final String INPUTS_FOLDER = "/xslt/inputs";
	public static final File LABEL_FOLDER = getFileFromUrl(Constants.class.getResource("/lang/xforms"));
	public static final String PARAMETERS_DEFAULT_XML = PARAMS_DEFAULT_FOLDER_PATH+"/parameters.xml";
	


	// Params : schema
	public static final URL ENO_PARAMETERS_XSD = Constants.class.getResource(PARAMS_SCHEMAS_FOLDER_PATH+"/ENOParameters.xsd");

	// ----- XSL Parameters path
	public static final String CONFIG_DDI2XFORMS = CONFIG_FOLDER + "/ddi2xforms.xml";
	public static final String CONFIG_DDI2FODT = CONFIG_FOLDER + "/ddi2fodt.xml";
	public static final String CONFIG_DDI2FO = CONFIG_FOLDER + "/ddi2fo.xml";
	public static final String CONFIG_POGUES_XML2DDI = CONFIG_FOLDER + "/pogues-xml2ddi.xml";
	public static final String CONFIG_DDI2LUNATIC_XML = CONFIG_FOLDER + "/ddi2lunatic-xml.xml";
	public static final String PARAMETERS_DEFAULT = PARAMS_DEFAULT_FOLDER_PATH + "/parameters.xml";
	public static final String METADATA_DEFAULT = PARAMS_DEFAULT_FOLDER_PATH + "/metadata.xml";
	public static final String MAPPING_DEFAULT = PARAMS_DEFAULT_FOLDER_PATH + "/mapping.xml";
	public static final String LABELS_FOLDER = "/lang/xforms/";


	/********************************************************/
	/********************** Pre-processing ******************/
	/********************************************************/
	public static final String PRE_PROCESSING_FOLDER = "/xslt/pre-processing";
	public static final String UTIL_DDI_SPLITTING_XSL = UTIL_FOLDER_PATH + "/ddi/splitting.xsl";
	/******************* DDI - Pre-processing ****************/
	public static final String UTIL_DDI_MD2XHTML_XSL = PRE_PROCESSING_FOLDER + "/ddi/md2xhtml.xsl";
	public static final String UTIL_DDI_TWEAK_XHTML_FOR_DDI_XSL = PRE_PROCESSING_FOLDER + "/ddi/tweak-xhtml-for-ddi.xsl";
	public static final String UTIL_DDI_DEREFERENCING_XSL = PRE_PROCESSING_FOLDER + "/ddi/dereferencing.xsl";
	public static final String UTIL_DDI_TITLING_XSL = PRE_PROCESSING_FOLDER + "/ddi/titling.xsl";
	public static final String UTIL_DDI_MAPPING_XSL = PRE_PROCESSING_FOLDER + "/ddi/mapping.xsl";
	public static final String UTIL_DDI_CLEANING_XSL = PRE_PROCESSING_FOLDER + "/ddi/cleaning.xsl";
	public static final String UTIL_DDI_MULTIMODAL_SELECTION_XSL = PRE_PROCESSING_FOLDER + "/ddi/multimodal-selection.xsl";
	public static final String UTIL_DDI32_TO_DDI33_XSL = UTIL_FOLDER_PATH + "/ddi/ddi32toddi33.xsl";
	
	/*************** PoguesXML - Pre-processing **************/
	public static final String UTIL_POGUES_XML_LOOP_FILTER_INTO_QUESTION_TREE_XSL = PRE_PROCESSING_FOLDER + "/pogues-xml/insert-filter-loop-into-question-tree.xsl";
	public static final String UTIL_POGUES_XML_SUPP_GOTO_XSL = PRE_PROCESSING_FOLDER + "/pogues-xml/2suppressionGoto.xsl";
	public static final String UTIL_POGUES_XML_MERGE_ITE_XSL = PRE_PROCESSING_FOLDER + "/pogues-xml/tweak-to-merge-equivalent-ite.xsl";
	public static final String UTIL_POGUES_XML_GOTO_ITE_XSL = PRE_PROCESSING_FOLDER + "/pogues-xml/goto-2-if-then-else.xsl";
	
	
	
	/********************************************************/
	/********************* Post-processing ******************/
	/********************************************************/
	public static final String POST_PROCESSING_FOLDER = "/xslt/post-processing";
	
	/********************* DDI - Post-processing ******************/
	
	public static final String UTIL_FODS_PREFORMATTING_XSL = UTIL_FOLDER_PATH + "/fods/preformatting.xsl";
	public static final String UTIL_XSL_INCORPORATION_XSL = UTIL_FOLDER_PATH + "/xsl/incorporation.xsl";

	
	/********************* XSL generation ******************/
	public static final String TRANSFORMATIONS_DDI2XFORMS_DDI2XFORMS_XSL = TRANSFORMATIONS_FOLDER + "/ddi2xforms/ddi2xforms.xsl";
	public static final String TRANSFORMATIONS_DDI2FODT_DDI2FODT_XSL = TRANSFORMATIONS_FOLDER + "/ddi2fodt/ddi2fodt.xsl";
	public static final String TRANSFORMATIONS_DDI2FO_DDI2FO_XSL = TRANSFORMATIONS_FOLDER + "/ddi2fo/ddi2fo.xsl";
	public static final String TRANSFORMATIONS_POGUES_XML2DDI_POGUES_XML2DDI_XSL = TRANSFORMATIONS_FOLDER + "/pogues-xml2ddi/pogues-xml2ddi.xsl";
	public static final String TRANSFORMATIONS_DDI2POGUES_XML_XSL = TRANSFORMATIONS_FOLDER + "/ddi2pogues-xml/ddi2pogues-xml.xsl";
	public static final String TRANSFORMATIONS_DDI2LUNATIC_XML_DDI2LUNATIC_XML_XSL = TRANSFORMATIONS_FOLDER + "/ddi2lunatic-xml/ddi2lunatic-xml.xsl";

	public static final String TRANSFORMATIONS_DDI2XFORMS_DRIVERS_FODS = TRANSFORMATIONS_FOLDER + "/ddi2xforms/drivers.fods";
	public static final String TRANSFORMATIONS_DDI2FODT_DRIVERS_FODS = TRANSFORMATIONS_FOLDER + "/ddi2fodt/drivers.fods";
	public static final String TRANSFORMATIONS_DDI2FO_DRIVERS_FODS = TRANSFORMATIONS_FOLDER + "/ddi2fo/drivers.fods";
	public static final String TRANSFORMATIONS_POGUES_XML2DDI_DRIVERS_FODS = TRANSFORMATIONS_FOLDER + "/pogues-xml2ddi/drivers.fods";
	public static final String TRANSFORMATIONS_DDI2LUNATIC_XML_DRIVERS_FODS = TRANSFORMATIONS_FOLDER + "/ddi2lunatic-xml/drivers.fods";

	public static final String TRANSFORMATIONS_DDI2XFORMS_FUNCTIONS_FODS = TRANSFORMATIONS_FOLDER	+ "/ddi2xforms/functions.fods";
	public static final String TRANSFORMATIONS_DDI2FODT_FUNCTIONS_FODS = TRANSFORMATIONS_FOLDER	+ "/ddi2fodt/functions.fods";
	public static final String TRANSFORMATIONS_DDI2FO_FUNCTIONS_FODS = TRANSFORMATIONS_FOLDER	+ "/ddi2fo/functions.fods";
	public static final String TRANSFORMATIONS_POGUES_XML2DDI_FUNCTIONS_FODS = TRANSFORMATIONS_FOLDER	+ "/pogues-xml2ddi/functions.fods";
	public static final String TRANSFORMATIONS_DDI2LUNATIC_XML_FUNCTIONS_FODS = TRANSFORMATIONS_FOLDER	+ "/ddi2lunatic-xml/functions.fods";

	public static final String TRANSFORMATIONS_DDI2XFORMS_FUNCTIONS_XSL = TRANSFORMATIONS_FOLDER + "/ddi2xforms/functions.xsl";
	public static final String TRANSFORMATIONS_DDI2FODT_FUNCTIONS_XSL = TRANSFORMATIONS_FOLDER + "/ddi2fodt/functions.xsl";
	public static final String TRANSFORMATIONS_DDI2FO_FUNCTIONS_XSL = TRANSFORMATIONS_FOLDER + "/ddi2fo/functions.xsl";
	public static final String TRANSFORMATIONS_POGUES_XML2DDI_FUNCTIONS_XSL = TRANSFORMATIONS_FOLDER + "/pogues-xml2ddi/functions.xsl";
	public static final String TRANSFORMATIONS_DDI2LUNATIC_XML_FUNCTIONS_XSL = TRANSFORMATIONS_FOLDER + "/ddi2lunatic-xml/functions.xsl";

	public static final String TRANSFORMATIONS_DDI2XFORMS_TREE_NAVIGATION_FODS = TRANSFORMATIONS_FOLDER + "/ddi2xforms/tree-navigation.fods";
	public static final String TRANSFORMATIONS_DDI2FODT_TREE_NAVIGATION_FODS = TRANSFORMATIONS_FOLDER + "/ddi2fodt/tree-navigation.fods";
	public static final String TRANSFORMATIONS_DDI2FO_TREE_NAVIGATION_FODS = TRANSFORMATIONS_FOLDER + "/ddi2fo/tree-navigation.fods";
	public static final String TRANSFORMATIONS_POGUES_XML2DDI_TREE_NAVIGATION_FODS = TRANSFORMATIONS_FOLDER + "/pogues-xml2ddi/tree-navigation.fods";
	public static final String TRANSFORMATIONS_DDI2LUNATIC_XML_TREE_NAVIGATION_FODS = TRANSFORMATIONS_FOLDER + "/ddi2lunatic-xml/tree-navigation.fods";
	public static final String TRANSFORMATIONS_DDI2XFORMS_TREE_NAVIGATION_XSL = TRANSFORMATIONS_FOLDER + "/ddi2xforms/tree-navigation.xsl";
	public static final String TRANSFORMATIONS_DDI2FODT_TREE_NAVIGATION_XSL = TRANSFORMATIONS_FOLDER + "/ddi2fodt/tree-navigation.xsl";
	public static final String TRANSFORMATIONS_DDI2FO_TREE_NAVIGATION_XSL = TRANSFORMATIONS_FOLDER + "/ddi2fo/tree-navigation.xsl";
	public static final String TRANSFORMATIONS_POGUES_XML2DDI_TREE_NAVIGATION_XSL = TRANSFORMATIONS_FOLDER + "/pogues-xml2ddi/tree-navigation.xsl";
	public static final String TRANSFORMATIONS_DDI2LUNATIC_XML_TREE_NAVIGATION_XSL = TRANSFORMATIONS_FOLDER + "/ddi2lunatic-xml/tree-navigation.xsl";

	public static final String TRANSFORMATIONS_DDI2XFORMS_DDI2XFORMS_FIXED_XSL = TRANSFORMATIONS_FOLDER + "/ddi2xforms/ddi2xforms-fixed.xsl";
	public static final String TRANSFORMATIONS_DDI2FODT_DDI2FODT_FIXED_XSL = TRANSFORMATIONS_FOLDER + "/ddi2fodt/ddi2fodt-fixed.xsl";
	public static final String TRANSFORMATIONS_DDI2FO_DDI2FO_FIXED_XSL = TRANSFORMATIONS_FOLDER + "/ddi2fo/ddi2fo-fixed.xsl";
	public static final String TRANSFORMATIONS_DDI2LUNATIC_XML_DDI2LUNATIC_XML_FIXED_XSL = TRANSFORMATIONS_FOLDER + "/ddi2lunatic-xml/ddi2lunatic-xml-fixed.xsl";
	public static final String TRANSFORMATIONS_POGUES_XML2DDI_POGUES_XML2DDI_FIXED_XSL = TRANSFORMATIONS_FOLDER + "/pogues-xml2ddi/pogues-xml2ddi-fixed.xsl";

	// ---------- 
	public static final String INPUTS_DDI_FUNCTIONS_FODS = INPUTS_FOLDER + "/ddi/functions.fods";
	public static final String INPUTS_DDI_FUNCTIONS_XSL = INPUTS_FOLDER + "/ddi/functions.xsl";
	public static final String INPUTS_DDI_TEMPLATES_FODS = INPUTS_FOLDER + "/ddi/templates.fods";
	public static final String INPUTS_DDI_TEMPLATES_XSL = INPUTS_FOLDER + "/ddi/templates.xsl";

	public static final String INPUTS_POGUES_XML_FUNCTIONS_FODS = INPUTS_FOLDER + "/pogues-xml/functions.fods";
	public static final String INPUTS_POGUES_XML_FUNCTIONS_XSL = INPUTS_FOLDER + "/pogues-xml/functions.xsl";
	public static final String INPUTS_POGUES_XML_TEMPLATES_FODS = INPUTS_FOLDER + "/pogues-xml/templates.fods";
	public static final String INPUTS_POGUES_XML_TEMPLATES_XSL = INPUTS_FOLDER + "/pogues-xml/templates.xsl";

	public static final String INPUTS_DDI_SOURCE_FIXED_XSL = INPUTS_FOLDER + "/ddi/source-fixed.xsl";
	public static final String INPUTS_POGUES_XML_SOURCE_FIXED_XSL = INPUTS_FOLDER + "/pogues-xml/source-fixed.xsl";
	public static final String FODS_2_XML_XSL = TRANSFORMATIONS_FOLDER + "/fods2xml.xsl";
	public static final String XML_2_XSL_XSL = TRANSFORMATIONS_FOLDER + "/xml2xsl.xsl";
	
	/********************* Merging paramters ******************/
	public static final String MERGE_PARAMETERS_XSL = UTIL_FOLDER_PATH + "/params/merge-parameters.xsl";
	
	

	/********************************************************/
	/********************* Post-processing ******************/
	/********************************************************/
	public static final String OUPUTS_FOLDER = "/xslt/outputs/fo";
	public static final String POST_PROCESSING_FOLDER_FO = "/xslt/post-processing/fo";
	public static final String POST_PROCESSING_FOLDER_LUNATIC_XML = "/xslt/post-processing/lunatic-xml";
	public static final String POST_PROCESSING_FOLDER_XFORMS = "/xslt/post-processing/xforms";
	public static final String TRANSFORMATIONS_CUSTOMIZATION_FO_4PDF =  OUPUTS_FOLDER + "/publipostage.xsl";

	/********************* PDF/FO - Post-processing ******************/
	public static final String TRANSFORMATIONS_CUSTOMIZATION_FO_4PDF_2 =  POST_PROCESSING_FOLDER_FO + "/mailing-vtl.xsl";
	public static final String TRANSFORMATIONS_SPECIF_TREATMENT_FO_4PDF =  POST_PROCESSING_FOLDER_FO +"/fo-specific-treatment.xsl";
	public static final String TRANSFORMATIONS_ACCOMPANYING_MAILS_FO_4PDF =  POST_PROCESSING_FOLDER_FO + "/accompanying-mails.xsl";
	public static final String TRANSFORMATIONS_COVER_PAGE_FO_4PDF =  POST_PROCESSING_FOLDER_FO + "/insert-cover-page.xsl";
	public static final String TRANSFORMATIONS_END_QUESTION_FO_4PDF =  POST_PROCESSING_FOLDER_FO + "/insert-end-questions.xsl";
	public static final String TRANSFORMATIONS_EDIT_STRUCTURE_PAGES_FO_4PDF =  POST_PROCESSING_FOLDER_FO + "/edit-structure-page.xsl";
	
	/********************* JS/XML-Lunatic - Post-processing ******************/
	public static final String TRANSFORMATIONS_SORT_COMPONENTS_LUNATIC_XML = POST_PROCESSING_FOLDER_LUNATIC_XML + "/sort-components.xsl";
	public static final String TRANSFORMATIONS_EXTERNALIZE_VARIABLES_AND_DEPENDENCIES_LUNATIC_XML = POST_PROCESSING_FOLDER_LUNATIC_XML + "/externalize-variables-and-dependencies.xsl";
	public static final String TRANSFORMATIONS_INSERT_GENERIC_QUESTIONS_LUNATIC_XML = POST_PROCESSING_FOLDER_LUNATIC_XML + "/insert-generic-questions.xsl";
	public static final String TRANSFORMATIONS_PAGINATION_LUNATIC_XML = POST_PROCESSING_FOLDER_LUNATIC_XML + "/pagination.xsl";
	
	/********************* FR/Xform Post-processing ******************/
	public static final String UTIL_XFORMS_BROWSING_XSL = POST_PROCESSING_FOLDER_XFORMS + "/browsing.xsl";
	public static final String UTIL_XFORMS_FIX_ADHERENCE_XSL = POST_PROCESSING_FOLDER_XFORMS + "/fix-adherence.xsl";
	public static final String UTIL_XFORMS_INSEE_PATTERN_XSL = POST_PROCESSING_FOLDER_XFORMS + "/insee-pattern.xsl";
	public static final String UTIL_XFORMS_IDENTIFICATION_XSL = POST_PROCESSING_FOLDER_XFORMS + "/identification.xsl";
	public static final String UTIL_XFORMS_INSERT_END_XSL = POST_PROCESSING_FOLDER_XFORMS + "/insert-end.xsl";
	public static final String UTIL_XFORMS_INSERT_GENERIC_QUESTIONS_XSL = POST_PROCESSING_FOLDER_XFORMS + "/insert-generic-questions.xsl";
	public static final String UTIL_XFORMS_INSERT_WELCOME_XSL = POST_PROCESSING_FOLDER_XFORMS + "/insert-welcome.xsl";
	public static final String UTIL_XFORMS_INSEE_MODEL_XSL = POST_PROCESSING_FOLDER_XFORMS + "/insee-model.xsl";
	public static final String UTIL_XFORMS_SPECIFIC_TREATMENT_XSL = POST_PROCESSING_FOLDER_XFORMS + "/xforms-specific-treatment.xsl";

	
	/********************* Temporary file system ******************/
	// ----- Folders
	public static final String TEMP_FOLDER_PATH = System.getProperty("java.io.tmpdir") + "/eno";

	public static final File TEMP_FOLDER = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH);

	public static final File TEMP_FILE_PARAMS(String file) {
		return getFileOrDirectoryFromPath(TEMP_FOLDER_PATH +"/"+file);
	}
	public static File SUB_TEMP_FOLDER_FILE (String survey){
		return getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/"+survey);
	}

	public static String sUB_TEMP_FOLDER (String survey){
		return TEMP_FOLDER_PATH + "/"+survey;
	}

	// ----- Files
	public static File tEMP_NULL_TMP (String sUB_TEMP_FOLDER){
		return getFileOrDirectoryFromPath(sUB_TEMP_FOLDER + "/null.tmp");
	}
	public static File tEMP_MAPPING_TMP (String sUB_TEMP_FOLDER){
		return getFileOrDirectoryFromPath(sUB_TEMP_FOLDER + "/mapping.xml");
	}
	public static final File TEMP_PREFORMATE_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/temp/preformate.tmp");
	public static final File TEMP_XML_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/temp/xml.tmp");
	public static final File TEMP_TEMP_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/temp/temp.tmp");
	public static final File TEMP_TEMP_BIS_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/temp/temp-bis.tmp");

	// Those files holds the XSL generated from FODS ; they will be then copied to resource directory when packaging to JAR
	public static final File TRANSFORMATIONS_DDI2XFORMS_DDI2XFORMS_XSL_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/ddi2xforms/ddi2xforms.xsl");
	public static final File TRANSFORMATIONS_DDI2FODT_DDI2FODT_XSL_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/ddi2fodt/ddi2fodt.xsl");
	public static final File TRANSFORMATIONS_DDI2FO_DDI2FO_XSL_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/ddi2fo/ddi2fo.xsl");
	public static final File TRANSFORMATIONS_POGUES_XML2DDI_POGUES_XML2DDI_XSL_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/pogues-xml2ddi/pogues-xml2ddi.xsl");
	public static final File TRANSFORMATIONS_DDI2LUNATIC_XML_DDI2LUNATIC_XML_XSL_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/ddi2lunatic-xml/ddi2lunatic-xml.xsl");
	public static final File TRANSFORMATIONS_DDI2XFORMS_DRIVERS_XSL_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/ddi2xforms/drivers.xsl");
	public static final File TRANSFORMATIONS_DDI2FODT_DRIVERS_XSL_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/ddi2fodt/drivers.xsl");
	public static final File TRANSFORMATIONS_DDI2FO_DRIVERS_XSL_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/ddi2fo/drivers.xsl");
	public static final File TRANSFORMATIONS_POGUES_XML2DDI_DRIVERS_XSL_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/pogues-xml2ddi/drivers.xsl");
	public static final File TRANSFORMATIONS_DDI2LUNATIC_XML_DRIVERS_XSL_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/ddi2lunatic-xml/drivers.xsl");
	public static final File TRANSFORMATIONS_DDI2XFORMS_FUNCTIONS_XSL_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/ddi2xforms/functions.xsl");
	public static final File TRANSFORMATIONS_DDI2FODT_FUNCTIONS_XSL_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/ddi2fodt/functions.xsl");
	public static final File TRANSFORMATIONS_DDI2FO_FUNCTIONS_XSL_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/ddi2fo/functions.xsl");
	public static final File TRANSFORMATIONS_POGUES_XML2DDI_FUNCTIONS_XSL_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/pogues-xml2ddi/functions.xsl");
	public static final File TRANSFORMATIONS_DDI2LUNATIC_XML_FUNCTIONS_XSL_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/ddi2lunatic-xml/functions.xsl");
	public static final File TRANSFORMATIONS_DDI2XFORMS_TREE_NAVIGATION_XSL_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/ddi2xforms/tree-navigation.xsl");
	public static final File TRANSFORMATIONS_DDI2FODT_TREE_NAVIGATION_XSL_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/ddi2fodt/tree-navigation.xsl");
	public static final File TRANSFORMATIONS_DDI2FO_TREE_NAVIGATION_XSL_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/ddi2fo/tree-navigation.xsl");
	public static final File TRANSFORMATIONS_POGUES_XML2DDI_TREE_NAVIGATION_XSL_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/pogues-xml2ddi/tree-navigation.xsl");
	public static final File TRANSFORMATIONS_DDI2LUNATIC_XML_TREE_NAVIGATION_XSL_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/ddi2lunatic-xml/tree-navigation.xsl");

	public static final File INPUTS_DDI_FUNCTIONS_XSL_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/ddi/functions.xsl");
	public static final File INPUTS_DDI_TEMPLATES_XSL_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/ddi/templates.xsl");
	public static final File INPUTS_DDI_SOURCE_XSL_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/ddi/source.xsl");

	public static final File INPUTS_POGUES_XML_FUNCTIONS_XSL_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/pogues-xml/functions.xsl");
	public static final File INPUTS_POGUES_XML_TEMPLATES_XSL_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/pogues-xml/templates.xsl");
	public static final File INPUTS_POGUES_XML_SOURCE_XSL_TMP = getFileOrDirectoryFromPath(TEMP_FOLDER_PATH + "/pogues-xml/source.xsl");

	// ---------- Utilies
	/** Generic file getter from classpath 
	 * @return the file or null when not found.
	 * */
	public static InputStream getInputStreamFromPath(String path) {
		logger.debug("Loading " + path);
		try {
			return Constants.class.getResourceAsStream(path);
		} catch (Exception e) {
			logger.error("Error when loading file");
			return null;
		}
	}


	/** Generic getter for files or directories */
	private static File getFileOrDirectoryFromPath(String path) {
		return Paths.get(path).toFile();
	}

	@SuppressWarnings("finally")
	public static File getFileFromUrl(URL url) {
		File file = null;
		try {
			file = new File(url.toURI());
		} catch (URISyntaxException e) {
			file = new File(url.getPath());
		} finally {
			return file;
		}
	}
	
	/********************************************************/
	/*********************** Temp foder  ********************/
	/********************************************************/
	public static String tEMP_XFORMS_FOLDER (String sUB_TEMP_FOLDER){
		return sUB_TEMP_FOLDER + "/xforms";
	}
	public static String tEMP_ODT_FOLDER(String sUB_TEMP_FOLDER){
		return sUB_TEMP_FOLDER + "/fodt";
	}
	public static String tEMP_JS_FOLDER(String sUB_TEMP_FOLDER){
		return sUB_TEMP_FOLDER+ "/lunatic-xml";
	}
	public static String tEMP_PDF_FOLDER(String sUB_TEMP_FOLDER){
		return sUB_TEMP_FOLDER+ "/fo";
	}
	public static String tEMP_DDI_FOLDER(String sUB_TEMP_FOLDER){
		return sUB_TEMP_FOLDER + "/ddi";
	}
	public static String tEMP_POGUES_XML_FOLDER(String sUB_TEMP_FOLDER){
		return sUB_TEMP_FOLDER + "/pogues-xml";
	}
	public static final String BASIC_FORM_TMP_FILENAME = "basic-form.xml";
	
	
	
	
	/********************************************************/
	/********************* File Extension *******************/
	/************** (used during post-processing) ***********/
	
	public static final String BASE_NAME_FORM_FILE = "/form";

	/************ DDI and pogues-xml extension ***************/
	public static final String CLEANED_EXTENSION = "-cleaned.tmp";
	public static final String MD_EXTENSION = "-md.tmp";
	public static final String MD2_EXTENSION = "-md2.tmp";
	public static final String FINAL_EXTENSION = "-final.tmp";
	public static final String TEMP_EXTENSION = "-temp.xml";
	public static final String FINAL_DDI_EXTENSION = "-final.xml";
	public static final String DDI32_DDI33_EXTENSION = "-ddi33.xml";
	public static final String MULTIMODAL_EXTENSION = "-modal.tmp";

	/********************* pdf/fo extension *******************/
	public static final String ACCOMPANYING_MAILS_FO_EXTENSION = "-accompanying-mails.fo";
	public static final String COVER_PAGE_FO_EXTENSION = "-cover-page.fo";
	public static final String EDIT_STRUCTURE_FO_EXTENSION = "-edit-structure.fo";
	public static final String END_QUESTION_FO_EXTENSION = "-end-question.fo";
	public static final String SPECIFIC_TREAT_PDF_EXTENSION = "-specific-form.fo";
	public static final String TABLE_COL_SIZE_PDF_EXTENSION = "-temp.fo";
	public static final String FINAL_PDF_EXTENSION = "-final-out.fo";
	public static final String MAILING_FO_EXTENSION = "-mailing-vtl.fo";

	/****************** js/xml-lunatic extension **************/
	public static final String SORT_COMPONENTS_LUNATIC_XML_EXTENSION = "-sorted.xml";
	public static final String INSERT_GENERIC_QUESTIONS_LUNATIC_XML_EXTENSION = "-insert-questions.xml";
	public static final String EXTERNALIZE_VARIABLES_LUNATIC_XML_EXTENSION = "-ext-variables.xml";
	public static final String VTL_PARSER_LUNATIC_XML_EXTENSION = "-vtl-parsed.xml";
	public static final String SPECIFIC_TREAT_LUNATIC_XML_EXTENSION = "-specific-form.xml";
	public static final String PAGINATION_LUNATIC_XML_EXTENSION = "-sorted.xml";
	public static final String FINAL_LUNATIC_XML_EXTENSION = "-lunatic.xml";

	/******************** fr/xform extension ******************/
	public static final String BROWSING_XFORMS_EXTENSION = "-browsing.xhtml";
	public static final String INSEE_PATTERN_XFORMS_EXTENSION = "-insee-pattern.xhtml";
	public static final String FIX_ADHERENCE_XFORMS_EXTENSION = "-fix-adherence.xhtml";
	public static final String IDENTIFICATION_XFORMS_EXTENSION = "-identification.xhtml";
	public static final String INSERT_END_XFORMS_EXTENSION = "-insert-end.xhtml";
	public static final String INSERT_WELCOME_XFORMS_EXTENSION = "-insert-welcome.xhtml";
	public static final String INSERT_GENERIC_QUESTIONS_XFORMS_EXTENSION = "-insert-questions.xhtml";
	public static final String INSEE_MODEL_XFORMS_EXTENSION = "-insee-model.xhtml";
	public static final String SPECIFIC_TREATMENT_XFORMS_EXTENSION = "-specific-treatment.xhtml";
}
src/main/java/fr/insee/eno/params/ValorizatorParameters.java
public interface ValorizatorParameters {

	/**
	 * 
	 * @param enoParameters
	 * @return ByteArrayOutputStream which represents xml parameter file
	 * @throws Exception
	 */
	ByteArrayOutputStream mergeParameters(ENOParameters enoParameters) throws Exception;
	
	/**
	 * 
	 * @param enoParameters java object
	 * @return ENOParameters object which is the result of the merging of default ENOParameters object and the param
	 * @throws Exception
	 */
	ENOParameters mergeEnoParameters(ENOParameters enoParameters) throws Exception;

	/**
	 * 
	 * @param inputStream which represents xml parameter file
	 * @return ENOParameters object which represents xml file according to xsd schema
	 * @throws Exception
	 */
	ENOParameters getParameters(InputStream inputStream) throws Exception;

	/**
	 * 
	 * @param enoParameters xml file
	 * @return File (xml) which is the result of the merging of default xml parameter file and the param
	 * @throws Exception
	 */
	File mergeParameters(File enoParameters) throws Exception;
	
}
src/main/java/fr/insee/eno/params/validation/ValidatorImpl.java
public class ValidatorImpl implements Validator {

	private static final Logger LOGGER = LoggerFactory.getLogger(ValidatorImpl.class);
	
	public static final PostProcessing[] POST_PROCESSINGS_FULL = PostProcessing.class.getEnumConstants();
	public static final PreProcessing[] PRE_PROCESSINGS_FULL = PreProcessing.class.getEnumConstants();
	
	@Override
	public ValidationMessage validate(ENOParameters parametersType) {
		Pipeline pipeline = parametersType.getPipeline();
		ValidationMessage validationIn2Out = validateIn2Out(pipeline.getInFormat(), pipeline.getOutFormat());
		ValidationMessage validationPreProcessings = validatePreProcessings(pipeline);
		ValidationMessage validationPostProcessings = validatePostProcessings(pipeline);
		ValidationMessage validationMode = validateMode(pipeline.getOutFormat(), parametersType.getMode());
		
		boolean isValid = validationIn2Out.isValid()
				&& validationPreProcessings.isValid()
				&& validationPostProcessings.isValid()
				&& validationMode.isValid();
		String message = validationIn2Out.getMessage() +", "+
				validationPreProcessings.getMessage() +", "+
				validationMode.getMessage() +", "+
				validationPostProcessings.getMessage();

		return new ValidationMessage(message,isValid);
	}

	@Override
	public ValidationMessage validateIn2Out(InFormat inFormat, OutFormat outFormat) {
		boolean isValid = inFormat!=null && outFormat!=null;
		String message = "";
		if(isValid) {
			switch (inFormat) {
			case DDI:
				isValid = true;
				break;
			case POGUES_XML:
				isValid = outFormat.equals(OutFormat.DDI);
				break;
			case XFORMS:
				isValid = outFormat.equals(OutFormat.XFORMS);
				break;
			default:
				isValid=false;
				break;
			}
			message += isValid ? "" : "The combination (in:'"+inFormat.value()+"'/out:'"+ outFormat.value() +"')"+" is not valid"; 
		}
		else {
			message = "One of In/Out format doesn't exist in Eno. ";
		}

		message += isValid ? "The combination In/Out format is valid" : "";
		LOGGER.info(message);
		return new ValidationMessage(message, isValid);
	}

	@Override
	public ValidationMessage validatePreProcessings(Pipeline pipeline) {
		boolean isValid=true;
		String message="";
		InFormat inFormat = pipeline.getInFormat();
		boolean preProcessingNeeded = pipeline.getPostProcessing().contains(PostProcessing.XFORMS_INSEE_MODEL);	
		List<PreProcessing> preProcessings = pipeline.getPreProcessing();
		List<PreProcessing> preProcessingsCopy = new ArrayList<>(preProcessings);

		if(inFormat!=null) {
			if(isValid) {
				Collections.sort(preProcessingsCopy);
				List<PreProcessing> preProcessingInFormat = Arrays.asList(Arrays.stream(PRE_PROCESSINGS_FULL).filter(p->p.value().contains(inFormat.value()+"-")).toArray(PreProcessing[]::new));
				
				boolean order = preProcessingsCopy.equals(preProcessings);
				boolean consistency = preProcessingInFormat.containsAll(preProcessingsCopy);
				boolean mapping = preProcessingNeeded ? preProcessings.contains(PreProcessing.DDI_MAPPING) || inFormat.equals(InFormat.XFORMS):true;
				
				isValid = order && consistency && mapping;
				
				message += order ? "" : "PreProcessings are not in the right order. The right order should be : "+preProcessingsCopy;
				message += consistency ? "" : "PreProcessings are not valid according to the InFormat ('"+inFormat.value()+"') ";
				message += mapping ? "" : "The PostProcessing '"+PostProcessing.XFORMS_INSEE_MODEL.value()+"', need the PreProcessing '"+PreProcessing.DDI_MAPPING.value()+"' ";
								
			}
			else {
				message+="One of PreProcessings doesn't exist in Eno.";
			}
		}
		else {
			isValid = false;
			message+="The inFormat doesn't exist in Eno, validator can't check PreProcessings.";
		}
		message += isValid ? "PreProcessing are valid" : "";
		LOGGER.info(message);
		return new ValidationMessage(message, isValid);
	}

	@Override
	public ValidationMessage validatePostProcessings(Pipeline pipeline) {
		boolean isValid = true;
		String message="";
		OutFormat outFormat = pipeline.getOutFormat();	
		List<PostProcessing> postProcessings = pipeline.getPostProcessing();
		List<PostProcessing> postProcessingsCopy = new ArrayList<>(postProcessings);
		
		if(outFormat!=null) {
			if(isValid) {
				
				Collections.sort(postProcessingsCopy);			
				List<PostProcessing> postProcessingOutFormat = Arrays.asList(Arrays.stream(POST_PROCESSINGS_FULL).filter(p->p.value().contains(outFormat.value()+"-")).toArray(PostProcessing[]::new));
				
				boolean order = postProcessingsCopy.equals(postProcessings);
				boolean consistency = postProcessingOutFormat.containsAll(postProcessingsCopy);
				
				isValid = order && consistency;
				
				message += order ? "" : "PostProcessings are not in the right order. The order should be : "+postProcessingsCopy;
				message += consistency ? "" : "PostProcessings are not valid according to the OutFormat ('"+outFormat.value()+"') ";
			}
			else {
				message+="One of PostProcessings doesn't exist in Eno.";
			}
		}
		else {
			isValid = false;
			message+="The outFormat doesn't exist in Eno, validator can't check PostProcessings.";
		}

		message += isValid ? "PostProcessing are valid" : "";
		LOGGER.info(message);
		return new ValidationMessage(message, isValid);
	}
	
	
	@Override
	public ValidationMessage validateMode(OutFormat outFormat, Mode mode) {
		boolean isValid = mode==null && outFormat !=OutFormat.LUNATIC_XML;
		String message = "";
		if(mode!=null) {
			switch (outFormat) {
			case DDI:
				isValid = mode.equals(Mode.ALL);
				break;
			case FODT:
				isValid = mode.equals(Mode.ALL);
				break;
			case FO:
				isValid = mode.equals(Mode.PAPI);
				break;
			case XFORMS:
				isValid = mode.equals(Mode.CAWI);
				break;
			case LUNATIC_XML:
				isValid = mode.equals(Mode.CAPI_CATI)
				||mode.equals(Mode.CAWI)
				||mode.equals(Mode.PROCESS);
				break;
			default:
				isValid=false;
				break;
			}
			message += isValid ? "" : "The combination (out:'"+outFormat.value()+"'/mode:'"+ mode.value() +"')"+" format is not valid"; 

		}
		else {
			message = "The mode is null (error if output = Lunatic). ";
		}

		message += isValid ? "The combination (out:'"+outFormat.value()+"'/mode:'"+ (mode!=null? mode.value() : "null") +"')"+" format is valid":"";
		LOGGER.info(message);
		return new ValidationMessage(message, isValid);
	}
}
src/main/java/fr/insee/eno/params/validation/SchemaValidatorImpl.java
public class SchemaValidatorImpl implements SchemaValidator {
	
	
	private static final Logger LOGGER = LoggerFactory.getLogger(SchemaValidatorImpl.class);
	
	private Schema schema;
	private Validator validator;
	
	public SchemaValidatorImpl() {
		SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
		try {
			schema = sf.newSchema(Constants.ENO_PARAMETERS_XSD);
		} catch (SAXException e) {
			e.printStackTrace();
		}
		validator = schema.newValidator();
		
	}
		
	@Override
	public ValidationMessage validate(InputStream paramsIS)  {
		LOGGER.info("Validation of parameters file...");
		boolean valid=false;
		String message="";
		try {
			validateIS(paramsIS);
			valid=true;
		} catch (Exception e) {
			e.printStackTrace();
			message = e.getMessage();
			LOGGER.error(message);
		}
		finally {
			LOGGER.info("Validation :"+valid);
		}
		message = valid ? "Parameters respect schema." : message;
		return new ValidationMessage(message, valid);
	}

	public void validateIS(InputStream paramsIS) throws Exception {
		validator.reset();
		Source source = new StreamSource(paramsIS);
		source = toDOMSource(source);
		validator.validate(source);
	}

	public DOMSource toDOMSource(Source source) throws Exception {
		if (source instanceof DOMSource) {
			return (DOMSource) source;
		}
		Transformer trans = TransformerFactory.newInstance().newTransformer();
		DOMResult result = new DOMResult();
		trans.transform(source, result);
		return new DOMSource(result.getNode());
	}

}
src/main/java/fr/insee/eno/params/validation/Validator.java
public interface Validator {
	
	/**
	 * It validates all ENOParameters and it is based on the following function
	 * @param parametersType
	 * @return a ValidationMessage with a message and the boolean if it is valid.
	 */
	ValidationMessage validate(ENOParameters parametersType);

	/**
	 * It validates the combination of InFormat/OutFormat.
	 * @param inFormat
	 * @param outFormat
	 * @return a ValidationMessage with a message and the boolean if it is valid.
	 */
	ValidationMessage validateIn2Out(InFormat inFormat, OutFormat outFormat);
	
	/**
	 * It validates PreProcessing according to the pipeline.
	 * @param pipeline
	 * @return a ValidationMessage with a message and the boolean if it is valid.
	 */
	ValidationMessage validatePreProcessings(Pipeline pipeline);

	/**
	 * It validates PostProcessing according to the pipeline.
	 * @param pipeline
	 * @return a ValidationMessage with a message and the boolean if it is valid.
	 */
	ValidationMessage validatePostProcessings(Pipeline pipeline);

	ValidationMessage validateMode(OutFormat outFormat, Mode mode);

	

}


Question: package fr.insee.eno.service;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.InputStream;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.insee.eno.Constants;
import fr.insee.eno.exception.EnoParametersException;
import fr.insee.eno.parameters.ENOParameters;
import fr.insee.eno.parameters.Pipeline;
import fr.insee.eno.params.ValorizatorParameters;
import fr.insee.eno.params.ValorizatorParametersImpl;
import fr.insee.eno.params.pipeline.PipeLineGeneratorImpl;
import fr.insee.eno.params.pipeline.PipelineGenerator;
import fr.insee.eno.params.validation.SchemaValidator;
import fr.insee.eno.params.validation.SchemaValidatorImpl;
import fr.insee.eno.params.validation.ValidationMessage;
import fr.insee.eno.params.validation.Validator;
import fr.insee.eno.params.validation.ValidatorImpl;
import fr.insee.eno.utils.FolderCleaner;




/**
 * Orchestrates the whole parameterized generation process.
 */
public class ParameterizedGenerationService {	

	private static final Logger LOGGER = LoggerFactory.getLogger(ParameterizedGenerationService.class);

	private PipelineGenerator pipelineGenerator;
	
	private ValorizatorParameters valorizatorParameters;
	
Answer: 	private Validator validator;