<commit_before>/***********************************************************************
 **                                                                   **
 **               This code belongs to the KETTLE project.            **
 **                                                                   **
 ** Kettle, from version 2.2 on, is released into the public domain   **
 ** under the Lesser GNU Public License (LGPL).                       **
 **                                                                   **
 ** For more details, please read the document LICENSE.txt, included  **
 ** in this project                                                   **
 **                                                                   **
 ** http://www.kettle.be                                              **
 ** <EMAIL>                                                    **
 **                                                                   **
 **********************************************************************/

 

package be.ibridge.kettle.core;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Date;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;

import be.ibridge.kettle.core.exception.KettleXMLException;
import be.ibridge.kettle.core.value.Value;

/**
 * This class contains a number of (static final) methods to facilitate 
 * the retreival of information from XML Node(s).
 * @author Matt
 * @since 04-04-2003
 *
 */
public class XMLHandler
{
	/**
	 * The header string to specify encoding in UTF-8 for XML files
	 * 
	 * @return The XML header.
	 */
	public static final String getXMLHeader()
	{
		return getXMLHeader(Const.XML_ENCODING);
	}

    /**
     * The header string to specify encoding in an XML file
     * @param encoding The desired encoding to use in the XML file
     * @return The XML header.
     */
    public static final String getXMLHeader(String encoding)
    {
    	//Tom modified this for performance
//        return "<?xml version=\"1.0\" encoding=\""+encoding+"\"?>"+Const.CR; // "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"+Const.CR;
        return (new StringBuffer(50).append("<?xml version=\"1.0\" encoding=\"").append(encoding).append("\"?>").append(Const.CR)).toString(); // "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"+Const.CR;
    }

	/**
	 * Get the value of a tag in a node
	 * @param n The node to look in
	 * @param tag The tag to look for
	 * @return The value of the tag or null if nothing was found.
	 */<commit_msg>Changed back to a READABLE format.<commit_after>/***********************************************************************
 **                                                                   **
 **               This code belongs to the KETTLE project.            **
 **                                                                   **
 ** Kettle, from version 2.2 on, is released into the public domain   **
 ** under the Lesser GNU Public License (LGPL).                       **
 **                                                                   **
 ** For more details, please read the document LICENSE.txt, included  **
 ** in this project                                                   **
 **                                                                   **
 ** http://www.kettle.be                                              **
 ** <EMAIL>                                                    **
 **                                                                   **
 **********************************************************************/

 

package be.ibridge.kettle.core;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Date;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;

import be.ibridge.kettle.core.exception.KettleXMLException;
import be.ibridge.kettle.core.value.Value;

/**
 * This class contains a number of (static final) methods to facilitate 
 * the retreival of information from XML Node(s).
 * @author Matt
 * @since 04-04-2003
 *
 */
public class XMLHandler
{
	/**
	 * The header string to specify encoding in UTF-8 for XML files
	 * 
	 * @return The XML header.
	 */
	public static final String getXMLHeader()
	{
		return getXMLHeader(Const.XML_ENCODING);
	}

    /**
     * The header string to specify encoding in an XML file
     * @param encoding The desired encoding to use in the XML file
     * @return The XML header.
     */
    public static final String getXMLHeader(String encoding)
    {
        return "<?xml version=\"1.0\" encoding=\""+encoding+"\"?>"+Const.CR;
    }

	/**
	 * Get the value of a tag in a node
	 * @param n The node to look in
	 * @param tag The tag to look for
	 * @return The value of the tag or null if nothing was found.
	 */
{'fraction_non_alphanumeric': 0.155547010190348, 'fraction_numerical': 0.009998077292828303, 'mean_word_length': 1.6718027734976888, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 5, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 11}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 42, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4031119', 'n_tokens_mistral': 1297, 'n_tokens_neox': 1210, 'n_words': 391}