module Text.XML.HaXml.Verbatim where
import Text.XML.HaXml.Types
import Text.XML.HaXml.Namespaces
qname :: QName -> String
qname :: QName -> String
qname QName
n = QName -> String
printableName QName
n
class Verbatim a where
verbatim :: a -> String
instance (Verbatim a) => Verbatim [a] where
verbatim :: [a] -> String
verbatim = forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap forall a. Verbatim a => a -> String
verbatim
instance Verbatim Char where
verbatim :: Char -> String
verbatim Char
c = [Char
c]
instance (Verbatim a, Verbatim b) => Verbatim (Either a b) where
verbatim :: Either a b -> String
verbatim (Left a
v) = forall a. Verbatim a => a -> String
verbatim a
v
verbatim (Right b
v) = forall a. Verbatim a => a -> String
verbatim b
v
instance Verbatim (Content i) where
verbatim :: Content i -> String
verbatim (CElem Element i
c i
_) = forall a. Verbatim a => a -> String
verbatim Element i
c
verbatim (CString Bool
_ String
c i
_) = String
c
verbatim (CRef Reference
c i
_) = forall a. Verbatim a => a -> String
verbatim Reference
c
verbatim (CMisc (Comment String
c) i
_) = String
"<!--"forall a. [a] -> [a] -> [a]
++String
cforall a. [a] -> [a] -> [a]
++String
"-->"
verbatim (CMisc Misc
_ i
_) = String
"<? ?>"
instance Verbatim (Element i) where
verbatim :: Element i -> String
verbatim (Elem QName
nam [Attribute]
att []) = String
"<" forall a. [a] -> [a] -> [a]
++ QName -> String
qname QName
nam
forall a. [a] -> [a] -> [a]
++ forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Attribute -> String
verbAttr [Attribute]
att
forall a. [a] -> [a] -> [a]
++ String
"/>"
verbatim (Elem QName
nam [Attribute]
att [Content i]
cont) = String
"<" forall a. [a] -> [a] -> [a]
++ QName -> String
qname QName
nam
forall a. [a] -> [a] -> [a]
++ forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap Attribute -> String
verbAttr [Attribute]
att
forall a. [a] -> [a] -> [a]
++ String
">" forall a. [a] -> [a] -> [a]
++ forall a. Verbatim a => a -> String
verbatim [Content i]
cont forall a. [a] -> [a] -> [a]
++ String
"</"
forall a. [a] -> [a] -> [a]
++ QName -> String
qname QName
nam forall a. [a] -> [a] -> [a]
++ String
">"
instance Verbatim Reference where
verbatim :: Reference -> String
verbatim (RefEntity String
r) = String
"&" forall a. [a] -> [a] -> [a]
++ forall a. Verbatim a => a -> String
verbatim String
r forall a. [a] -> [a] -> [a]
++ String
";"
verbatim (RefChar CharRef
c) = String
"&#" forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show CharRef
c forall a. [a] -> [a] -> [a]
++ String
";"
instance Verbatim AttValue where
verbatim :: AttValue -> String
verbatim (AttValue [Either String Reference]
v) = forall a. Verbatim a => a -> String
verbatim [Either String Reference]
v
verbAttr :: Attribute -> String
verbAttr :: Attribute -> String
verbAttr (QName
n, AttValue [Either String Reference]
v) = String
" " forall a. [a] -> [a] -> [a]
++ QName -> String
qname QName
n forall a. [a] -> [a] -> [a]
++ String
"=\"" forall a. [a] -> [a] -> [a]
++ forall a. Verbatim a => a -> String
verbatim [Either String Reference]
v forall a. [a] -> [a] -> [a]
++ String
"\""