<commit_before>package org.basex.query.func.fn;

import static org.basex.query.QueryError.*;

import org.basex.build.json.*;
import org.basex.build.json.JsonOptions.*;
import org.basex.query.*;
import org.basex.query.func.json.*;
import org.basex.query.value.item.*;
import org.basex.query.value.node.*;
import org.basex.util.*;

/**
 * Function implementation.
 *
 * @author BaseX Team 2005-17, BSD License
 * @author <NAME>
 */
public class FnXmlToJson extends FnParseJson {
  @Override
  public Item item(final QueryContext qc, final InputInfo ii) throws QueryException {
    final ANode node = toEmptyNode(exprs[0], qc);
    final JsonSerialOptions jopts = toOptions(1, new JsonSerialOptions(), qc);
    jopts.set(JsonOptions.FORMAT, JsonFormat.BASIC);
    return node == null ? null :
      Str.get(serialize(node.iter(), JsonSerialize.options(jopts), INVALIDOPT_X));
  }
}<commit_msg>[MOD] XQuery, xml-to-json: Adopt indentation from module<commit_after>package org.basex.query.func.fn;

import static org.basex.query.QueryError.*;

import org.basex.build.json.*;
import org.basex.build.json.JsonOptions.*;
import org.basex.io.serial.*;
import org.basex.query.*;
import org.basex.query.func.json.*;
import org.basex.query.value.item.*;
import org.basex.query.value.node.*;
import org.basex.util.*;
import org.basex.util.options.Options.*;

/**
 * Function implementation.
 *
 * @author BaseX Team 2005-17, BSD License
 * @author <NAME>
 */
public class FnXmlToJson extends FnParseJson {
  @Override
  public Item item(final QueryContext qc, final InputInfo ii) throws QueryException {
    final ANode node = toEmptyNode(exprs[0], qc);
    final JsonSerialOptions jopts = toOptions(1, new JsonSerialOptions(), qc);
    jopts.set(JsonOptions.FORMAT, JsonFormat.BASIC);

    // no indentation specified: adopt module indentation
    final Boolean indent = jopts.get(JsonSerialOptions.INDENT);
    if(indent == null) jopts.set(JsonSerialOptions.INDENT,
        qc.serParams().get(SerializerOptions.INDENT) == YesNo.YES);

    return node == null ? null :
      Str.get(serialize(node.iter(), JsonSerialize.options(jopts), INVALIDOPT_X));
  }
}
{'fraction_non_alphanumeric': 0.13613053613053613, 'fraction_numerical': 0.007459207459207459, 'mean_word_length': 4.351620947630923, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, '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': '532357', 'n_tokens_mistral': 703, 'n_tokens_neox': 686, 'n_words': 157}