-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A light-weight XML library -- -- Light-weight XML library derived from the `xml` package for -- simple parsing and creation of XML documents. It only depends on -- base, deepseq, bytestring, text, -- and text-short. -- -- This library provides support for the following specifications: -- -- @package X @version 0.2.0.0 -- | Basic XML types. module Text.XML.Types type Root = Root' Content -- | Represents the implicit root node of an XML document data Root' cnode Root :: Maybe XmlDeclaration -> MiscNodes -> Maybe (Text, MiscNodes) -> Element' cnode -> MiscNodes -> Root' cnode -- | (optional) XML declaration [rootXmlDeclaration] :: Root' cnode -> Maybe XmlDeclaration -- | Miscellaneous nodes before root element & DOCTYPE declaration [rootPreElem] :: Root' cnode -> MiscNodes -- | optional DOCTYPE declaration and more miscellaneous nodes between -- DOCTYPE and root element [rootDoctype] :: Root' cnode -> Maybe (Text, MiscNodes) -- | The single root document element [rootElement] :: Root' cnode -> Element' cnode -- | Miscellaneous nodes after root element [rootPostElem] :: Root' cnode -> MiscNodes -- | Sequence of "miscellaneous" nodes type MiscNodes = [Either Comment PI] -- | Denotes the version="1.0" encoding="..." standalone="..." -- ? declaration data XmlDeclaration XmlDeclaration :: Maybe ShortText -> Maybe Bool -> XmlDeclaration -- | Processing instruction data PI PI :: !ShortText -> !Text -> PI -- | Invariant: MUST not be [Xx][Mm][Ll] [piTarget] :: PI -> !ShortText -- | Invariant: MUST not contain ?> [piData] :: PI -> !Text -- | Represents a XML comment -- -- Invariant: SHOULD not contain -- (occurences of -- -- will be automatically substituted by -~ on serialization) newtype Comment Comment :: Text -> Comment -- | XML content data Content Elem :: Element -> Content Text :: CData -> Content CRef :: !ShortText -> Content Proc :: PI -> Content Comm :: Comment -> Content type Element = Element' Content -- | XML elements data Element' cnode Element :: !QName -> [Attr] -> [cnode] -> Element' cnode [elName] :: Element' cnode -> !QName [elAttribs] :: Element' cnode -> [Attr] [elContent] :: Element' cnode -> [cnode] -- | XML attributes data Attr Attr :: !QName -> !Text -> Attr [attrKey] :: Attr -> !QName [attrVal] :: Attr -> !Text -- | XML CData data CData CData :: !CDataKind -> !Text -> CData [cdVerbatim] :: CData -> !CDataKind [cdData] :: CData -> !Text data CDataKind -- | Ordinary character data; pretty printer escapes &, < etc. CDataText :: CDataKind -- | Unescaped character data; pretty printer embeds it in <![CDATA[.. CDataVerbatim :: CDataKind -- | As-is character data; pretty printer passes it along without any -- escaping or CDATA wrap-up. CDataRaw :: CDataKind -- | A NCName -- -- NB: Among other properties this means that an NCName shall -- never be the empty string. type NCName = ShortText -- | XML (expanded) qualified names data QName QName :: !LName -> Maybe URI -> Maybe NCName -> QName [qLName] :: QName -> !LName [qURI] :: QName -> Maybe URI -- | Invariant: MUST be a proper NCName [qPrefix] :: QName -> Maybe NCName -- | XML local names -- -- Invariant: MUST be a proper NCName newtype LName LName :: NCName -> LName [unLName] :: LName -> NCName -- | URIs resembling anyURI -- -- Invariant: MUST not be "" newtype URI URI :: ShortText -> URI [unURI] :: URI -> ShortText -- | Position expressed in number of code-points -- -- A negative value denotes EOF type Pos = Int -- | Blank names blank_name :: QName -- | Blank cdata blank_cdata :: CData -- | Blank elements blank_element :: Element -- | Smart constructor for xmlns:<prefix> = -- <namespace-uri> xmlns_attr :: NCName -> URI -> Attr -- | Smart constructor for xmlns = [<namespace-uri>|""] xmlns_def_attr :: Maybe URI -> Attr instance Data.Traversable.Traversable Text.XML.Types.Root' instance Data.Foldable.Foldable Text.XML.Types.Root' instance GHC.Base.Functor Text.XML.Types.Root' instance GHC.Generics.Generic (Text.XML.Types.Root' cnode) instance Data.Data.Data cnode => Data.Data.Data (Text.XML.Types.Root' cnode) instance GHC.Show.Show cnode => GHC.Show.Show (Text.XML.Types.Root' cnode) instance GHC.Generics.Generic Text.XML.Types.Content instance Data.Data.Data Text.XML.Types.Content instance GHC.Show.Show Text.XML.Types.Content instance Data.Traversable.Traversable Text.XML.Types.Element' instance Data.Foldable.Foldable Text.XML.Types.Element' instance GHC.Base.Functor Text.XML.Types.Element' instance GHC.Generics.Generic (Text.XML.Types.Element' cnode) instance Data.Data.Data cnode => Data.Data.Data (Text.XML.Types.Element' cnode) instance GHC.Show.Show cnode => GHC.Show.Show (Text.XML.Types.Element' cnode) instance GHC.Generics.Generic Text.XML.Types.Attr instance Data.Data.Data Text.XML.Types.Attr instance GHC.Show.Show Text.XML.Types.Attr instance GHC.Classes.Ord Text.XML.Types.Attr instance GHC.Classes.Eq Text.XML.Types.Attr instance GHC.Generics.Generic Text.XML.Types.QName instance Data.Data.Data Text.XML.Types.QName instance GHC.Show.Show Text.XML.Types.QName instance GHC.Generics.Generic Text.XML.Types.URI instance Control.DeepSeq.NFData Text.XML.Types.URI instance Data.String.IsString Text.XML.Types.URI instance Data.Data.Data Text.XML.Types.URI instance GHC.Classes.Eq Text.XML.Types.URI instance GHC.Classes.Ord Text.XML.Types.URI instance GHC.Generics.Generic Text.XML.Types.LName instance Control.DeepSeq.NFData Text.XML.Types.LName instance Data.String.IsString Text.XML.Types.LName instance Data.Data.Data Text.XML.Types.LName instance GHC.Classes.Eq Text.XML.Types.LName instance GHC.Classes.Ord Text.XML.Types.LName instance GHC.Generics.Generic Text.XML.Types.CData instance Data.Data.Data Text.XML.Types.CData instance GHC.Show.Show Text.XML.Types.CData instance GHC.Generics.Generic Text.XML.Types.CDataKind instance Data.Data.Data Text.XML.Types.CDataKind instance GHC.Show.Show Text.XML.Types.CDataKind instance GHC.Classes.Eq Text.XML.Types.CDataKind instance Control.DeepSeq.NFData Text.XML.Types.Comment instance GHC.Generics.Generic Text.XML.Types.Comment instance Data.Data.Data Text.XML.Types.Comment instance GHC.Show.Show Text.XML.Types.Comment instance GHC.Generics.Generic Text.XML.Types.PI instance Data.Data.Data Text.XML.Types.PI instance GHC.Show.Show Text.XML.Types.PI instance GHC.Generics.Generic Text.XML.Types.XmlDeclaration instance Data.Data.Data Text.XML.Types.XmlDeclaration instance GHC.Show.Show Text.XML.Types.XmlDeclaration instance Control.DeepSeq.NFData cnode => Control.DeepSeq.NFData (Text.XML.Types.Root' cnode) instance Control.DeepSeq.NFData Text.XML.Types.Content instance Control.DeepSeq.NFData cnode => Control.DeepSeq.NFData (Text.XML.Types.Element' cnode) instance Control.DeepSeq.NFData Text.XML.Types.Attr instance Control.DeepSeq.NFData Text.XML.Types.QName instance GHC.Classes.Eq Text.XML.Types.QName instance GHC.Classes.Ord Text.XML.Types.QName instance GHC.Show.Show Text.XML.Types.URI instance GHC.Show.Show Text.XML.Types.LName instance Control.DeepSeq.NFData Text.XML.Types.CData instance Control.DeepSeq.NFData Text.XML.Types.CDataKind instance Control.DeepSeq.NFData Text.XML.Types.PI instance Control.DeepSeq.NFData Text.XML.Types.XmlDeclaration module Text.XML.Proc -- | Get the text value of an XML element. This function ignores non-text -- elements, and concatenates all text elements. strContent :: Element -> Text -- | Select only the elements from a list of XML content. onlyElems :: [Content] -> [Element] -- | Select only the elements from a parent. elChildren :: Element -> [Element] -- | Select only the text from a list of XML content. onlyText :: [Content] -> [CData] -- | Find all immediate children with the given name. findChildren :: QName -> Element -> [Element] -- | Filter all immediate children wrt a given predicate. filterChildren :: (Element -> Bool) -> Element -> [Element] -- | Filter all immediate children wrt a given predicate over their names. filterChildrenName :: (QName -> Bool) -> Element -> [Element] -- | Find an immediate child with the given name. findChild :: QName -> Element -> Maybe Element -- | Find an immediate child with the given name. filterChild :: (Element -> Bool) -> Element -> Maybe Element -- | Find an immediate child with name matching a predicate. filterChildName :: (QName -> Bool) -> Element -> Maybe Element -- | Find the left-most occurrence of an element matching given name. findElement :: QName -> Element -> Maybe Element -- | Filter the left-most occurrence of an element wrt. given predicate. filterElement :: (Element -> Bool) -> Element -> Maybe Element -- | Filter the left-most occurrence of an element wrt. given predicate. filterElementName :: (QName -> Bool) -> Element -> Maybe Element -- | Find all non-nested occurances of an element. (i.e., once we have -- found an element, we do not search for more occurances among the -- element's children). findElements :: QName -> Element -> [Element] -- | Find all non-nested occurrences of an element wrt. given predicate. -- (i.e., once we have found an element, we do not search for more -- occurances among the element's children). filterElements :: (Element -> Bool) -> Element -> [Element] -- | Find all non-nested occurences of an element wrt a predicate over -- element names. (i.e., once we have found an element, we do not search -- for more occurances among the element's children). filterElementsName :: (QName -> Bool) -> Element -> [Element] -- | Lookup the value of an attribute. findAttr :: QName -> Element -> Maybe Text -- | Lookup attribute name from list. lookupAttr :: QName -> [Attr] -> Maybe Text -- | Lookup the first attribute whose name satisfies the given predicate. lookupAttrBy :: (QName -> Bool) -> [Attr] -> Maybe Text -- | Lookup the value of the first attribute whose name satisfies the given -- predicate. findAttrBy :: (QName -> Bool) -> Element -> Maybe Text -- | XML cursors for working XML content withing the context of an XML -- document. This implementation is based on the general tree zipper -- written by Krasimir Angelov and Iavor S. Diatchki. module Text.XML.Cursor data Tag Tag :: QName -> [Attr] -> Tag [tagName] :: Tag -> QName [tagAttribs] :: Tag -> [Attr] getTag :: Element -> Tag setTag :: Tag -> Element -> Element fromTag :: Tag -> [Content] -> Element -- | The position of a piece of content in an XML document. data Cursor Cur :: Content -> [Content] -> [Content] -> Path -> Cursor -- | The currently selected content. [current] :: Cursor -> Content -- | Siblings on the left, closest first. [lefts] :: Cursor -> [Content] -- | Siblings on the right, closest first. [rights] :: Cursor -> [Content] -- | The contexts of the parent elements of this location. [parents] :: Cursor -> Path type Path = [([Content], Tag, [Content])] -- | A cursor for the given content. fromContent :: Content -> Cursor -- | A cursor for the given element. fromElement :: Element -> Cursor -- | The location of the first tree in a forest. fromForest :: [Content] -> Maybe Cursor -- | Computes the forest containing this location. toForest :: Cursor -> [Content] -- | Computes the tree containing this location. toTree :: Cursor -> Content -- | The parent of the given location. parent :: Cursor -> Maybe Cursor -- | The top-most parent of the given location. root :: Cursor -> Cursor -- | The child with the given index (starting from 0). getChild :: Int -> Cursor -> Maybe Cursor -- | The first child of the given location. firstChild :: Cursor -> Maybe Cursor -- | The last child of the given location. lastChild :: Cursor -> Maybe Cursor -- | The left sibling of the given location. left :: Cursor -> Maybe Cursor -- | The right sibling of the given location. right :: Cursor -> Maybe Cursor -- | The next position in a left-to-right depth-first traversal of a -- document: either the first child, right sibling, or the right sibling -- of a parent that has one. nextDF :: Cursor -> Maybe Cursor -- | The first child that satisfies a predicate. findChild :: (Cursor -> Bool) -> Cursor -> Maybe Cursor -- | Find the next left sibling that satisfies a predicate. findLeft :: (Cursor -> Bool) -> Cursor -> Maybe Cursor -- | Find the next right sibling that satisfies a predicate. findRight :: (Cursor -> Bool) -> Cursor -> Maybe Cursor -- | Perform a depth first search for a descendant that satisfies the given -- predicate. findRec :: (Cursor -> Bool) -> Cursor -> Maybe Cursor -- | Are we at the top of the document? isRoot :: Cursor -> Bool -- | Are we at the left end of the the document? isFirst :: Cursor -> Bool -- | Are we at the right end of the document? isLast :: Cursor -> Bool -- | Are we at the bottom of the document? isLeaf :: Cursor -> Bool -- | Do we have a parent? isChild :: Cursor -> Bool -- | Do we have children? hasChildren :: Cursor -> Bool -- | Get the node index inside the sequence of children getNodeIndex :: Cursor -> Int -- | Change the current content. setContent :: Content -> Cursor -> Cursor -- | Modify the current content. modifyContent :: (Content -> Content) -> Cursor -> Cursor -- | Modify the current content, allowing for an effect. modifyContentM :: Monad m => (Content -> m Content) -> Cursor -> m Cursor -- | Insert content to the left of the current position. insertLeft :: Content -> Cursor -> Cursor -- | Insert content to the right of the current position. insertRight :: Content -> Cursor -> Cursor -- | Insert content to the left of the current position. The new content -- becomes the current position. insertGoLeft :: Content -> Cursor -> Cursor -- | Insert content to the right of the current position. The new content -- becomes the current position. insertGoRight :: Content -> Cursor -> Cursor -- | Remove the content on the left of the current position, if any. removeLeft :: Cursor -> Maybe (Content, Cursor) -- | Remove the content on the right of the current position, if any. removeRight :: Cursor -> Maybe (Content, Cursor) -- | Remove the current element. The new position is the one on the left. removeGoLeft :: Cursor -> Maybe Cursor -- | Remove the current element. The new position is the one on the right. removeGoRight :: Cursor -> Maybe Cursor -- | Remove the current element. The new position is the parent of the old -- position. removeGoUp :: Cursor -> Maybe Cursor instance Data.Data.Data Text.XML.Cursor.Cursor instance GHC.Generics.Generic Text.XML.Cursor.Cursor instance GHC.Show.Show Text.XML.Cursor.Cursor instance Data.Data.Data Text.XML.Cursor.Tag instance GHC.Generics.Generic Text.XML.Cursor.Tag instance GHC.Show.Show Text.XML.Cursor.Tag instance Control.DeepSeq.NFData Text.XML.Cursor.Cursor instance Control.DeepSeq.NFData Text.XML.Cursor.Tag -- | Output handling for the lightweight XML lib. module Text.XML.Output -- | Serialize a sequence of XML Content nodes serializeXML :: [Content] -> Text -- | Serialize XML 1.0 document prefixed by the XML prologue "<?xml -- version='1.0' ?>" serializeXMLDoc :: Element -> Text -- | Serialize a XML Root serializeXMLRoot :: SerializeXMLOptions -> Root -> Text -- | Options for tweaking XML serialization output data SerializeXMLOptions SerializeXMLOptions :: (QName -> Bool) -> Bool -> SerializeXMLOptions [serializeAllowEmptyTag] :: SerializeXMLOptions -> QName -> Bool [serializeProEpilogAddNLs] :: SerializeXMLOptions -> Bool -- | Default rendering options -- -- defaultSerializeXMLOptions :: SerializeXMLOptions -- | Lightweight XML parsing module Text.XML.Input -- | parseXML to a list of Content chunks -- -- NOTE: As opposed to parseXMLDoc, this function will -- not discard any BOM characters. parseXML :: XmlSource s => s -> Either (Pos, String) [Content] -- | Parse a XML document to an Element -- -- If you need access to the prolog and epilog use parseXMLRoot -- -- An optional (single) leading BOM (U+FEFF) character will be -- discard (and not counted in the source positions). parseXMLDoc :: XmlSource s => s -> Either (Pos, String) Element -- | Parse a XML document -- -- An optional (single) leading BOM (U+FEFF) character will be -- discard (and not counted in the source positions). parseXMLRoot :: XmlSource s => s -> Either (Pos, String) Root class XmlSource s uncons :: XmlSource s => s -> Maybe (Char, s) -- | This type may be used to provide a custom scanning function for -- extracting characters. data Scanner s -- | This type may be used to provide a custom scanning function for -- extracting characters. customScanner :: (s -> Maybe (Char, s)) -> s -> Scanner s -- | XML Lexer token. data Token -- | opening start-tag (the Bool field denotes whether this is an -- empty tag) TokStart :: !Pos -> QName -> [Attr] -> Bool -> Token -- | closing end-tag TokEnd :: !Pos -> QName -> Token -- | character entity reference TokCRef :: ShortText -> Token -- | character data TokText :: CData -> Token -- | Lexer error TokError :: !Pos -> String -> Token TokXmlDecl :: XmlDeclaration -> Token TokComment :: Comment -> Token TokPI :: !Pos -> PI -> Token TokDTD :: Text -> Token -- | Run XML lexer over XmlSource scanXML :: XmlSource source => source -> [Token] instance GHC.Generics.Generic Text.XML.Input.ContentF instance Data.Data.Data Text.XML.Input.ContentF instance GHC.Show.Show Text.XML.Input.ContentF instance Control.DeepSeq.NFData Text.XML.Input.ContentF -- | A lightweight XML parsing, filtering and generating library. -- -- This module reexports functions from: -- -- module Text.XML -- | A smart element constructor which uses the type of its argument to -- determine what sort of element to make. class Node t node :: Node t => QName -> t -> Element -- | Add an attribute to an element. add_attr :: Attr -> Element -> Element -- | Add some attributes to an element. add_attrs :: [Attr] -> Element -> Element -- | Create an unqualified name. unqual :: LName -> QName -- | Create node with unqualified name unode :: Node t => LName -> t -> Element instance Text.XML.Node [Text.XML.Types.Attr] instance Text.XML.Node Text.XML.Types.Attr instance Text.XML.Node () instance Text.XML.Node ([Text.XML.Types.Attr], [Text.XML.Types.Content]) instance Text.XML.Node ([Text.XML.Types.Attr], Text.XML.Types.Content) instance Text.XML.Node (Text.XML.Types.Attr, Text.XML.Types.Content) instance Text.XML.Node [Text.XML.Types.Content] instance Text.XML.Node Text.XML.Types.Content instance Text.XML.Node ([Text.XML.Types.Attr], [Text.XML.Types.Element]) instance Text.XML.Node ([Text.XML.Types.Attr], Text.XML.Types.Element) instance Text.XML.Node (Text.XML.Types.Attr, Text.XML.Types.Element) instance Text.XML.Node [Text.XML.Types.Element] instance Text.XML.Node Text.XML.Types.Element instance Text.XML.Node ([Text.XML.Types.Attr], [Text.XML.Types.CData]) instance Text.XML.Node ([Text.XML.Types.Attr], Text.XML.Types.CData) instance Text.XML.Node (Text.XML.Types.Attr, Text.XML.Types.CData) instance Text.XML.Node [Text.XML.Types.CData] instance Text.XML.Node Text.XML.Types.CData instance Text.XML.Node ([Text.XML.Types.Attr], Data.Text.Internal.Text) instance Text.XML.Node (Text.XML.Types.Attr, Data.Text.Internal.Text) instance Text.XML.Node Data.Text.Internal.Text instance Text.XML.Node ([Text.XML.Types.Attr], Data.Text.Short.Internal.ShortText) instance Text.XML.Node (Text.XML.Types.Attr, Data.Text.Short.Internal.ShortText) instance Text.XML.Node Data.Text.Short.Internal.ShortText