    {-# LANGUAGE DeriveDataTypeable #-}

    -- ------------------------------------------------------------

    {- |
       Module     : Text.XML.HXT.DOM.TypeDefs
       Copyright  : Copyright (C) 2008-2010 Uwe Schmidt
       License    : MIT

       Maintainer : Uwe Schmidt (uwe@fh-wedel.de)
       Stability  : stable
       Portability: portable

       The core data types of the HXT DOM.

    -}

    -- ------------------------------------------------------------

    module Text.XML.HXT.DOM.TypeDefs
        ( module Data.AssocList
        , module Text.XML.HXT.DOM.TypeDefs
        , module Text.XML.HXT.DOM.QualifiedName
        )

    where

    import           Control.DeepSeq
    import           Control.FlatSeq

    import           Data.AssocList

    import           Data.Binary
    import qualified Data.ByteString.Lazy            as BS
    import qualified Data.ByteString.Lazy.Char8      as CS

    import           Data.Tree.NTree.TypeDefs
    import           Data.Tree.NTree.Zipper.TypeDefs

    import           Data.Typeable

    import           Text.XML.HXT.DOM.QualifiedName

    -- -----------------------------------------------------------------------------
    --
    -- Basic types for xml tree and filters

    -- | Rose tree with XML nodes (XNode)

    type XmlTree    = NTree    XNode

    -- | List of rose trees with XML nodes

    type XmlTrees   = NTrees   XNode

    -- | Navigatable rose tree with XML nodes

    type XmlNavTree = NTZipper XNode

    -- | List of navigatable rose trees with XML nodes

    type XmlNavTrees = [NTZipper XNode]

    -- -----------------------------------------------------------------------------
    --
    -- XNode

    -- | Represents elements

    data XNode      = XText           String                        -- ^ ordinary text                                       (leaf)
                    | XBlob           Blob                          -- ^ text represented more space efficient as bytestring (leaf)
                    | XCharRef        Int                           -- ^ character reference                                 (leaf)
                    | XEntityRef      String                        -- ^ entity reference                                    (leaf)
                    | XCmt            String                        -- ^ comment                                             (leaf)
                    | XCdata          String                        -- ^ CDATA section                                       (leaf)
                    | XPi             QName XmlTrees                -- ^ Processing Instr with qualified name                (leaf)
                                                                    --   with list of attributes.
                                                                    --   If tag name is xml, attributes are \"version\", \"encoding\", \"standalone\",
                                                                    --   else attribute list is empty, content is a text child node
                    | XTag            QName XmlTrees                -- ^ tag with qualified name and list of attributes (inner node or leaf)
                    | XDTD            DTDElem  Attributes           -- ^ DTD element with assoc list for dtd element features
                    | XAttr           QName                         -- ^ attribute with qualified name, the attribute value is stored in children
                    | XError          Int  String                   -- ^ error message with level and text
                      deriving (XNode -> XNode -> Bool
    (XNode -> XNode -> Bool) -> (XNode -> XNode -> Bool) -> Eq XNode
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: XNode -> XNode -> Bool
    == :: XNode -> XNode -> Bool
    $c/= :: XNode -> XNode -> Bool
    /= :: XNode -> XNode -> Bool
    Eq, Int -> XNode -> ShowS
    [XNode] -> ShowS
    XNode -> String
    (Int -> XNode -> ShowS)
    -> (XNode -> String) -> ([XNode] -> ShowS) -> Show XNode
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> XNode -> ShowS
    showsPrec :: Int -> XNode -> ShowS
    $cshow :: XNode -> String
    show :: XNode -> String
    $cshowList :: [XNode] -> ShowS
    showList :: [XNode] -> ShowS
    Show, Typeable)

    instance NFData XNode where
        rnf :: XNode -> ()
    rnf (XText String
    s)               = String -> ()
    forall a. NFData a => a -> ()
    rnf String
    s
        rnf (XTag QName
    qn XmlTrees
    cs)            = QName -> ()
    forall a. NFData a => a -> ()
    rnf QName
    qn () -> () -> ()
    forall a b. a -> b -> b
    `seq` XmlTrees -> ()
    forall a. NFData a => a -> ()
    rnf XmlTrees
    cs
        rnf (XAttr QName
    qn)              = QName -> ()
    forall a. NFData a => a -> ()
    rnf QName
    qn
        rnf (XCharRef Int
    i)            = Int -> ()
    forall a. NFData a => a -> ()
    rnf Int
    i
        rnf (XEntityRef String
    n)          = String -> ()
    forall a. NFData a => a -> ()
    rnf String
    n
        rnf (XCmt String
    c)                = String -> ()
    forall a. NFData a => a -> ()
    rnf String
    c
        rnf (XCdata String
    s)              = String -> ()
    forall a. NFData a => a -> ()
    rnf String
    s
        rnf (XPi QName
    qn XmlTrees
    ts)             = QName -> ()
    forall a. NFData a => a -> ()
    rnf QName
    qn () -> () -> ()
    forall a b. a -> b -> b
    `seq` XmlTrees -> ()
    forall a. NFData a => a -> ()
    rnf XmlTrees
    ts
        rnf (XDTD DTDElem
    de Attributes
    al)            = DTDElem -> ()
    forall a. NFData a => a -> ()
    rnf DTDElem
    de () -> () -> ()
    forall a b. a -> b -> b
    `seq` Attributes -> ()
    forall a. NFData a => a -> ()
    rnf Attributes
    al
        rnf (XBlob Blob
    b)               = Blob -> Int64
    BS.length Blob
    b Int64 -> () -> ()
    forall a b. a -> b -> b
    `seq` ()
        rnf (XError Int
    n String
    e)            = Int -> ()
    forall a. NFData a => a -> ()
    rnf Int
    n  () -> () -> ()
    forall a b. a -> b -> b
    `seq` String -> ()
    forall a. NFData a => a -> ()
    rnf String
    e

    instance WNFData XNode where
        rwnf :: XNode -> ()
    rwnf (XText String
    s)              = String -> ()
    forall a. WNFData a => a -> ()
    rwnf String
    s
        rwnf (XTag QName
    qn XmlTrees
    cs)           = QName -> ()
    forall a. WNFData a => a -> ()
    rwnf QName
    qn () -> () -> ()
    forall a b. a -> b -> b
    `seq` XmlTrees -> ()
    forall a. WNFData a => a -> ()
    rwnf XmlTrees
    cs
        rwnf (XAttr QName
    qn)             = QName -> ()
    forall a. WNFData a => a -> ()
    rwnf QName
    qn
        rwnf (XCharRef Int
    i)           = Int
    i Int -> () -> ()
    forall a b. a -> b -> b
    `seq` ()
        rwnf (XEntityRef String
    n)         = String -> ()
    forall a. WNFData a => a -> ()
    rwnf String
    n
        rwnf (XCmt String
    c)               = String -> ()
    forall a. WNFData a => a -> ()
    rwnf String
    c
        rwnf (XCdata String
    s)             = String -> ()
    forall a. WNFData a => a -> ()
    rwnf String
    s
        rwnf (XPi QName
    qn XmlTrees
    ts)            = QName -> ()
    forall a. WNFData a => a -> ()
    rwnf QName
    qn () -> () -> ()
    forall a b. a -> b -> b
    `seq` XmlTrees -> ()
    forall a. WNFData a => a -> ()
    rwnf XmlTrees
    ts
        rwnf (XDTD DTDElem
    de Attributes
    al)           = DTDElem -> ()
    forall a. WNFData a => a -> ()
    rwnf DTDElem
    de () -> () -> ()
    forall a b. a -> b -> b
    `seq` Attributes -> ()
    rwnfAttributes Attributes
    al
        rwnf (XBlob Blob
    _b)             = () -- BS.length b `seq` () -- lazy bytestrings are not evaluated
        rwnf (XError Int
    n String
    e)           = Int
    n Int -> () -> ()
    forall a b. a -> b -> b
    `seq` String -> ()
    forall a. WNFData a => a -> ()
    rwnf String
    e

    -- | Evaluate an assoc list of strings
    rwnfAttributes                  :: Attributes -> ()
    rwnfAttributes :: Attributes -> ()
    rwnfAttributes [] = ()
    rwnfAttributes ((String
    k, String
    v) : Attributes
    as)    = String -> ()
    forall a. WNFData a => a -> ()
    rwnf String
    k () -> () -> ()
    forall a b. a -> b -> b
    `seq` String -> ()
    forall a. WNFData a => a -> ()
    rwnf String
    v () -> () -> ()
    forall a b. a -> b -> b
    `seq` Attributes -> ()
    rwnfAttributes Attributes
    as

    instance Binary XNode where
        put :: XNode -> Put
    put (XText String
    s)               = Word8 -> Put
    forall t. Binary t => t -> Put
    put ( Word8
    0::Word8) Put -> Put -> Put
    forall a b. PutM a -> PutM b -> PutM b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> String -> Put
    forall t. Binary t => t -> Put
    put String
    s
        put (XTag QName
    qn XmlTrees
    cs)            = Word8 -> Put
    forall t. Binary t => t -> Put
    put ( Word8
    6::Word8) Put -> Put -> Put
    forall a b. PutM a -> PutM b -> PutM b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> QName -> Put
    forall t. Binary t => t -> Put
    put QName
    qn Put -> Put -> Put
    forall a b. PutM a -> PutM b -> PutM b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> XmlTrees -> Put
    forall t. Binary t => t -> Put
    put XmlTrees
    cs
        put (XAttr QName
    qn)              = Word8 -> Put
    forall t. Binary t => t -> Put
    put ( Word8
    8::Word8) Put -> Put -> Put
    forall a b. PutM a -> PutM b -> PutM b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> QName -> Put
    forall t. Binary t => t -> Put
    put QName
    qn
        put (XCharRef Int
    i)            = Word8 -> Put
    forall t. Binary t => t -> Put
    put ( Word8
    1::Word8) Put -> Put -> Put
    forall a b. PutM a -> PutM b -> PutM b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Int -> Put
    forall t. Binary t => t -> Put
    put Int
    i
        put (XEntityRef String
    n)          = Word8 -> Put
    forall t. Binary t => t -> Put
    put ( Word8
    2::Word8) Put -> Put -> Put
    forall a b. PutM a -> PutM b -> PutM b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> String -> Put
    forall t. Binary t => t -> Put
    put String
    n
        put (XCmt String
    c)                = Word8 -> Put
    forall t. Binary t => t -> Put
    put ( Word8
    3::Word8) Put -> Put -> Put
    forall a b. PutM a -> PutM b -> PutM b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> String -> Put
    forall t. Binary t => t -> Put
    put String
    c
        put (XCdata String
    s)              = Word8 -> Put
    forall t. Binary t => t -> Put
    put ( Word8
    4::Word8) Put -> Put -> Put
    forall a b. PutM a -> PutM b -> PutM b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> String -> Put
    forall t. Binary t => t -> Put
    put String
    s
        put (XPi QName
    qn XmlTrees
    ts)             = Word8 -> Put
    forall t. Binary t => t -> Put
    put ( Word8
    5::Word8) Put -> Put -> Put
    forall a b. PutM a -> PutM b -> PutM b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> QName -> Put
    forall t. Binary t => t -> Put
    put QName
    qn Put -> Put -> Put
    forall a b. PutM a -> PutM b -> PutM b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> XmlTrees -> Put
    forall t. Binary t => t -> Put
    put XmlTrees
    ts
        put (XDTD DTDElem
    de Attributes
    al)            = Word8 -> Put
    forall t. Binary t => t -> Put
    put ( Word8
    7::Word8) Put -> Put -> Put
    forall a b. PutM a -> PutM b -> PutM b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> DTDElem -> Put
    forall t. Binary t => t -> Put
    put DTDElem
    de Put -> Put -> Put
    forall a b. PutM a -> PutM b -> PutM b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Attributes -> Put
    forall t. Binary t => t -> Put
    put Attributes
    al
        put (XError Int
    n String
    e)            = Word8 -> Put
    forall t. Binary t => t -> Put
    put ( Word8
    9::Word8) Put -> Put -> Put
    forall a b. PutM a -> PutM b -> PutM b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Int -> Put
    forall t. Binary t => t -> Put
    put Int
    n  Put -> Put -> Put
    forall a b. PutM a -> PutM b -> PutM b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> String -> Put
    forall t. Binary t => t -> Put
    put String
    e
        put (XBlob Blob
    b)               = Word8 -> Put
    forall t. Binary t => t -> Put
    put (Word8
    10::Word8) Put -> Put -> Put
    forall a b. PutM a -> PutM b -> PutM b
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Blob -> Put
    forall t. Binary t => t -> Put
    put Blob
    b

        get :: Get XNode
    get                         = do
                                      Word8
    tag <- Get Word8
    getWord8
                                      case Word8
    tag of
                                        Word8
    0  -> Get String
    forall t. Binary t => Get t
    get Get String -> (String -> Get XNode) -> Get XNode
    forall a b. Get a -> (a -> Get b) -> Get b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= XNode -> Get XNode
    forall a. a -> Get a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (XNode -> Get XNode) -> (String -> XNode) -> String -> Get XNode
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> XNode
    XText
                                        Word8
    1  -> Get Int
    forall t. Binary t => Get t
    get Get Int -> (Int -> Get XNode) -> Get XNode
    forall a b. Get a -> (a -> Get b) -> Get b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= XNode -> Get XNode
    forall a. a -> Get a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (XNode -> Get XNode) -> (Int -> XNode) -> Int -> Get XNode
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Int -> XNode
    XCharRef
                                        Word8
    2  -> Get String
    forall t. Binary t => Get t
    get Get String -> (String -> Get XNode) -> Get XNode
    forall a b. Get a -> (a -> Get b) -> Get b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= XNode -> Get XNode
    forall a. a -> Get a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (XNode -> Get XNode) -> (String -> XNode) -> String -> Get XNode
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> XNode
    XEntityRef
                                        Word8
    3  -> Get String
    forall t. Binary t => Get t
    get Get String -> (String -> Get XNode) -> Get XNode
    forall a b. Get a -> (a -> Get b) -> Get b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= XNode -> Get XNode
    forall a. a -> Get a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (XNode -> Get XNode) -> (String -> XNode) -> String -> Get XNode
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> XNode
    XCmt
                                        Word8
    4  -> Get String
    forall t. Binary t => Get t
    get Get String -> (String -> Get XNode) -> Get XNode
    forall a b. Get a -> (a -> Get b) -> Get b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= XNode -> Get XNode
    forall a. a -> Get a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (XNode -> Get XNode) -> (String -> XNode) -> String -> Get XNode
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> XNode
    XCdata
                                        Word8
    5  -> do
                                              QName
    qn <- Get QName
    forall t. Binary t => Get t
    get
                                              Get XmlTrees
    forall t. Binary t => Get t
    get Get XmlTrees -> (XmlTrees -> Get XNode) -> Get XNode
    forall a b. Get a -> (a -> Get b) -> Get b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= XNode -> Get XNode
    forall a. a -> Get a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (XNode -> Get XNode)
    -> (XmlTrees -> XNode) -> XmlTrees -> Get XNode
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . QName -> XmlTrees -> XNode
    XPi QName
    qn
                                        Word8
    6  -> do
                                              QName
    qn <- Get QName
    forall t. Binary t => Get t
    get
                                              Get XmlTrees
    forall t. Binary t => Get t
    get Get XmlTrees -> (XmlTrees -> Get XNode) -> Get XNode
    forall a b. Get a -> (a -> Get b) -> Get b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= XNode -> Get XNode
    forall a. a -> Get a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (XNode -> Get XNode)
    -> (XmlTrees -> XNode) -> XmlTrees -> Get XNode
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . QName -> XmlTrees -> XNode
    XTag QName
    qn
                                        Word8
    7  -> do
                                              DTDElem
    de <- Get DTDElem
    forall t. Binary t => Get t
    get
                                              Get Attributes
    forall t. Binary t => Get t
    get Get Attributes -> (Attributes -> Get XNode) -> Get XNode
    forall a b. Get a -> (a -> Get b) -> Get b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= XNode -> Get XNode
    forall a. a -> Get a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (XNode -> Get XNode)
    -> (Attributes -> XNode) -> Attributes -> Get XNode
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . DTDElem -> Attributes -> XNode
    XDTD DTDElem
    de
                                        Word8
    8  -> Get QName
    forall t. Binary t => Get t
    get Get QName -> (QName -> Get XNode) -> Get XNode
    forall a b. Get a -> (a -> Get b) -> Get b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= XNode -> Get XNode
    forall a. a -> Get a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (XNode -> Get XNode) -> (QName -> XNode) -> QName -> Get XNode
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . QName -> XNode
    XAttr
                                        Word8
    9  -> do
                                              Int
    n <- Get Int
    forall t. Binary t => Get t
    get
                                              Get String
    forall t. Binary t => Get t
    get Get String -> (String -> Get XNode) -> Get XNode
    forall a b. Get a -> (a -> Get b) -> Get b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= XNode -> Get XNode
    forall a. a -> Get a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (XNode -> Get XNode) -> (String -> XNode) -> String -> Get XNode
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Int -> String -> XNode
    XError Int
    n
                                        Word8
    10 -> Get Blob
    forall t. Binary t => Get t
    get Get Blob -> (Blob -> Get XNode) -> Get XNode
    forall a b. Get a -> (a -> Get b) -> Get b
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= XNode -> Get XNode
    forall a. a -> Get a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (XNode -> Get XNode) -> (Blob -> XNode) -> Blob -> Get XNode
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Blob -> XNode
    XBlob
                                        Word8
    _  -> String -> Get XNode
    forall a. HasCallStack => String -> a
    error String
    "XNode.get: error while decoding XNode"

    -- -----------------------------------------------------------------------------
    --
    -- DTDElem

    -- | Represents a DTD element

    data DTDElem    = DOCTYPE       -- ^ attr: name, system, public,        XDTD elems as children
                    | ELEMENT       -- ^ attr: name, kind
                                    --
                                    --  name: element name
                                    --
                                    --  kind: \"EMPTY\" | \"ANY\" | \"\#PCDATA\" | children | mixed
                    | CONTENT       -- ^ element content
                                    --
                                    --  attr: kind, modifier
                                    --
                                    --  modifier: \"\" | \"?\" | \"*\" | \"+\"
                                    --
                                    --  kind: seq | choice
                    | ATTLIST       -- ^ attributes:
                                    --  name - name of element
                                    --
                                    --  value - name of attribute
                                    --
                                    --  type: \"CDATA\" | \"ID\" | \"IDREF\" | \"IDREFS\" | \"ENTITY\" | \"ENTITIES\" |
                                    --
                                    --        \"NMTOKEN\" | \"NMTOKENS\" |\"NOTATION\" | \"ENUMTYPE\"
                                    --
                                    --  kind: \"#REQUIRED\" | \"#IMPLIED\" | \"DEFAULT\"
                    | ENTITY        -- ^ for entity declarations
                    | PENTITY       -- ^ for parameter entity declarations
                    | NOTATION      -- ^ for notations
                    | CONDSECT      -- ^ for INCLUDEs, IGNOREs and peRefs: attr: type
                                    --
                                    --  type = INCLUDE, IGNORE or %...;
                    | NAME          -- ^ attr: name
                                    --
                                    --  for lists of names in notation types or nmtokens in enumeration types
                    | PEREF         -- ^ for Parameter Entity References in DTDs
                      deriving (DTDElem -> DTDElem -> Bool
    (DTDElem -> DTDElem -> Bool)
    -> (DTDElem -> DTDElem -> Bool) -> Eq DTDElem
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: DTDElem -> DTDElem -> Bool
    == :: DTDElem -> DTDElem -> Bool
    $c/= :: DTDElem -> DTDElem -> Bool
    /= :: DTDElem -> DTDElem -> Bool
    Eq, Eq DTDElem
    Eq DTDElem
    -> (DTDElem -> DTDElem -> Ordering)
    -> (DTDElem -> DTDElem -> Bool)
    -> (DTDElem -> DTDElem -> Bool)
    -> (DTDElem -> DTDElem -> Bool)
    -> (DTDElem -> DTDElem -> Bool)
    -> (DTDElem -> DTDElem -> DTDElem)
    -> (DTDElem -> DTDElem -> DTDElem)
    -> Ord DTDElem
    DTDElem -> DTDElem -> Bool
    DTDElem -> DTDElem -> Ordering
    DTDElem -> DTDElem -> DTDElem
    forall a.
    Eq a
    -> (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: DTDElem -> DTDElem -> Ordering
    compare :: DTDElem -> DTDElem -> Ordering
    $c< :: DTDElem -> DTDElem -> Bool
    < :: DTDElem -> DTDElem -> Bool
    $c<= :: DTDElem -> DTDElem -> Bool
    <= :: DTDElem -> DTDElem -> Bool
    $c> :: DTDElem -> DTDElem -> Bool
    > :: DTDElem -> DTDElem -> Bool
    $c>= :: DTDElem -> DTDElem -> Bool
    >= :: DTDElem -> DTDElem -> Bool
    $cmax :: DTDElem -> DTDElem -> DTDElem
    max :: DTDElem -> DTDElem -> DTDElem
    $cmin :: DTDElem -> DTDElem -> DTDElem
    min :: DTDElem -> DTDElem -> DTDElem
    Ord, Int -> DTDElem
    DTDElem -> Int
    DTDElem -> [DTDElem]
    DTDElem -> DTDElem
    DTDElem -> DTDElem -> [DTDElem]
    DTDElem -> DTDElem -> DTDElem -> [DTDElem]
    (DTDElem -> DTDElem)
    -> (DTDElem -> DTDElem)
    -> (Int -> DTDElem)
    -> (DTDElem -> Int)
    -> (DTDElem -> [DTDElem])
    -> (DTDElem -> DTDElem -> [DTDElem])
    -> (DTDElem -> DTDElem -> [DTDElem])
    -> (DTDElem -> DTDElem -> DTDElem -> [DTDElem])
    -> Enum DTDElem
    forall a.
    (a -> a)
    -> (a -> a)
    -> (Int -> a)
    -> (a -> Int)
    -> (a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> [a])
    -> (a -> a -> a -> [a])
    -> Enum a
    $csucc :: DTDElem -> DTDElem
    succ :: DTDElem -> DTDElem
    $cpred :: DTDElem -> DTDElem
    pred :: DTDElem -> DTDElem
    $ctoEnum :: Int -> DTDElem
    toEnum :: Int -> DTDElem
    $cfromEnum :: DTDElem -> Int
    fromEnum :: DTDElem -> Int
    $cenumFrom :: DTDElem -> [DTDElem]
    enumFrom :: DTDElem -> [DTDElem]
    $cenumFromThen :: DTDElem -> DTDElem -> [DTDElem]
    enumFromThen :: DTDElem -> DTDElem -> [DTDElem]
    $cenumFromTo :: DTDElem -> DTDElem -> [DTDElem]
    enumFromTo :: DTDElem -> DTDElem -> [DTDElem]
    $cenumFromThenTo :: DTDElem -> DTDElem -> DTDElem -> [DTDElem]
    enumFromThenTo :: DTDElem -> DTDElem -> DTDElem -> [DTDElem]
    Enum, Int -> DTDElem -> ShowS
    [DTDElem] -> ShowS
    DTDElem -> String
    (Int -> DTDElem -> ShowS)
    -> (DTDElem -> String) -> ([DTDElem] -> ShowS) -> Show DTDElem
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> DTDElem -> ShowS
    showsPrec :: Int -> DTDElem -> ShowS
    $cshow :: DTDElem -> String
    show :: DTDElem -> String
    $cshowList :: [DTDElem] -> ShowS
    showList :: [DTDElem] -> ShowS
    Show, ReadPrec [DTDElem]
    ReadPrec DTDElem
    Int -> ReadS DTDElem
    ReadS [DTDElem]
    (Int -> ReadS DTDElem)
    -> ReadS [DTDElem]
    -> ReadPrec DTDElem
    -> ReadPrec [DTDElem]
    -> Read DTDElem
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS DTDElem
    readsPrec :: Int -> ReadS DTDElem
    $creadList :: ReadS [DTDElem]
    readList :: ReadS [DTDElem]
    $creadPrec :: ReadPrec DTDElem
    readPrec :: ReadPrec DTDElem
    $creadListPrec :: ReadPrec [DTDElem]
    readListPrec :: ReadPrec [DTDElem]
    Read, Typeable)

    instance NFData DTDElem
        where rnf :: DTDElem -> ()
    rnf DTDElem
    x = DTDElem -> () -> ()
    forall a b. a -> b -> b
    seq DTDElem
    x ()

    instance WNFData DTDElem

    instance Binary DTDElem where
        put :: DTDElem -> Put
    put DTDElem
    de = Word8 -> Put
    forall t. Binary t => t -> Put
    put ((Int -> Word8
    forall a. Enum a => Int -> a
    toEnum (Int -> Word8) -> (DTDElem -> Int) -> DTDElem -> Word8
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . DTDElem -> Int
    forall a. Enum a => a -> Int
    fromEnum (DTDElem -> Word8) -> DTDElem -> Word8
    forall a b. (a -> b) -> a -> b
    $ DTDElem
    de)::Word8)         -- DTDElem is not yet instance of Enum
        get :: Get DTDElem
    get    = do Word8
    tag <- Get Word8
    getWord8
                    DTDElem -> Get DTDElem
    forall a. a -> Get a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (DTDElem -> Get DTDElem) -> DTDElem -> Get DTDElem
    forall a b. (a -> b) -> a -> b
    $! (Int -> DTDElem
    forall a. Enum a => Int -> a
    toEnum (Int -> DTDElem) -> (Word8 -> Int) -> Word8 -> DTDElem
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Word8 -> Int
    forall a. Enum a => a -> Int
    fromEnum (Word8 -> DTDElem) -> Word8 -> DTDElem
    forall a b. (a -> b) -> a -> b
    $ Word8
    tag)

    -- -----------------------------------------------------------------------------

    -- | Binary large object implemented as a lazy bytestring

    type Blob       = BS.ByteString

    blobToString    :: Blob -> String
    blobToString :: Blob -> String
    blobToString    = Blob -> String
    CS.unpack
    {-# INLINE blobToString #-}

    stringToBlob    :: String -> Blob
    stringToBlob :: String -> Blob
    stringToBlob    = String -> Blob
    CS.pack
    {-# INLINE stringToBlob #-}

    -- -----------------------------------------------------------------------------

    -- | Attribute list
    --
    -- used for storing option lists and features of DTD parts

    type Attributes = AssocList String String

    -- -----------------------------------------------------------------------------
    --
    -- Constants for error levels

    -- | no error, everything is ok
    c_ok    :: Int
    c_ok :: Int
    c_ok    = Int
    0

    -- | Error level for XError, type warning
    c_warn  :: Int
    c_warn :: Int
    c_warn  = Int
    c_ok Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    1

    -- | Error level for XError, type error
    c_err   :: Int
    c_err :: Int
    c_err   = Int
    c_warn Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    1

    -- | Error level for XError, type fatal error
    c_fatal :: Int
    c_fatal :: Int
    c_fatal = Int
    c_err Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + Int
    1

    -- -----------------------------------------------------------------------------

    -- | data type for representing a set of nodes as a tree structure
    --
    -- this structure is e.g. used to repesent the result of an XPath query
    -- such that the selected nodes can be processed or selected later in
    -- processing a document tree

    data XmlNodeSet = XNS { XmlNodeSet -> Bool
    thisNode   :: Bool         -- ^ is this node part of the set ?
                          , XmlNodeSet -> [QName]
    attrNodes  :: [QName]      -- ^ the set of attribute nodes
                          , XmlNodeSet -> ChildNodes
    childNodes :: ChildNodes   -- ^ the set of child nodes, a list of pairs of index and node set
                          }
                      deriving (XmlNodeSet -> XmlNodeSet -> Bool
    (XmlNodeSet -> XmlNodeSet -> Bool)
    -> (XmlNodeSet -> XmlNodeSet -> Bool) -> Eq XmlNodeSet
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: XmlNodeSet -> XmlNodeSet -> Bool
    == :: XmlNodeSet -> XmlNodeSet -> Bool
    $c/= :: XmlNodeSet -> XmlNodeSet -> Bool
    /= :: XmlNodeSet -> XmlNodeSet -> Bool
    Eq, Int -> XmlNodeSet -> ShowS
    [XmlNodeSet] -> ShowS
    XmlNodeSet -> String
    (Int -> XmlNodeSet -> ShowS)
    -> (XmlNodeSet -> String)
    -> ([XmlNodeSet] -> ShowS)
    -> Show XmlNodeSet
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> XmlNodeSet -> ShowS
    showsPrec :: Int -> XmlNodeSet -> ShowS
    $cshow :: XmlNodeSet -> String
    show :: XmlNodeSet -> String
    $cshowList :: [XmlNodeSet] -> ShowS
    showList :: [XmlNodeSet] -> ShowS
    Show, Typeable)

    type ChildNodes = [(Int, XmlNodeSet)]

    -- -----------------------------------------------------------------------------