<commit_before>package de.adito.propertly.core.common.serialization.xml;

import de.adito.propertly.core.common.serialization.ISerializationProvider;
import de.adito.propertly.core.common.serialization.converter.ConverterRegistry;
import de.adito.propertly.core.spi.IPropertyPitProvider;
import org.w3c.dom.*;

import javax.annotation.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.StringWriter;
import java.lang.annotation.Annotation;
import java.util.List;

/**
 * @author j.boesl, 28.02.15
 */
public class XMLSerializationProvider implements ISerializationProvider<Document, Element>
{

  private final ConverterRegistry converterRegistry;


  public XMLSerializationProvider()
  {
    converterRegistry = new ConverterRegistry();
  }

  public static String toString(Element pElement) throws TransformerException
  {
    return toString(pElement.getOwnerDocument());
  }

  public static String toString(Document pDocument) throws TransformerException
  {
    Transformer transformer = TransformerFactory.newInstance().newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
    StreamResult result = new StreamResult(new StringWriter());
    DOMSource source = new DOMSource(pDocument);<commit_msg>ConverterRegistry for XMLSerializationProvider can be provided.<commit_after>package de.adito.propertly.core.common.serialization.xml;

import de.adito.propertly.core.common.serialization.ISerializationProvider;
import de.adito.propertly.core.common.serialization.converter.ConverterRegistry;
import de.adito.propertly.core.spi.IPropertyPitProvider;
import org.w3c.dom.*;

import javax.annotation.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.StringWriter;
import java.lang.annotation.Annotation;
import java.util.List;

/**
 * @author j.boesl, 28.02.15
 */
public class XMLSerializationProvider implements ISerializationProvider<Document, Element>
{

  private final ConverterRegistry converterRegistry;


  public XMLSerializationProvider()
  {
    this(new ConverterRegistry());
  }

  public XMLSerializationProvider(ConverterRegistry pConverterRegistry)
  {
    converterRegistry = pConverterRegistry;
  }

  public static String toString(Element pElement) throws TransformerException
  {
    return toString(pElement.getOwnerDocument());
  }

  public static String toString(Document pDocument) throws TransformerException
  {
    Transformer transformer = TransformerFactory.newInstance().newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
    StreamResult result = new StreamResult(new StringWriter());
    DOMSource source = new DOMSource(pDocument);
{'fraction_non_alphanumeric': 0.10254713860403572, 'fraction_numerical': 0.005292755540853457, 'mean_word_length': 5.780269058295964, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, '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': '3115968', 'n_tokens_mistral': 857, 'n_tokens_neox': 839, 'n_words': 160}