module Text.XML.Basic.String where
import qualified Text.XML.Basic.Character as XMLChar
import qualified Text.XML.Basic.Entity as XMLEnt
import qualified Data.Map as Map
import qualified Data.Char as Char
type Encoded = String
decode ::
(Encoded -> String) ->
[XMLChar.T] ->
String
decode =
decodeGen XMLEnt.mapNameToChar
decodeGen ::
Map.Map XMLEnt.Name Char ->
(Encoded -> String) ->
[XMLChar.T] ->
String
decodeGen mapNameToChar decoder =
foldr ($) [] .
XMLChar.switchUnicodeRuns
((++) . decoder)
(\n ->
if XMLChar.validCharRef n
then (Char.chr n :)
else id)
(\n ->
maybe id (:) $
Map.lookup n mapNameToChar)