<commit_before>/*jshint laxbreak:true*/
/*global window, require, console*/

var transform = (typeof exports === 'object') ? require('../lib/xpath-object-transform') : window.jsonpathObjectTransform;

var template = {
    seekObject: {
        seekSingle: 'object/single',
        seekArray: [
            'object/array/item', {
                key: 'item/key',
                seekGoingUp: '^^/goingUp/@attr',
                seekGoingUpArray: ['^^/goingUp/age', {
                    age: '.'
                }]
            }
        ]
    }
    ,sum: 'sum(/root/object/goingUp/age)'
}

var xml = require('fs').readFileSync('./example.xml', 'utf8')

var result = transform(xml, template);

console.log(JSON.stringify(result, null, 2));
<commit_msg>return empty array if seekArray fail or empty<commit_after>/*jshint laxbreak:true*/
/*global window, require, console*/

var transform = (typeof exports === 'object') ? require('../lib/xpath-object-transform') : window.jsonpathObjectTransform;

var template = {
    seekObject: {
        seekSingle: 'object/single',
        seekArray: [
            'object/array/item', {
                key: 'item/key',
                seekGoingUp: '^^/goingUp/@attr',
                seekGoingUpArray: ['^^/goingUp/age', {
                    age: '.'
                }]
            }
        ]
    },
    sum: 'sum(/root/object/goingUp/age)'
}

var xml = require('fs').readFileSync('./example.xml', 'utf8')

var result = transform(xml, template);

console.log(JSON.stringify(result, null, 2));

{'fraction_non_alphanumeric': 0.16579634464751958, 'fraction_numerical': 0.0026109660574412533, 'mean_word_length': 2.180497925311203, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '3666470', 'n_tokens_mistral': 474, 'n_tokens_neox': 451, 'n_words': 87}