<commit_before>package com.excilys.ebi.gatling.core.provider.capture

import com.ximpleware.CustomVTDGen
import com.ximpleware.VTDNav
import com.ximpleware.AutoPilot

class XPathCaptureProvider(xmlContent: Array[Byte]) extends AbstractCaptureProvider {

  val vtdEngine = new CustomVTDGen
  vtdEngine.setDoc(xmlContent)
  vtdEngine.parse(false)

  var vn = vtdEngine.getNav()
  var ap = new AutoPilot(vn)

  def capture(expression: Any): Option[String] = {
    logger.debug("[XPathCaptureProvider] Capturing with expression : {}", expression)
    ap.selectXPath(expression.toString)
    val value = Some(ap.evalXPathToString)
    logger.debug("XPATH CAPTURE: {}", value)
    value
  }

}<commit_msg>Fixes a Bug<commit_after>package com.excilys.ebi.gatling.core.provider.capture

import com.ximpleware.CustomVTDGen
import com.ximpleware.VTDNav
import com.ximpleware.AutoPilot
import org.apache.commons.lang3.StringUtils

class XPathCaptureProvider(xmlContent: Array[Byte]) extends AbstractCaptureProvider {

  val vtdEngine = new CustomVTDGen
  vtdEngine.setDoc(xmlContent)
  vtdEngine.parse(false)

  var vn = vtdEngine.getNav()
  var ap = new AutoPilot(vn)

  def capture(expression: Any): Option[String] = {
    logger.debug("[XPathCaptureProvider] Capturing with expression : {}", expression)
    ap.selectXPath(expression.toString)
    val result = ap.evalXPathToString
    val value = if (result.equals(StringUtils.EMPTY))
      None
    else
      Some(ap.evalXPathToString)
    logger.debug("XPATH CAPTURE: {}", value)
    value
  }
}
{'fraction_non_alphanumeric': 0.10253082414016872, 'fraction_numerical': 0.0006489292667099286, 'mean_word_length': 4.775280898876405, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '2021398', 'n_tokens_mistral': 510, 'n_tokens_neox': 501, 'n_words': 97}