Portability | non-portable |
---|---|
Stability | experimental |
Maintainer | Fumiaki Kinoshita <fumiexcel@gmail.com> |
Safe Haskell | None |
Useful traversals inspired by XPath
- data Element = Element {
- elementName :: Name
- elementAttributes :: Map Name Text
- elementNodes :: [Node]
- (./) :: Plated a => Traversal s t a a -> Traversal a a u v -> Traversal s t u v
- name :: Lens' Element Name
- localName :: Lens' Element Text
- el :: Name -> Traversal' Element Element
- ell :: Text -> Traversal' Element Element
- attributeIs :: Name -> Text -> Traversal' Element Element
- attributeSatisfies :: Name -> (Text -> Bool) -> Traversal' Element Element
- attr :: Name -> Traversal' Element Text
- attribute :: Name -> Lens' Element (Maybe Text)
- attrs :: Lens' Element (Map Name Text)
- text :: Traversal' Element Text
- comment :: Traversal' Element Text
- entire :: Traversal' Element Element
- nodes :: Lens' Element [Node]
- data Node
- _Element :: Prism' Node Element
- _Content :: Prism' Node Text
- class AsInstruction t where
- class AsComment t where
- data Document = Document {}
- root :: Lens' Document Element
- prologue :: Lens' Document Prologue
- epilogue :: Lens' Document [Miscellaneous]
- doctype :: Lens' Prologue (Maybe Doctype)
- data Name = Name {
- nameLocalName :: Text
- nameNamespace :: Maybe Text
- namePrefix :: Maybe Text
- _nameLocalName :: Lens' Name Text
- _nameNamespace :: Lens' Name (Maybe Text)
- _namePrefix :: Lens' Name (Maybe Text)
- data Instruction = Instruction {}
- _instructionTarget :: Lens' Instruction Text
- _instructionData :: Lens' Instruction Text
- module Control.Lens
Lenses, traversals for Element
data Element
Element | |
|
Names
ell :: Text -> Traversal' Element ElementSource
Traverse elements which has the specified *local* name.
Attributes
attributeIs :: Name -> Text -> Traversal' Element ElementSource
attributeSatisfies :: Name -> (Text -> Bool) -> Traversal' Element ElementSource
Contents
text :: Traversal' Element TextSource
Traverse all contents of the element.
comment :: Traversal' Element TextSource
Traverse all comments of the element.
Children
entire :: Traversal' Element ElementSource
Traverse itself with its all children. Rewriting subnodes of each children will break a traversal law.
Prisms for Node
data Node
class AsInstruction t whereSource
Lenses for Document
data Document
Lenses for Name
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"
Name | |
|
_nameNamespace :: Lens' Name (Maybe Text)Source
_namePrefix :: Lens' Name (Maybe Text)Source
Lenses for Instruction
data Instruction
Eq Instruction | |
Data Instruction | |
Ord Instruction | |
Show Instruction | |
Typeable Instruction | |
NFData Instruction |
Reexport
module Control.Lens