Text.XML

xml-conduit-1.10.0.0: Pure-Haskell utilities for dealing with XML with the conduit package.

Safe Haskell | None
Language | Haskell2010

Text.XML

Contents

- Data types
- Parsing
  - Files
  - Bytes
  - Text
  - Other
- Rendering
- Settings
  - Parsing
    - Entity decoding
  - Rendering
- Conversion

Description

DOM-based parsing and rendering.

This module requires that all entities be resolved at parsing. If you need to interact with unresolved entities, please use Text.XML.Unresolved. This is the recommended module for most uses cases.

While many of the datatypes in this module are simply re-exported from `Data.XML.Types`, `Document`, `Node` and `Element` are all redefined here to disallow the possibility of unresolved entities. Conversion functions are provided to switch between the two sets of datatypes.

For simpler, bidirectional traversal of the DOM tree, see the Text.XML.Cursor module.

Synopsis

- data Document = Document {
  - documentPrologue :: Prologue
  - documentRoot :: Element
  - documentEpilogue :: [Miscellaneous]
  }
- data Prologue = Prologue {
  - prologueBefore :: [Miscellaneous]
  - prologueDoctype :: Maybe Doctype
  - prologueAfter :: [Miscellaneous]
  }
- data Instruction = Instruction {
  - instructionTarget :: Text
  - instructionData :: Text
  }
- data Miscellaneous
  - = MiscInstruction Instruction
  - | MiscComment Text
- data Node
  - = NodeElement Element
  - | NodeInstruction Instruction
  - | NodeContent Text
  - | NodeComment Text
- data Element = Element {
  - elementName :: Name
  - elementAttributes :: Map Name Text
  - elementNodes :: [Node]
  }
- data Name = Name {
  - nameLocalName :: Text
  - nameNamespace :: Maybe Text
  - namePrefix :: Maybe Text
  }
- data Doctype = Doctype {
  - doctypeName :: Text
  - doctypeID :: Maybe ExternalID
  }
- data ExternalID
  - = SystemID Text
  - | PublicID Text Text
- readFile :: ParseSettings -> FilePath -> IO Document
- parseLBS :: ParseSettings -> ByteString -> Either SomeException Document
- parseLBS_ :: ParseSettings -> ByteString -> Document
- sinkDoc :: forall (m :: Type -> Type) o. MonadThrow m => ParseSettings -> ConduitT ByteString o m Document
- parseText :: ParseSettings -> Text -> Either SomeException Document
- parseText_ :: ParseSettings -> Text -> Document
- sinkTextDoc :: forall (m :: Type -> Type) o. MonadThrow m => ParseSettings -> ConduitT Text o m Document
- fromEvents :: forall (m :: Type -> Type) o. MonadThrow m => ConduitT EventPos o m Document
- data UnresolvedEntityException = UnresolvedEntityException (Set Text)
- data XMLException = InvalidXMLFile FilePath SomeException
- writeFile :: RenderSettings -> FilePath -> Document -> IO ()
- renderLBS :: RenderSettings -> Document -> ByteString
- renderText :: RenderSettings -> Document -> Text
- renderBytes :: forall (m :: Type -> Type) i. PrimMonad m => RenderSettings -> Document -> ConduitT i ByteString m ()
- def :: Default a => a
- data ParseSettings
- psDecodeEntities :: ParseSettings -> DecodeEntities
- psRetainNamespaces :: ParseSettings -> Bool
- decodeXmlEntities :: DecodeEntities
- decodeHtmlEntities :: DecodeEntities
- data RenderSettings
- rsNamespaces :: RenderSettings -> [(Text, Text)]
- rsAttrOrder :: RenderSettings -> Name -> Map Name Text -> [(Name, Text)]
- rsUseCDATA :: RenderSettings -> Content -> Bool
- rsXMLDeclaration :: RenderSettings -> Bool
- orderAttrs :: [(Name, [Name])] -> Name -> Map Name Text -> [(Name, Text)]
- toXMLDocument :: Document -> Document
- fromXMLDocument :: Document -> Either (Set Text) Document
- toXMLNode :: Node -> Node
- fromXMLNode :: Node -> Either (Set Text) Node
- toXMLElement :: Element -> Element
- fromXMLElement :: Element -> Either (Set Text) Element

# Data types

data Document #

Constructors

Document |
Fields documentPrologue :: Prologue documentRoot :: Element documentEpilogue :: [Miscellaneous]

#### Instances

Instances details

ToMarkup Document # |
Instance details Defined in Text.XML Methods toMarkup :: Document -> Markup # preEscapedToMarkup :: Document -> Markup #
NFData Document # |
Instance details Defined in Text.XML Methods rnf :: Document -> () #
Data Document # |
Instance details Defined in Text.XML Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Document -> c Document # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Document # toConstr :: Document -> Constr # dataTypeOf :: Document -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Document) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Document) # gmapT :: (forall b. Data b => b -> b) -> Document -> Document # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Document -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Document -> r # gmapQ :: (forall d. Data d => d -> u) -> Document -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Document -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Document -> m Document # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Document -> m Document # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Document -> m Document #
Show Document # |
Instance details Defined in Text.XML Methods showsPrec :: Int -> Document -> ShowS # show :: Document -> String # showList :: [Document] -> ShowS #
Eq Document # |
Instance details Defined in Text.XML Methods (==) :: Document -> Document -> Bool # (/=) :: Document -> Document -> Bool #

data Prologue #

Constructors

Prologue |
Fields prologueBefore :: [Miscellaneous] prologueDoctype :: Maybe Doctype prologueAfter :: [Miscellaneous]

#### Instances

Instances details

NFData Prologue |
Instance details Defined in Data.XML.Types Methods rnf :: Prologue -> () #
Data Prologue |
Instance details Defined in Data.XML.Types Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Prologue -> c Prologue # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Prologue # toConstr :: Prologue -> Constr # dataTypeOf :: Prologue -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Prologue) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Prologue) # gmapT :: (forall b. Data b => b -> b) -> Prologue -> Prologue # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Prologue -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Prologue -> r # gmapQ :: (forall d. Data d => d -> u) -> Prologue -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Prologue -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Prologue -> m Prologue # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Prologue -> m Prologue # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Prologue -> m Prologue #
Generic Prologue |
Instance details Defined in Data.XML.Types Associated Types
type Rep Prologue |
Instance details Defined in Data.XML.Types type Rep Prologue = D1 ('MetaData "Prologue" "Data.XML.Types" "xml-types-0.3.8-FwSR3o5KEB5Crfesb7jmPZ" 'False) (C1 ('MetaCons "Prologue" 'PrefixI 'True) (S1 ('MetaSel ('Just "prologueBefore") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Miscellaneous]) :*: (S1 ('MetaSel ('Just "prologueDoctype") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Doctype)) :*: S1 ('MetaSel ('Just "prologueAfter") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Miscellaneous]))))
Methods from :: Prologue -> Rep Prologue x # to :: Rep Prologue x -> Prologue #
Show Prologue |
Instance details Defined in Data.XML.Types Methods showsPrec :: Int -> Prologue -> ShowS # show :: Prologue -> String # showList :: [Prologue] -> ShowS #
Eq Prologue |
Instance details Defined in Data.XML.Types Methods (==) :: Prologue -> Prologue -> Bool # (/=) :: Prologue -> Prologue -> Bool #
Ord Prologue |
Instance details Defined in Data.XML.Types Methods compare :: Prologue -> Prologue -> Ordering # (<) :: Prologue -> Prologue -> Bool # (<=) :: Prologue -> Prologue -> Bool # (>) :: Prologue -> Prologue -> Bool # (>=) :: Prologue -> Prologue -> Bool # max :: Prologue -> Prologue -> Prologue # min :: Prologue -> Prologue -> Prologue #
type Rep Prologue |
Instance details Defined in Data.XML.Types type Rep Prologue = D1 ('MetaData "Prologue" "Data.XML.Types" "xml-types-0.3.8-FwSR3o5KEB5Crfesb7jmPZ" 'False) (C1 ('MetaCons "Prologue" 'PrefixI 'True) (S1 ('MetaSel ('Just "prologueBefore") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Miscellaneous]) :*: (S1 ('MetaSel ('Just "prologueDoctype") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Doctype)) :*: S1 ('MetaSel ('Just "prologueAfter") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Miscellaneous]))))

data Instruction #

Constructors

Instruction |
Fields instructionTarget :: Text instructionData :: Text

#### Instances

Instances details

NFData Instruction |
Instance details Defined in Data.XML.Types Methods rnf :: Instruction -> () #
Data Instruction |
Instance details Defined in Data.XML.Types Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Instruction -> c Instruction # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Instruction # toConstr :: Instruction -> Constr # dataTypeOf :: Instruction -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Instruction) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Instruction) # gmapT :: (forall b. Data b => b -> b) -> Instruction -> Instruction # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Instruction -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Instruction -> r # gmapQ :: (forall d. Data d => d -> u) -> Instruction -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Instruction -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Instruction -> m Instruction # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Instruction -> m Instruction # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Instruction -> m Instruction #
Generic Instruction |
Instance details Defined in Data.XML.Types Associated Types
type Rep Instruction |
Instance details Defined in Data.XML.Types type Rep Instruction = D1 ('MetaData "Instruction" "Data.XML.Types" "xml-types-0.3.8-FwSR3o5KEB5Crfesb7jmPZ" 'False) (C1 ('MetaCons "Instruction" 'PrefixI 'True) (S1 ('MetaSel ('Just "instructionTarget") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "instructionData") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))
Methods from :: Instruction -> Rep Instruction x # to :: Rep Instruction x -> Instruction #
Show Instruction |
Instance details Defined in Data.XML.Types Methods showsPrec :: Int -> Instruction -> ShowS # show :: Instruction -> String # showList :: [Instruction] -> ShowS #
Eq Instruction |
Instance details Defined in Data.XML.Types Methods (==) :: Instruction -> Instruction -> Bool # (/=) :: Instruction -> Instruction -> Bool #
Ord Instruction |
Instance details Defined in Data.XML.Types Methods compare :: Instruction -> Instruction -> Ordering # (<) :: Instruction -> Instruction -> Bool # (<=) :: Instruction -> Instruction -> Bool # (>) :: Instruction -> Instruction -> Bool # (>=) :: Instruction -> Instruction -> Bool # max :: Instruction -> Instruction -> Instruction # min :: Instruction -> Instruction -> Instruction #
type Rep Instruction |
Instance details Defined in Data.XML.Types type Rep Instruction = D1 ('MetaData "Instruction" "Data.XML.Types" "xml-types-0.3.8-FwSR3o5KEB5Crfesb7jmPZ" 'False) (C1 ('MetaCons "Instruction" 'PrefixI 'True) (S1 ('MetaSel ('Just "instructionTarget") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "instructionData") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

data Miscellaneous #

Constructors

MiscInstruction Instruction |
MiscComment Text |

#### Instances

Instances details

NFData Miscellaneous |
Instance details Defined in Data.XML.Types Methods rnf :: Miscellaneous -> () #
Data Miscellaneous |
Instance details Defined in Data.XML.Types Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Miscellaneous -> c Miscellaneous # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Miscellaneous # toConstr :: Miscellaneous -> Constr # dataTypeOf :: Miscellaneous -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Miscellaneous) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Miscellaneous) # gmapT :: (forall b. Data b => b -> b) -> Miscellaneous -> Miscellaneous # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Miscellaneous -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Miscellaneous -> r # gmapQ :: (forall d. Data d => d -> u) -> Miscellaneous -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Miscellaneous -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Miscellaneous -> m Miscellaneous # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Miscellaneous -> m Miscellaneous # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Miscellaneous -> m Miscellaneous #
Generic Miscellaneous |
Instance details Defined in Data.XML.Types Associated Types
type Rep Miscellaneous |
Instance details Defined in Data.XML.Types type Rep Miscellaneous = D1 ('MetaData "Miscellaneous" "Data.XML.Types" "xml-types-0.3.8-FwSR3o5KEB5Crfesb7jmPZ" 'False) (C1 ('MetaCons "MiscInstruction" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Instruction)) :+: C1 ('MetaCons "MiscComment" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))
Methods from :: Miscellaneous -> Rep Miscellaneous x # to :: Rep Miscellaneous x -> Miscellaneous #
Show Miscellaneous |
Instance details Defined in Data.XML.Types Methods showsPrec :: Int -> Miscellaneous -> ShowS # show :: Miscellaneous -> String # showList :: [Miscellaneous] -> ShowS #
Eq Miscellaneous |
Instance details Defined in Data.XML.Types Methods (==) :: Miscellaneous -> Miscellaneous -> Bool # (/=) :: Miscellaneous -> Miscellaneous -> Bool #
Ord Miscellaneous |
Instance details Defined in Data.XML.Types Methods compare :: Miscellaneous -> Miscellaneous -> Ordering # (<) :: Miscellaneous -> Miscellaneous -> Bool # (<=) :: Miscellaneous -> Miscellaneous -> Bool # (>) :: Miscellaneous -> Miscellaneous -> Bool # (>=) :: Miscellaneous -> Miscellaneous -> Bool # max :: Miscellaneous -> Miscellaneous -> Miscellaneous # min :: Miscellaneous -> Miscellaneous -> Miscellaneous #
type Rep Miscellaneous |
Instance details Defined in Data.XML.Types type Rep Miscellaneous = D1 ('MetaData "Miscellaneous" "Data.XML.Types" "xml-types-0.3.8-FwSR3o5KEB5Crfesb7jmPZ" 'False) (C1 ('MetaCons "MiscInstruction" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Instruction)) :+: C1 ('MetaCons "MiscComment" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

data Node #

Constructors

NodeElement Element |
NodeInstruction Instruction |
NodeContent Text |
NodeComment Text |

#### Instances

Instances details

ToMarkup Node # |
Instance details Defined in Text.XML Methods toMarkup :: Node -> Markup # preEscapedToMarkup :: Node -> Markup #
NFData Node # |
Instance details Defined in Text.XML Methods rnf :: Node -> () #
Data Node # |
Instance details Defined in Text.XML Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Node -> c Node # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Node # toConstr :: Node -> Constr # dataTypeOf :: Node -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Node) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Node) # gmapT :: (forall b. Data b => b -> b) -> Node -> Node # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Node -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Node -> r # gmapQ :: (forall d. Data d => d -> u) -> Node -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Node -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Node -> m Node # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Node -> m Node # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Node -> m Node #
Show Node # |
Instance details Defined in Text.XML Methods showsPrec :: Int -> Node -> ShowS # show :: Node -> String # showList :: [Node] -> ShowS #
Eq Node # |
Instance details Defined in Text.XML Methods (==) :: Node -> Node -> Bool # (/=) :: Node -> Node -> Bool #
Ord Node # |
Instance details Defined in Text.XML Methods compare :: Node -> Node -> Ordering # (<) :: Node -> Node -> Bool # (<=) :: Node -> Node -> Bool # (>) :: Node -> Node -> Bool # (>=) :: Node -> Node -> Bool # max :: Node -> Node -> Node # min :: Node -> Node -> Node #

data Element #

Constructors

Element |
Fields elementName :: Name elementAttributes :: Map Name Text elementNodes :: [Node]

#### Instances

Instances details

ToMarkup Element # | Note that the special element name `{http:/www.snoyman.comxml2html}ie-cond` with the single attribute `cond` is used to indicate an IE conditional comment.
Instance details Defined in Text.XML Methods toMarkup :: Element -> Markup # preEscapedToMarkup :: Element -> Markup #
NFData Element # |
Instance details Defined in Text.XML Methods rnf :: Element -> () #
Data Element # |
Instance details Defined in Text.XML Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Element -> c Element # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Element # toConstr :: Element -> Constr # dataTypeOf :: Element -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Element) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Element) # gmapT :: (forall b. Data b => b -> b) -> Element -> Element # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Element -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Element -> r # gmapQ :: (forall d. Data d => d -> u) -> Element -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Element -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Element -> m Element # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Element -> m Element # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Element -> m Element #
Show Element # |
Instance details Defined in Text.XML Methods showsPrec :: Int -> Element -> ShowS # show :: Element -> String # showList :: [Element] -> ShowS #
Eq Element # |
Instance details Defined in Text.XML Methods (==) :: Element -> Element -> Bool # (/=) :: Element -> Element -> Bool #
Ord Element # |
Instance details Defined in Text.XML Methods compare :: Element -> Element -> Ordering # (<) :: Element -> Element -> Bool # (<=) :: Element -> Element -> Bool # (>) :: Element -> Element -> Bool # (>=) :: Element -> Element -> Bool # max :: Element -> Element -> Element # min :: Element -> Element -> Element #

data Name #

A fully qualified name.

Prefixes are not semantically important; they are included only to simplify pass-through parsing. When comparing names with `Eq` or `Ord` methods, prefixes are ignored.

The `IsString` instance supports Clark notation; see http://www.jclark.com/xml/xmlns.htm and http://infohost.nmt.edu/tcc/help/pubs/pylxml/etree-QName.html. Use the `OverloadedStrings` language extension for very simple `Name` construction:

    myname :: Name
    myname = "{http://example.com/ns/my-namespace}my-name"

Constructors

Name |
Fields nameLocalName :: Text nameNamespace :: Maybe Text namePrefix :: Maybe Text

#### Instances

Instances details

NFData Name |
Instance details Defined in Data.XML.Types Methods rnf :: Name -> () #
Data Name |
Instance details Defined in Data.XML.Types Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Name -> c Name # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Name # toConstr :: Name -> Constr # dataTypeOf :: Name -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Name) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Name) # gmapT :: (forall b. Data b => b -> b) -> Name -> Name # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r # gmapQ :: (forall d. Data d => d -> u) -> Name -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Name -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Name -> m Name # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Name -> m Name # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Name -> m Name #
IsString Name |
Instance details Defined in Data.XML.Types Methods fromString :: String -> Name #
Generic Name |
Instance details Defined in Data.XML.Types Associated Types
type Rep Name |
Instance details Defined in Data.XML.Types type Rep Name = D1 ('MetaData "Name" "Data.XML.Types" "xml-types-0.3.8-FwSR3o5KEB5Crfesb7jmPZ" 'False) (C1 ('MetaCons "Name" 'PrefixI 'True) (S1 ('MetaSel ('Just "nameLocalName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: (S1 ('MetaSel ('Just "nameNamespace") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Text)) :*: S1 ('MetaSel ('Just "namePrefix") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Text)))))
Methods from :: Name -> Rep Name x # to :: Rep Name x -> Name #
Show Name |
Instance details Defined in Data.XML.Types Methods showsPrec :: Int -> Name -> ShowS # show :: Name -> String # showList :: [Name] -> ShowS #
Eq Name |
Instance details Defined in Data.XML.Types Methods (==) :: Name -> Name -> Bool # (/=) :: Name -> Name -> Bool #
Ord Name |
Instance details Defined in Data.XML.Types Methods compare :: Name -> Name -> Ordering # (<) :: Name -> Name -> Bool # (<=) :: Name -> Name -> Bool # (>) :: Name -> Name -> Bool # (>=) :: Name -> Name -> Bool # max :: Name -> Name -> Name # min :: Name -> Name -> Name #
type Rep Name |
Instance details Defined in Data.XML.Types type Rep Name = D1 ('MetaData "Name" "Data.XML.Types" "xml-types-0.3.8-FwSR3o5KEB5Crfesb7jmPZ" 'False) (C1 ('MetaCons "Name" 'PrefixI 'True) (S1 ('MetaSel ('Just "nameLocalName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: (S1 ('MetaSel ('Just "nameNamespace") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Text)) :*: S1 ('MetaSel ('Just "namePrefix") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe Text)))))

data Doctype #

Note: due to the incredible complexity of DTDs, this type only supports external subsets. I've tried adding internal subset types, but they quickly gain more code than the rest of this module put together.

It is possible that some future version of this library might support internal subsets, but I am no longer actively working on adding them.

Constructors

Doctype |
Fields doctypeName :: Text doctypeID :: Maybe ExternalID

#### Instances

Instances details

NFData Doctype |
Instance details Defined in Data.XML.Types Methods rnf :: Doctype -> () #
Data Doctype |
Instance details Defined in Data.XML.Types Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Doctype -> c Doctype # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Doctype # toConstr :: Doctype -> Constr # dataTypeOf :: Doctype -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Doctype) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Doctype) # gmapT :: (forall b. Data b => b -> b) -> Doctype -> Doctype # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Doctype -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Doctype -> r # gmapQ :: (forall d. Data d => d -> u) -> Doctype -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Doctype -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Doctype -> m Doctype # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Doctype -> m Doctype # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Doctype -> m Doctype #
Generic Doctype |
Instance details Defined in Data.XML.Types Associated Types
type Rep Doctype |
Instance details Defined in Data.XML.Types type Rep Doctype = D1 ('MetaData "Doctype" "Data.XML.Types" "xml-types-0.3.8-FwSR3o5KEB5Crfesb7jmPZ" 'False) (C1 ('MetaCons "Doctype" 'PrefixI 'True) (S1 ('MetaSel ('Just "doctypeName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "doctypeID") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe ExternalID))))
Methods from :: Doctype -> Rep Doctype x # to :: Rep Doctype x -> Doctype #
Show Doctype |
Instance details Defined in Data.XML.Types Methods showsPrec :: Int -> Doctype -> ShowS # show :: Doctype -> String # showList :: [Doctype] -> ShowS #
Eq Doctype |
Instance details Defined in Data.XML.Types Methods (==) :: Doctype -> Doctype -> Bool # (/=) :: Doctype -> Doctype -> Bool #
Ord Doctype |
Instance details Defined in Data.XML.Types Methods compare :: Doctype -> Doctype -> Ordering # (<) :: Doctype -> Doctype -> Bool # (<=) :: Doctype -> Doctype -> Bool # (>) :: Doctype -> Doctype -> Bool # (>=) :: Doctype -> Doctype -> Bool # max :: Doctype -> Doctype -> Doctype # min :: Doctype -> Doctype -> Doctype #
type Rep Doctype |
Instance details Defined in Data.XML.Types type Rep Doctype = D1 ('MetaData "Doctype" "Data.XML.Types" "xml-types-0.3.8-FwSR3o5KEB5Crfesb7jmPZ" 'False) (C1 ('MetaCons "Doctype" 'PrefixI 'True) (S1 ('MetaSel ('Just "doctypeName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "doctypeID") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe ExternalID))))

data ExternalID #

Constructors

SystemID Text |
PublicID Text Text |

#### Instances

Instances details

NFData ExternalID |
Instance details Defined in Data.XML.Types Methods rnf :: ExternalID -> () #
Data ExternalID |
Instance details Defined in Data.XML.Types Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ExternalID -> c ExternalID # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ExternalID # toConstr :: ExternalID -> Constr # dataTypeOf :: ExternalID -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ExternalID) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ExternalID) # gmapT :: (forall b. Data b => b -> b) -> ExternalID -> ExternalID # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ExternalID -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ExternalID -> r # gmapQ :: (forall d. Data d => d -> u) -> ExternalID -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> ExternalID -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ExternalID -> m ExternalID # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ExternalID -> m ExternalID # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ExternalID -> m ExternalID #
Generic ExternalID |
Instance details Defined in Data.XML.Types Associated Types
type Rep ExternalID |
Instance details Defined in Data.XML.Types type Rep ExternalID = D1 ('MetaData "ExternalID" "Data.XML.Types" "xml-types-0.3.8-FwSR3o5KEB5Crfesb7jmPZ" 'False) (C1 ('MetaCons "SystemID" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)) :+: C1 ('MetaCons "PublicID" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))
Methods from :: ExternalID -> Rep ExternalID x # to :: Rep ExternalID x -> ExternalID #
Show ExternalID |
Instance details Defined in Data.XML.Types Methods showsPrec :: Int -> ExternalID -> ShowS # show :: ExternalID -> String # showList :: [ExternalID] -> ShowS #
Eq ExternalID |
Instance details Defined in Data.XML.Types Methods (==) :: ExternalID -> ExternalID -> Bool # (/=) :: ExternalID -> ExternalID -> Bool #
Ord ExternalID |
Instance details Defined in Data.XML.Types Methods compare :: ExternalID -> ExternalID -> Ordering # (<) :: ExternalID -> ExternalID -> Bool # (<=) :: ExternalID -> ExternalID -> Bool # (>) :: ExternalID -> ExternalID -> Bool # (>=) :: ExternalID -> ExternalID -> Bool # max :: ExternalID -> ExternalID -> ExternalID # min :: ExternalID -> ExternalID -> ExternalID #
type Rep ExternalID |
Instance details Defined in Data.XML.Types type Rep ExternalID = D1 ('MetaData "ExternalID" "Data.XML.Types" "xml-types-0.3.8-FwSR3o5KEB5Crfesb7jmPZ" 'False) (C1 ('MetaCons "SystemID" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)) :+: C1 ('MetaCons "PublicID" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

# Parsing

## Files

readFile :: ParseSettings -> FilePath -> IO Document #

## Bytes

parseLBS :: ParseSettings -> ByteString -> Either SomeException Document #

parseLBS_ :: ParseSettings -> ByteString -> Document #

sinkDoc :: forall (m :: Type -> Type) o. MonadThrow m => ParseSettings -> ConduitT ByteString o m Document #

## Text

parseText :: ParseSettings -> Text -> Either SomeException Document #

parseText_ :: ParseSettings -> Text -> Document #

sinkTextDoc :: forall (m :: Type -> Type) o. MonadThrow m => ParseSettings -> ConduitT Text o m Document #

## Other

fromEvents :: forall (m :: Type -> Type) o. MonadThrow m => ConduitT EventPos o m Document #

data UnresolvedEntityException #

Constructors

UnresolvedEntityException (Set Text) |

#### Instances

Instances details

Exception UnresolvedEntityException # |
Instance details Defined in Text.XML Methods toException :: UnresolvedEntityException -> SomeException # fromException :: SomeException -> Maybe UnresolvedEntityException # displayException :: UnresolvedEntityException -> String # backtraceDesired :: UnresolvedEntityException -> Bool #
Show UnresolvedEntityException # |
Instance details Defined in Text.XML Methods showsPrec :: Int -> UnresolvedEntityException -> ShowS # show :: UnresolvedEntityException -> String # showList :: [UnresolvedEntityException] -> ShowS #

data XMLException #

Constructors

InvalidXMLFile FilePath SomeException |

#### Instances

Instances details

Exception XMLException # |
Instance details Defined in Text.XML Methods toException :: XMLException -> SomeException # fromException :: SomeException -> Maybe XMLException # displayException :: XMLException -> String # backtraceDesired :: XMLException -> Bool #
Show XMLException # |
Instance details Defined in Text.XML Methods showsPrec :: Int -> XMLException -> ShowS # show :: XMLException -> String # showList :: [XMLException] -> ShowS #

# Rendering

writeFile :: RenderSettings -> FilePath -> Document -> IO () #

renderLBS :: RenderSettings -> Document -> ByteString #

renderText :: RenderSettings -> Document -> Text #

renderBytes :: forall (m :: Type -> Type) i. PrimMonad m => RenderSettings -> Document -> ConduitT i ByteString m () #

# Settings

def :: Default a => a #

The default value for this type.

## Parsing

data ParseSettings #

#### Instances

Instances details

Default ParseSettings # |
Instance details Defined in Text.XML.Stream.Parse Methods def :: ParseSettings #

psDecodeEntities :: ParseSettings -> DecodeEntities #

psRetainNamespaces :: ParseSettings -> Bool #

Whether the original xmlns attributes should be retained in the parsed values. For more information on motivation, see:

https://github.com/snoyberg/xml/issues/38

Default: False

Since 1.2.1

### Entity decoding

decodeXmlEntities :: DecodeEntities #

Default implementation of `DecodeEntities`, which leaves the entity as-is. Numeric character references and the five standard entities (lt, gt, amp, quot, pos) are handled internally by the parser.

decodeHtmlEntities :: DecodeEntities #

HTML4-compliant entity decoder. Handles the additional 248 entities defined by HTML 4 and XHTML 1.

Note that HTML 5 introduces a drastically larger number of entities, and this code does not recognize most of them.

## Rendering

data RenderSettings #

#### Instances

Instances details

Default RenderSettings # |
Instance details Defined in Text.XML.Stream.Render.Internal Methods def :: RenderSettings #

rsNamespaces :: RenderSettings -> [(Text, Text)] #

Defines some top level namespace definitions to be used, in the form of (prefix, namespace). This has absolutely no impact on the meaning of your documents, but can increase readability by moving commonly used namespace declarations to the top level.

rsAttrOrder :: RenderSettings -> Name -> Map Name Text -> [(Name, Text)] #

Specify how to turn the unordered attributes used by the Text.XML module into an ordered list.

rsUseCDATA :: RenderSettings -> Content -> Bool #

Determines if for a given text content the renderer should use a CDATA node.

Default: `False`

Since: 1.3.3

rsXMLDeclaration :: RenderSettings -> Bool #

Determines whether the XML declaration will be output.

Default: `True`

Since: 1.5.1

orderAttrs :: [(Name, [Name])] -> Name -> Map Name Text -> [(Name, Text)] #

Convenience function to create an ordering function suitable for use as the value of `rsAttrOrder`. The ordering function is created from an explicit ordering of the attributes, specified as a list of tuples, as follows: In each tuple, the first component is the `Name` of an element, and the second component is a list of attributes names. When the given element is rendered, the attributes listed, when present, appear first in the given order, followed by any other attributes in arbitrary order. If an element does not appear, all of its attributes are rendered in arbitrary order.

# Conversion

toXMLDocument :: Document -> Document #

fromXMLDocument :: Document -> Either (Set Text) Document #

toXMLNode :: Node -> Node #

fromXMLNode :: Node -> Either (Set Text) Node #

toXMLElement :: Element -> Element #

fromXMLElement :: Element -> Either (Set Text) Element #