-- 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.3.1.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 <?xml version="1.0" encoding="..." standalone="..." -- ?> declaration data XmlDeclaration XmlDeclaration :: Maybe ShortText -> Maybe Bool -> XmlDeclaration 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] -- | Blank elements -- -- __NOTE: This value is not a propler Element. blank_element :: Element -- | Verify whether sub-tree is wellformed with respect to namespaces -- -- The first argument denotes an optional parent context of -- xmlns-declarations that are in scope (where ShortText -- and URI have the same semantics as for the arguments of -- xmlns_attr). In case of duplicate prefixes, earlier entries -- shadow later entries. -- -- NOTE: This function doesn't take into account the namespace -- prefixes of xs:QName-valued text-nodes or attributes; if you -- need to handle such cases, see the xmlns_elem_wellformed' -- function. xmlns_elem_wellformed :: [(ShortText, URI)] -> Element -> Bool -- | Variant of xmlns_elem_wellformed which supports introspecting -- xs:QName valued attributes and text-nodes. -- -- The first argument is a function for extracting a (possibly empty) -- list of QNames from attribute values and text-nodes: -- -- -- -- This QName extracing function may return a list to accomodate -- for test fields which may contain multiple xs:QName such as -- e.g. for -- --
--   <xs:list itemType="xs:QName" />
--   
-- -- The qnameFromText function can be useful for decoding -- xs:QNames text values. -- --
--   xmlns_elem_wellformed' (\_ _ -> []) topns el = xmlns_elem_wellformed topns el
--   
xmlns_elem_wellformed' :: (Either Attr [Content] -> [QName] -> [QName]) -> [(ShortText, URI)] -> Element -> Bool -- | XML attributes data Attr Attr :: !QName -> !Text -> Attr -- | Note that the default namespace doesn't apply to unprefixed names [attrKey] :: Attr -> !QName [attrVal] :: Attr -> !Text -- | Smart constructor for xmlns:<prefix> = -- <namespace-uri> -- -- Invariant: <namespace-uri> MUST be non-empty for -- non-empty prefixes xmlns_attr :: ShortText -> URI -> Attr -- | Smart constructor for xmlns = [<namespace-uri>|""] -- (i.e. for declaring the default namespace) -- --
--   xmlns_attr "" ns == xmlns_def_attr ns
--   
xmlns_def_attr :: URI -> Attr -- | Convert xmlns Attr into a -- (prefix,namespace-uri) pair; returns Nothing if the -- argument isn't a xmlns attribute. -- -- An empty prefix denotes the default-namespace -- --
--   xmlns_from_attr (xmlns_attr pfx ns) == Just (pfx,ns)
--   
xmlns_from_attr :: Attr -> Maybe (ShortText, URI) -- | XML content data Content Elem :: Element -> Content Text :: CData -> Content CRef :: !ShortText -> Content Proc :: PI -> Content Comm :: Comment -> Content -- | Processing instruction data PI PI :: !ShortText -> !Text -> PI -- | Invariant: MUST be a NCName but not be [Xx][Mm][Ll] -- (see also PITarget and https://www.w3.org/TR/xml-names/) [piTarget] :: PI -> !ShortText -- | Invariant: MUST not contain ?> [piData] :: PI -> !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 -- | Empty text-node blank_cdata :: CData -- | Represents a XML comment -- -- Invariant: SHOULD not contain -- (occurences of -- -- will be automatically substituted by -~ on serialization) newtype Comment Comment :: Text -> Comment -- | XML (expanded) namespace-qualified names -- -- Used by attrKey and elName. data QName QName :: !LName -> !URI -> Maybe NCName -> QName -- | Local name part [qLName] :: QName -> !LName -- | Invariant: the qURI field MUST always be populated with the -- proper namespace. Specifically, entities belonging to the -- http://www.w3.org/2000/xmlns/ or -- http://www.w3.org/XML/1998/namespace must have the qURI -- field set accordingly. The special empty URI (see also -- isNullURI) is only allowed iff qPrefix is -- Nothing (i.e. when the name is unprefixed) [qURI] :: QName -> !URI -- | Nothing denotes an unprefixed name; Just denotes a -- prefixed name. -- -- Invariant: MUST be a proper NCName (unless Nothing) [qPrefix] :: QName -> Maybe NCName -- | Blank names -- -- NOTE: This value is not a proper QName. blank_name :: QName -- | Convert a QName to its text-representation, i.e. -- --
--   QName          ::= PrefixedName | UnprefixedName
--   PrefixedName   ::= Prefix ':' LocalPart
--   UnprefixedName ::= LocalPart
--   Prefix         ::= NCName
--   LocalPart      ::= NCName
--   
-- -- See also NCName -- --
--   >>> qnameToText (QName "foo" "urn:example.org:bar" (Just "doo"))
--   "doo:foo"
--   
-- --
--   >>> qnameToText (QName "foo" "urn:example.org:bar" Nothing)
--   "foo"
--   
-- -- See also qnameFromText qnameToText :: QName -> Text -- | Decode a QName from its text-representation (see -- qnameToText) -- -- This is the inverse to the qnameToText function. However, -- qnameToText is a lossy conversion, therefore this function -- needs to reconstruct the namespace (i.e. qURI) with the help of -- a lookup function provided in the first argument: The lookup functions -- takes a ShortText which can be either -- -- -- -- The result of this function shall be the respective namespace -- URI to associate with this QName. An empty URI may be -- returned In case of unprefixed names to denote the name being in no -- namespace. -- -- Finally, this function returns Nothing in case of syntax errors -- or when the prefix lookup function returns an empty URI (see -- isNullURI) for a prefixed name. qnameFromText :: (ShortText -> URI) -> Text -> Maybe QName -- | A NCName -- -- NB: Among other properties this means that an NCName shall -- never be the empty string. type NCName = ShortText -- | XML local names -- -- Invariant: MUST be a proper NCName newtype LName LName :: NCName -> LName [unLName] :: LName -> NCName -- | URIs resembling anyURI -- -- Invariant: MUST be a valid URI-reference as defined in -- RFC3986 -- -- NOTE: The special empty URI is valid for denoting -- QNames that aren't in any namespace. newtype URI URI :: ShortText -> URI [unURI] :: URI -> ShortText -- | Test for empty URI -- --
--   >>> isNullURI (URI mempty)
--   True
--   
-- --
--   >>> isNullURI (URI "")
--   True
--   
-- --
--   >>> isNullURI (URI " ")
--   False
--   
isNullURI :: URI -> Bool -- | Position expressed in number of code-points -- -- A negative value denotes EOF type Pos = Int 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 -- | 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 -> Bool -> SerializeXMLOptions [serializeAllowEmptyTag] :: SerializeXMLOptions -> QName -> Bool [serializeProEpilogAddNLs] :: SerializeXMLOptions -> Bool [serializeSortAttributes] :: SerializeXMLOptions -> Bool -- | Default rendering options -- -- defaultSerializeXMLOptions :: SerializeXMLOptions -- | 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. -- -- NOTE: The Cursor API has been significantly altered in 0.3.0, -- hence this module's API is to be considered "since 0.3.0" 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 -- | General cursor type Cursor = Cursor' Content -- | The position of a piece of content in an XML document. data Cursor' content Cur :: content -> [Content] -> [Content] -> Path -> Cursor' content -- | The currently selected content. [current] :: Cursor' content -> content -- | Siblings on the left, closest first. [lefts] :: Cursor' content -> [Content] -- | Siblings on the right, closest first. [rights] :: Cursor' content -> [Content] -- | The contexts of the parent elements of this location. [parents] :: Cursor' content -> Path -- | Parent path (with the root as last element) consisting of list of left -- siblings, parent, and right siblings type Path = [([Content], Tag, [Content])] -- | A cursor for the given (root) element. fromRootElement :: Element -> Cursor' Element -- | Construct cursor from document Root fromRoot :: Root -> Cursor' Element -- | Computes the root element containing this location. -- -- NOTE: The root element might have siblings; see toRoot -- or root if you need to deal with such siblings. toRootElement :: IsContent content => Cursor' content -> Element -- | Constructs the document Root containing this location. -- -- Returns Nothing if invalid top-level "miscellaneous" nodes are -- encountered. toRoot :: IsContent content => Cursor' content -> Maybe Root -- | Generalize content type of current Cursor location upCast :: IsContent content => Cursor' content -> Cursor -- | Specialize content type of current Cursor location downCast :: IsContent content => Cursor -> Maybe (Cursor' content) -- | The parent of the given location. parent :: IsContent content => Cursor' content -> Maybe (Cursor' Element) -- | The top-most parent of the given location. root :: IsContent content => Cursor' content -> Cursor' Element -- | The child with the given index (starting from 0). getChild :: IsContent content => Word -> Cursor' content -> Maybe Cursor -- | The first child of the given location. firstChild :: IsContent content => Cursor' content -> Maybe Cursor -- | The last child of the given location. lastChild :: IsContent content => Cursor' content -> Maybe Cursor -- | The left sibling of the given location. left :: IsContent content => Cursor' content -> Maybe Cursor -- | The right sibling of the given location. right :: IsContent content => Cursor' content -> 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 :: IsContent content => Cursor' content -> Maybe Cursor -- | The first child that satisfies a predicate. findChild :: IsContent content => (Cursor -> Bool) -> Cursor' content -> Maybe Cursor -- | Find the next left sibling that satisfies a predicate. findLeft :: IsContent content => (Cursor -> Bool) -> Cursor' content -> Maybe Cursor -- | Find the next right sibling that satisfies a predicate. findRight :: IsContent content => (Cursor -> Bool) -> Cursor' content -> Maybe Cursor -- | Perform a depth first search for a descendant that satisfies the given -- predicate. findRec :: IsContent content => (Cursor -> Bool) -> Cursor' content -> Maybe Cursor -- | Are we at the top of the document? isRoot :: Cursor' content -> Bool -- | Are we at the left end of the the document (i.e. the locally left-most -- sibling)? isFirst :: Cursor' content -> Bool -- | Are we at the right end of the document (i.e. the locally right-most -- sibling)? isLast :: Cursor' content -> Bool -- | Are we at the bottom of the document? isLeaf :: IsContent content => Cursor' content -> Bool -- | Do we have a parent? isChild :: Cursor' content -> Bool -- | Do we have children? hasChildren :: IsContent content => Cursor' content -> Bool -- | Get the node index inside the sequence of children/siblings getNodeIndex :: Cursor' content -> Word -- | Insert content to the left of the current position. insertLeft :: IsContent c => c -> Cursor' content -> Cursor' content -- | Insert content to the right of the current position. insertRight :: IsContent c => c -> Cursor' content -> Cursor' content -- | Insert content to the left of the current position. The new content -- becomes the current position. insertGoLeft :: IsContent content2 => content -> Cursor' content2 -> Cursor' content -- | Insert content to the right of the current position. The new content -- becomes the current position. insertGoRight :: IsContent content2 => content -> Cursor' content2 -> Cursor' content -- | Remove the content on the left of the current position, if any. removeLeft :: Cursor' content -> Maybe (Content, Cursor' content) -- | Remove the content on the right of the current position, if any. removeRight :: Cursor' content -> Maybe (Content, Cursor' content) -- | Remove the current element. The new position is the one on the left. removeGoLeft :: Cursor' content -> Maybe Cursor -- | Remove the current element. The new position is the one on the right. removeGoRight :: Cursor' content -> Maybe Cursor -- | Remove the current element. The new position is the parent of the old -- position. removeGoUp :: Cursor' content -> Maybe Cursor instance Data.Traversable.Traversable Text.XML.Cursor.Cursor' instance Data.Foldable.Foldable Text.XML.Cursor.Cursor' instance GHC.Base.Functor Text.XML.Cursor.Cursor' instance Data.Data.Data content => Data.Data.Data (Text.XML.Cursor.Cursor' content) instance GHC.Generics.Generic (Text.XML.Cursor.Cursor' content) instance GHC.Show.Show content => GHC.Show.Show (Text.XML.Cursor.Cursor' content) 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 content => Control.DeepSeq.NFData (Text.XML.Cursor.Cursor' content) instance Control.DeepSeq.NFData Text.XML.Cursor.Tag -- | 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 -- | Create an unqualified name. unqual :: LName -> QName -- | Create node with unqualified name unode :: Node t => LName -> t -> Element -- | Add an attribute to an element. add_attr :: Attr -> Element -> Element -- | Add some attributes to an element. add_attrs :: [Attr] -> Element -> Element -- | Convenience class for converting to/from Content values class IsContent x -- | upcast or generalize to Content toContent :: IsContent x => x -> Content -- | downcast or specialize (if possible) to a specific -- Content subtype fromContent :: IsContent x => Content -> Maybe x instance Text.XML.Node [Text.XML.Types.Core.Attr] instance Text.XML.Node Text.XML.Types.Core.Attr instance Text.XML.Node () instance Text.XML.Node ([Text.XML.Types.Core.Attr], [Text.XML.Types.Core.Content]) instance Text.XML.Node ([Text.XML.Types.Core.Attr], Text.XML.Types.Core.Content) instance Text.XML.Node (Text.XML.Types.Core.Attr, Text.XML.Types.Core.Content) instance Text.XML.Node [Text.XML.Types.Core.Content] instance Text.XML.Node Text.XML.Types.Core.Content instance Text.XML.Node ([Text.XML.Types.Core.Attr], [Text.XML.Types.Core.Element]) instance Text.XML.Node ([Text.XML.Types.Core.Attr], Text.XML.Types.Core.Element) instance Text.XML.Node (Text.XML.Types.Core.Attr, Text.XML.Types.Core.Element) instance Text.XML.Node [Text.XML.Types.Core.Element] instance Text.XML.Node Text.XML.Types.Core.Element instance Text.XML.Node ([Text.XML.Types.Core.Attr], [Text.XML.Types.Core.CData]) instance Text.XML.Node ([Text.XML.Types.Core.Attr], Text.XML.Types.Core.CData) instance Text.XML.Node (Text.XML.Types.Core.Attr, Text.XML.Types.Core.CData) instance Text.XML.Node [Text.XML.Types.Core.CData] instance Text.XML.Node Text.XML.Types.Core.CData instance Text.XML.Node ([Text.XML.Types.Core.Attr], Data.Text.Internal.Text) instance Text.XML.Node (Text.XML.Types.Core.Attr, Data.Text.Internal.Text) instance Text.XML.Node Data.Text.Internal.Text instance Text.XML.Node ([Text.XML.Types.Core.Attr], Data.Text.Short.Internal.ShortText) instance Text.XML.Node (Text.XML.Types.Core.Attr, Data.Text.Short.Internal.ShortText) instance Text.XML.Node Data.Text.Short.Internal.ShortText