<commit_before>package org.quattor.pan.utils;

import static org.quattor.pan.utils.MessageUtils.MSG_MISSING_SAX_TRANSFORMER;
import static org.quattor.pan.utils.MessageUtils.MSG_UNEXPECTED_EXCEPTION_WHILE_WRITING_OUTPUT;

import java.util.Properties;

import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.sax.TransformerHandler;

import org.quattor.pan.exceptions.CompilerError;

public class XmlUtils {

	private XmlUtils() {

	}

	public static TransformerHandler getSaxTransformerHandler() {

		try {

			// Generate the transformer factory. Need to guarantee that we get a
			// SAXTransformerFactory.
			TransformerFactory factory = TransformerFactory.newInstance();
			if (!factory.getFeature(SAXTransformerFactory.FEATURE)) {
				throw CompilerError.create(MSG_MISSING_SAX_TRANSFORMER);
			}

			// Can safely cast the factory to a SAX-specific one. Get the
			// handler to feed with SAX events.<commit_msg>fix indentation for annotation files (possibly also for xml output files)<commit_after>package org.quattor.pan.utils;

import static org.quattor.pan.utils.MessageUtils.MSG_MISSING_SAX_TRANSFORMER;
import static org.quattor.pan.utils.MessageUtils.MSG_UNEXPECTED_EXCEPTION_WHILE_WRITING_OUTPUT;

import java.util.Properties;

import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.sax.SAXTransformerFactory;
import javax.xml.transform.sax.TransformerHandler;

import org.quattor.pan.exceptions.CompilerError;

public class XmlUtils {

	private XmlUtils() {

	}

	public static TransformerHandler getSaxTransformerHandler() {

		try {

			// Generate the transformer factory. Need to guarantee that we get a
			// SAXTransformerFactory.
			TransformerFactory factory = TransformerFactory.newInstance();
			if (!factory.getFeature(SAXTransformerFactory.FEATURE)) {
				throw CompilerError.create(MSG_MISSING_SAX_TRANSFORMER);
			}
			factory.setAttribute("indent-number", new Integer(4));

			// Can safely cast the factory to a SAX-specific one. Get the
			// handler to feed with SAX events.
{'fraction_non_alphanumeric': 0.08319327731092437, 'fraction_numerical': 0.0004201680672268908, 'mean_word_length': 5.349333333333333, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 13}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3738702', 'n_tokens_mistral': 758, 'n_tokens_neox': 701, 'n_words': 152}