Copyright | 2010-2011 John Millikin |
---|---|
License | MIT |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Basic types for representing XML.
The idea is to have a full set of appropriate types, which various XML libraries can share. Instead of having equivalent-but-incompatible types for every binding, parser, or client, they all share the same types can can thus interoperate easily.
This library contains complete types for most parts of an XML document, including the prologue, node tree, and doctype. Some basic combinators are included for common tasks, including traversing the node tree and filtering children.
Synopsis
- data Document = Document {}
- data Prologue = Prologue {}
- data Instruction = Instruction {}
- data Miscellaneous
- data Node
- data Element = Element {
- elementName :: Name
- elementAttributes :: [(Name, [Content])]
- elementNodes :: [Node]
- data Content
- data Name = Name {}
- data Doctype = Doctype {}
- data ExternalID
- data Event
- isElement :: Node -> [Element]
- isInstruction :: Node -> [Instruction]
- isContent :: Node -> [Content]
- isComment :: Node -> [Text]
- isNamed :: Name -> Element -> [Element]
- elementChildren :: Element -> [Element]
- elementContent :: Element -> [Content]
- elementText :: Element -> [Text]
- nodeChildren :: Node -> [Node]
- nodeContent :: Node -> [Content]
- nodeText :: Node -> [Text]
- hasAttribute :: Name -> Element -> [Element]
- hasAttributeText :: Name -> (Text -> Bool) -> Element -> [Element]
- attributeContent :: Name -> Element -> Maybe [Content]
- attributeText :: Name -> Element -> Maybe Text
Types
Document prologue
Instances
Data Document Source # | |
Defined in Data.XML.Types 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 # | |
Generic Document Source # | |
Show Document Source # | |
NFData Document Source # | |
Defined in Data.XML.Types | |
Eq Document Source # | |
Ord Document Source # | |
Defined in Data.XML.Types | |
type Rep Document Source # | |
Defined in Data.XML.Types type Rep Document = D1 ('MetaData "Document" "Data.XML.Types" "xml-types-0.3.8-IpGyuvvNOu2AH1SOobl25" 'False) (C1 ('MetaCons "Document" 'PrefixI 'True) (S1 ('MetaSel ('Just "documentPrologue") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Prologue) :*: (S1 ('MetaSel ('Just "documentRoot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Element) :*: S1 ('MetaSel ('Just "documentEpilogue") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Miscellaneous])))) |
Instances
Data Prologue Source # | |
Defined in Data.XML.Types 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 Source # | |
Show Prologue Source # | |
NFData Prologue Source # | |
Defined in Data.XML.Types | |
Eq Prologue Source # | |
Ord Prologue Source # | |
Defined in Data.XML.Types | |
type Rep Prologue Source # | |
Defined in Data.XML.Types type Rep Prologue = D1 ('MetaData "Prologue" "Data.XML.Types" "xml-types-0.3.8-IpGyuvvNOu2AH1SOobl25" '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 #
Instances
data Miscellaneous Source #
Instances
Document body
Instances
Data Node Source # | |
Defined in Data.XML.Types 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 # | |
IsString Node Source # | |
Defined in Data.XML.Types fromString :: String -> Node Source # | |
Generic Node Source # | |
Show Node Source # | |
NFData Node Source # | |
Defined in Data.XML.Types | |
Eq Node Source # | |
Ord Node Source # | |
type Rep Node Source # | |
Defined in Data.XML.Types type Rep Node = D1 ('MetaData "Node" "Data.XML.Types" "xml-types-0.3.8-IpGyuvvNOu2AH1SOobl25" 'False) ((C1 ('MetaCons "NodeElement" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Element)) :+: C1 ('MetaCons "NodeInstruction" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Instruction))) :+: (C1 ('MetaCons "NodeContent" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Content)) :+: C1 ('MetaCons "NodeComment" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))) |
Element | |
|
Instances
Data Element Source # | |
Defined in Data.XML.Types 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 # | |
Generic Element Source # | |
Show Element Source # | |
NFData Element Source # | |
Defined in Data.XML.Types | |
Eq Element Source # | |
Ord Element Source # | |
type Rep Element Source # | |
Defined in Data.XML.Types type Rep Element = D1 ('MetaData "Element" "Data.XML.Types" "xml-types-0.3.8-IpGyuvvNOu2AH1SOobl25" 'False) (C1 ('MetaCons "Element" 'PrefixI 'True) (S1 ('MetaSel ('Just "elementName") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Name) :*: (S1 ('MetaSel ('Just "elementAttributes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [(Name, [Content])]) :*: S1 ('MetaSel ('Just "elementNodes") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Node])))) |
ContentText Text | |
ContentEntity Text | For pass-through parsing |
Instances
Data Content Source # | |
Defined in Data.XML.Types gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Content -> c Content Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Content Source # toConstr :: Content -> Constr Source # dataTypeOf :: Content -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Content) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Content) Source # gmapT :: (forall b. Data b => b -> b) -> Content -> Content Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Content -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Content -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Content -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Content -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Content -> m Content Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Content -> m Content Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Content -> m Content Source # | |
IsString Content Source # | |
Defined in Data.XML.Types fromString :: String -> Content Source # | |
Generic Content Source # | |
Show Content Source # | |
NFData Content Source # | |
Defined in Data.XML.Types | |
Eq Content Source # | |
Ord Content Source # | |
type Rep Content Source # | |
Defined in Data.XML.Types type Rep Content = D1 ('MetaData "Content" "Data.XML.Types" "xml-types-0.3.8-IpGyuvvNOu2AH1SOobl25" 'False) (C1 ('MetaCons "ContentText" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)) :+: C1 ('MetaCons "ContentEntity" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text))) |
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"
Name | |
|
Instances
Data Name Source # | |
Defined in Data.XML.Types 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 Source # | |
Defined in Data.XML.Types fromString :: String -> Name Source # | |
Generic Name Source # | |
Show Name Source # | |
NFData Name Source # | |
Defined in Data.XML.Types | |
Eq Name Source # | |
Ord Name Source # | |
type Rep Name Source # | |
Defined in Data.XML.Types type Rep Name = D1 ('MetaData "Name" "Data.XML.Types" "xml-types-0.3.8-IpGyuvvNOu2AH1SOobl25" '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))))) |
Doctypes
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.
Instances
Data Doctype Source # | |
Defined in Data.XML.Types 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 Source # | |
Show Doctype Source # | |
NFData Doctype Source # | |
Defined in Data.XML.Types | |
Eq Doctype Source # | |
Ord Doctype Source # | |
type Rep Doctype Source # | |
Defined in Data.XML.Types type Rep Doctype = D1 ('MetaData "Doctype" "Data.XML.Types" "xml-types-0.3.8-IpGyuvvNOu2AH1SOobl25" '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 #
Instances
Incremental processing
Some XML processing tools are incremental, and work in terms of events
rather than node trees. The Event
type allows a document to be fully
specified as a sequence of events.
Event-based XML libraries include:
Instances
Combinators
Filters
isInstruction :: Node -> [Instruction] Source #
Element traversal
elementChildren :: Element -> [Element] Source #
elementContent :: Element -> [Content] Source #
elementText :: Element -> [Text] Source #
Node traversal
nodeChildren :: Node -> [Node] Source #
nodeContent :: Node -> [Content] Source #