module Main where

import Text.XML.Expat.Tree
import qualified Data.ByteString as B
import Data.ByteString.Internal (c2w, w2c)
import qualified Data.ByteString.Lazy as L
import Control.Monad

infiniteDoc = "<?xml version=\"1.0\"?><infinite>"++body 1
    where
        body i | i == 5000 = "</bad-xml>" ++ body (i+1)
        body i = "\n  <item idx=\"" ++ show i ++ "\"/>"++body (i+1)

toBL :: String -> L.ByteString
toBL = L.fromChunks . chunkify
  where
    chunkify [] = []
    chunkify str =
        let (start, rem) = splitAt 1024 str
        in  (B.pack $ map c2w start):chunkify rem

infiniteBL = toBL infiniteDoc

main = do
    print $ (parseTreeThrowing Nothing infiniteBL :: UNode B.ByteString)


module Main where

import Text.XML.Expat.Tree
import qualified Data.ByteString as B
import Data.ByteString.Internal (c2w, w2c)
import qualified Data.ByteString.Lazy as L
import Control.Monad

infiniteDoc = "<?xml version=\"1.0\"?><infinite>"++body 1
    where
        body i | i == 5000 = "</bad-xml>" ++ body (i+1)
        body i = "\n  <item idx=\"" ++ show i ++ "\"/>"++body (i+1)

toBL :: String -> L.ByteString
toBL = L.fromChunks . chunkify
  where
    chunkify [] = []
    chunkify str =
        let (start, rem) = splitAt 1024 str
        in  (B.pack $ map c2w start):chunkify rem

infiniteBL = toBL infiniteDoc

-- This test passes if it raises an exception when it gets bad XML.

main = do
    print $ (parseTreeThrowing Nothing infiniteBL :: UNode B.ByteString)


Add a note about exceptions
Add a note about exceptions

Ignore-this: 44c57604e9b162a1873d4e81395f44d4

darcs-hash:20090317225243-ed7c9-f5292c89525acf9541090d7452f839943a72b923.gz
