<commit_before>module Setup
  class XsltValidator < CustomValidator
    include CenitScoped
    include CustomTitle

    BuildInDataType.regist(self).with(:namespace).referenced_by(:namespace)

    field :xslt, type: String

    field :schema_type, type: Symbol

    def before_save
      errors.blank?
    end

    def validate_data(data)
      xslt = Nokogiri::XSLT(self.xslt)
      begin
        xslt.transform(Nokogiri::XML(data.to_xml()))
        validate = true
      rescue  Exception => ex
        ex.message<commit_msg>Customising data type for XSLT validators<commit_after>module Setup
  class XsltValidator < CustomValidator
    include CenitScoped
    include CustomTitle

    BuildInDataType.regist(self).referenced_by(:namespace, :name)

    field :xslt, type: String

    field :schema_type, type: Symbol

    def before_save
      errors.blank?
    end

    def validate_data(data)
      xslt = Nokogiri::XSLT(self.xslt)
      begin
        xslt.transform(Nokogiri::XML(data.to_xml()))
        validate = true
      rescue  Exception => ex
        ex.message
{'fraction_non_alphanumeric': 0.08193668528864059, 'fraction_numerical': 0.0, 'mean_word_length': 2.952205882352941, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '5505745', 'n_tokens_mistral': 345, 'n_tokens_neox': 330, 'n_words': 73}