<commit_before>import Text.XML.Expat.Tree
import Text.XML.Expat.Format
import Text.XML.Expat.Qualified
import Text.XML.Expat.Namespaced
import qualified Data.ByteString as B

{-- | Load the XSD schema in using all three strategies - raw tags, qualified tags and namespaced tags.
    We are checking that thing are going according to plan. In particular, that namespace URIs are being substituted in correctly.
| --}
main = do
  --xml <- B.readFile "test.xml"
  xml <- B.readFile "XMLSchema.xsd"
  
  case parseTree' qualifiedByteStringFlavor Nothing xml of
    Left qerr -> putStrLn $ show qerr
    Right q -> do
      case parseTree' byteStringFlavor Nothing xml of
        Left terr -> putStrLn $ show terr
        Right t -> do
          let tq = toQualified t
          putStrLn . show $ q == tq<commit_msg>test that fromQualified . toQualified is id<commit_after>import Text.XML.Expat.Tree
import Text.XML.Expat.Format
import Text.XML.Expat.Qualified
import Text.XML.Expat.Namespaced
import qualified Data.ByteString as B

{-- | Load the XSD schema in using all three strategies - raw tags, qualified tags and namespaced tags.
    We are checking that thing are going according to plan. In particular, that namespace URIs are being substituted in correctly.
| --}
main = do
  --xml <- B.readFile "test.xml"
  xml <- B.readFile "XMLSchema.xsd"
  
  case parseTree' qualifiedByteStringFlavor Nothing xml of
    Left qerr -> putStrLn $ show qerr
    Right q -> do
      case parseTree' byteStringFlavor Nothing xml of
        Left terr -> putStrLn $ show terr
        Right t -> do
          let tq = toQualified t
          putStr "Flavor and toQualified are equivalent: "
          putStrLn . show $ q == tq
          let fq = fromQualified tq
          putStr "Plane text and fromQualified . toQualified are equivalent: "
          putStrLn . show $ t == fq
{'fraction_non_alphanumeric': 0.07357679914070892, 'fraction_numerical': 0.0, 'mean_word_length': 2.7636363636363637, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, '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': '5382040', 'n_tokens_mistral': 556, 'n_tokens_neox': 541, 'n_words': 212}