<commit_before>// The ratago command-line utility runs an input file through an XSLT stylesheet.
package main

import (
	"flag"
	"fmt"
	"github.com/jbowtie/ratago/xslt"
	"github.com/moovweb/gokogiri/xml"
	"io/ioutil"
	"os"
)

func xmlReadFile(filename string) (doc *xml.XmlDocument, err error) {
	data, err := ioutil.ReadFile(filename)
	if err != nil {
		return
	}
	doc, err = xml.Parse(data, xml.DefaultEncodingBytes, nil, xml.StrictParseOption, xml.DefaultEncodingBytes)
	return
}

func usage() {
	fmt.Fprintf(os.Stderr, "Usage: %s [options] STYLESHEET INPUT\n", os.Args[0])
	flag.PrintDefaults()
}

var indent = flag.Bool("indent", false, "Attempt to indent any XML output")

func main() {
	flag.Usage = usage
	flag.Parse()
	if flag.NArg() < 2 {
		usage()
		return
	}
	//set some prefs based on flags
	xslfile := flag.Arg(0)
	inxml := flag.Arg(1)

	style, err := xmlReadFile(xslfile)
	if err != nil {
		fmt.Println(err)
		return
	}

	doc, err := xmlReadFile(inxml)
	if err != nil {
		fmt.Println(err)
		return
	}
<commit_msg>Use the xml.ReadFile function to parse the input and stylesheet files<commit_after>// The ratago command-line utility runs an input file through an XSLT stylesheet.
package main

import (
	"flag"
	"fmt"
	"github.com/jbowtie/ratago/xslt"
	"github.com/moovweb/gokogiri/xml"
	"os"
)

func usage() {
	fmt.Fprintf(os.Stderr, "Usage: %s [options] STYLESHEET INPUT\n", os.Args[0])
	flag.PrintDefaults()
}

var indent = flag.Bool("indent", false, "Attempt to indent any XML output")

func main() {
	flag.Usage = usage
	flag.Parse()
	if flag.NArg() < 2 {
		usage()
		return
	}
	//set some prefs based on flags
	xslfile := flag.Arg(0)
	inxml := flag.Arg(1)

	style, err := xml.ReadFile(xslfile, xml.StrictParseOption)
	if err != nil {
		fmt.Println(err)
		return
	}

	doc, err := xml.ReadFile(inxml, xml.StrictParseOption)
	if err != nil {
		fmt.Println(err)
		return
	}

{'fraction_non_alphanumeric': 0.14028586553732134, 'fraction_numerical': 0.004235044997353097, 'mean_word_length': 3.8711340206185567, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 19}, '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': '5947274', 'n_tokens_mistral': 763, 'n_tokens_neox': 731, 'n_words': 189}