{-# LANGUAGE DeriveDataTypeable #-}
module Text.XML.Light.Types where
import Data.Typeable(Typeable)
import Data.Data(Data)
type Line = Integer
data Content = Elem Element
| Text CData
| CRef String
deriving (Show, Typeable, Data)
data Element = Element {
elName :: QName,
elAttribs :: [Attr],
elContent :: [Content],
elLine :: Maybe Line
} deriving (Show, Typeable, Data)
data Attr = Attr {
attrKey :: QName,
attrVal :: String
} deriving (Eq, Ord, Show, Typeable, Data)
data CData = CData {
cdVerbatim :: CDataKind,
cdData :: String,
cdLine :: Maybe Line
} deriving (Show, Typeable, Data)
data CDataKind
= CDataText
| CDataVerbatim
| CDataRaw
deriving ( Eq, Show, Typeable, Data )
data QName = QName {
qName :: String,
qURI :: Maybe String,
qPrefix :: Maybe String
} deriving (Show, Typeable, Data)
instance Eq QName where
q1 == q2 = compare q1 q2 == EQ
instance Ord QName where
compare q1 q2 =
case compare (qName q1) (qName q2) of
EQ -> case (qURI q1, qURI q2) of
(Nothing,Nothing) -> compare (qPrefix q1) (qPrefix q2)
(u1,u2) -> compare u1 u2
x -> x
blank_name :: QName
blank_name = QName { qName = "", qURI = Nothing, qPrefix = Nothing }
blank_cdata :: CData
blank_cdata = CData { cdVerbatim = CDataText, cdData = "", cdLine = Nothing }
blank_element :: Element
blank_element = Element
{ elName = blank_name
, elAttribs = []
, elContent = []
, elLine = Nothing
}