xml-conduit-1.10.1.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 Source #

Constructors

Document |

Fields

- documentPrologue :: Prologue
- documentRoot :: Element
- documentEpilogue :: [Miscellaneous]

#### Instances

Instances details

ToMarkup Document Source # |
Instance details Defined in Text.XML Methods toMarkup :: Document -> Markup Source # preEscapedToMarkup :: Document -> Markup Source #
NFData Document Source # |
Instance details Defined in Text.XML Methods rnf :: Document -> () Source #
Data Document Source # |

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 Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Document Source #

toConstr :: Document -> Constr Source #

dataTypeOf :: Document -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Document) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Document) Source #

gmapT :: (forall b. Data b => b -> b) -> Document -> Document Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Document -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Document -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Document -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Document -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Document -> m Document Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Document -> m Document Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Document -> m Document Source #

Show Document Source # |
Instance details Defined in Text.XML Methods showsPrec :: Int -> Document -> ShowS Source # show :: Document -> String Source # showList :: [Document] -> ShowS Source #
Eq Document Source # |
Instance details Defined in Text.XML Methods (==) :: Document -> Document -> Bool Source # (/=) :: Document -> Document -> Bool Source #

data Prologue Source #

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 -> () Source #
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 Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Prologue Source #

toConstr :: Prologue -> Constr Source #

dataTypeOf :: Prologue -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Prologue) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Prologue) Source #

gmapT :: (forall b. Data b => b -> b) -> Prologue -> Prologue Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Prologue -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Prologue -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Prologue -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Prologue -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Prologue -> m Prologue Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Prologue -> m Prologue Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Prologue -> m Prologue Source #

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-CPraXujWO7hCdGwznbCwrz" '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 Source #

to :: Rep Prologue x -> Prologue Source #

Show Prologue |
Instance details Defined in Data.XML.Types Methods showsPrec :: Int -> Prologue -> ShowS Source # show :: Prologue -> String Source # showList :: [Prologue] -> ShowS Source #
Eq Prologue |
Instance details Defined in Data.XML.Types Methods (==) :: Prologue -> Prologue -> Bool Source # (/=) :: Prologue -> Prologue -> Bool Source #
Ord Prologue |
Instance details Defined in Data.XML.Types Methods compare :: Prologue -> Prologue -> Ordering Source # (<) :: Prologue -> Prologue -> Bool Source # (<=) :: Prologue -> Prologue -> Bool Source # (>) :: Prologue -> Prologue -> Bool Source # (>=) :: Prologue -> Prologue -> Bool Source # max :: Prologue -> Prologue -> Prologue Source # min :: Prologue -> Prologue -> Prologue Source #
type Rep Prologue |

Instance details

Defined in Data.XML.Types

type Rep Prologue = D1 ('MetaData "Prologue" "Data.XML.Types" "xml-types-0.3.8-CPraXujWO7hCdGwznbCwrz" '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 Source #

Constructors

Instruction |

Fields

- instructionTarget :: Text
- instructionData :: Text

#### Instances

Instances details

NFData Instruction |
Instance details Defined in Data.XML.Types Methods rnf :: Instruction -> () Source #
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 Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Instruction Source #

toConstr :: Instruction -> Constr Source #

dataTypeOf :: Instruction -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Instruction) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Instruction) Source #

gmapT :: (forall b. Data b => b -> b) -> Instruction -> Instruction Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Instruction -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Instruction -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Instruction -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Instruction -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Instruction -> m Instruction Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Instruction -> m Instruction Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Instruction -> m Instruction Source #

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-CPraXujWO7hCdGwznbCwrz" '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 Source #

to :: Rep Instruction x -> Instruction Source #

Show Instruction |
Instance details Defined in Data.XML.Types Methods showsPrec :: Int -> Instruction -> ShowS Source # show :: Instruction -> String Source # showList :: [Instruction] -> ShowS Source #
Eq Instruction |
Instance details Defined in Data.XML.Types Methods (==) :: Instruction -> Instruction -> Bool Source # (/=) :: Instruction -> Instruction -> Bool Source #
Ord Instruction |

Instance details

Defined in Data.XML.Types

Methods

compare :: Instruction -> Instruction -> Ordering Source #

(<) :: Instruction -> Instruction -> Bool Source #

(<=) :: Instruction -> Instruction -> Bool Source #

(>) :: Instruction -> Instruction -> Bool Source #

(>=) :: Instruction -> Instruction -> Bool Source #

max :: Instruction -> Instruction -> Instruction Source #

min :: Instruction -> Instruction -> Instruction Source #

type Rep Instruction |

Instance details

Defined in Data.XML.Types

type Rep Instruction = D1 ('MetaData "Instruction" "Data.XML.Types" "xml-types-0.3.8-CPraXujWO7hCdGwznbCwrz" '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 Source #

Constructors

MiscInstruction Instruction |
MiscComment Text |

#### Instances

Instances details

NFData Miscellaneous |
Instance details Defined in Data.XML.Types Methods rnf :: Miscellaneous -> () Source #
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 Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Miscellaneous Source #

toConstr :: Miscellaneous -> Constr Source #

dataTypeOf :: Miscellaneous -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Miscellaneous) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Miscellaneous) Source #

gmapT :: (forall b. Data b => b -> b) -> Miscellaneous -> Miscellaneous Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Miscellaneous -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Miscellaneous -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Miscellaneous -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Miscellaneous -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Miscellaneous -> m Miscellaneous Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Miscellaneous -> m Miscellaneous Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Miscellaneous -> m Miscellaneous Source #

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-CPraXujWO7hCdGwznbCwrz" '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 Source #

to :: Rep Miscellaneous x -> Miscellaneous Source #

Show Miscellaneous |
Instance details Defined in Data.XML.Types Methods showsPrec :: Int -> Miscellaneous -> ShowS Source # show :: Miscellaneous -> String Source # showList :: [Miscellaneous] -> ShowS Source #
Eq Miscellaneous |
Instance details Defined in Data.XML.Types Methods (==) :: Miscellaneous -> Miscellaneous -> Bool Source # (/=) :: Miscellaneous -> Miscellaneous -> Bool Source #
Ord Miscellaneous |

Instance details

Defined in Data.XML.Types

Methods

compare :: Miscellaneous -> Miscellaneous -> Ordering Source #

(<) :: Miscellaneous -> Miscellaneous -> Bool Source #

(<=) :: Miscellaneous -> Miscellaneous -> Bool Source #

(>) :: Miscellaneous -> Miscellaneous -> Bool Source #

(>=) :: Miscellaneous -> Miscellaneous -> Bool Source #

max :: Miscellaneous -> Miscellaneous -> Miscellaneous Source #

min :: Miscellaneous -> Miscellaneous -> Miscellaneous Source #

type Rep Miscellaneous |

Instance details

Defined in Data.XML.Types

type Rep Miscellaneous = D1 ('MetaData "Miscellaneous" "Data.XML.Types" "xml-types-0.3.8-CPraXujWO7hCdGwznbCwrz" '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 Source #

Constructors

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

#### Instances

Instances details

ToMarkup Node Source # |
Instance details Defined in Text.XML Methods toMarkup :: Node -> Markup Source # preEscapedToMarkup :: Node -> Markup Source #
NFData Node Source # |
Instance details Defined in Text.XML Methods rnf :: Node -> () Source #
Data Node Source # |

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 Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Node Source #

toConstr :: Node -> Constr Source #

dataTypeOf :: Node -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Node) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Node) Source #

gmapT :: (forall b. Data b => b -> b) -> Node -> Node Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Node -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Node -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Node -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Node -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Node -> m Node Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Node -> m Node Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Node -> m Node Source #

Show Node Source # |
Instance details Defined in Text.XML Methods showsPrec :: Int -> Node -> ShowS Source # show :: Node -> String Source # showList :: [Node] -> ShowS Source #
Eq Node Source # |
Instance details Defined in Text.XML Methods (==) :: Node -> Node -> Bool Source # (/=) :: Node -> Node -> Bool Source #
Ord Node Source # |
Instance details Defined in Text.XML Methods compare :: Node -> Node -> Ordering Source # (<) :: Node -> Node -> Bool Source # (<=) :: Node -> Node -> Bool Source # (>) :: Node -> Node -> Bool Source # (>=) :: Node -> Node -> Bool Source # max :: Node -> Node -> Node Source # min :: Node -> Node -> Node Source #

data Element Source #

Constructors

Element |

Fields

- elementName :: Name
- elementAttributes :: Map Name Text
- elementNodes :: [Node]

#### Instances

Instances details

ToMarkup Element Source # | 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 Source # preEscapedToMarkup :: Element -> Markup Source #
NFData Element Source # |
Instance details Defined in Text.XML Methods rnf :: Element -> () Source #
Data Element Source # |

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 Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Element Source #

toConstr :: Element -> Constr Source #

dataTypeOf :: Element -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Element) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Element) Source #

gmapT :: (forall b. Data b => b -> b) -> Element -> Element Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Element -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Element -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Element -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Element -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Element -> m Element Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Element -> m Element Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Element -> m Element Source #

Show Element Source # |
Instance details Defined in Text.XML Methods showsPrec :: Int -> Element -> ShowS Source # show :: Element -> String Source # showList :: [Element] -> ShowS Source #
Eq Element Source # |
Instance details Defined in Text.XML Methods (==) :: Element -> Element -> Bool Source # (/=) :: Element -> Element -> Bool Source #
Ord Element Source # |
Instance details Defined in Text.XML Methods compare :: Element -> Element -> Ordering Source # (<) :: Element -> Element -> Bool Source # (<=) :: Element -> Element -> Bool Source # (>) :: Element -> Element -> Bool Source # (>=) :: Element -> Element -> Bool Source # max :: Element -> Element -> Element Source # min :: Element -> Element -> Element Source #

data Name Source #

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 -> () Source #
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 Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Name Source #

toConstr :: Name -> Constr Source #

dataTypeOf :: Name -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Name) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Name) Source #

gmapT :: (forall b. Data b => b -> b) -> Name -> Name Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Name -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Name -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Name -> m Name Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Name -> m Name Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Name -> m Name Source #

IsString Name |
Instance details Defined in Data.XML.Types Methods fromString :: String -> Name Source #
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-CPraXujWO7hCdGwznbCwrz" '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 Source #

to :: Rep Name x -> Name Source #

Show Name |
Instance details Defined in Data.XML.Types Methods showsPrec :: Int -> Name -> ShowS Source # show :: Name -> String Source # showList :: [Name] -> ShowS Source #
Eq Name |
Instance details Defined in Data.XML.Types Methods (==) :: Name -> Name -> Bool Source # (/=) :: Name -> Name -> Bool Source #
Ord Name |
Instance details Defined in Data.XML.Types Methods compare :: Name -> Name -> Ordering Source # (<) :: Name -> Name -> Bool Source # (<=) :: Name -> Name -> Bool Source # (>) :: Name -> Name -> Bool Source # (>=) :: Name -> Name -> Bool Source # max :: Name -> Name -> Name Source # min :: Name -> Name -> Name Source #
type Rep Name |

Instance details

Defined in Data.XML.Types

type Rep Name = D1 ('MetaData "Name" "Data.XML.Types" "xml-types-0.3.8-CPraXujWO7hCdGwznbCwrz" '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 Source #

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 -> () Source #
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 Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Doctype Source #

toConstr :: Doctype -> Constr Source #

dataTypeOf :: Doctype -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Doctype) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Doctype) Source #

gmapT :: (forall b. Data b => b -> b) -> Doctype -> Doctype Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Doctype -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Doctype -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> Doctype -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Doctype -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Doctype -> m Doctype Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Doctype -> m Doctype Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Doctype -> m Doctype Source #

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-CPraXujWO7hCdGwznbCwrz" '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 Source #

to :: Rep Doctype x -> Doctype Source #

Show Doctype |
Instance details Defined in Data.XML.Types Methods showsPrec :: Int -> Doctype -> ShowS Source # show :: Doctype -> String Source # showList :: [Doctype] -> ShowS Source #
Eq Doctype |
Instance details Defined in Data.XML.Types Methods (==) :: Doctype -> Doctype -> Bool Source # (/=) :: Doctype -> Doctype -> Bool Source #
Ord Doctype |
Instance details Defined in Data.XML.Types Methods compare :: Doctype -> Doctype -> Ordering Source # (<) :: Doctype -> Doctype -> Bool Source # (<=) :: Doctype -> Doctype -> Bool Source # (>) :: Doctype -> Doctype -> Bool Source # (>=) :: Doctype -> Doctype -> Bool Source # max :: Doctype -> Doctype -> Doctype Source # min :: Doctype -> Doctype -> Doctype Source #
type Rep Doctype |

Instance details

Defined in Data.XML.Types

type Rep Doctype = D1 ('MetaData "Doctype" "Data.XML.Types" "xml-types-0.3.8-CPraXujWO7hCdGwznbCwrz" '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 Source #

Constructors

SystemID Text |
PublicID Text Text |

#### Instances

Instances details

NFData ExternalID |
Instance details Defined in Data.XML.Types Methods rnf :: ExternalID -> () Source #
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 Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ExternalID Source #

toConstr :: ExternalID -> Constr Source #

dataTypeOf :: ExternalID -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ExternalID) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ExternalID) Source #

gmapT :: (forall b. Data b => b -> b) -> ExternalID -> ExternalID Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ExternalID -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ExternalID -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> ExternalID -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> ExternalID -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> ExternalID -> m ExternalID Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ExternalID -> m ExternalID Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ExternalID -> m ExternalID Source #

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-CPraXujWO7hCdGwznbCwrz" '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 Source #

to :: Rep ExternalID x -> ExternalID Source #

Show ExternalID |
Instance details Defined in Data.XML.Types Methods showsPrec :: Int -> ExternalID -> ShowS Source # show :: ExternalID -> String Source # showList :: [ExternalID] -> ShowS Source #
Eq ExternalID |
Instance details Defined in Data.XML.Types Methods (==) :: ExternalID -> ExternalID -> Bool Source # (/=) :: ExternalID -> ExternalID -> Bool Source #
Ord ExternalID |

Instance details

Defined in Data.XML.Types

Methods

compare :: ExternalID -> ExternalID -> Ordering Source #

(<) :: ExternalID -> ExternalID -> Bool Source #

(<=) :: ExternalID -> ExternalID -> Bool Source #

(>) :: ExternalID -> ExternalID -> Bool Source #

(>=) :: ExternalID -> ExternalID -> Bool Source #

max :: ExternalID -> ExternalID -> ExternalID Source #

min :: ExternalID -> ExternalID -> ExternalID Source #

type Rep ExternalID |

Instance details

Defined in Data.XML.Types

type Rep ExternalID = D1 ('MetaData "ExternalID" "Data.XML.Types" "xml-types-0.3.8-CPraXujWO7hCdGwznbCwrz" '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 Source #

## Bytes

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

parseLBS_ :: ParseSettings -> ByteString -> Document Source #

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

## Text

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

parseText_ :: ParseSettings -> Text -> Document Source #

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

## Other

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

data UnresolvedEntityException Source #

Constructors

UnresolvedEntityException (Set Text) |

#### Instances

Instances details

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

data XMLException Source #

Constructors

InvalidXMLFile FilePath SomeException |

#### Instances

Instances details

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

# Rendering

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

renderLBS :: RenderSettings -> Document -> ByteString Source #

renderText :: RenderSettings -> Document -> Text Source #

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

# Settings

def :: Default a => a Source #

The default value for this type.

## Parsing

data ParseSettings Source #

#### Instances

Instances details

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

psDecodeEntities :: ParseSettings -> DecodeEntities Source #

psRetainNamespaces :: ParseSettings -> Bool Source #

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 Source #

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 Source #

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 Source #

#### Instances

Instances details

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

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

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)] Source #

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

rsUseCDATA :: RenderSettings -> Content -> Bool Source #

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

Default: `False`

Since: 1.3.3

rsXMLDeclaration :: RenderSettings -> Bool Source #

Determines whether the XML declaration will be output. Note that when using the streaming API the XML declaration will be output only if this is set to true and the stream includes an `EventBeginDocument` event. Apart from yielding it explicitly, this can be achieved by wrapping the stream in the `document` function.

Default: `True`

Since: 1.5.1

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

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 Source #

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

toXMLNode :: Node -> Node Source #

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

toXMLElement :: Element -> Element Source #

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