Safe Haskell | Safe-Infered |
---|
Text.XML
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.
- data Document = Document {}
- data Prologue = Prologue {}
- data Instruction = Instruction {}
- data Miscellaneous
- data Node
- data Element = Element {
- elementName :: Name
- elementAttributes :: [(Name, Text)]
- elementNodes :: [Node]
- data Name = Name {}
- data Doctype = Doctype {}
- data ExternalID
- readFile :: ParseSettings -> FilePath -> IO (Either SomeException Document)
- readFile_ :: ParseSettings -> FilePath -> IO Document
- parseLBS :: ParseSettings -> ByteString -> Either SomeException Document
- parseLBS_ :: ParseSettings -> ByteString -> Document
- parseEnum :: Monad m => ParseSettings -> Enumerator ByteString m Document -> m (Either SomeException Document)
- parseEnum_ :: Monad m => ParseSettings -> Enumerator ByteString m Document -> m Document
- parseText :: ParseSettings -> Text -> Either SomeException Document
- parseText_ :: ParseSettings -> Text -> Document
- parseTextEnum :: Monad m => ParseSettings -> Enumerator Text m Document -> m (Either SomeException Document)
- parseTextEnum_ :: Monad m => ParseSettings -> Enumerator Text m Document -> m Document
- fromEvents :: Monad m => Iteratee Event m Document
- data UnresolvedEntityException = UnresolvedEntityException (Set Text)
- writeFile :: RenderSettings -> FilePath -> Document -> IO ()
- renderLBS :: RenderSettings -> Document -> ByteString
- renderText :: RenderSettings -> Document -> Text
- renderBytes :: MonadIO m => RenderSettings -> Document -> Enumerator ByteString m a
- def :: Default a => a
- data ParseSettings
- psDecodeEntities :: ParseSettings -> DecodeEntities
- data RenderSettings
- rsPretty :: RenderSettings -> Bool
- 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
Constructors
Document | |
Fields |
data Miscellaneous
Constructors
MiscInstruction Instruction | |
MiscComment Text |
Constructors
NodeElement Element | |
NodeInstruction Instruction | |
NodeContent Text | |
NodeComment Text |
Constructors
Element | |
Fields
|
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
|
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
|
data ExternalID
Instances
Parsing
Files
readFile :: ParseSettings -> FilePath -> IO (Either SomeException Document)Source
Bytes
parseLBS_ :: ParseSettings -> ByteString -> DocumentSource
parseEnum :: Monad m => ParseSettings -> Enumerator ByteString m Document -> m (Either SomeException Document)Source
parseEnum_ :: Monad m => ParseSettings -> Enumerator ByteString m Document -> m DocumentSource
Text
parseText_ :: ParseSettings -> Text -> DocumentSource
parseTextEnum :: Monad m => ParseSettings -> Enumerator Text m Document -> m (Either SomeException Document)Source
parseTextEnum_ :: Monad m => ParseSettings -> Enumerator Text m Document -> m DocumentSource
Other
data UnresolvedEntityException Source
Constructors
UnresolvedEntityException (Set Text) |
Rendering
renderLBS :: RenderSettings -> Document -> ByteStringSource
renderText :: RenderSettings -> Document -> TextSource
renderBytes :: MonadIO m => RenderSettings -> Document -> Enumerator ByteString m aSource
Settings
Parsing
data ParseSettings Source
Instances
Rendering
data RenderSettings Source
Instances
rsPretty :: RenderSettings -> BoolSource
Conversion
toXMLElement :: Element -> ElementSource