-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A collection of tools for processing XML with Haskell. -- -- The Haskell XML Toolbox bases on the ideas of HaXml and HXML, but -- introduces a more general approach for processing XML with Haskell. -- The Haskell XML Toolbox uses a generic data model for representing XML -- documents, including the DTD subset and the document subset, in -- Haskell. It contains a validating XML parser, a HTML parser, namespace -- support, an XPath expression evaluator, an XSLT library, a RelaxNG -- schema validator and funtions for serialization and deserialization of -- user defined data. The libraray make extensive use of the arrow -- approach for processing XML. @package hxt @version 8.3.0 -- | $Id: XPathKeywords.hs,v 1.1 20040902 19:12:05 hxml Exp $ -- -- the XPath keywords module Text.XML.HXT.XPath.XPathKeywords a_ancestor_or_self :: String a_attribute :: String a_child :: String a_descendant :: String a_descendant_or_self :: String a_following :: String a_following_sibling :: String a_namespace :: String a_parent :: String a_preceding :: String a_preceding_sibling :: String a_self :: String a_ancestor :: String n_text :: String n_processing_instruction :: String n_node :: String n_comment :: String module Text.XML.HXT.Version hxt_version :: String -- | W3C XML Schema Regular Expression Matcher -- -- Grammar can be found under -- http://www.w3.org/TR/xmlschema11-2/#regexs module Text.XML.HXT.RelaxNG.XmlSchema.Regex data Regex -- | enumerate all chars specified by a predicate -- -- this function is expensive, it should only be used for testing chars :: (Char -> Bool) -> [Char] charRngs :: [Char] -> [(Char, Char)] mkZero :: String -> Regex mkUnit :: Regex mkSym :: (Char -> Bool) -> Regex mkSym1 :: Char -> Regex mkSymRng :: Char -> Char -> Regex mkDot :: Regex mkStar :: Regex -> Regex mkAlt :: Regex -> Regex -> Regex mkSeq :: Regex -> Regex -> Regex mkRep :: Int -> Regex -> Regex mkRng :: Int -> Int -> Regex -> Regex mkOpt :: Regex -> Regex mkDif :: Regex -> Regex -> Regex mkCompl :: Regex -> Regex isZero :: Regex -> Bool nullable :: Regex -> Bool delta :: Regex -> Char -> Regex matchWithRE :: Regex -> String -> Maybe String (<&&>) :: (Char -> Bool) -> (Char -> Bool) -> (Char -> Bool) (<||>) :: (Char -> Bool) -> (Char -> Bool) -> (Char -> Bool) instance Show Regex -- | Version : $Id$ -- -- Unicode character properties -- -- don't edit this module it's generated from -- 'http://www.unicode.org/Public/UNIDATA/UnicodeData.txt' module Text.XML.HXT.RelaxNG.Unicode.CharProps isUnicodeC :: Char -> Bool isUnicodeCc :: Char -> Bool isUnicodeCf :: Char -> Bool isUnicodeCo :: Char -> Bool isUnicodeCs :: Char -> Bool isUnicodeL :: Char -> Bool isUnicodeLl :: Char -> Bool isUnicodeLm :: Char -> Bool isUnicodeLo :: Char -> Bool isUnicodeLt :: Char -> Bool isUnicodeLu :: Char -> Bool isUnicodeM :: Char -> Bool isUnicodeMc :: Char -> Bool isUnicodeMe :: Char -> Bool isUnicodeMn :: Char -> Bool isUnicodeN :: Char -> Bool isUnicodeNd :: Char -> Bool isUnicodeNl :: Char -> Bool isUnicodeNo :: Char -> Bool isUnicodeP :: Char -> Bool isUnicodePc :: Char -> Bool isUnicodePd :: Char -> Bool isUnicodePe :: Char -> Bool isUnicodePf :: Char -> Bool isUnicodePi :: Char -> Bool isUnicodePo :: Char -> Bool isUnicodePs :: Char -> Bool isUnicodeS :: Char -> Bool isUnicodeSc :: Char -> Bool isUnicodeSk :: Char -> Bool isUnicodeSm :: Char -> Bool isUnicodeSo :: Char -> Bool isUnicodeZ :: Char -> Bool isUnicodeZl :: Char -> Bool isUnicodeZp :: Char -> Bool isUnicodeZs :: Char -> Bool -- | Version : $Id$ -- -- Unicode Code Blocks -- -- don't edit this module it's generated from -- 'http://www.unicode.org/Public/UNIDATA/Blocks.txt' module Text.XML.HXT.RelaxNG.Unicode.Blocks codeBlocks :: [(String, (Char, Char))] -- | Predefined XML Entity References -- -- This module defines a table of all predefined XML entity references module Text.XML.HXT.Parser.XmlEntities -- | list of predefined XML entity names and their unicode values xmlEntities :: [(String, Int)] -- | XHTML Entity References -- -- This module defines a table of all predefined XHTML entity references -- for special or none ASCII chars including the predefined XML entity -- refs module Text.XML.HXT.Parser.XhtmlEntities -- | table with all XHTML entity refs and corresponding unicode values xhtmlEntities :: [(String, Int)] -- | The GET method for file protocol module Text.XML.HXT.IO.GetFILE getStdinCont :: Bool -> IO (Either String String) getCont :: Bool -> String -> IO (Either String String) -- | A module for regular expression matching based on derivatives of -- regular expressions. -- -- The code was taken from Joe English -- (http://www.flightlab.com/~joe/sgml/validate.html). Tested and -- extended by Martin Schmidt. -- -- Further references for the algorithm: -- -- Janusz A. Brzozowski. -- -- Derivatives of Regular Expressions. Journal of the ACM, Volume 11, -- Issue 4, 1964. -- -- Mark Hopkins. -- -- Regular Expression Package. Posted to comp.compilers, 1994. Available -- per FTP at ftp://iecc.com/pub/file/regex.tar.gz. module Text.XML.HXT.DTDValidation.RE -- | Data type for regular expressions. data RE a RE_ZERO :: String -> RE a RE_UNIT :: RE a RE_SYM :: a -> RE a RE_DOT :: RE a RE_REP :: (RE a) -> RE a RE_PLUS :: (RE a) -> RE a RE_OPT :: (RE a) -> RE a RE_SEQ :: (RE a) -> (RE a) -> RE a RE_ALT :: (RE a) -> (RE a) -> RE a -- | Constructs a regular expression for an empty sequence. -- -- re_unit :: RE a -- | Constructs a regular expression for an empty set. -- -- re_zero :: String -> RE a -- | Constructs a regular expression for accepting a symbol -- -- re_sym :: a -> RE a -- | Constructs an optional repetition (*) of a regular expression -- -- re_rep :: RE a -> RE a -- | Constructs a repetition (+) of a regular expression -- -- re_plus :: RE a -> RE a -- | Constructs an option (?) of a regular expression -- -- re_opt :: RE a -> RE a -- | Constructs a sequence (,) of two regular expressions -- -- re_seq :: RE a -> RE a -> RE a -- | Constructs an alternative (|) of two regular expressions -- -- re_alt :: RE a -> RE a -> RE a -- | Constructs a regular expression for accepting any singel symbol -- -- re_dot :: RE a -- | Checks if an input matched a regular expression. The function should -- be called after matches. -- -- Was the sentence used in matches in the language of the -- regular expression? -> matches e s == s `in` L(e)? -- -- checkRE :: (Show a) => RE a -> String -- | Derives a regular expression with respect to a sentence. -- -- matches :: (Eq a, Show a) => RE a -> [a] -> RE a -- | Checks if a regular expression matches the empty sequence. -- -- nullable e == [] `in` L(e) -- -- This check indicates if a regular expression fits to a sentence or -- not. -- -- nullable :: (Show a) => RE a -> Bool -- | Constructs a string representation of a regular expression. -- -- printRE :: (Show a) => RE a -> String instance (Show a) => Show (RE a) instance (Eq a) => Eq (RE a) -- | Constants for XML keywords, for special attribute names and special -- attribute values module Text.XML.HXT.DOM.XmlKeywords t_root :: String t_xml :: String a_default :: String a_check_namespaces :: String a_contentLength :: String a_collect_errors :: String a_column :: String a_default_baseuri :: String a_do_not_canonicalize :: String a_do_not_check_namespaces :: String a_do_not_issue_errors :: String a_do_not_issue_warnings :: String a_do_not_preserve_comment :: String a_do_not_remove_whitespace :: String a_do_not_use_curl :: String a_do_not_validate :: String a_encoding :: String a_error :: String a_error_log :: String a_help :: String a_ignore_encoding_errors :: String a_ignore_none_xml_contents :: String a_indent :: String a_issue_errors :: String a_issue_warnings :: String a_kind :: String a_line :: String a_mime_types :: String a_module :: String a_modifier :: String a_name :: String a_no_empty_elements :: String a_no_xml_pi :: String a_options_curl :: String a_output_encoding :: String a_output_file :: String a_output_xml :: String a_output_html :: String a_parse_by_mimetype :: String a_parse_html :: String a_parse_xml :: String a_peref :: String a_preserve_comment :: String a_propagate_errors :: String a_proxy :: String a_remove_whitespace :: String a_show_haskell :: String a_show_tree :: String a_source :: String a_status :: String a_standalone :: String a_strict_input :: String a_tagsoup :: String a_trace :: String a_type :: String a_use_curl :: String a_url :: String a_validate :: String a_value :: String a_verbose :: String a_version :: String a_xml :: String a_xmlns :: String a_canonicalize :: String v_1 :: String v_yes :: String v_no :: String v_any :: String v_children :: String v_choice :: String v_empty :: String v_mixed :: String v_seq :: String v_null :: String v_option :: String v_pcdata :: String v_star :: String v_plus :: String v_0 :: String k_cdata :: String k_empty :: String k_entity :: String k_entities :: String k_id :: String k_idref :: String k_idrefs :: String k_include :: String k_ignore :: String k_nmtoken :: String k_nmtokens :: String k_peref :: String k_public :: String k_system :: String k_enumeration :: String k_fixed :: String k_implied :: String k_ndata :: String k_notation :: String k_pcdata :: String k_required :: String k_default :: String k_any :: String transferProtocol :: String transferMimeType :: String transferEncoding :: String transferURI :: String transferDefaultURI :: String transferStatus :: String transferMessage :: String transferVersion :: String transferPrefix :: String httpPrefix :: String stringProtocol :: String iso8859_1 :: String iso8859_2 :: String iso8859_3 :: String iso8859_4 :: String iso8859_5 :: String iso8859_6 :: String iso8859_7 :: String iso8859_8 :: String iso8859_9 :: String iso8859_10 :: String iso8859_11 :: String iso8859_13 :: String iso8859_14 :: String iso8859_15 :: String iso8859_16 :: String usAscii :: String ucs2 :: String utf8 :: String utf16 :: String utf16be :: String utf16le :: String unicodeString :: String isoLatin1 :: String -- | the predefined namespace uri for xml: -- "http://www.w3.org/XML/1998/namespace" xmlNamespace :: String -- | the predefined namespace uri for xmlns: -- "http://www.w3.org/2000/xmlns/" xmlnsNamespace :: String -- | Relax NG namespace relaxNamespace :: String a_do_not_check_restrictions :: String a_check_restrictions :: String a_do_not_validate_externalRef :: String a_validate_externalRef :: String a_do_not_validate_include :: String a_validate_include :: String a_output_changes :: String a_do_not_collect_errors :: String a_relax_schema :: String -- | utility functions module Text.XML.HXT.DOM.Util -- | remove leading and trailing whitespace with standard Haskell predicate -- isSpace stringTrim :: String -> String -- | convert string to upercase with standard Haskell toUpper function stringToUpper :: String -> String -- | Removes leading / trailing whitespaces and leading zeros normalizeNumber :: String -> String -- | Reduce whitespace sequences to a single whitespace normalizeWhitespace :: String -> String -- | replace all whitespace chars by blanks normalizeBlanks :: String -> String -- | Escape all disallowed characters in URI references (see -- http://www.w3.org/TR/xlink/#link-locators) escapeURI :: String -> String -- | escape XML chars &lt; and ampercent by transforming them into -- character references, used for escaping text nodes -- -- see also : attrEscapeXml textEscapeXml :: String -> String -- | escape XML chars &lt;, &gt;, &quot;, and ampercent by -- transforming them into character references -- -- see also : attrEscapeXml stringEscapeXml :: String -> String -- | escape XML chars in attribute values, same as stringEscapeXml, but -- none blank whitespace is also escaped -- -- see also : stringEscapeXml attrEscapeXml :: String -> String stringToInt :: Int -> String -> Int -- | convert a string into a hexadecimal string applying charToHexString -- -- see also : charToHexString stringToHexString :: String -> String -- | convert a char (byte) into a 2-digit hexadecimal string -- -- see also : stringToHexString, intToHexString charToHexString :: Char -> String -- | convert a none negative Int into a hexadecimal string -- -- see also : charToHexString intToHexString :: Int -> String -- | convert a string of hexadecimal digits into an Int hexStringToInt :: String -> Int -- | convert a string of digits into an Int decimalStringToInt :: String -> Int -- | take all elements of a list which occur more than once. The result -- does not contain doubles. (doubles . doubles == doubles) doubles :: (Eq a) => [a] -> [a] -- | drop all elements from a list which occur more than once. singles :: (Eq a) => [a] -> [a] -- | remove duplicates from list noDoubles :: (Eq a) => [a] -> [a] swap :: (a, b) -> (b, a) partitionEither :: [Either a b] -> ([a], [b]) toMaybe :: Bool -> a -> Maybe a -- | mothers little helpers for to much curry uncurry3 :: (a -> b -> c -> d) -> (a, b, c) -> d uncurry4 :: (a -> b -> c -> d -> e) -> (a, b, c, d) -> e module Text.XML.HXT.Parser.ProtocolHandlerUtil parseContentType :: Parser [(String, String)] -- | default mime type table -- -- this file is generated from file etcmime.types module Text.XML.HXT.DOM.MimeTypeDefaults -- | the table with the mapping from file name extensions to mime types mimeTypeDefaults :: [(String, String)] -- | mime type related data and functions module Text.XML.HXT.DOM.MimeTypes type MimeTypeTable = Map String String application_xml :: String application_xml_external_parsed_entity :: String application_xml_dtd :: String text_html :: String text_xml :: String text_xml_external_parsed_entity :: String application_xhtml :: String isHtmlMimeType :: String -> Bool isXmlMimeType :: String -> Bool defaultMimeTypeTable :: MimeTypeTable extensionToMimeType :: String -> MimeTypeTable -> String readMimeTypeTable :: FilePath -> IO MimeTypeTable parseMimeTypeTable :: String -> [(String, String)] module Text.XML.HXT.DOM.IsoLatinTables iso_8859_2 :: [(Char, Char)] iso_8859_3 :: [(Char, Char)] iso_8859_4 :: [(Char, Char)] iso_8859_5 :: [(Char, Char)] iso_8859_6 :: [(Char, Char)] iso_8859_7 :: [(Char, Char)] iso_8859_8 :: [(Char, Char)] iso_8859_9 :: [(Char, Char)] iso_8859_10 :: [(Char, Char)] iso_8859_11 :: [(Char, Char)] iso_8859_13 :: [(Char, Char)] iso_8859_14 :: [(Char, Char)] iso_8859_15 :: [(Char, Char)] iso_8859_16 :: [(Char, Char)] -- | Interface definition for trees module Data.Tree.Class -- | The interface for trees class Tree t mkTree :: (Tree t) => a -> [t a] -> t a mkLeaf :: (Tree t) => a -> t a isLeaf :: (Tree t) => t a -> Bool isInner :: (Tree t) => t a -> Bool getNode :: (Tree t) => t a -> a getChildren :: (Tree t) => t a -> [t a] changeNode :: (Tree t) => (a -> a) -> t a -> t a changeChildren :: (Tree t) => ([t a] -> [t a]) -> t a -> t a setNode :: (Tree t) => a -> t a -> t a setChildren :: (Tree t) => [t a] -> t a -> t a foldTree :: (Tree t) => (a -> [b] -> b) -> t a -> b nodesTree :: (Tree t) => t a -> [a] depthTree :: (Tree t) => t a -> Int cardTree :: (Tree t) => t a -> Int formatTree :: (Tree t) => (a -> String) -> t a -> String -- | Interface definition for trees -- -- n-ary tree structure (rose trees) module Data.Tree.NTree.TypeDefs -- | n-ary ordered tree (rose trees) -- -- a tree consists of a node and a possible empty list of children. If -- the list of children is empty, the node is a leaf, else it's an inner -- node. -- -- NTree implements Eq, Ord, Show and Read data NTree a NTree :: a -> (NTrees a) -> NTree a -- | shortcut for a sequence of n-ary trees type NTrees a = [NTree a] -- | convert a tree into a pseudo graphical string reprsentation formatNTreeF :: (node -> String) -> (String -> String) -> (String -> String) -> NTree node -> String -> String instance Typeable1 NTree instance (Eq a) => Eq (NTree a) instance (Ord a) => Ord (NTree a) instance (Show a) => Show (NTree a) instance (Read a) => Read (NTree a) instance Tree NTree instance Functor NTree instance (NFData a) => NFData (NTree a) -- | Navigable tree structure which allow a program to traverse up the tree -- as well as down. copied and modified from HXML -- (http://www.flightlab.com/~joe/hxml/) module Data.NavTree -- | navigable tree with nodes of type node -- -- a navigable tree consists of a n-ary tree for the current fragment -- tree, a navigable tree for all ancestors, and two n-ary trees for the -- previous- and following siblings data NavTree a NT :: (NTree a) -> [NavTree a] -> [NTree a] -> [NTree a] -> NavTree a -- | converts a n-ary tree in a navigable tree ntree :: NTree a -> NavTree a -- | converts a navigable tree in a n-ary tree subtreeNT :: NavTree a -> NTree a -- | function for selecting the value of the current fragment tree dataNT :: NavTree a -> a downNT :: NavTree a -> Maybe (NavTree a) leftNT :: NavTree a -> Maybe (NavTree a) rightNT :: NavTree a -> Maybe (NavTree a) upNT :: NavTree a -> Maybe (NavTree a) preorderNT :: NavTree a -> [NavTree a] revPreorderNT :: NavTree a -> [NavTree a] getChildrenNT :: NavTree a -> [NavTree a] -- | Kleisli composition: o' :: (Monad m) => (b -> m c) -> (a -> m b) -> (a -> m c) maybePlus :: (a -> Maybe a) -> a -> [a] maybeStar :: (a -> Maybe a) -> a -> [a] instance (Show a) => Show (NavTree a) instance (Eq a) => Eq (NavTree a) instance (Ord a) => Ord (NavTree a) module Data.Char.UTF8 encode :: [Char] -> [Word8] decode :: [Word8] -> ([Char], [(Error, Int)]) decodeEmbedErrors :: [Word8] -> [Either (Error, Int) Char] encodeOne :: Char -> [Word8] decodeOne :: [Word8] -> (Either Error Char, Int, [Word8]) data Error instance Show Error instance Eq Error -- | Interface for Data.Char.UTF8 funtions module Text.XML.HXT.DOM.UTF8Decoding -- | calls Data.Char.UTF8.decode for parsing and decoding UTF-8 decodeUtf8 :: String -> (String, [String]) decodeUtf8EmbedErrors :: String -> [Either String Char] decodeUtf8IgnoreErrors :: String -> String -- | Unicode and UTF-8 Conversion Functions module Text.XML.HXT.DOM.Unicode -- | Unicode is represented as the Char type Precondition for this is the -- support of Unicode character range in the compiler (e.g. ghc but not -- hugs) type Unicode = Char -- | the type for Unicode strings type UString = [Unicode] -- | UTF-8 charachters are represented by the Char type type UTF8Char = Char -- | UTF-8 strings are implemented as Haskell strings type UTF8String = String type UStringWithErrors = [Either String Char] -- | Decoding function with a pair containing the result string and a list -- of decoding errors as result type DecodingFct = String -> (UString, [String]) -- | Decoding function where decoding errors are interleaved with decoded -- characters type DecodingFctEmbedErrors = String -> UStringWithErrors -- | checking for valid XML characters isXmlChar :: Unicode -> Bool -- | test for a legal latin1 XML char isXmlLatin1Char :: Unicode -> Bool -- | checking for XML space character: \n, \r, \t and " " isXmlSpaceChar :: Unicode -> Bool -- | checking for XML1.1 space character: additional space 0x85 and 0x2028 -- -- see also : isXmlSpaceChar isXml11SpaceChar :: Unicode -> Bool -- | checking for XML name character isXmlNameChar :: Unicode -> Bool -- | checking for XML name start character -- -- see also : isXmlNameChar isXmlNameStartChar :: Unicode -> Bool -- | checking for XML NCName character: no ":" allowed -- -- see also : isXmlNameChar isXmlNCNameChar :: Unicode -> Bool -- | checking for XML NCName start character: no ":" allowed -- -- see also : isXmlNameChar, isXmlNCNameChar isXmlNCNameStartChar :: Unicode -> Bool -- | checking for XML public id character isXmlPubidChar :: Unicode -> Bool -- | checking for XML letter isXmlLetter :: Unicode -> Bool -- | checking for XML base charater isXmlBaseChar :: Unicode -> Bool -- | checking for XML ideographic charater isXmlIdeographicChar :: Unicode -> Bool -- | checking for XML combining charater isXmlCombiningChar :: Unicode -> Bool -- | checking for XML digit isXmlDigit :: Unicode -> Bool -- | checking for XML extender isXmlExtender :: Unicode -> Bool -- | checking for XML control or permanently discouraged char -- -- see Errata to XML1.0 (http://www.w3.org/XML/xml-V10-2e-errata) No 46 -- -- Document authors are encouraged to avoid compatibility -- characters, as defined in section 6.8 of [Unicode] (see also D21 -- in section 3.6 of [Unicode3]). The characters defined in the following -- ranges are also discouraged. They are either control characters or -- permanently undefined Unicode characters: isXmlControlOrPermanentlyUndefined :: Unicode -> Bool -- | UTF-8 to Unicode conversion with deletion of leading byte order mark, -- as described in XML standard F.1 utf8ToUnicode :: DecodingFct utf8ToUnicodeEmbedErrors :: DecodingFctEmbedErrors -- | code conversion from latin1 to Unicode latin1ToUnicode :: String -> UString -- | UCS-2 to UTF-8 conversion with byte order mark analysis ucs2ToUnicode :: String -> UString -- | UCS-2 big endian to Unicode conversion ucs2BigEndianToUnicode :: String -> UString -- | UCS-2 little endian to Unicode conversion ucs2LittleEndianToUnicode :: String -> UString -- | UTF-16 big endian to UTF-8 conversion with removal of byte order mark utf16beToUnicode :: String -> UString -- | UTF-16 little endian to UTF-8 conversion with removal of byte order -- mark utf16leToUnicode :: String -> UString -- | conversion from Unicode (Char) to a UTF8 encoded string. unicodeCharToUtf8 :: Unicode -> UTF8String -- | conversion from Unicode strings (UString) to UTF8 encoded strings. unicodeToUtf8 :: UString -> UTF8String -- | substitute all Unicode characters, that are not legal 1-byte UTF-8 XML -- characters by a character reference. -- -- This function can be used to translate all text nodes and attribute -- values into pure ascii. -- -- see also : unicodeToLatin1 unicodeToXmlEntity :: UString -> String -- | substitute all Unicode characters, that are not legal latin1 UTF-8 XML -- characters by a character reference. -- -- This function can be used to translate all text nodes and attribute -- values into ISO latin1. -- -- see also : unicodeToXmlEntity unicodeToLatin1 :: UString -> String -- | removes all non ascii chars, may be used to transform a document into -- a pure ascii representation by removing all non ascii chars from tag -- and attibute names -- -- see also : unicodeRemoveNoneLatin1, unicodeToXmlEntity unicodeRemoveNoneAscii :: UString -> String -- | removes all non latin1 chars, may be used to transform a document into -- a pure ascii representation by removing all non ascii chars from tag -- and attibute names -- -- see also : unicodeRemoveNoneAscii, unicodeToLatin1 unicodeRemoveNoneLatin1 :: UString -> String -- | convert an Unicode into a XML character reference. -- -- see also : intToCharRefHex intToCharRef :: Int -> String -- | convert an Unicode into a XML hexadecimal character reference. -- -- see also: intToCharRef intToCharRefHex :: Int -> String -- | the lookup function for selecting the decoding function getDecodingFct :: String -> Maybe DecodingFct -- | the lookup function for selecting the decoding function getDecodingFctEmbedErrors :: String -> Maybe DecodingFctEmbedErrors -- | the lookup function for selecting the encoding function getOutputEncodingFct :: String -> Maybe (String -> UString) -- | White Space (XML Standard 2.3) and end of line handling (2.11) -- -- #x0D and #x0D#x0A are mapped to #x0A normalizeNL :: String -> String guessEncoding :: String -> String -- | UTF-8 character parser and simple XML token parsers -- -- Version : $Id: XmlCharParser.hs,v 1.2 20050531 16:01:12 hxml -- Exp $ module Text.XML.HXT.Parser.XmlCharParser -- | parse a single Unicode character xmlChar :: GenParser Char state Unicode -- | parse a XML name character xmlNameChar :: GenParser Char state Unicode -- | parse a XML name start character xmlNameStartChar :: GenParser Char state Unicode -- | parse a XML NCName character xmlNCNameChar :: GenParser Char state Unicode -- | parse a XML NCName start character xmlNCNameStartChar :: GenParser Char state Unicode -- | parse a XML letter character xmlLetter :: GenParser Char state Unicode -- | White Space (2.3) -- -- end of line handling (2.11) #x0D and #x0D#x0A are mapped to #x0A is -- done in XmlInput before parsing otherwise #x0D in internal parsing, -- e.g. for entities would normalize, would be transformed xmlSpaceChar :: GenParser Char state Char -- | W3C XML Schema Regular Expression Parser -- -- This parser supports the full W3C standard, the complete grammar can -- be found under http://www.w3.org/TR/xmlschema11-2/#regexs module Text.XML.HXT.RelaxNG.XmlSchema.RegexParser parseRegex :: String -> Either String Regex -- | Convenient functions for W3C XML Schema Regular Expression Matcher. -- For internals see Text.XML.HXT.RelaxNG.XmlSchema.Regex -- -- Grammar can be found under -- http://www.w3.org/TR/xmlschema11-2/#regexs module Text.XML.HXT.RelaxNG.XmlSchema.RegexMatch -- | match a string with a regular expression -- -- First argument is the regex, second the input string, if the regex is -- not well formed, Nothing is returned, else Just the -- match result -- -- Examples: -- --
--   matchRE "x*" "xxx" = Just True
--   matchRE "x" "xxx"  = Just False
--   matchRE "[" "xxx"  = Nothing
--   
matchRE :: String -> String -> Maybe Bool -- | split a string by taking the longest prefix matching a regular -- expression -- -- Nothing is returned in case of a syntactically wrong regex -- string or in case there is no matching prefix, else the pair of prefix -- and rest is returned -- -- examples: -- --
--   splitRE "a*b" "abc" = Just ("ab","c")
--   splitRE "a*"  "bc"  = Just ("", "bc")
--   splitRE "a+"  "bc"  = Nothing
--   splitRE "["   "abc" = Nothing
--   
splitRE :: String -> String -> Maybe (String, String) -- | sed like editing function -- -- All matching tokens are edited by the 1. argument, the editing -- function, all other chars remain as they are -- -- examples: -- --
--   sedRE (const "b") "a" "xaxax"       = Just "xbxbx"
--   sedRE (\ x -> x ++ x) "a" "xax"     = Just "xaax"
--   sedRE undefined       "[" undefined = Nothing
--   
sedRE :: (String -> String) -> String -> String -> Maybe String -- | split a string into tokens (words) by giving a regular expression -- which all tokens must match -- -- This can be used for simple tokenizers. The words in the result list -- contain at least one char. All none matching chars are discarded. If -- the given regex contains syntax errors, Nothing is returned -- -- examples: -- --
--   tokenizeRE "a*b" ""         = Just []
--   tokenizeRE "a*b" "abc"      = Just ["ab"]
--   tokenizeRE "a*b" "abaab ab" = Just ["ab","aab","ab"]
--   
--   tokenizeRE "[a-z]{2,}|[0-9]{2,}|[0-9]+[.][0-9]+" "ab123 456.7abc"
--                                  = Just ["ab","123","456.7","abc"]
--   
--   tokenizeRE "[a-z]*|[0-9]{2,}|[0-9]+[.][0-9]+" "cab123 456.7abc"
--                                  = Just ["cab","123","456.7","abc"]
--   
--   tokenizeRE "[^ \t\n\r]*" "abc def\t\n\rxyz"
--                                  = Just ["abc","def","xyz"]
--   
--   tokenizeRE "[^ \t\n\r]*"    = words
--   
tokenizeRE :: String -> String -> Maybe [String] -- | split a string into tokens and delimierter by giving a regular -- expression wich all tokens must match -- -- This is a generalisation of the above tokenizeRE functions. The -- none matching char sequences are marked with Left, the -- matching ones are marked with Right -- -- If the regular expression contains syntax errors Nothing is -- returned -- -- The following Law holds: -- --
--   concat . map (either id id) . fromJust . tokenizeRE' re == id
--   
tokenizeRE' :: String -> String -> Maybe [Either String String] -- | convenient function for matchRE -- -- syntax errors in R.E. are interpreted as no match found match :: String -> String -> Bool -- | convenient function for tokenizeRE a string -- -- syntax errors in R.E. result in an empty list tokenize :: String -> String -> [String] -- | convenient function for tokenizeRE' -- -- When the regular expression contains errors [Left input] is -- returned, that means tokens are found tokenize' :: String -> String -> [Either String String] -- | convenient function for sedRE -- -- When the regular expression contains errors, sed is the identity, else -- the funtionality is like sedRE -- --
--   sed undefined "["  == id
--   
sed :: (String -> String) -> String -> String -> String -- | convenient function for splitRE -- -- syntax errors in R.E. are interpreted as no matching prefix found split :: String -> String -> (String, String) -- | Unique Atoms generated from Strings and managed as flyweights -- -- Data.Atom can be used for caching and storage optimisation of -- frequently used strings. An Atom is constructed from a -- String. For two equal strings the identical atom is returned. -- -- This module can be used for optimizing memory usage when working with -- strings or names. Many applications use data types like Map String -- SomeAttribute where a rather fixed set of keys is used. -- Especially XML applications often work with a limited set of element -- and attribute names. For these applications it becomes more memory -- efficient when working with types like Map Atom SomeAttribute -- and convert the keys into atoms before operating on such a map. -- -- Internally this module manages a map of atoms. The atoms are -- internally represented by ByteStrings. When creating a new -- atom from a string, the string is first converted into an UTF8 -- Word8 sequence, which is packed into a ByteString. -- This ByteString is looked up in the table of atoms. If it is -- already there, the value in the map is used as atom, else the new -- ByteString is inserted into the map. -- -- Of course the implementation of this name cache uses -- unsavePerformIO and MVars for managing this kind of -- global state. -- -- The following laws hold for atoms -- --
--   s  ==       t => newAtom s  ==       newAtom t
--   s `compare` t => newAtom s `compare` newAtom t
--   show . newAtom == id
--   
-- -- Equality test for Atoms runs in O(1), it is just a -- pointer comarison. The Ord comparisons have the same runtime -- like the ByteString comparisons. Internally there is an UTF8 -- comparison, but UTF8 encoding preserves the total order. -- -- Warning: The internal cache never shrinks during execution. So using -- it in a undisciplined way can lead to memory leaks. module Data.Atom data Atom -- | creation of an Atom from a String newAtom :: String -> Atom -- | Insert a String into the atom cache and convert the atom back -- into a String. -- -- locically share == id holds, but internally equal strings -- share the same memory. share :: String -> String instance Typeable Atom instance NFData Atom instance Show Atom instance Read Atom instance Ord Atom instance Eq Atom -- | simple key value assocciation list implemented as unordered list of -- pairs -- -- Version : $Id: AssocList.hs,v 1.2 20050527 13:15:23 hxml Exp $ module Data.AssocList type AssocList k v = [(k, v)] -- | lookup with default value lookupDef :: (Eq k) => v -> k -> AssocList k v -> v -- | lookup with empty list (empty string) as default value lookup1 :: (Eq k) => k -> AssocList k [e] -> [e] -- | test for existence of a key hasEntry :: (Eq k) => k -> AssocList k v -> Bool -- | add an entry, remove an existing entry before adding the new one at -- the top of the list, addEntry is strict addEntry :: (Eq k) => k -> v -> AssocList k v -> AssocList k v -- | add a whole list of entries with addEntry addEntries :: (Eq k) => AssocList k v -> AssocList k v -> AssocList k v -- | delete an entry, delEntry is strict delEntry :: (Eq k) => k -> AssocList k v -> AssocList k v -- | delete a list of entries with delEntry delEntries :: (Eq k) => [k] -> AssocList k v -> AssocList k v -- | The core data types of the HXT DOM. module Text.XML.HXT.DOM.QualifiedName -- | Namespace support for element and attribute names. -- -- A qualified name consists of a name prefix, a local name and a -- namespace uri. All modules, which are not namespace aware, use only -- the localPart component. When dealing with namespaces, the -- document tree must be processed by propagateNamespaces to split -- names of structure "prefix:localPart" and label the name with the -- apropriate namespace uri data QName -- | XML names are represented by Strings, but these strings do not mix up -- with normal strings. Names are always reduced to normal form, and they -- are stored internally in a name cache for sharing equal names by the -- same data structure type XName = Atom -- | Type for the namespace association list, used when propagating -- namespaces by modifying the QName values in a tree type NsEnv = AssocList XName XName -- | constructs a complete qualified name with namePrefix, -- localPart and namespaceUri. This function can be used to -- build not wellformed prefix:localpart names. The XPath module uses -- wildcard names like xxx:*. These must be build with -- mkQName and not with mkName. mkQName :: String -> String -> String -> QName -- | constructs a simple, namespace unaware name. If the name is in -- prefix:localpart form and the prefix is not empty the name is -- split internally into a prefix and a local part. mkName :: String -> QName -- | constructs a simple, namespace aware name, with prefix:localPart as -- first parameter, namspace uri as second. -- -- see also mkName, mkPrefixLocalPart mkNsName :: String -> String -> QName -- | old name for mkName mkSNsName :: String -> QName -- | constructs a simple name, with prefix and localPart but without a -- namespace uri. -- -- see also mkQName, mkName mkPrefixLocalPart :: String -> String -> QName -- | Equivalent QNames are defined as follows: The URIs are normalized -- before comparison. Comparison is done with equalQNameBy and -- equivUri equivQName :: QName -> QName -> Bool -- | Comparison of normalized namespace URIs using normalizeNsUri equivUri :: String -> String -> Bool -- | Sometimes a weaker equality relation than equalQName is appropriate, -- e.g no case significance in names, ... a name normalization function -- can be applied to the strings before comparing. Called by equalQName -- and equivQName equalQNameBy :: (String -> String -> Bool) -> QName -> QName -> Bool namePrefix :: QName -> String localPart :: QName -> String namespaceUri :: QName -> String newXName :: String -> XName nullXName :: XName isNullXName :: XName -> Bool mkQName' :: XName -> XName -> XName -> QName -- | access name prefix namePrefix' :: QName -> XName -- | access local part localPart' :: QName -> XName -- | access namespace uri namespaceUri' :: QName -> XName -- | set name prefix setNamePrefix' :: XName -> QName -> QName -- | set local part setLocalPart' :: XName -> QName -> QName -- | set name prefix setNamespaceUri' :: XName -> QName -> QName -- | builds the full name "prefix:localPart", if prefix is not null, else -- the local part is the result qualifiedName :: QName -> String -- | builds the "universal" name, that is the namespace uri surrounded with -- "{" and "}" followed by the local part (specialisation of -- buildUniversalName) universalName :: QName -> String -- | builds an "universal" uri, that is the namespace uri followed by the -- local part. This is usefull for RDF applications, where the subject, -- predicate and object often are concatenated from namespace uri and -- local part (specialisation of buildUniversalName) universalUri :: QName -> String -- | builds a string from the namespace uri and the local part. If the -- namespace uri is empty, the local part is returned, else namespace uri -- and local part are combined with the combining function given by the -- first parameter buildUniversalName :: (String -> String -> String) -> QName -> String -- | Normalization of URIs: Normalization is done by conversion into -- lowercase letters. A trailing "/" is ignored normalizeNsUri :: String -> String -- | Compute the name prefix and the namespace uri for a qualified name. -- -- This function does not test whether the name is a wellformed qualified -- name. see Namespaces in XML Rule [6] to [8]. Error checking is done -- with separate functions, see isWellformedQName and -- isWellformedQualifiedName for error checking. setNamespace :: NsEnv -> QName -> QName -- | test for wellformed NCName, rule [4] XML Namespaces isNCName :: String -> Bool -- | test for wellformed QName, rule [6] XML Namespaces predicate is used -- in filter valdateNamespaces. isWellformedQualifiedName :: String -> Bool -- | test for wellformed QName values. A QName is wellformed, if the local -- part is a NCName, the namePrefix, if not empty, is also a NCName. -- predicate is used in filter valdateNamespaces. isWellformedQName :: QName -> Bool -- | test whether an attribute name is a namesapce declaration name. If -- this is not the case True is the result, else the name must be a well -- formed namespace name: All namespace prefixes starting with "xml" are -- reserved for XML related definitions. predicate is used in filter -- valdateNamespaces. isWellformedNSDecl :: QName -> Bool -- | test for a namespace name to be well formed isWellformedNameSpaceName :: QName -> Bool -- | test whether a name is a namespace declaration attribute name isNameSpaceName :: QName -> Bool -- | predicate is used in filter valdateNamespaces. isDeclaredNamespace :: QName -> Bool xmlNamespaceXName :: XName xmlXName :: XName xmlnsNamespaceXName :: XName xmlnsXName :: XName xmlnsQN :: QName toNsEnv :: AssocList String String -> NsEnv instance Typeable Atom instance Typeable QName instance Eq Atom instance Ord Atom instance Ord QName instance Show QName instance Read QName instance NFData Atom instance Show Atom instance Read Atom instance NFData QName instance Eq QName -- | The core data types of the HXT DOM. module Text.XML.HXT.DOM.TypeDefs -- | Node of xml tree representation type XmlTree = NTree XNode -- | List of nodes of xml tree representation type XmlTrees = NTrees XNode -- | Represents elements data XNode -- | ordinary text (leaf) XText :: String -> XNode -- | character reference (leaf) XCharRef :: Int -> XNode -- | entity reference (leaf) XEntityRef :: String -> XNode -- | comment (leaf) XCmt :: String -> XNode -- | CDATA section (leaf) XCdata :: String -> XNode -- | Processing Instr with qualified name (leaf) with list of attributes. -- If tag name is xml, attributs are "version", "encoding", "standalone", -- else attribute list is empty, content is a text child node XPi :: QName -> XmlTrees -> XNode -- | tag with qualified name and list of attributes (inner node or leaf) XTag :: QName -> XmlTrees -> XNode -- | DTD element with assoc list for dtd element features XDTD :: DTDElem -> Attributes -> XNode -- | attribute with qualified name, the attribute value is stored in -- children XAttr :: QName -> XNode -- | error message with level and text XError :: Int -> String -> XNode -- | Represents a DTD element data DTDElem -- | attr: name, system, public, XDTD elems as children DOCTYPE :: DTDElem -- | attr: name, kind -- -- name: element name -- -- kind: "EMPTY" | "ANY" | "#PCDATA" | children | mixed ELEMENT :: DTDElem -- | element content -- -- attr: kind, modifier -- -- modifier: "" | "?" | "*" | "+" -- -- kind: seq | choice CONTENT :: DTDElem -- | attributes: name - name of element -- -- value - name of attribute -- -- type: "CDATA" | "ID" | "IDREF" | "IDREFS" | "ENTITY" | "ENTITIES" | -- -- "NMTOKEN" | "NMTOKENS" |"NOTATION" | "ENUMTYPE" -- -- kind: "IMPLIED" | "DEFAULT" ATTLIST :: DTDElem -- | for entity declarations ENTITY :: DTDElem -- | for parameter entity declarations PENTITY :: DTDElem -- | for notations NOTATION :: DTDElem -- | for INCLUDEs, IGNOREs and peRefs: attr: type -- -- type = INCLUDE, IGNORE or %...; CONDSECT :: DTDElem -- | attr: name -- -- for lists of names in notation types or nmtokens in enumeration types NAME :: DTDElem -- | for Parameter Entity References in DTDs PEREF :: DTDElem -- | Attribute list -- -- used for storing option lists and features of DTD parts type Attributes = AssocList String String -- | no error, everything is ok c_ok :: Int -- | Error level for XError, type warning c_warn :: Int -- | Error level for XError, type error c_err :: Int -- | Error level for XError, type fatal error c_fatal :: Int -- | data type for representing a set of nodes as a tree structure -- -- this structure is e.g. used to repesent the result of an XPath query -- such that the selected nodes can be processed or selected later in -- processing a document tree data XmlNodeSet XNS :: Bool -> [QName] -> ChildNodes -> XmlNodeSet -- | is this node part of the set ? thisNode :: XmlNodeSet -> Bool -- | the set of attribute nodes attrNodes :: XmlNodeSet -> [QName] -- | the set of child nodes, a list of pairs of index and node set childNodes :: XmlNodeSet -> ChildNodes type ChildNodes = [(Int, XmlNodeSet)] instance Typeable XmlNodeSet instance Typeable DTDElem instance Typeable XNode instance Eq XmlNodeSet instance Show XmlNodeSet instance Eq DTDElem instance Ord DTDElem instance Show DTDElem instance Read DTDElem instance Eq XNode instance Ord XNode instance Show XNode instance Read XNode instance NFData DTDElem instance NFData XNode -- | Common useful options -- -- Version : $Id: XmlOptions.hs,v 1.1 20061109 20:27:42 hxml Exp $ module Text.XML.HXT.DOM.XmlOptions -- | commonly useful options for XML input -- -- can be used for option definition with haskell getopt -- -- defines options: a_trace, a_proxy, a_use_curl, -- a_do_not_use_curl, a_options_curl, a_encoding, -- a_issue_errors, a_do_not_issue_errors, -- a_parse_html, a_parse_by_mimetype, a_tagsoup -- a_issue_warnings, a_do_not_issue_warnings, -- a_parse_xml, a_validate, a_do_not_validate, -- a_canonicalize, a_do_not_canonicalize, inputOptions :: [OptDescr (String, String)] -- | available Relax NG validation options -- -- defines options a_check_restrictions, -- a_validate_externalRef, a_validate_include, -- a_do_not_check_restrictions, -- a_do_not_validate_externalRef, a_do_not_validate_include relaxOptions :: [OptDescr (String, String)] -- | commonly useful options for XML output -- -- defines options: a_indent, a_output_encoding, -- a_output_file, a_output_html outputOptions :: [OptDescr (String, String)] -- | commonly useful options -- -- defines options: a_verbose, a_help generalOptions :: [OptDescr (String, String)] -- | defines a_version option versionOptions :: [OptDescr (String, String)] -- | debug output options showOptions :: [OptDescr (String, String)] -- | select options from a predefined list of option desciptions selectOptions :: [String] -> [OptDescr (String, String)] -> [OptDescr (String, String)] removeOptions :: [String] -> [OptDescr (String, String)] -> [OptDescr (String, String)] -- | check whether an option is set -- -- reads the value of an attribute, usually applied to a document root -- node, and checks if the value represents True. The following strings -- are interpreted as true: "1", "True", "true", "yes", "Yes". optionIsSet :: String -> Attributes -> Bool -- | check whether a string represents True -- -- definition: -- --
--   isTrueValue	= (`elem` ["1", "True", "true", "Yes", "yes"])
--   
isTrueValue :: String -> Bool -- | The interface to the primitive DOM data types and constants and -- utility functions module Text.XML.HXT.DOM.Interface -- | Interface for XmlArrow to basic data types NTree and XmlTree -- -- If this module must be used in code working with arrows, it should be -- imported qualified e.g. as XN, to prevent name clashes. -- -- For code working on the "node and tree level" this module is the -- interface for writing code without using the constructor functions of -- XNode and NTree directly module Text.XML.HXT.DOM.XmlNode class XmlNode a isText :: (XmlNode a) => a -> Bool isCharRef :: (XmlNode a) => a -> Bool isEntityRef :: (XmlNode a) => a -> Bool isCmt :: (XmlNode a) => a -> Bool isCdata :: (XmlNode a) => a -> Bool isPi :: (XmlNode a) => a -> Bool isElem :: (XmlNode a) => a -> Bool isRoot :: (XmlNode a) => a -> Bool isDTD :: (XmlNode a) => a -> Bool isAttr :: (XmlNode a) => a -> Bool isError :: (XmlNode a) => a -> Bool mkText :: (XmlNode a) => String -> a mkCharRef :: (XmlNode a) => Int -> a mkEntityRef :: (XmlNode a) => String -> a mkCmt :: (XmlNode a) => String -> a mkCdata :: (XmlNode a) => String -> a mkPi :: (XmlNode a) => QName -> XmlTrees -> a mkError :: (XmlNode a) => Int -> String -> a getText :: (XmlNode a) => a -> Maybe String getCharRef :: (XmlNode a) => a -> Maybe Int getEntityRef :: (XmlNode a) => a -> Maybe String getCmt :: (XmlNode a) => a -> Maybe String getCdata :: (XmlNode a) => a -> Maybe String getPiName :: (XmlNode a) => a -> Maybe QName getPiContent :: (XmlNode a) => a -> Maybe XmlTrees getElemName :: (XmlNode a) => a -> Maybe QName getAttrl :: (XmlNode a) => a -> Maybe XmlTrees getDTDPart :: (XmlNode a) => a -> Maybe DTDElem getDTDAttrl :: (XmlNode a) => a -> Maybe Attributes getAttrName :: (XmlNode a) => a -> Maybe QName getErrorLevel :: (XmlNode a) => a -> Maybe Int getErrorMsg :: (XmlNode a) => a -> Maybe String getName :: (XmlNode a) => a -> Maybe QName getQualifiedName :: (XmlNode a) => a -> Maybe String getUniversalName :: (XmlNode a) => a -> Maybe String getUniversalUri :: (XmlNode a) => a -> Maybe String getLocalPart :: (XmlNode a) => a -> Maybe String getNamePrefix :: (XmlNode a) => a -> Maybe String getNamespaceUri :: (XmlNode a) => a -> Maybe String changeText :: (XmlNode a) => (String -> String) -> a -> a changeCmt :: (XmlNode a) => (String -> String) -> a -> a changeName :: (XmlNode a) => (QName -> QName) -> a -> a changeElemName :: (XmlNode a) => (QName -> QName) -> a -> a changeAttrl :: (XmlNode a) => (XmlTrees -> XmlTrees) -> a -> a changeAttrName :: (XmlNode a) => (QName -> QName) -> a -> a changePiName :: (XmlNode a) => (QName -> QName) -> a -> a changeDTDAttrl :: (XmlNode a) => (Attributes -> Attributes) -> a -> a setText :: (XmlNode a) => String -> a -> a setCmt :: (XmlNode a) => String -> a -> a setName :: (XmlNode a) => QName -> a -> a setElemName :: (XmlNode a) => QName -> a -> a setElemAttrl :: (XmlNode a) => XmlTrees -> a -> a setAttrName :: (XmlNode a) => QName -> a -> a setPiName :: (XmlNode a) => QName -> a -> a setDTDAttrl :: (XmlNode a) => Attributes -> a -> a mkElementNode :: QName -> XmlTrees -> XNode mkAttrNode :: QName -> XNode mkDTDNode :: DTDElem -> Attributes -> XNode mkElement :: QName -> XmlTrees -> XmlTrees -> XmlTree mkRoot :: XmlTrees -> XmlTrees -> XmlTree mkAttr :: QName -> XmlTrees -> XmlTree mkDTDElem :: DTDElem -> Attributes -> XmlTrees -> XmlTree addAttr :: XmlTree -> XmlTrees -> XmlTrees mergeAttrl :: XmlTrees -> XmlTrees -> XmlTrees instance (XmlNode a) => XmlNode (NTree a) instance XmlNode XNode -- | XML tree conversion to external string representation module Text.XML.HXT.DOM.ShowXml -- | convert the result of a filter into a string -- -- see also : xmlTreesToText for filter version, -- Text.XML.HXT.Parser.XmlParsec.xread for the inverse operation xshow :: XmlTrees -> String showElemType :: String -> XmlTrees -> String -> String -- | Format a xml tree in tree representation module Text.XML.HXT.DOM.FormatXmlTree formatXmlTree :: XmlTree -> String formatXmlContents :: XmlTree -> XmlTrees -- | Version : $Id: XmlTokenParser.hs,v 1.3 20050902 17:09:39 hxml -- Exp $ -- -- Parsec parser for XML tokens module Text.XML.HXT.Parser.XmlTokenParser allBut :: (GenParser Char state Char -> GenParser Char state String) -> String -> GenParser Char state String allBut1 :: (GenParser Char state Char -> GenParser Char state String) -> (Char -> Bool) -> String -> GenParser Char state String asciiLetter :: GenParser Char state Char attrValue :: GenParser Char state String bar :: GenParser Char state () charRef :: GenParser Char state Int comma :: GenParser Char state () dq :: GenParser Char state Char encName :: GenParser Char state String entityRef :: GenParser Char state String entityValue :: GenParser Char state String eq :: GenParser Char state () gt :: GenParser Char state Char keyword :: String -> GenParser Char state String keywords :: [String] -> GenParser Char state String lpar :: GenParser Char state () lt :: GenParser Char state Char name :: GenParser Char state String names :: GenParser Char state [String] ncName :: GenParser Char state String nmtoken :: GenParser Char state String nmtokens :: GenParser Char state [String] peReference :: GenParser Char state String pubidLiteral :: GenParser Char state String qName :: GenParser Char state (String, String) quoted :: GenParser Char state a -> GenParser Char state a reference :: GenParser Char state String rpar :: GenParser Char state () semi :: GenParser Char state Char separator :: Char -> GenParser Char state () singleChar :: String -> GenParser Char state Char singleChars :: String -> GenParser Char state String skipS :: GenParser Char state () skipS0 :: GenParser Char state () sPace :: GenParser Char state String sPace0 :: GenParser Char state String sq :: GenParser Char state Char systemLiteral :: GenParser Char state String versionNum :: GenParser Char state String concRes :: GenParser Char state [[a]] -> GenParser Char state [a] mkList :: GenParser Char state a -> GenParser Char state [a] nameT :: GenParser Char state XmlTree nmtokenT :: GenParser Char state XmlTree entityValueT :: GenParser Char state XmlTrees entityTokensT :: String -> GenParser Char state XmlTrees entityCharT :: String -> GenParser Char state XmlTree attrValueT :: GenParser Char state XmlTrees attrValueT' :: String -> GenParser Char state XmlTrees referenceT :: GenParser Char state XmlTree charRefT :: GenParser Char state XmlTree entityRefT :: GenParser Char state XmlTree peReferenceT :: GenParser Char state XmlTree singleCharsT :: String -> GenParser Char state XmlTree -- | Version : $Id: XmlDTDTokenParser.hs,v 1.4 20050902 17:09:39 -- hxml Exp $ -- -- Parsec parser for tokenizing DTD declarations for ELEMENT, ATTLIST, -- ENTITY and NOTATION module Text.XML.HXT.Parser.XmlDTDTokenParser dtdDeclTokenizer :: GenParser Char state XmlTree dtdDeclStart :: GenParser Char state (DTDElem, Attributes) dtdDeclEnd :: GenParser Char state () dtdToken :: GenParser Char state XmlTree peReference :: GenParser Char state XmlTree attrValue :: GenParser Char state XmlTree dtdChars :: GenParser Char state XmlTree percent :: GenParser Char state XmlTree -- | Parsec parser for DTD declarations for ELEMENT, ATTLIST, ENTITY and -- NOTATION declarations module Text.XML.HXT.Parser.XmlDTDParser -- | parse a tokenized DTD declaration represented by a DTD tree. The -- content is represented by the children containing text and parameter -- entity reference nodes. The parameter entity reference nodes contain -- their value in the children list, consisting of text and possibly -- again parameter entity reference nodes. This structure is build by the -- parameter entity substitution. Output is again a DTD declaration node, -- but this time completely parsed and ready for further DTD processing parseXmlDTDdecl :: XmlTree -> XmlTrees parseXmlDTDdeclPart :: XmlTree -> XmlTrees parseXmlDTDEntityValue :: XmlTree -> XmlTrees elementDecl :: SParser XmlTrees attlistDecl :: SParser XmlTrees entityDecl :: SParser XmlTrees notationDecl :: SParser XmlTrees -- | Version : $Id: XmlParsec.hs,v 1.14 20050902 17:09:39 hxml Exp $ -- -- Xml Parsec parser with pure filter interface module Text.XML.HXT.Parser.XmlParsec charData :: GenParser Char state XmlTrees charData' :: GenParser Char state XmlTree comment :: GenParser Char state XmlTree pI :: GenParser Char state XmlTree cDSect :: GenParser Char state XmlTree document :: GenParser Char state XmlTree document' :: GenParser Char state XmlTrees prolog :: GenParser Char state XmlTrees xMLDecl :: GenParser Char state XmlTrees xMLDecl' :: GenParser Char state XmlTrees versionInfo :: GenParser Char state XmlTrees misc :: GenParser Char state XmlTree doctypedecl :: GenParser Char state XmlTrees markupdecl :: GenParser Char state XmlTrees sDDecl :: GenParser Char state XmlTrees element :: GenParser Char state XmlTree content :: GenParser Char state XmlTrees contentWithTextDecl :: GenParser Char state XmlTrees textDecl :: GenParser Char state XmlTrees encodingDecl :: GenParser Char state XmlTrees -- | the inverse function to xshow, (for XML content). -- -- the string parameter is parsed with the XML content parser. result is -- the list of trees or in case of an error a single element list with -- the error message as node. No entity or character subtitution is done. -- -- see also: parseXmlContent xread :: String -> XmlTrees -- | Parser for attribute values parseXmlAttrValue :: String -> XmlTree -> XmlTrees -- | the filter version of xread parseXmlContent :: XmlTree -> XmlTrees parseXmlDocEncodingSpec :: XmlTree -> XmlTrees parseXmlDocument :: String -> String -> XmlTrees -- | Parser for parts of a DTD parseXmlDTDPart :: String -> XmlTree -> XmlTrees -- | try to parse a xml encoding spec. -- -- parseXmlEncodingSpec :: Parser XmlTree -> XmlTree -> XmlTrees parseXmlEntityEncodingSpec :: XmlTree -> XmlTrees -- | Parser for general entites parseXmlGeneralEntityValue :: String -> XmlTree -> XmlTrees -- | general parser for parsing arbitray parts of a XML document parseXmlPart :: Parser XmlTrees -> String -> String -> XmlTree -> XmlTrees -- | a more general version of parseXmlContent. The parser to be -- used and the context are extra parameter parseXmlText :: Parser XmlTrees -> String -> XmlTree -> XmlTrees -- | Parser for NMTOKENs parseNMToken :: String -> XmlTree -> XmlTrees -- | Parser for XML names parseName :: String -> XmlTree -> XmlTrees removeEncodingSpec :: XmlTree -> XmlTrees -- | This parser tries to interprete everything as HTML no errors are -- emitted during parsing. If something looks weired, warning messages -- are inserted in the document tree. -- -- All filter are pure XmlFilter, errror handling and IO is done in -- Text.XML.HXT.Parser.HtmlParser or other modules module Text.XML.HXT.Parser.HtmlParsec parseHtmlText :: String -> XmlTree -> XmlTrees parseHtmlDocument :: String -> String -> XmlTrees parseHtmlContent :: String -> XmlTrees isEmptyHtmlTag :: String -> Bool isInnerHtmlTagOf :: String -> String -> Bool closesHtmlTag :: String -> String -> Bool emptyHtmlTags :: [String] -- | lasy HTML and simpe XML parser implemented with tagsoup parsing is -- done with a very simple monadic top down parser module Text.XML.HXT.Parser.TagSoup parseHtmlTagSoup :: Bool -> Bool -> Bool -> Bool -> Bool -> String -> String -> XmlTrees instance Monad Parser -- | Helper functions for RelaxNG validation module Text.XML.HXT.RelaxNG.Utils -- | Tests whether a URI matches the Relax NG anyURI symbol isRelaxAnyURI :: String -> Bool -- | Tests whether two URIs are equal after normalizeURI is -- performed compareURI :: String -> String -> Bool -- | Converts all letters to the corresponding lower-case letter and -- removes a trailing "/" normalizeURI :: String -> String -- | Tests whether a string matches a number [-](0-9)* isNumber :: String -> Bool isNmtoken :: String -> Bool isName :: String -> Bool formatStringList :: (String -> String) -> String -> [String] -> String -- | Formats a list of strings into a single string. The first parameter -- formats the elements, the 2. is inserted between two elements. -- -- example: -- --
--   formatStringList show ", " ["foo", "bar", "baz"] -> "foo", "bar", "baz"
--   
formatStringListPatt :: [String] -> String formatStringListId :: [String] -> String formatStringListQuot :: [String] -> String formatStringListPairs :: [(String, String)] -> String formatStringListArr :: [String] -> String -- | Navigable tree structure which allow a program to traverse for XPath -- expressions copied and modified from HXML -- (http://www.flightlab.com/~joe/hxml/) module Text.XML.HXT.XPath.NavTree parentAxis :: NavTree a -> [NavTree a] ancestorAxis :: NavTree a -> [NavTree a] ancestorOrSelfAxis :: NavTree a -> [NavTree a] childAxis :: NavTree a -> [NavTree a] descendantAxis :: NavTree a -> [NavTree a] descendantOrSelfAxis :: NavTree a -> [NavTree a] followingSiblingAxis :: NavTree a -> [NavTree a] precedingSiblingAxis :: NavTree a -> [NavTree a] selfAxis :: NavTree a -> [NavTree a] followingAxis :: NavTree a -> [NavTree a] precedingAxis :: NavTree a -> [NavTree a] attributeAxis :: NavTree XNode -> [NavTree XNode] -- | The core data types of XPath. The Type NodeSet is based on the module -- NavTree which was adapted from HXML -- (http://www.flightlab.com/~joe/hxml/) module Text.XML.HXT.XPath.XPathDataTypes -- | Represents expression data Expr -- | generic expression with an operator and one or more operands GenExpr :: Op -> [Expr] -> Expr -- | a path expression contains an optional filter-expression or an -- optional locationpath. one expression is urgently necessary, both are -- possible PathExpr :: (Maybe Expr) -> (Maybe LocationPath) -> Expr -- | filter-expression with zero or more predicates FilterExpr :: [Expr] -> Expr -- | variable VarExpr :: VarName -> Expr -- | string LiteralExpr :: Literal -> Expr -- | number NumberExpr :: XPNumber -> Expr -- | a function with a name and an optional list of arguments FctExpr :: FctName -> FctArguments -> Expr -- | Represents XPath operators data Op Or :: Op And :: Op Eq :: Op NEq :: Op Less :: Op Greater :: Op LessEq :: Op GreaterEq :: Op Plus :: Op Minus :: Op Div :: Op Mod :: Op Mult :: Op Unary :: Op Union :: Op -- | Represents a floating-point number according the IEEE 754 standard -- -- The standard includes a special Not-a-Number (NaN) value, positive and -- negative infinity, positive and negative zero. data XPNumber -- | floating-point number Float :: Float -> XPNumber -- | not-a-number NaN :: XPNumber -- | negative infinity NegInf :: XPNumber -- | negative zero Neg0 :: XPNumber -- | positive zero Pos0 :: XPNumber -- | positive infinity PosInf :: XPNumber -- | Represents location path -- -- A location path consists of a sequence of one or more location steps. data LocationPath LocPath :: Path -> [XStep] -> LocationPath -- | A location path is either a relative or an absolute path. data Path Rel :: Path Abs :: Path -- | Represents location step -- -- A location step consists of an axis, a node-test and zero or more -- predicates. data XStep Step :: AxisSpec -> NodeTest -> [Expr] -> XStep -- | Represents XPath axis data AxisSpec Ancestor :: AxisSpec AncestorOrSelf :: AxisSpec Attribute :: AxisSpec Child :: AxisSpec Descendant :: AxisSpec DescendantOrSelf :: AxisSpec Following :: AxisSpec FollowingSibling :: AxisSpec Namespace :: AxisSpec Parent :: AxisSpec Preceding :: AxisSpec PrecedingSibling :: AxisSpec Self :: AxisSpec -- | Represents XPath node-tests data NodeTest -- | name-test NameTest :: QName -> NodeTest -- | processing-instruction-test with a literal argument PI :: String -> NodeTest -- | all nodetype-tests TypeTest :: XPathNode -> NodeTest -- | Represents nodetype-tests data XPathNode -- | all 7 nodetypes (root, element, attribute, namespace, pi, comment, -- text) XPNode :: XPathNode -- | comment-nodes XPCommentNode :: XPathNode -- | processing-instruction-nodes XPPINode :: XPathNode -- | text-nodes: cdata, character data XPTextNode :: XPathNode type Name = (NamePrefix, LocalName) type NamePrefix = String type LocalName = String -- | Variable name type VarName = Name -- | a string type Literal = String -- | Function name type FctName = String -- | Function arguments type FctArguments = [Expr] -- | Evaluation context type Context = (ConPos, ConLen, ConNode) -- | Context position type ConPos = Int -- | Context length type ConLen = Int -- | Context node type ConNode = NavXmlTree -- | Represents XPath results data XPathValue -- | node-set XPVNode :: NodeSet -> XPathValue -- | boolean value XPVBool :: Bool -> XPathValue -- | number according the IEEE 754 standard XPVNumber :: XPNumber -> XPathValue -- | string value XPVString :: String -> XPathValue -- | error message with text XPVError :: String -> XPathValue -- | Node of navigable tree representation type NavXmlTree = NavTree XNode -- | List of nodes of navigable tree representation type NavXmlTrees = [NavXmlTree] -- | Type synonym for a list of navigable tree representation type NodeSet = NavXmlTrees -- | A functions that takes a XPath result and returns a XPath result type XPathFilter = XPathValue -> XPathValue -- | XPath environment -- -- All variables are stored in the environment, each variable name is -- bound to a value. type VarTab = [(VarName, XPathValue)] type KeyTab = [(QName, String, NavXmlTree)] type Env = (VarTab, KeyTab) varEnv :: Env instance Show XPathValue instance Eq XPathValue instance Ord XPathValue instance Show XPathNode instance Eq XPathNode instance Show NodeTest instance Eq NodeTest instance Show AxisSpec instance Eq AxisSpec instance Show XStep instance Eq XStep instance Show Path instance Eq Path instance Show LocationPath instance Eq LocationPath instance Show Op instance Eq Op instance Show Expr instance Eq Expr instance Ord XPNumber instance Eq XPNumber instance Show XPNumber -- | The module contains arithmetic calculations according the IEEE 754 -- standard for plus, minus, unary minus, multiplication, modulo and -- division. module Text.XML.HXT.XPath.XPathArithmetic -- | Multiplication xPathMulti :: Op -> XPathValue -> XPathFilter -- | Modulo xPathMod :: Op -> XPathValue -> XPathFilter -- | Division: the divison-operator is not according the IEEE 754 standard, -- it calculates the same as the % operator in Java and ECMAScript xPathDiv :: Op -> XPathValue -> XPathFilter -- | Plus and minus -- -- 1.parameter op : plus or minus operation xPathAdd :: Op -> XPathValue -> XPathFilter -- | Unary minus: the value NaN is not calculatable and returned -- unchanged, all other values can be denied. xPathUnary :: XPathFilter -- | Format an expression or value in tree- or string-representation module Text.XML.HXT.XPath.XPathToString -- | Format a parsed XPath-expression in tree representation. Text output -- is done by formatXmlTree expr2XPathTree :: Expr -> XPathTree -- | Format a XPath-value in string representation. Text output is done by -- formatXmlTree for node-sets (trees), all other values are -- represented as strings. xPValue2String :: XPathValue -> String -- | Convert a a XPath-value into XmlTrees. xPValue2XmlTrees :: XPathValue -> XmlTrees nt2XPathTree :: NodeTest -> XPathTree pred2XPathTree :: [Expr] -> XPathTree -- | Convert an navigable tree in a xmltree toXPathTree :: [NavTree a] -> [NTree a] module Text.XML.HXT.IO.GetHTTPLibCurl getCont :: [(String, String)] -> String -> IO (Either String ([(String, String)], String)) module Text.XML.HXT.RelaxNG.DataTypes relaxSchemaFile :: String relaxSchemaGrammarFile :: String a_relaxSimplificationChanges :: String defineOrigName :: String a_numberOfErrors :: String type Env = [(String, XmlTree)] -- | Start of a context attribute value (see also: -- Text.XML.HXT.RelaxNG.Simplification.simplificationStep1) -- -- The value is always followed by the original attribute name and value contextAttributes :: String -- | Start of base uri attribute value (see also: simplificationStep1 in -- Text.XML.HXT.RelaxNG.Simplification) contextBaseAttr :: String type OldName = String type NewName = String type NamePair = (OldName, NewName) type RefList = [NamePair] -- | Type of all datatype libraries functions that tests whether a XML -- instance value matches a value-pattern. -- -- Returns Just "errorMessage" in case of an error else Nothing. type DatatypeEqual = DatatypeName -> String -> Context -> String -> Context -> Maybe String -- | Type of all datatype libraries functions that tests whether a XML -- instance value matches a data-pattern. -- -- Returns Just "errorMessage" in case of an error else Nothing. type DatatypeAllows = DatatypeName -> ParamList -> String -> Context -> Maybe String -- | List of all supported datatype libraries type DatatypeLibraries = [DatatypeLibrary] -- | Each datatype library is identified by a URI. type DatatypeLibrary = (Uri, DatatypeCheck) type DatatypeName = String type ParamName = String -- | List of all supported params for a datatype type AllowedParams = [ParamName] -- | List of all supported datatypes and there allowed params type AllowedDatatypes = [(DatatypeName, AllowedParams)] -- | The Constructor exports the list of supported datatypes for a library. -- It also exports the specialized datatype library functions to validate -- a XML instance value with respect to a datatype. data DatatypeCheck DTC :: DatatypeAllows -> DatatypeEqual -> AllowedDatatypes -> DatatypeCheck -- | function to test whether a value matches a data-pattern dtAllowsFct :: DatatypeCheck -> DatatypeAllows -- | function to test whether a value matches a value-pattern dtEqualFct :: DatatypeCheck -> DatatypeEqual -- | list of all supported params for a datatype dtAllowedTypes :: DatatypeCheck -> AllowedDatatypes type Uri = String type LocalName = String -- | List of parameters; each parameter is a pair consisting of a local -- name and a value. type ParamList = [(LocalName, String)] type Prefix = String -- | A Context represents the context of an XML element. It consists of a -- base URI and a mapping from prefixes to namespace URIs. type Context = (Uri, [(Prefix, Uri)]) -- | A Datatype identifies a datatype by a datatype library name and a -- local name. type Datatype = (Uri, LocalName) showDatatype :: Datatype -> String -- | Represents a name class data NameClass AnyName :: NameClass AnyNameExcept :: NameClass -> NameClass Name :: Uri -> LocalName -> NameClass NsName :: Uri -> NameClass NsNameExcept :: Uri -> NameClass -> NameClass NameClassChoice :: NameClass -> NameClass -> NameClass NCError :: String -> NameClass -- | Represents a pattern after simplification data Pattern Empty :: Pattern NotAllowed :: ErrMessage -> Pattern Text :: Pattern Choice :: Pattern -> Pattern -> Pattern Interleave :: Pattern -> Pattern -> Pattern Group :: Pattern -> Pattern -> Pattern OneOrMore :: Pattern -> Pattern List :: Pattern -> Pattern Data :: Datatype -> ParamList -> Pattern DataExcept :: Datatype -> ParamList -> Pattern -> Pattern Value :: Datatype -> String -> Context -> Pattern Attribute :: NameClass -> Pattern -> Pattern Element :: NameClass -> Pattern -> Pattern After :: Pattern -> Pattern -> Pattern data ErrMessage ErrMsg :: ErrLevel -> [String] -> ErrMessage type ErrLevel = Int -- | smart constructor for NotAllowed notAllowed :: String -> Pattern notAllowed1 :: String -> Pattern notAllowed2 :: String -> Pattern notAllowedN :: ErrLevel -> String -> Pattern -- | merge error messages -- -- If error levels are different, the more important is taken, if level -- is 2 (max level) both error messages are taken else the 1. error -- mesage is taken mergeNotAllowed :: Pattern -> Pattern -> Pattern -- | smart constructor for Choice choice :: Pattern -> Pattern -> Pattern -- | smart constructor for Group group :: Pattern -> Pattern -> Pattern -- | smart constructor for OneOrMore oneOrMore :: Pattern -> Pattern -- | smart constructor for Interleave interleave :: Pattern -> Pattern -> Pattern -- | smart constructor for After after :: Pattern -> Pattern -> Pattern -- | Possible content types of a Relax NG pattern. (see also chapter 7.2 in -- Relax NG specification) data ContentType CTEmpty :: ContentType CTComplex :: ContentType CTSimple :: ContentType CTNone :: ContentType instance Show ContentType instance Eq ContentType instance Ord ContentType instance Eq NameClass instance Show ErrMessage instance Show Pattern instance Show NameClass -- | exports helper functions for the integration of new datatype-libraries module Text.XML.HXT.RelaxNG.DataTypeLibUtils errorMsgEqual :: DatatypeName -> String -> String -> String errorMsgDataTypeNotAllowed :: String -> String -> [(String, String)] -> String -> String errorMsgDataTypeNotAllowed0 :: String -> String -> String errorMsgDataTypeNotAllowed2 :: String -> String -> String -> String -> String errorMsgDataLibQName :: String -> String -> String -> String -- | Error Message for the equality test of two datatype values -- -- -- -- example: -- --
--   errorMsgEqual "Int" "21" "42" -> "Datatype Int with value = 21 expected, but value = 42 found"
--   
errorMsgParam :: LocalName -> String -> String -> String rng_length :: String rng_maxLength :: String rng_minLength :: String rng_maxExclusive :: String rng_minExclusive :: String rng_maxInclusive :: String rng_minInclusive :: String -- | Function table type type FunctionTable = [(String, String -> String -> Bool)] stringValidFT :: FunctionTable -> DatatypeName -> Integer -> Integer -> ParamList -> CheckString -- | Function table for string tests, XML document value is first operand, -- schema value second fctTableString :: FunctionTable -- | Function table for list tests, XML document value is first operand, -- schema value second fctTableList :: FunctionTable -- | Tests whether a "string" datatype value is between the lower and upper -- bound of the datatype and matches all parameters. -- -- All tests are performed on the string value. -- -- stringValid :: DatatypeName -> Integer -> Integer -> ParamList -> CheckString -- | Tests whether a "numeric" datatype value is between the lower and -- upper bound of the datatype and matches all parameters. -- -- First, the string value is parsed into a numeric representation. If no -- error occur, all following tests are performed on the numeric value. -- -- numberValid :: DatatypeName -> Integer -> Integer -> ParamList -> CheckString -- | tests whether a string value matches a numeric param -- -- valid example: -- --
--   <data type="CHAR"> <param name="maxLength">5</param> </data>
--   
-- -- invalid example: -- --
--   <data type="CHAR"> <param name="minLength">foo</param> </data>
--   
numParamValid :: (Integer -> Integer -> Bool) -> String -> String -> Bool data CheckA a b type CheckString = CheckA String String type CheckInteger = CheckA Integer Integer -- | run a check and deliver Just an error message or Nothing performCheck :: CheckA a b -> a -> Maybe String -- | every thing is fine ok :: CheckA a a -- | always failure failure :: (a -> String) -> CheckA a b -- | perform a simple check with a predicate p, when the predicate holds, -- assert acts as identity, else an error message is generated assert :: (a -> Bool) -> (a -> String) -> CheckA a a -- | perform a simple check with a Maybe function, Nothing indicates error assertMaybe :: (a -> Maybe b) -> (a -> String) -> CheckA a b -- | perform a check, but convert the value before checking checkWith :: (a -> b) -> CheckA b c -> CheckA a a instance ArrowPlus CheckA instance ArrowZero CheckA instance Arrow CheckA instance Category CheckA -- | Datatype library for the MySQL datatypes -- -- $Id: DataTypeLibMysql.hs,v 1.1 20050902 17:09:39 hxml Exp $ module Text.XML.HXT.RelaxNG.DataTypeLibMysql -- | Namespace of the MySQL datatype library mysqlNS :: String -- | The main entry point to the MySQL datatype library. -- -- The DTC constructor exports the list of supported datatypes and -- params. It also exports the specialized functions to validate a XML -- instance value with respect to a datatype. mysqlDatatypeLib :: DatatypeLibrary -- | Version : $Id$ -- -- Datatype library for the W3C XML schema datatypes module Text.XML.HXT.RelaxNG.XmlSchema.DataTypeLibW3C -- | Namespace of the W3C XML schema datatype library w3cNS :: String -- | The main entry point to the W3C XML schema datatype library. -- -- The DTC constructor exports the list of supported datatypes and -- params. It also exports the specialized functions to validate a XML -- instance value with respect to a datatype. w3cDatatypeLib :: DatatypeLibrary xsd_string :: String xsd_normalizedString :: String xsd_token :: String xsd_language :: String xsd_NMTOKEN :: String xsd_NMTOKENS :: String xsd_Name :: String xsd_NCName :: String xsd_ID :: String xsd_IDREF :: String xsd_IDREFS :: String xsd_ENTITY :: String xsd_ENTITIES :: String xsd_anyURI :: String xsd_QName :: String xsd_NOTATION :: String xsd_hexBinary :: String xsd_base64Binary :: String xsd_decimal :: String xsd_length :: String xsd_maxLength :: String xsd_minLength :: String xsd_maxExclusive :: String xsd_minExclusive :: String xsd_maxInclusive :: String xsd_minInclusive :: String xsd_totalDigits :: String xsd_fractionDigits :: String xsd_pattern :: String xsd_enumeration :: String -- | Version : $Id$ -- -- Datatypes and functions for building a content model for XML picklers. -- A schema is part of every pickler and can be used to derive a -- corrensponding DTD (or Relax NG schema). This schema further enables -- checking the picklers. module Text.XML.HXT.Arrow.Pickle.Schema -- | The datatype for modelling the structure of an data Schema Any :: Schema Seq :: [Schema] -> Schema sc_l :: Schema -> [Schema] Alt :: [Schema] -> Schema sc_l :: Schema -> [Schema] Rep :: Int -> Int -> Schema -> Schema sc_lb :: Schema -> Int sc_ub :: Schema -> Int sc_1 :: Schema -> Schema Element :: Name -> Schema -> Schema sc_n :: Schema -> Name sc_1 :: Schema -> Schema Attribute :: Name -> Schema -> Schema sc_n :: Schema -> Name sc_1 :: Schema -> Schema ElemRef :: Name -> Schema sc_n :: Schema -> Name CharData :: DataTypeDescr -> Schema sc_dt :: Schema -> DataTypeDescr type Name = String type Schemas = [Schema] data DataTypeDescr DTDescr :: String -> String -> Attributes -> DataTypeDescr dtLib :: DataTypeDescr -> String dtName :: DataTypeDescr -> String dtParams :: DataTypeDescr -> Attributes -- | test: is schema a simple XML Schema datatype isScXsd :: (String -> Bool) -> Schema -> Bool -- | test: is type a fixed value attribute type isScFixed :: Schema -> Bool isScEnum :: Schema -> Bool isScElem :: Schema -> Bool isScAttr :: Schema -> Bool isScElemRef :: Schema -> Bool isScCharData :: Schema -> Bool isScSARE :: Schema -> Bool isScList :: Schema -> Bool isScOpt :: Schema -> Bool -- | access an attribute of a descr of an atomic type xsdParam :: String -> Schema -> String scDT :: String -> String -> Attributes -> Schema scDTxsd :: String -> Attributes -> Schema scString :: Schema scString1 :: Schema scFixed :: String -> Schema scEnum :: [String] -> Schema scNmtoken :: Schema scNmtokens :: Schema scEmpty :: Schema scSeq :: Schema -> Schema -> Schema scSeqs :: [Schema] -> Schema scNull :: Schema scAlt :: Schema -> Schema -> Schema scAlts :: [Schema] -> Schema scOption :: Schema -> Schema scList :: Schema -> Schema scList1 :: Schema -> Schema scOpt :: Schema -> Schema scRep :: Int -> Int -> Schema -> Schema scElem :: String -> Schema -> Schema scAttr :: String -> Schema -> Schema instance Show DataTypeDescr instance Eq Schema instance Show Schema instance Eq DataTypeDescr -- | Version : $Id$ -- -- Functions for converting a pickler schema into a DTD module Text.XML.HXT.Arrow.Pickle.DTD data DTDdescr DTDdescr :: Name -> Schemas -> [(Name, Schemas)] -> DTDdescr -- | convert a DTD descr into XmlTrees dtdDescrToXml :: DTDdescr -> XmlTrees checkAttrModell :: Name -> Schemas -> XmlTrees checkAM :: Name -> Schema -> XmlTrees checkAMC :: Name -> Name -> Schema -> XmlTrees checkContentModell :: Name -> Schema -> XmlTrees scContToXml :: Schema -> (Attributes, XmlTrees) scWrap :: Schema -> Schema scCont :: Attributes -> Schema -> XmlTrees scConts :: Attributes -> Schemas -> XmlTrees scAttrToXml :: Schema -> (Attributes, XmlTrees) checkErr :: Bool -> String -> XmlTrees foundErr :: String -> XmlTrees -- | convert a pickler schema into a DTD descr dtdDescr :: Schema -> DTDdescr elementDeclarations :: Schema -> Schemas elementDecs :: Schemas -> Schemas -> Schemas elemNames :: Schemas -> [Name] elemName :: Schema -> Maybe Name elemRefs :: Schemas -> Schemas attrDec :: Schema -> [(Name, Schemas)] remAttrDec :: Schema -> Schema instance Show DTDdescr -- | This modul exports the list of supported datatype libraries. It also -- exports the main functions to validate an XML instance value with -- respect to a datatype. module Text.XML.HXT.RelaxNG.DataTypeLibraries -- | List of all supported datatype libraries which can be used within the -- Relax NG validator modul. datatypeLibraries :: DatatypeLibraries -- | Tests whether a XML instance value matches a value-pattern. -- -- The following tests are performed: -- -- -- -- The hard work is done by the specialized DatatypeEqual function -- (see also: DatatypeCheck) of the datatype library. datatypeEqual :: Uri -> DatatypeEqual -- | Tests whether a XML instance value matches a data-pattern. -- -- The following tests are performed: -- -- -- -- The hard work is done by the specialized DatatypeAllows -- function (see also: DatatypeCheck) of the datatype library. datatypeAllows :: Uri -> DatatypeAllows -- | basic Pattern functions module Text.XML.HXT.RelaxNG.PatternFunctions isRelaxEmpty :: Pattern -> Bool isRelaxNotAllowed :: Pattern -> Bool isRelaxText :: Pattern -> Bool isRelaxChoice :: Pattern -> Bool isRelaxInterleave :: Pattern -> Bool isRelaxGroup :: Pattern -> Bool isRelaxOneOrMore :: Pattern -> Bool isRelaxList :: Pattern -> Bool isRelaxData :: Pattern -> Bool isRelaxDataExcept :: Pattern -> Bool isRelaxValue :: Pattern -> Bool isRelaxAttribute :: Pattern -> Bool isRelaxElement :: Pattern -> Bool isRelaxAfter :: Pattern -> Bool -- | Returns a list of children pattern for each pattern, e.g. (Choice p1 -- p2) = [p1, p2] getChildrenPattern :: Pattern -> [Pattern] -- | Returns the nameclass of a element- or attribute pattern. Otherwise -- NCError is returned. getNameClassFromPattern :: Pattern -> NameClass -- | Returns a string representation of the pattern name getPatternName :: Pattern -> String -- | the XPath Parser module Text.XML.HXT.XPath.XPathParser -- | parsing a number, parseNumber is used in XPathFct by the number -- function -- -- parseNumber :: String -> XPathValue -- | the main entry point: parsing a XPath expression parseXPath :: XParser Expr -- | Convert an XPath result set into a node set module Text.XML.HXT.XPath.XPathToNodeSet -- | Convert a a XPath-value into a XmlNodeSet represented by a tree -- structure -- -- The XmlNodeSet can be used to traverse a tree an process all marked -- nodes. xPValue2NodeSet :: XPathValue -> XmlNodeSet emptyNodeSet :: XmlNodeSet -- | Arrows for managing an explicit state -- -- State arrows work similar to state monads. A state value is threaded -- through the application of arrows. module Control.Arrow.ArrowState -- | The interface for accessing and changing the state component. -- -- Multi parameter classes and functional dependencies are required. class (Arrow a) => ArrowState s a | a -> s changeState :: (ArrowState s a) => (s -> b -> s) -> a b b accessState :: (ArrowState s a) => (s -> b -> c) -> a b c getState :: (ArrowState s a) => a b s setState :: (ArrowState s a) => a s s nextState :: (ArrowState s a) => (s -> s) -> a b s -- | Arrows for evaluation of normal form results module Control.Arrow.ArrowNF -- | complete evaluation of an arrow result using rnf -- -- this is sometimes useful for preventing space leaks, especially after -- reading and validation of a document, all DTD stuff is not longer in -- use and can be recycled by the GC. strictA :: (Arrow a, NFData b) => a b b class (Arrow a) => ArrowNF a rnfA :: (ArrowNF a, NFData c) => a b c -> a b c -- | Version : $Id: ArrowList.hs,v 1.11 20060601 12:59:04 hxml Exp $ -- -- The List Arrow Class -- -- This module defines the interface for list arrows. -- -- A list arrow is a function, that gives a list of results for a given -- argument. A single element result represents a normal function. An -- empty list oven indicates, the function is undefined for the given -- argument. The empty list may also represent False, none empty lists -- True. A list with more than one element gives all results for a -- nondeterministic function. module Control.Arrow.ArrowList -- | The interface for list arrows -- -- Only mkA, arr2A, isA '(>>.)' don't have default -- implementations class (Arrow a, ArrowPlus a, ArrowZero a, ArrowApply a) => ArrowList a arr2 :: (ArrowList a) => (b1 -> b2 -> c) -> a (b1, b2) c arr3 :: (ArrowList a) => (b1 -> b2 -> b3 -> c) -> a (b1, (b2, b3)) c arr4 :: (ArrowList a) => (b1 -> b2 -> b3 -> b4 -> c) -> a (b1, (b2, (b3, b4))) c arr2A :: (ArrowList a) => (b -> a c d) -> a (b, c) d arrL :: (ArrowList a) => (b -> [c]) -> a b c arr2L :: (ArrowList a) => (b -> c -> [d]) -> a (b, c) d constA :: (ArrowList a) => c -> a b c constL :: (ArrowList a) => [c] -> a b c isA :: (ArrowList a) => (b -> Bool) -> a b b (>>.) :: (ArrowList a) => a b c -> ([c] -> [d]) -> a b d (>.) :: (ArrowList a) => a b c -> ([c] -> d) -> a b d listA :: (ArrowList a) => a b c -> a b [c] unlistA :: (ArrowList a) => a [b] b this :: (ArrowList a) => a b b none :: (ArrowList a) => a b c withDefault :: (ArrowList a) => a b c -> c -> a b c single :: (ArrowList a) => a b c -> a b c applyA :: (ArrowList a) => a b (a b c) -> a b c ($<) :: (ArrowList a) => (c -> a b d) -> a b c -> a b d ($<<) :: (ArrowList a) => (c1 -> c2 -> a b d) -> a b (c1, c2) -> a b d ($<<<) :: (ArrowList a) => (c1 -> c2 -> c3 -> a b d) -> a b (c1, (c2, c3)) -> a b d ($<<<<) :: (ArrowList a) => (c1 -> c2 -> c3 -> c4 -> a b d) -> a b (c1, (c2, (c3, c4))) -> a b d ($<$) :: (ArrowList a) => (c -> (a b b)) -> a b c -> a b b mergeA :: (ArrowList a) => (a (a1, b1) a1 -> a (a1, b1) b1 -> a (a1, b1) c) -> a (a1, b1) c perform :: (ArrowList a) => a b c -> a b b catA :: (ArrowList a) => [a b c] -> a b c seqA :: (ArrowList a) => [a b b] -> a b b -- | Version : $Id: ArrowIf.hs,v 1.8 20060504 14:17:53 hxml Exp $ -- -- Conditionals for List Arrows -- -- This module defines conditional combinators for list arrows. -- -- The empty list as result represents False, none empty lists True. module Control.Arrow.ArrowIf -- | The interface for arrows as conditionals. -- -- Requires list arrows because False is represented as empty list, True -- as none empty lists. -- -- Only ifA and orElse don't have default implementations class (ArrowList a) => ArrowIf a ifA :: (ArrowIf a) => a b c -> a b d -> a b d -> a b d ifP :: (ArrowIf a) => (b -> Bool) -> a b d -> a b d -> a b d neg :: (ArrowIf a) => a b c -> a b b when :: (ArrowIf a) => a b b -> a b c -> a b b whenP :: (ArrowIf a) => a b b -> (b -> Bool) -> a b b whenNot :: (ArrowIf a) => a b b -> a b c -> a b b whenNotP :: (ArrowIf a) => a b b -> (b -> Bool) -> a b b guards :: (ArrowIf a) => a b c -> a b d -> a b d guardsP :: (ArrowIf a) => (b -> Bool) -> a b d -> a b d filterA :: (ArrowIf a) => a b c -> a b b containing :: (ArrowIf a) => a b c -> a c d -> a b c notContaining :: (ArrowIf a) => a b c -> a c d -> a b c orElse :: (ArrowIf a) => a b c -> a b c -> a b c choiceA :: (ArrowIf a) => [IfThen (a b c) (a b d)] -> a b d tagA :: (ArrowIf a) => a b c -> a b (Either b b) spanA :: (ArrowIf a) => a b b -> a [b] ([b], [b]) partitionA :: (ArrowIf a) => a b b -> a [b] ([b], [b]) -- | an auxiliary data type for choiceA data IfThen a b (:->) :: a -> b -> IfThen a b -- | Version : $Id: ArrowTree.hs,v 1.12 20061130 16:05:24 hxml Exp $ -- -- List arrows for tree processing. -- -- Trees that implement the Data.Tree.Class interface, can be -- processed with these arrows. module Control.Arrow.ArrowTree -- | The interface for tree arrows -- -- all functions have default implementations class (ArrowPlus a, ArrowIf a) => ArrowTree a mkLeaf :: (ArrowTree a, Tree t) => b -> a c (t b) mkTree :: (ArrowTree a, Tree t) => b -> [t b] -> a c (t b) getChildren :: (ArrowTree a, Tree t) => a (t b) (t b) getNode :: (ArrowTree a, Tree t) => a (t b) b setChildren :: (ArrowTree a, Tree t) => [t b] -> a (t b) (t b) setNode :: (ArrowTree a, Tree t) => b -> a (t b) (t b) changeChildren :: (ArrowTree a, Tree t) => ([t b] -> [t b]) -> a (t b) (t b) changeNode :: (ArrowTree a, Tree t) => (b -> b) -> a (t b) (t b) processChildren :: (ArrowTree a, Tree t) => a (t b) (t b) -> a (t b) (t b) replaceChildren :: (ArrowTree a, Tree t) => a (t b) (t b) -> a (t b) (t b) (/>) :: (ArrowTree a, Tree t) => a (t b) (t b) -> a (t b) (t b) -> a (t b) (t b) ( a (t b) (t b) -> a (t b) (t b) -> a (t b) (t b) deep :: (ArrowTree a, Tree t) => a (t b) (t b) -> a (t b) (t b) deepest :: (ArrowTree a, Tree t) => a (t b) (t b) -> a (t b) (t b) multi :: (ArrowTree a, Tree t) => a (t b) c -> a (t b) c processBottomUp :: (ArrowTree a, Tree t) => a (t b) (t b) -> a (t b) (t b) processTopDown :: (ArrowTree a, Tree t) => a (t b) (t b) -> a (t b) (t b) processBottomUpWhenNot :: (ArrowTree a, Tree t) => a (t b) (t b) -> a (t b) (t b) -> a (t b) (t b) processTopDownUntil :: (ArrowTree a, Tree t) => a (t b) (t b) -> a (t b) (t b) insertChildrenAt :: (ArrowTree a, Tree t) => Int -> a (t b) (t b) -> a (t b) (t b) insertChildrenAfter :: (ArrowTree a, Tree t) => a (t b) (t b) -> a (t b) (t b) -> a (t b) (t b) insertTreeTemplate :: (ArrowTree a, Tree t) => a (t b) (t b) -> [IfThen (a (t b) c) (a (t b) (t b))] -> a (t b) (t b) -- | The interface for trees class Tree t -- | Implementation of pure list arrows module Control.Arrow.ListArrow -- | pure list arrow data type newtype LA a b LA :: (a -> [b]) -> LA a b runLA :: LA a b -> a -> [b] -- | conversion of pure list arrows into other possibly more complex list -- arrows fromLA :: (ArrowList a) => LA b c -> a b c instance ArrowNF LA instance ArrowTree LA instance ArrowIf LA instance ArrowList LA instance ArrowApply LA instance ArrowChoice LA instance ArrowPlus LA instance ArrowZero LA instance Arrow LA instance Category LA -- | Implementation of list arrows with a state module Control.Arrow.StateListArrow -- | list arrow combined with a state newtype SLA s a b SLA :: (s -> a -> (s, [b])) -> SLA s a b runSLA :: SLA s a b -> s -> a -> (s, [b]) -- | conversion of state list arrows into arbitray other list arrows. -- -- allows running a state list arrow within another arrow: -- -- example: -- --
--   ... >>> fromSLA 0 (... setState ... getState ... ) >>> ...
--   
-- -- runs a state arrow with initial state 0 (e..g. an Int) within another -- arrow sequence fromSLA :: (ArrowList a) => s -> SLA s b c -> a b c instance (NFData s) => ArrowNF (SLA s) instance ArrowTree (SLA s) instance ArrowState s (SLA s) instance ArrowIf (SLA s) instance ArrowList (SLA s) instance ArrowApply (SLA s) instance ArrowChoice (SLA s) instance ArrowPlus (SLA s) instance ArrowZero (SLA s) instance Arrow (SLA s) instance Category (SLA s) -- | Version : $Id: ArrowIO.hs,v 1.6 20050902 17:09:39 hxml Exp $ -- -- Lifting of IO actions to arrows module Control.Arrow.ArrowIO -- | the interface for converting an IO action into an arrow class (Arrow a) => ArrowIO a arrIO :: (ArrowIO a) => (b -> IO c) -> a b c arrIO0 :: (ArrowIO a) => IO c -> a b c arrIO2 :: (ArrowIO a) => (b1 -> b2 -> IO c) -> a (b1, b2) c arrIO3 :: (ArrowIO a) => (b1 -> b2 -> b3 -> IO c) -> a (b1, (b2, b3)) c arrIO4 :: (ArrowIO a) => (b1 -> b2 -> b3 -> b4 -> IO c) -> a (b1, (b2, (b3, b4))) c -- | the interface for converting an IO predicate into a list arrow class (Arrow a, ArrowIO a) => ArrowIOIf a isIOA :: (ArrowIOIf a) => (b -> IO Bool) -> a b b -- | Implementation of pure list arrows with IO module Control.Arrow.IOListArrow -- | list arrow combined with IO monad newtype IOLA a b IOLA :: (a -> IO [b]) -> IOLA a b runIOLA :: IOLA a b -> a -> IO [b] instance ArrowNF IOLA instance ArrowTree IOLA instance ArrowIOIf IOLA instance ArrowIO IOLA instance ArrowIf IOLA instance ArrowList IOLA instance ArrowApply IOLA instance ArrowChoice IOLA instance ArrowPlus IOLA instance ArrowZero IOLA instance Arrow IOLA instance Category IOLA -- | Implementation of arrows with IO and a state module Control.Arrow.IOStateListArrow -- | list arrow combined with a state and the IO monad newtype IOSLA s a b IOSLA :: (s -> a -> IO (s, [b])) -> IOSLA s a b runIOSLA :: IOSLA s a b -> s -> a -> IO (s, [b]) -- | lift the state of an IOSLA arrow to a state with an additional -- component. -- -- This is uesful, when running predefined IO arrows, e.g. for document -- input, in a context with a more complex state component. liftSt :: IOSLA s1 b c -> IOSLA (s1, s2) b c -- | run an arrow with augmented state in the context of a simple state -- arrow. An initial value for the new state component is needed. -- -- This is useful, when running an arrow with an extra environment -- component, e.g. for namespace handling in XML. runSt :: s2 -> IOSLA (s1, s2) b c -> IOSLA s1 b c instance (NFData s) => ArrowNF (IOSLA s) instance ArrowTree (IOSLA s) instance ArrowState s (IOSLA s) instance ArrowIOIf (IOSLA s) instance ArrowIO (IOSLA s) instance ArrowIf (IOSLA s) instance ArrowList (IOSLA s) instance ArrowApply (IOSLA s) instance ArrowChoice (IOSLA s) instance ArrowPlus (IOSLA s) instance ArrowZero (IOSLA s) instance Arrow (IOSLA s) instance Category (IOSLA s) -- | Basic arrows for processing XML documents -- -- All arrows use IO and a global state for options, errorhandling, ... module Text.XML.HXT.Arrow.XmlArrow -- | Arrows for processing Text.XML.HXT.DOM.TypeDefs.XmlTrees -- -- These arrows can be grouped into predicates, selectors, constructors, -- and transformers. -- -- All predicates (tests) act like Control.Arrow.ArrowIf.none for failure -- and Control.Arrow.ArrowIf.this for success. A logical and can be -- formed by a1 >>> a2 , a locical or by a1 -- <+> a2 . -- -- Selector arrows will fail, when applied to wrong input, e.g. selecting -- the text of a node with getText will fail when applied to a -- none text node. -- -- Edit arrows will remain the input unchanged, when applied to wrong -- argument, e.g. editing the content of a text node with -- changeText applied to an element node will return the unchanged -- element node. class (Arrow a, ArrowList a, ArrowTree a) => ArrowXml a isText :: (ArrowXml a) => a XmlTree XmlTree isCharRef :: (ArrowXml a) => a XmlTree XmlTree isEntityRef :: (ArrowXml a) => a XmlTree XmlTree isCmt :: (ArrowXml a) => a XmlTree XmlTree isCdata :: (ArrowXml a) => a XmlTree XmlTree isPi :: (ArrowXml a) => a XmlTree XmlTree isXmlPi :: (ArrowXml a) => a XmlTree XmlTree isElem :: (ArrowXml a) => a XmlTree XmlTree isDTD :: (ArrowXml a) => a XmlTree XmlTree isAttr :: (ArrowXml a) => a XmlTree XmlTree isError :: (ArrowXml a) => a XmlTree XmlTree isRoot :: (ArrowXml a) => a XmlTree XmlTree hasText :: (ArrowXml a) => (String -> Bool) -> a XmlTree XmlTree isWhiteSpace :: (ArrowXml a) => a XmlTree XmlTree hasNameWith :: (ArrowXml a) => (QName -> Bool) -> a XmlTree XmlTree hasQName :: (ArrowXml a) => QName -> a XmlTree XmlTree hasName :: (ArrowXml a) => String -> a XmlTree XmlTree hasLocalPart :: (ArrowXml a) => String -> a XmlTree XmlTree hasNamePrefix :: (ArrowXml a) => String -> a XmlTree XmlTree hasNamespaceUri :: (ArrowXml a) => String -> a XmlTree XmlTree hasAttr :: (ArrowXml a) => String -> a XmlTree XmlTree hasQAttr :: (ArrowXml a) => QName -> a XmlTree XmlTree hasAttrValue :: (ArrowXml a) => String -> (String -> Bool) -> a XmlTree XmlTree hasQAttrValue :: (ArrowXml a) => QName -> (String -> Bool) -> a XmlTree XmlTree mkText :: (ArrowXml a) => a String XmlTree mkCharRef :: (ArrowXml a) => a Int XmlTree mkEntityRef :: (ArrowXml a) => a String XmlTree mkCmt :: (ArrowXml a) => a String XmlTree mkCdata :: (ArrowXml a) => a String XmlTree mkError :: (ArrowXml a) => Int -> a String XmlTree mkElement :: (ArrowXml a) => QName -> a n XmlTree -> a n XmlTree -> a n XmlTree mkAttr :: (ArrowXml a) => QName -> a n XmlTree -> a n XmlTree mkPi :: (ArrowXml a) => QName -> a n XmlTree -> a n XmlTree mkqelem :: (ArrowXml a) => QName -> [a n XmlTree] -> [a n XmlTree] -> a n XmlTree mkelem :: (ArrowXml a) => String -> [a n XmlTree] -> [a n XmlTree] -> a n XmlTree aelem :: (ArrowXml a) => String -> [a n XmlTree] -> a n XmlTree selem :: (ArrowXml a) => String -> [a n XmlTree] -> a n XmlTree eelem :: (ArrowXml a) => String -> a n XmlTree root :: (ArrowXml a) => [a n XmlTree] -> [a n XmlTree] -> a n XmlTree qattr :: (ArrowXml a) => QName -> a n XmlTree -> a n XmlTree attr :: (ArrowXml a) => String -> a n XmlTree -> a n XmlTree txt :: (ArrowXml a) => String -> a n XmlTree charRef :: (ArrowXml a) => Int -> a n XmlTree entityRef :: (ArrowXml a) => String -> a n XmlTree cmt :: (ArrowXml a) => String -> a n XmlTree warn :: (ArrowXml a) => String -> a n XmlTree err :: (ArrowXml a) => String -> a n XmlTree fatal :: (ArrowXml a) => String -> a n XmlTree spi :: (ArrowXml a) => String -> String -> a n XmlTree sqattr :: (ArrowXml a) => QName -> String -> a n XmlTree sattr :: (ArrowXml a) => String -> String -> a n XmlTree getText :: (ArrowXml a) => a XmlTree String getCharRef :: (ArrowXml a) => a XmlTree Int getEntityRef :: (ArrowXml a) => a XmlTree String getCmt :: (ArrowXml a) => a XmlTree String getCdata :: (ArrowXml a) => a XmlTree String getPiName :: (ArrowXml a) => a XmlTree QName getPiContent :: (ArrowXml a) => a XmlTree XmlTree getElemName :: (ArrowXml a) => a XmlTree QName getAttrl :: (ArrowXml a) => a XmlTree XmlTree getDTDPart :: (ArrowXml a) => a XmlTree DTDElem getDTDAttrl :: (ArrowXml a) => a XmlTree Attributes getAttrName :: (ArrowXml a) => a XmlTree QName getErrorLevel :: (ArrowXml a) => a XmlTree Int getErrorMsg :: (ArrowXml a) => a XmlTree String getQName :: (ArrowXml a) => a XmlTree QName getName :: (ArrowXml a) => a XmlTree String getUniversalName :: (ArrowXml a) => a XmlTree String getUniversalUri :: (ArrowXml a) => a XmlTree String getLocalPart :: (ArrowXml a) => a XmlTree String getNamePrefix :: (ArrowXml a) => a XmlTree String getNamespaceUri :: (ArrowXml a) => a XmlTree String getAttrValue :: (ArrowXml a) => String -> a XmlTree String getAttrValue0 :: (ArrowXml a) => String -> a XmlTree String getQAttrValue :: (ArrowXml a) => QName -> a XmlTree String getQAttrValue0 :: (ArrowXml a) => QName -> a XmlTree String changeText :: (ArrowXml a) => (String -> String) -> a XmlTree XmlTree changeCmt :: (ArrowXml a) => (String -> String) -> a XmlTree XmlTree changeQName :: (ArrowXml a) => (QName -> QName) -> a XmlTree XmlTree changeElemName :: (ArrowXml a) => (QName -> QName) -> a XmlTree XmlTree changeAttrName :: (ArrowXml a) => (QName -> QName) -> a XmlTree XmlTree changePiName :: (ArrowXml a) => (QName -> QName) -> a XmlTree XmlTree changeAttrValue :: (ArrowXml a) => (String -> String) -> a XmlTree XmlTree changeAttrl :: (ArrowXml a) => (XmlTrees -> XmlTrees -> XmlTrees) -> a XmlTree XmlTree -> a XmlTree XmlTree setQName :: (ArrowXml a) => QName -> a XmlTree XmlTree setElemName :: (ArrowXml a) => QName -> a XmlTree XmlTree setAttrName :: (ArrowXml a) => QName -> a XmlTree XmlTree setPiName :: (ArrowXml a) => QName -> a XmlTree XmlTree setAttrl :: (ArrowXml a) => a XmlTree XmlTree -> a XmlTree XmlTree addAttrl :: (ArrowXml a) => a XmlTree XmlTree -> a XmlTree XmlTree addAttr :: (ArrowXml a) => String -> String -> a XmlTree XmlTree removeAttr :: (ArrowXml a) => String -> a XmlTree XmlTree removeQAttr :: (ArrowXml a) => QName -> a XmlTree XmlTree processAttrl :: (ArrowXml a) => a XmlTree XmlTree -> a XmlTree XmlTree processTopDownWithAttrl :: (ArrowXml a) => a XmlTree XmlTree -> a XmlTree XmlTree (+=) :: (ArrowXml a) => a b XmlTree -> a b XmlTree -> a b XmlTree xshow :: (ArrowXml a) => a n XmlTree -> a n String -- | Document Type Definition arrows -- -- These are separated, because they are not needed for document -- processing, only when processing the DTD, e.g. for generating access -- funtions for the toolbox from a DTD (se example DTDtoHaskell in the -- examples directory) class (ArrowXml a) => ArrowDTD a isDTDDoctype :: (ArrowDTD a) => a XmlTree XmlTree isDTDElement :: (ArrowDTD a) => a XmlTree XmlTree isDTDContent :: (ArrowDTD a) => a XmlTree XmlTree isDTDAttlist :: (ArrowDTD a) => a XmlTree XmlTree isDTDEntity :: (ArrowDTD a) => a XmlTree XmlTree isDTDPEntity :: (ArrowDTD a) => a XmlTree XmlTree isDTDNotation :: (ArrowDTD a) => a XmlTree XmlTree isDTDCondSect :: (ArrowDTD a) => a XmlTree XmlTree isDTDName :: (ArrowDTD a) => a XmlTree XmlTree isDTDPERef :: (ArrowDTD a) => a XmlTree XmlTree hasDTDAttr :: (ArrowDTD a) => String -> a XmlTree XmlTree getDTDAttrValue :: (ArrowDTD a) => String -> a XmlTree String setDTDAttrValue :: (ArrowDTD a) => String -> String -> a XmlTree XmlTree mkDTDElem :: (ArrowDTD a) => DTDElem -> Attributes -> a n XmlTree -> a n XmlTree mkDTDDoctype :: (ArrowDTD a) => Attributes -> a n XmlTree -> a n XmlTree mkDTDElement :: (ArrowDTD a) => Attributes -> a n XmlTree mkDTDEntity :: (ArrowDTD a) => Attributes -> a n XmlTree mkDTDPEntity :: (ArrowDTD a) => Attributes -> a n XmlTree instance ArrowDTD (IOSLA s) instance ArrowDTD IOLA instance ArrowDTD (SLA s) instance ArrowDTD LA instance ArrowXml (IOSLA s) instance ArrowXml IOLA instance ArrowXml (SLA s) instance ArrowXml LA -- | common edit arrows module Text.XML.HXT.Arrow.Edit -- | Applies some Canonical XML rules to a document tree. -- -- The rule differ slightly for canonical XML and XPath in handling of -- comments -- -- Note: This is not the whole canonicalization as it is specified by the -- W3C Recommendation. Adding attribute defaults or sorting attributes in -- lexicographic order is done by the transform function of -- module Text.XML.HXT.Validator.Validation. Replacing entities -- or line feed normalization is done by the parser. -- -- Rules: remove DTD parts, processing instructions, comments and -- substitute char refs in attribute values and text -- -- Not implemented yet: -- -- canonicalizeAllNodes :: (ArrowList a) => a XmlTree XmlTree -- | Canonicalize a tree for XPath Like canonicalizeAllNodes but -- comment nodes are not removed -- -- see canonicalizeAllNodes canonicalizeForXPath :: (ArrowList a) => a XmlTree XmlTree -- | Canonicalize the contents of a document -- -- substitutes all char refs in text and attribute values, removes CDATA -- section and combines all sequences of resulting text nodes into a -- single text node -- -- see canonicalizeAllNodes canonicalizeContents :: (ArrowList a) => a XmlTree XmlTree -- | Applies collapseXText recursively. -- -- see also : collapseXText collapseAllXText :: (ArrowList a) => a XmlTree XmlTree -- | Collects sequences of text nodes in the list of children of a node -- into one single text node. This is useful, e.g. after char and entity -- reference substitution collapseXText :: (ArrowList a) => a XmlTree XmlTree -- | apply an arrow to the input and convert the resulting XML trees into -- an XML escaped string -- -- This is a save variant for converting a tree into an XML string -- representation that is parsable with Text.XML.HXT.Arrow.ReadDocument. -- It is implemented with xshow, but xshow does no XML escaping. -- The XML escaping is done with escapeXmlDoc before xshow is -- applied. -- -- So the following law holds -- --
--   xshowEscape f >>> xread == f
--   
xshowEscapeXml :: (ArrowXml a) => a n XmlTree -> a n String -- | escape all special XML chars into XML entity references or char -- references -- -- convert the special XML chars < and & in text nodes into -- prefefiened XML entity references, in attribute values also ', ", -- >, \n, \r and \t are converted into entity or char references, in -- comments nothing is converted (see XML standard 2.4, useful e.g. for -- JavaScript). escapeXmlDoc :: (ArrowList a) => a XmlTree XmlTree -- | escape all special HTML chars into XHTML entity references or char -- references -- -- convert the special XML chars < and & and all none ASCII chars -- in text nodes into prefefiened XML or XHTML entity references, in -- attribute values also ', ", >, \n, \r and \t are converted into -- entity or char references, in comments nothing is converted escapeHtmlDoc :: (ArrowList a) => a XmlTree XmlTree -- | convert a document into a Haskell representation (with show). -- -- Useful for debugging and trace output. see also : -- treeRepOfXmlDoc, numberLinesInXmlDoc haskellRepOfXmlDoc :: (ArrowList a) => a XmlTree XmlTree -- | convert a document into a text representation in tree form. -- -- Useful for debugging and trace output. see also : -- haskellRepOfXmlDoc, numberLinesInXmlDoc treeRepOfXmlDoc :: (ArrowList a) => a XmlTree XmlTree addHeadlineToXmlDoc :: (ArrowXml a) => a XmlTree XmlTree -- | filter for indenting a document tree for pretty printing. -- -- the tree is traversed for inserting whitespace for tag indentation. -- -- whitespace is only inserted or changed at places, where it isn't -- significant, is's not inserted between tags and text containing non -- whitespace chars. -- -- whitespace is only inserted or changed at places, where it's not -- significant. preserving whitespace may be controlled in a document -- tree by a tag attribute xml:space -- -- allowed values for this attribute are default | preserve. -- -- input is a complete document tree or a document fragment result is the -- semantically equivalent formatted tree. -- -- see also : removeDocWhiteSpace indentDoc :: (ArrowXml a) => a XmlTree XmlTree -- | convert a document into a text and add line numbers to the text -- representation. -- -- Result is a root node with a single text node as child. Useful for -- debugging and trace output. see also : haskellRepOfXmlDoc, -- treeRepOfXmlDoc numberLinesInXmlDoc :: (ArrowList a) => a XmlTree XmlTree preventEmptyElements :: (ArrowList a) => Bool -> a XmlTree XmlTree -- | remove Comments: none when isCmt removeComment :: (ArrowXml a) => a XmlTree XmlTree -- | remove all comments recursively removeAllComment :: (ArrowXml a) => a XmlTree XmlTree -- | simple filter for removing whitespace. -- -- no check on sigificant whitespace, e.g. in HTML <pre>-elements, -- is done. -- -- see also : removeAllWhiteSpace, removeDocWhiteSpace removeWhiteSpace :: (ArrowXml a) => a XmlTree XmlTree -- | simple recursive filter for removing all whitespace. -- -- removes all text nodes in a tree that consist only of whitespace. -- -- see also : removeWhiteSpace, removeDocWhiteSpace removeAllWhiteSpace :: (ArrowXml a) => a XmlTree XmlTree -- | filter for removing all not significant whitespace. -- -- the tree traversed for removing whitespace between elements, that was -- inserted for indentation and readability. whitespace is only removed -- at places, where it's not significat preserving whitespace may be -- controlled in a document tree by a tag attribute xml:space -- -- allowed values for this attribute are default | preserve -- -- input is root node of the document to be cleaned up, output the -- semantically equivalent simplified tree -- -- see also : indentDoc, removeAllWhiteSpace removeDocWhiteSpace :: (ArrowXml a) => a XmlTree XmlTree -- | converts a CDATA section node into a normal text node transfCdata :: (ArrowXml a) => a XmlTree XmlTree -- | converts CDATA sections in whole document tree into normal text nodes transfAllCdata :: (ArrowXml a) => a XmlTree XmlTree -- | converts character references to normal text transfCharRef :: (ArrowXml a) => a XmlTree XmlTree -- | recursively converts all character references to normal text transfAllCharRef :: (ArrowXml a) => a XmlTree XmlTree hasXmlPi :: (ArrowXml a) => a XmlTree XmlTree -- | add an <?xml version="1.0"?> processing instruction if it's not -- already there addXmlPi :: (ArrowXml a) => a XmlTree XmlTree -- | add an encoding spec to the <?xml version="1.0"?> processing -- instruction addXmlPiEncoding :: (ArrowXml a) => String -> a XmlTree XmlTree -- | add an XHTML strict doctype declaration to a document -- -- add an XHTML transitional doctype declaration to a document -- -- add an XHTML frameset doctype declaration to a document -- -- add a doctype declaration to a document -- -- The arguments are the root element name, the PUBLIC id and the SYSTEM -- id addDoctypeDecl :: (ArrowXml a) => String -> String -> String -> a XmlTree XmlTree addXHtmlDoctypeStrict :: (ArrowXml a) => a XmlTree XmlTree -- | add an XHTML strict doctype declaration to a document addXHtmlDoctypeTransitional :: (ArrowXml a) => a XmlTree XmlTree addXHtmlDoctypeFrameset :: (ArrowXml a) => a XmlTree XmlTree -- | namespace specific arrows module Text.XML.HXT.Arrow.Namespace -- | attach all valid namespace declarations to the attribute list of -- element nodes. -- -- This arrow is useful for document processing, that requires access to -- all namespace declarations at any element node, but which cannot be -- done with a simple processWithNsEnv. attachNsEnv :: (ArrowXml a) => NsEnv -> a XmlTree XmlTree -- | does the real work for namespace cleanup. -- -- The parameter is used for collecting namespace uris and prefixes from -- the input tree cleanupNamespaces :: LA XmlTree (String, String) -> LA XmlTree XmlTree -- | collect all namespace declarations contained in a document -- -- apply getNamespaceDecl to a whole XmlTree collectNamespaceDecl :: LA XmlTree (String, String) -- | collect all (namePrefix, namespaceUri) pairs from a tree -- -- all qualified names are inspected, whether a namespace uri is defined, -- for these uris the prefix and uri is returned. This arrow is useful -- for namespace cleanup, e.g. for documents generated with XSLT. It can -- be used together with collectNamespaceDecl to -- cleanupNamespaces collectPrefixUriPairs :: LA XmlTree (String, String) -- | test whether an attribute node contains an XML Namespace declaration isNamespaceDeclAttr :: (ArrowXml a) => a XmlTree XmlTree -- | get the namespace prefix and the namespace URI out of an attribute -- tree with a namespace declaration (see isNamespaceDeclAttr) for -- all other nodes this arrow fails getNamespaceDecl :: (ArrowXml a) => a XmlTree (String, String) -- | process a document tree with an arrow, containing always the valid -- namespace environment as extra parameter. -- -- The namespace environment is implemented as a Data.AssocList.AssocList processWithNsEnv :: (ArrowXml a) => (NsEnv -> a XmlTree XmlTree) -> NsEnv -> a XmlTree XmlTree -- | process all element nodes of a document tree with an arrow, containing -- always the valid namespace environment as extra parameter. Attribute -- lists are not processed. -- -- See also: processWithNsEnv processWithNsEnvWithoutAttrl :: (ArrowXml a) => (NsEnv -> a XmlTree XmlTree) -> NsEnv -> a XmlTree XmlTree -- | propagate all namespace declarations "xmlns:ns=..." to all element and -- attribute nodes of a document. -- -- This arrow does not check for illegal use of namespaces. The real work -- is done by propagateNamespaceEnv. -- -- The arrow may be applied repeatedly if neccessary. propagateNamespaces :: (ArrowXml a) => a XmlTree XmlTree -- | generate unique namespaces and add all namespace declarations to the -- root element -- -- Calls cleanupNamespaces with collectNamespaceDecl uniqueNamespaces :: (ArrowXml a) => a XmlTree XmlTree -- | generate unique namespaces and add all namespace declarations for all -- prefix-uri pairs in all qualified names -- -- useful for cleanup of namespaces in generated documents. Calls -- cleanupNamespaces with collectNamespaceDecl + -- collectPrefixUriPairs uniqueNamespacesFromDeclAndQNames :: (ArrowXml a) => a XmlTree XmlTree -- | validate the namespace constraints in a whole tree. -- -- Result is the list of errors concerning namespaces. Predicates -- isWellformedQName, isWellformedQualifiedName, -- isDeclaredNamespace and isWellformedNSDecl are applied -- to the appropriate elements and attributes. validateNamespaces :: (ArrowXml a) => a XmlTree XmlTree -- | This module provides all datatypes for DTD validation module Text.XML.HXT.DTDValidation.TypeDefs type XmlArrow = LA XmlTree XmlTree type XmlArrowS = LA XmlTree XmlTrees dtd_value :: Attributes -> String dtd_type :: Attributes -> String dtd_kind :: Attributes -> String dtd_modifier :: Attributes -> String dtd_default :: Attributes -> String dtd_name :: Attributes -> String isUnparsedEntity :: (ArrowDTD a) => a XmlTree XmlTree hasDTDAttrValue :: (ArrowDTD a) => String -> (String -> Bool) -> a XmlTree XmlTree isRequiredAttrKind :: (ArrowDTD a) => a XmlTree XmlTree isDefaultAttrKind :: (ArrowDTD a) => a XmlTree XmlTree isFixedAttrKind :: (ArrowDTD a) => a XmlTree XmlTree isMixedContentElement :: (ArrowDTD a) => a XmlTree XmlTree isEmptyElement :: (ArrowDTD a) => a XmlTree XmlTree isEnumAttrType :: (ArrowDTD a) => a XmlTree XmlTree isIdAttrType :: (ArrowDTD a) => a XmlTree XmlTree isIdRefAttrType :: (ArrowDTD a) => a XmlTree XmlTree isNotationAttrType :: (ArrowDTD a) => a XmlTree XmlTree isAttlistOfElement :: (ArrowDTD a) => String -> a XmlTree XmlTree valueOfDTD :: String -> XmlTree -> String valueOf :: String -> XmlTree -> String getDTDAttributes :: XmlTree -> Attributes isDTDDoctypeNode :: XmlTree -> Bool isDTDElementNode :: XmlTree -> Bool isDTDAttlistNode :: XmlTree -> Bool isDTDContentNode :: XmlTree -> Bool isDTDNameNode :: XmlTree -> Bool isElemNode :: XmlTree -> Bool nameOfAttr :: XmlTree -> String nameOfElem :: XmlTree -> String -- | infix operator for applying an arrow to a list of trees -- -- ($$) :: XmlArrow -> XmlTrees -> XmlTrees -- | create an error message msgToErr :: (String -> String) -> LA String XmlTree -- | This module provides functions for validating attributes. -- -- The main functions are: -- -- module Text.XML.HXT.DTDValidation.AttributeValueValidation -- | Checks if the attribute value meets the lexical constraints of its -- type. -- -- checkAttributeValue :: XmlTrees -> XmlTree -> XmlArrow -- | Normalizes an attribute value with respect to its type. (3.3.3 / p.29 -- in Spec) -- -- normalizeAttributeValue :: Maybe XmlTree -> String -> String -- | This module provides functions for validating the DTD of XML documents -- represented as XmlTree. -- -- Unlike other popular XML validation tools the validation process -- returns a list of errors instead of aborting after the first error was -- found. -- -- Unlike validation of the document, the DTD branch is traversed four -- times: -- -- module Text.XML.HXT.DTDValidation.DTDValidation -- | Removes doublicate declarations from the DTD, which first declaration -- is binding. This is the case for ATTLIST and ENTITY declarations. -- -- removeDoublicateDefs :: XmlArrow -- | Validate a DTD. -- -- validateDTD :: XmlArrow -- | This module provides functions for transforming XML documents -- represented as XmlTree with respect to its DTD. -- -- Transforming an XML document with respect to its DTD means: -- -- -- -- Note: Transformation should be started after validation. -- -- Before the document is validated, a lookup-table is build on the basis -- of the DTD which maps element names to their transformation functions. -- After this initialization phase the whole document is traversed in -- preorder and every element is transformed by the XmlFilter from the -- lookup-table. module Text.XML.HXT.DTDValidation.DocTransformation -- | filter for transforming the document. -- -- transform :: XmlTree -> XmlArrow -- | This module provides functions for checking special -- IDIDREFIDREFS constraints. -- -- Checking special ID/IDREF/IDREFS constraints means: -- -- -- -- ID-Validation should be started before or after validating the -- document. -- -- First all nodes with ID attributes are collected from the document, -- then it is validated that values of ID attributes do not occure more -- than once. During a second iteration over the document it is validated -- that there exists an ID attribute value for IDREF/IDREFS attribute -- values. module Text.XML.HXT.DTDValidation.IdValidation -- | Perform the validation of the IDIDREFIDREFS constraints. -- -- validateIds :: XmlTree -> XmlArrow -- | A module for regular expression matching, adapted for XML DTDs. -- -- This module is based on the module RE. module Text.XML.HXT.DTDValidation.XmlRE -- | Data type for regular expressions. data RE a -- | Checks if an input matched a regular expression. The function should -- be called after matches. -- -- Was the sentence used in matches in the language of the -- regular expression? -> matches e s == s `in` L(e)? -- -- checkRE :: (Show a) => RE a -> String -- | Derives a regular expression with respect to a list of elements. -- -- matches :: RE String -> XmlTrees -> RE String -- | Constructs a string representation of a regular expression. -- -- printRE :: (Show a) => RE a -> String -- | Constructs a regular expression for an empty sequence. -- -- re_unit :: RE a -- | Constructs a regular expression for an empty set. -- -- re_zero :: String -> RE a -- | Constructs a regular expression for accepting a symbol -- -- re_sym :: a -> RE a -- | Constructs an optional repetition (*) of a regular expression -- -- re_rep :: RE a -> RE a -- | Constructs a repetition (+) of a regular expression -- -- re_plus :: RE a -> RE a -- | Constructs an option (?) of a regular expression -- -- re_opt :: RE a -> RE a -- | Constructs a sequence (,) of two regular expressions -- -- re_seq :: RE a -> RE a -> RE a -- | Constructs an alternative (|) of two regular expressions -- -- re_alt :: RE a -> RE a -> RE a -- | Constructs a regular expression for accepting any singel symbol -- -- re_dot :: RE a -- | This module provides functions for validating XML Documents -- represented as XmlTree. -- -- Unlike other popular XML validation tools the validation process -- returns a list of errors instead of aborting after the first error was -- found. -- -- Before the document is validated, a lookup-table is build on the basis -- of the DTD which maps element names to their validation functions. -- After this initialization phase the whole document is traversed in -- preorder and every element is validated by the XmlFilter from the -- lookup-table. module Text.XML.HXT.DTDValidation.DocValidation -- | Validate a document. -- -- validateDoc :: XmlTree -> XmlArrow -- | This module provides functions for validating XML documents -- represented as XmlTree. -- -- Unlike other popular XML validation tools the validation functions -- return a list of errors instead of aborting after the first error was -- found. -- -- Note: The validation process has been split into validation and -- transformation! If validate did not report any errors, -- transform should be called, to change the document the way a -- validating parser is expected to do. module Text.XML.HXT.DTDValidation.Validation getDTDSubset :: XmlArrow -- | Main validation filter. Check if the DTD and the document are valid. -- -- validate :: XmlArrow -- | Check if the DTD is valid. -- -- validateDTD :: XmlArrow -- | Check if the document corresponds to the given DTD. -- -- validateDoc :: XmlArrow -- | Removes doublicate declarations from the DTD which first declaration -- is binding. This is the case for ATTLIST and ENTITY declarations. -- -- removeDoublicateDefs :: XmlArrow -- | filter for transforming a document with respect to the given DTD. -- -- Validating parsers are expected to normalize attribute values and add -- default values. This function should be called after a successful -- validation. -- -- transform :: XmlArrow -- | interface to the HXT XML and DTD parsers -- -- version: $Id: ParserInterface.hs,v 1.1 20060501 18:56:24 hxml -- Exp $ module Text.XML.HXT.Arrow.ParserInterface parseXmlDoc :: (ArrowXml a) => a (String, String) XmlTree parseXmlDTDPart :: (ArrowXml a) => a (String, XmlTree) XmlTree parseXmlContent :: (ArrowXml a) => a String XmlTree parseXmlDocEncodingSpec :: (ArrowXml a) => a XmlTree XmlTree removeEncodingSpec :: (ArrowXml a) => a XmlTree XmlTree parseXmlEntityEncodingSpec :: (ArrowXml a) => a XmlTree XmlTree parseXmlDTDdeclPart :: (ArrowXml a) => a XmlTree XmlTree parseXmlDTDdecl :: (ArrowXml a) => a XmlTree XmlTree parseXmlDTDEntityValue :: (ArrowXml a) => a XmlTree XmlTree parseXmlAttrValue :: (ArrowXml a) => String -> a XmlTree XmlTree parseXmlGeneralEntityValue :: (ArrowXml a) => String -> a XmlTree XmlTree parseHtmlDoc :: (ArrowList a) => a (String, String) XmlTree parseHtmlContent :: (ArrowList a) => a String XmlTree parseHtmlTagSoup :: (ArrowList a) => Bool -> Bool -> Bool -> Bool -> Bool -> a (String, String) XmlTree validateDoc :: (ArrowList a) => a XmlTree XmlTree transformDoc :: (ArrowList a) => a XmlTree XmlTree -- | substitution of all predefined XHTMT entities for none ASCII chars -- -- This arrow recurses through a whole XML tree and substitutes all -- entity refs within text nodes and attribute values by a text node -- containing of a single char corresponding to this entity. -- -- Unknown entity refs remain unchanged substHtmlEntityRefs :: (ArrowList a) => a XmlTree XmlTree -- | substitution of the five predefined XMT entities, works like -- substHtmlEntityRefs substXmlEntityRefs :: (ArrowList a) => a XmlTree XmlTree -- | the entity substitution arrow called from substXmlEntityRefs -- and substHtmlEntityRefs substEntityRefs :: (ArrowList a) => [(String, Int)] -> a XmlTree XmlTree -- | Module for importing all list arrows module Control.Arrow.ListArrows -- | Regular Expression Matcher working on lists of XmlTrees -- -- It's intendet to import this module with an explicit import -- declaration for not spoiling the namespace with these somewhat special -- arrows module Text.XML.HXT.Arrow.XmlRegex data XmlRegex mkZero :: String -> XmlRegex mkUnit :: XmlRegex mkPrim :: (XmlTree -> Bool) -> XmlRegex mkPrimA :: LA XmlTree XmlTree -> XmlRegex mkDot :: XmlRegex mkStar :: XmlRegex -> XmlRegex mkAlt :: XmlRegex -> XmlRegex -> XmlRegex mkSeq :: XmlRegex -> XmlRegex -> XmlRegex mkRep :: Int -> XmlRegex -> XmlRegex mkRng :: Int -> Int -> XmlRegex -> XmlRegex mkOpt :: XmlRegex -> XmlRegex nullable :: XmlRegex -> Bool delta :: XmlRegex -> XmlTree -> XmlRegex -- | match a sequence of XML trees with a regular expression over trees -- -- If the input matches, the result is Nothing, else Just an error -- message is returned matchXmlRegex :: XmlRegex -> XmlTrees -> Maybe String -- | split a sequence of XML trees into a pair of a a matching prefix and a -- rest -- -- If there is no matching prefix, Nothing is returned splitXmlRegex :: XmlRegex -> XmlTrees -> Maybe (XmlTrees, XmlTrees) -- | scan a sequence of XML trees and split it into parts matching the -- given regex -- -- If the parts cannot be split because of a missing match, or because of -- the empty sequence as match, Nothing is returned scanXmlRegex :: XmlRegex -> XmlTrees -> Maybe [XmlTrees] -- | check whether a sequence of XmlTrees match an Xml regular expression -- -- The arrow for matchXmlRegex. -- -- The expession is build up from simple arrows acting as predicate -- (mkPrimA) for an XmlTree and of the usual cobinators for -- sequence (mkSeq), repetition (mkStar, mkRep', -- mkRng) and choice (mkAlt, mkOpt) matchRegexA :: XmlRegex -> LA XmlTree XmlTree -> LA XmlTree XmlTrees -- | split the sequence of trees computed by the filter a into -- -- The arrow for splitXmlRegex. -- -- a first part matching the regex and a rest, if a prefix of the input -- sequence does not match the regex, the arrow fails else the pair -- containing the result lists is returned splitRegexA :: XmlRegex -> LA XmlTree XmlTree -> LA XmlTree (XmlTrees, XmlTrees) -- | scan the input sequence with a regex and give the result as a list of -- lists of trees back the regex must at least match one input tree, so -- the empty sequence should not match the regex -- -- The arrow for scanXmlRegex. scanRegexA :: XmlRegex -> LA XmlTree XmlTree -> LA XmlTree XmlTrees instance Show XmlRegex -- | Version : $Id$ -- -- Constants and basic arrows for Relax NG module Text.XML.HXT.RelaxNG.BasicArrows hasRngName :: (ArrowXml a) => String -> a XmlTree XmlTree checkRngName :: (ArrowXml a) => [String] -> a XmlTree XmlTree noOfChildren :: (ArrowXml a) => (Int -> Bool) -> a XmlTree XmlTree isAttributeRef :: (ArrowXml a) => a XmlTree XmlTree isAttributeRefTextListGroupInterleaveOneOrMoreEmpty :: (ArrowXml a) => a XmlTree XmlTree isAttributeRefTextListInterleave :: (ArrowXml a) => a XmlTree XmlTree isAttributeListGroupInterleaveOneOrMore :: (ArrowXml a) => a XmlTree XmlTree isExternalRefInclude :: (ArrowXml a) => a XmlTree XmlTree isNameNsNameValue :: (ArrowXml a) => a XmlTree XmlTree isNameNsName :: (ArrowXml a) => a XmlTree XmlTree isNameAnyNameNsName :: (ArrowXml a) => a XmlTree XmlTree isDefineOneOrMoreZeroOrMoreOptionalListMixed :: (ArrowXml a) => a XmlTree XmlTree isChoiceGroupInterleave :: (ArrowXml a) => a XmlTree XmlTree isChoiceGroupInterleaveOneOrMore :: (ArrowXml a) => a XmlTree XmlTree isGroupInterleave :: (ArrowXml a) => a XmlTree XmlTree isRngAnyName :: (ArrowXml a) => a XmlTree XmlTree isRngAttribute :: (ArrowXml a) => a XmlTree XmlTree isRngChoice :: (ArrowXml a) => a XmlTree XmlTree isRngCombine :: (ArrowXml a) => a XmlTree XmlTree isRngData :: (ArrowXml a) => a XmlTree XmlTree isRngDefine :: (ArrowXml a) => a XmlTree XmlTree isRngDiv :: (ArrowXml a) => a XmlTree XmlTree isRngElement :: (ArrowXml a) => a XmlTree XmlTree isRngEmpty :: (ArrowXml a) => a XmlTree XmlTree isRngExcept :: (ArrowXml a) => a XmlTree XmlTree isRngExternalRef :: (ArrowXml a) => a XmlTree XmlTree isRngGrammar :: (ArrowXml a) => a XmlTree XmlTree isRngGroup :: (ArrowXml a) => a XmlTree XmlTree isRngInclude :: (ArrowXml a) => a XmlTree XmlTree isRngInterleave :: (ArrowXml a) => a XmlTree XmlTree isRngList :: (ArrowXml a) => a XmlTree XmlTree isRngMixed :: (ArrowXml a) => a XmlTree XmlTree isRngName :: (ArrowXml a) => a XmlTree XmlTree isRngNotAllowed :: (ArrowXml a) => a XmlTree XmlTree isRngNsName :: (ArrowXml a) => a XmlTree XmlTree isRngOneOrMore :: (ArrowXml a) => a XmlTree XmlTree isRngOptional :: (ArrowXml a) => a XmlTree XmlTree isRngParam :: (ArrowXml a) => a XmlTree XmlTree isRngParentRef :: (ArrowXml a) => a XmlTree XmlTree isRngRef :: (ArrowXml a) => a XmlTree XmlTree isRngRelaxError :: (ArrowXml a) => a XmlTree XmlTree isRngStart :: (ArrowXml a) => a XmlTree XmlTree isRngText :: (ArrowXml a) => a XmlTree XmlTree isRngType :: (ArrowXml a) => a XmlTree XmlTree isRngValue :: (ArrowXml a) => a XmlTree XmlTree isRngZeroOrMore :: (ArrowXml a) => a XmlTree XmlTree mkRngElement :: (ArrowXml a) => String -> a n XmlTree -> a n XmlTree -> a n XmlTree mkRngChoice :: (ArrowXml a) => a n XmlTree -> a n XmlTree -> a n XmlTree mkRngDefine :: (ArrowXml a) => a n XmlTree -> a n XmlTree -> a n XmlTree mkRngEmpty :: (ArrowXml a) => a n XmlTree -> a n XmlTree mkRngGrammar :: (ArrowXml a) => a n XmlTree -> a n XmlTree -> a n XmlTree mkRngGroup :: (ArrowXml a) => a n XmlTree -> a n XmlTree -> a n XmlTree mkRngInterleave :: (ArrowXml a) => a n XmlTree -> a n XmlTree -> a n XmlTree mkRngName :: (ArrowXml a) => a n XmlTree -> a n XmlTree -> a n XmlTree mkRngNotAllowed :: (ArrowXml a) => a n XmlTree -> a n XmlTree -> a n XmlTree mkRngOneOrMore :: (ArrowXml a) => a n XmlTree -> a n XmlTree -> a n XmlTree mkRngRef :: (ArrowXml a) => a n XmlTree -> a n XmlTree -> a n XmlTree mkRngRelaxError :: (ArrowXml a) => a n XmlTree -> a n XmlTree -> a n XmlTree mkRngStart :: (ArrowXml a) => a n XmlTree -> a n XmlTree -> a n XmlTree mkRngText :: (ArrowXml a) => a n XmlTree -> a n XmlTree setRngName :: (ArrowXml a) => String -> a XmlTree XmlTree setRngNameDiv :: (ArrowXml a) => a XmlTree XmlTree setRngNameRef :: (ArrowXml a) => a XmlTree XmlTree isRngAttrAttribute :: (ArrowXml a) => a XmlTree XmlTree isRngAttrCombine :: (ArrowXml a) => a XmlTree XmlTree isRngAttrDatatypeLibrary :: (ArrowXml a) => a XmlTree XmlTree isRngAttrHref :: (ArrowXml a) => a XmlTree XmlTree isRngAttrName :: (ArrowXml a) => a XmlTree XmlTree isRngAttrNs :: (ArrowXml a) => a XmlTree XmlTree isRngAttrType :: (ArrowXml a) => a XmlTree XmlTree hasRngAttrAttribute :: (ArrowXml a) => a XmlTree XmlTree hasRngAttrCombine :: (ArrowXml a) => a XmlTree XmlTree hasRngAttrDatatypeLibrary :: (ArrowXml a) => a XmlTree XmlTree hasRngAttrHref :: (ArrowXml a) => a XmlTree XmlTree hasRngAttrName :: (ArrowXml a) => a XmlTree XmlTree hasRngAttrNs :: (ArrowXml a) => a XmlTree XmlTree hasRngAttrType :: (ArrowXml a) => a XmlTree XmlTree getRngAttrAttribute :: (ArrowXml a) => a XmlTree String getRngAttrCombine :: (ArrowXml a) => a XmlTree String getRngAttrDatatypeLibrary :: (ArrowXml a) => a XmlTree String getRngAttrDescr :: (ArrowXml a) => a XmlTree String getRngAttrHref :: (ArrowXml a) => a XmlTree String getRngAttrName :: (ArrowXml a) => a XmlTree String getRngAttrNs :: (ArrowXml a) => a XmlTree String getRngAttrType :: (ArrowXml a) => a XmlTree String -- | Creates the Pattern datastructure from a simplified Relax NG -- schema. The created datastructure is used in the validation algorithm -- (see also: Text.XML.HXT.RelaxNG.Validation) module Text.XML.HXT.RelaxNG.CreatePattern -- | Creates the Pattern datastructure from a simplified Relax NG -- schema. createPatternFromXmlTree :: LA XmlTree Pattern -- | Creates a NameClass from an "anyName"-, "nsName"- or -- "name"-Pattern, createNameClass :: LA XmlTree NameClass -- | Simple access arrows firstChild :: (ArrowTree a, Tree t) => a (t b) (t b) lastChild :: (ArrowTree a, Tree t) => a (t b) (t b) module Text.XML.HXT.RelaxNG.PatternToString -- | Returns a tree representation of the pattern structure. The hard work -- is done by formatTree. -- -- Example: -- --
--   +---element {}bar
--       |
--       +---group
--           |
--           +---oneOrMore
--           |   |
--           |   +---attribute AnyName
--           |       |
--           |       +---text
--           |
--           +---text
--   
-- -- The function can be used to display circular ref-pattern structures. -- -- Example: -- --
--   <define name="baz">
--     <element name="baz">
--       ... <ref name="baz"/> ...
--     </element>
--   </define>
--   
patternToStringTree :: LA Pattern String -- | Returns a formated string representation of the pattern structure. -- -- Example: -- --
--   Element {}foo (Choice (Choice ( Value = abc, 
--   datatypelibrary = http://relaxng.org/ns/structure/1.0, type = token, 
--   context (base-uri =file://test.rng, 
--   parameter: xml = http://www.w3.org/XML/1998/namespaces, foo = www.bar.baz), 
--   
-- -- The function can be used to display circular ref-pattern structures. patternToFormatedString :: SLA [NameClass] Pattern String -- | Returns a tree representation of the pattern structure. (see also: -- createPatternFromXmlTree and patternToStringTree) xmlTreeToPatternStringTree :: LA XmlTree String -- | Returns a formated string representation of the pattern structure. -- (see also: createPatternFromXmlTree and -- patternToFormatedString) xmlTreeToPatternFormatedString :: LA XmlTree String -- | Returns a string representation of the pattern structure. (see also: -- createPatternFromXmlTree) -- -- Example: -- --
--   Element {}foo (Choice (Choice (Value ("","token") "abc"
--   ("foo","www.bar.baz")]))(Data ("http://www.mysql.com","VARCHAR")
--   [("length","2"),("maxLength","5")])) (Element {}bar (Group (Element {}baz
--   
-- -- The function can not be used to display circular ref-pattern -- structures. xmlTreeToPatternString :: LA XmlTree String -- | Returns a string representation of a nameclass. nameClassToString :: NameClass -> String -- | Don't edit this module, it's generated by RelaxSchemaToXmlTree module Text.XML.HXT.RelaxNG.Schema relaxSchemaTree :: XmlTree relaxSchemaArrow :: (ArrowList a) => a b XmlTree -- | Don't edit this module, it's generated by RelaxSchemaToXmlTree module Text.XML.HXT.RelaxNG.SchemaGrammar relaxSchemaTree :: XmlTree relaxSchemaArrow :: (ArrowList a) => a b XmlTree -- | Version : $Id: XmlIOStateArrow.hs,v 1.39 20061109 20:27:42 hxml -- Exp $ -- -- the basic state arrows for XML processing -- -- A state is needed for global processing options, like encoding -- options, document base URI, trace levels and error message handling -- -- The state is separated into a user defined state and a system state. -- The system state contains variables for error message handling, for -- tracing, for the document base for accessing XML documents with -- relative references, e.g. DTDs, and a global key value store. This -- assoc list has strings as keys and lists of XmlTrees as values. It is -- used to store arbitrary XML and text values, e.g. user defined global -- options. -- -- The user defined part of the store is in the default case empty, -- defined as (). It can be extended with an arbitray data type module Text.XML.HXT.Arrow.XmlIOStateArrow -- | state datatype consists of a system state and a user state the user -- state is not fixed data XIOState us XIOState :: !XIOSysState -> !us -> XIOState us xio_sysState :: XIOState us -> !XIOSysState xio_userState :: XIOState us -> !us -- | predefined system state data type with all components for the system -- functions, like trace, error handling, ... data XIOSysState XIOSys :: !Int -> !Int -> !String -> (String -> IO ()) -> !Bool -> !XmlTrees -> !String -> !String -> !AssocList String XmlTrees -> MimeTypeTable -> XIOSysState xio_trace :: XIOSysState -> !Int xio_errorStatus :: XIOSysState -> !Int xio_errorModule :: XIOSysState -> !String xio_errorMsgHandler :: XIOSysState -> String -> IO () xio_errorMsgCollect :: XIOSysState -> !Bool xio_errorMsgList :: XIOSysState -> !XmlTrees xio_baseURI :: XIOSysState -> !String xio_defaultBaseURI :: XIOSysState -> !String xio_attrList :: XIOSysState -> !AssocList String XmlTrees xio_mimeTypes :: XIOSysState -> MimeTypeTable -- | The arrow type for stateful arrows type IOStateArrow s b c = IOSLA (XIOState s) b c -- | The arrow for stateful arrows with no user defined state type IOSArrow b c = IOStateArrow () b c -- | the default global state, used as initial state when running an -- IOSArrow with runIOSLA or runX initialState :: us -> XIOState us initialSysState :: XIOSysState -- | apply an IOSArrow to an empty root node with -- initialState () as initial state -- -- the main entry point for running a state arrow with IO -- -- when running runX f an empty XML root node is applied to -- f. usually f will start with a constant arrow -- (ignoring the input), e.g. a -- Text.XML.HXT.Arrow.ReadDocument.readDocument arrow. -- -- for usage see examples with -- Text.XML.HXT.Arrow.WriteDocument.writeDocument -- -- if input has to be feed into the arrow use runIOSLA like in -- runIOSLA f emptyX inputDoc runX :: IOSArrow XmlTree c -> IO [c] -- | read the user defined part of the state getUserState :: IOStateArrow s b s -- | set the user defined part of the state setUserState :: IOStateArrow s s s -- | change the user defined part of the state changeUserState :: (b -> s -> s) -> IOStateArrow s b b -- | extend user state -- -- Run an arrow with an extended user state component, The old component -- is stored together with a new one in a pair, the arrow is executed -- with this extended state, and the augmented state component is removed -- form the state when the arrow has finished its execution withExtendedUserState :: s1 -> IOStateArrow (s1, s0) b c -> IOStateArrow s0 b c -- | change the type of user state -- -- This conversion is useful, when running a state arrow with another -- structure of the user state, e.g. with () when executing some IO -- arrows withOtherUserState :: s1 -> IOStateArrow s1 b c -> IOStateArrow s0 b c getSysParam :: (XIOSysState -> c) -> IOStateArrow s b c changeSysParam :: (b -> XIOSysState -> XIOSysState) -> IOStateArrow s b b -- | store a list of XML trees in global system state under a given -- attribute name setParamList :: String -> IOStateArrow s XmlTrees XmlTree -- | store a single XML tree in global state under a given attribute name setParam :: String -> IOStateArrow s XmlTree XmlTree -- | remove an entry in global state, arrow input remains unchanged unsetParam :: String -> IOStateArrow s b b -- | read an attribute value from global state getParam :: String -> IOStateArrow s b XmlTree -- | read all attributes from global state getAllParams :: IOStateArrow s b (AssocList String XmlTrees) -- | read all attributes from global state and convert the values to -- strings getAllParamsString :: IOStateArrow s b (AssocList String String) setParamString :: String -> String -> IOStateArrow s b b -- | read a string value from global state, if parameter not set "" is -- returned getParamString :: String -> IOStateArrow s b String -- | store an int value in global state setParamInt :: String -> Int -> IOStateArrow s b b -- | read an int value from global state -- --
--   getParamInt 0 myIntAttr
--   
getParamInt :: Int -> String -> IOStateArrow s b Int clearErrStatus :: IOStateArrow s b b -- | set global error variable setErrStatus :: IOStateArrow s Int Int -- | read current global error status getErrStatus :: IOStateArrow s XmlTree Int -- | raise the global error status level to that of the input tree setErrMsgStatus :: IOStateArrow s XmlTree XmlTree -- | set the error message handler and the flag for collecting the errors setErrorMsgHandler :: Bool -> (String -> IO ()) -> IOStateArrow s b b -- | the default error message handler: error output to stderr errorMsgStderr :: IOStateArrow s b b -- | error message handler for collecting errors errorMsgCollect :: IOStateArrow s b b -- | error message handler for output to stderr and collecting errorMsgStderrAndCollect :: IOStateArrow s b b -- | error message handler for ignoring errors errorMsgIgnore :: IOStateArrow s b b -- | if error messages are collected by the error handler for processing -- these messages by the calling application, this arrow reads the stored -- messages and clears the error message store getErrorMessages :: IOStateArrow s b XmlTree -- | filter error messages from input trees and issue errors filterErrorMsg :: IOStateArrow s XmlTree XmlTree -- | generate a warnig message issueWarn :: String -> IOStateArrow s b b -- | generate an error message issueErr :: String -> IOStateArrow s b b -- | generate a fatal error message, e.g. document not found issueFatal :: String -> IOStateArrow s b b -- | add the error level and the module where the error occured to the -- attributes of a document root node and remove the children when level -- is greater or equal to c_err. called by -- setDocumentStatusFromSystemState when the system state -- indicates an error setDocumentStatus :: Int -> String -> IOStateArrow s XmlTree XmlTree -- | check whether the error level attribute in the system state is set to -- error, in this case the children of the document root are removed and -- the module name where the error occured and the error level are added -- as attributes with setDocumentStatus else nothing is changed setDocumentStatusFromSystemState :: String -> IOStateArrow s XmlTree XmlTree -- | check whether tree is a document root and the status attribute has a -- value less than c_err documentStatusOk :: (ArrowXml a) => a XmlTree XmlTree -- | set the base URI of a document, used e.g. for reading includes, e.g. -- external entities, the input must be an absolute URI setBaseURI :: IOStateArrow s String String -- | read the base URI from the globale state getBaseURI :: IOStateArrow s b String -- | change the base URI with a possibly relative URI, can be used for -- evaluating the xml:base attribute. Returns the new absolute base URI. -- Fails, if input is not parsable with parseURIReference -- -- see also: setBaseURI, mkAbsURI changeBaseURI :: IOStateArrow s String String -- | set the default base URI, if parameter is null, the system base ( -- file:///<cwd>/ ) is used, else the parameter, must be -- called before any document is read setDefaultBaseURI :: String -> IOStateArrow s b String -- | get the default base URI getDefaultBaseURI :: IOStateArrow s b String -- | remember base uri, run an arrow and restore the base URI, used with -- external entity substitution runInLocalURIContext :: IOStateArrow s b c -> IOStateArrow s b c -- | set the global trace level setTraceLevel :: Int -> IOStateArrow s b b -- | read the global trace level getTraceLevel :: IOStateArrow s b Int -- | run an arrow with a given trace level, the old trace level is restored -- after the arrow execution withTraceLevel :: Int -> IOStateArrow s b c -> IOStateArrow s b c -- | apply a trace arrow and issue message to stderr trace :: Int -> IOStateArrow s b String -> IOStateArrow s b b -- | issue a string message as trace traceMsg :: Int -> String -> IOStateArrow s b b -- | trace the current value transfered in a sequence of arrows. -- -- The value is formated by a string conversion function. This is a -- substitute for the old and less general traceString function traceValue :: Int -> (b -> String) -> IOStateArrow s b b -- | an old alias for traceValue traceString :: Int -> (b -> String) -> IOStateArrow s b b -- | issue the source representation of a document if trace level >= 3 -- -- for better readability the source is formated with indentDoc traceSource :: IOStateArrow s XmlTree XmlTree -- | issue the tree representation of a document if trace level >= 4 traceTree :: IOStateArrow s XmlTree XmlTree -- | trace a main computation step issue a message when trace level >= -- 1, issue document source if level >= 3, issue tree when level is -- >= 4 traceDoc :: String -> IOStateArrow s XmlTree XmlTree -- | trace the global state traceState :: IOStateArrow s b b -- | compute the absolut URI for a given URI and a base URI expandURIString :: String -> String -> Maybe String -- | arrow variant of expandURIString, fails if -- expandURIString returns Nothing expandURI :: (ArrowXml a) => a (String, String) String -- | arrow for expanding an input URI into an absolute URI using global -- base URI, fails if input is not a legal URI mkAbsURI :: IOStateArrow s String String -- | arrow for computing the fragment component of an URI, fails if input -- is not a legal URI getFragmentFromURI :: (ArrowList a) => a String String -- | arrow for computing the path component of an URI, fails if input is -- not a legal URI getPathFromURI :: (ArrowList a) => a String String -- | arrow for selecting the port number of the URI without leading ':', -- fails if input is not a legal URI getPortFromURI :: (ArrowList a) => a String String -- | arrow for computing the query component of an URI, fails if input is -- not a legal URI getQueryFromURI :: (ArrowList a) => a String String -- | arrow for selecting the registered name (host) of the URI, fails if -- input is not a legal URI getRegNameFromURI :: (ArrowList a) => a String String -- | arrow for selecting the scheme (protocol) of the URI, fails if input -- is not a legal URI. -- -- See Network.URI for URI components getSchemeFromURI :: (ArrowList a) => a String String -- | arrow for selecting the user info of the URI without trailing '@', -- fails if input is not a legal URI getUserInfoFromURI :: (ArrowList a) => a String String -- | set the table mapping of file extensions to mime types in the system -- state -- -- Default table is defined in Text.XML.HXT.DOM.MimeTypeDefaults. This -- table is used when reading loacl files, (file: protocol) to determine -- the mime type setMimeTypeTable :: MimeTypeTable -> IOStateArrow s b b -- | set the table mapping of file extensions to mime types by an external -- config file -- -- The config file must follow the conventions of etcmime.types on -- a debian linux system, that means all empty lines and all lines -- starting with a # are ignored. The other lines must consist of a mime -- type followed by a possible empty list of extensions. The list of -- extenstions and mime types overwrites the default list in the system -- state of the IOStateArrow setMimeTypeTableFromFile :: FilePath -> IOStateArrow s b b instance (NFData us) => NFData (XIOState us) instance NFData XIOSysState -- | Version : $Id$ -- -- State arrows for document input module Text.XML.HXT.Arrow.DocumentInput getURIContents :: IOStateArrow s XmlTree XmlTree -- | Read the content of a document. -- -- This routine is usually called from -- Text.XML.HXT.Arrow.ProcessDocument.getDocumentContents. -- -- The input must be a root node (constructed with root), usually -- without children. The attribute list contains all input parameters, -- e.g. URI or source file name, encoding preferences, ... If the source -- name is empty, the input is read from standard input. -- -- The source is transformed into an absolute URI. If the source is a -- relative URI, or a file name, it is expanded into an absolut URI with -- respect to the current base URI. The default base URI is of protocol -- "file" and points to the current working directory. -- -- The currently supported protocols are "http", "file", "stdin" and -- "string". -- -- The latter two are internal protocols. An uri of the form "stdin:" -- stands for the content of the standard input stream. -- -- "string:some text" means, that "some text" is taken as input. This -- internal protocol is used for reading from normal String -- values. getXmlContents :: IOStateArrow s XmlTree XmlTree getXmlEntityContents :: IOStateArrow s XmlTree XmlTree getEncoding :: IOStateArrow s XmlTree String decodeDocument :: IOStateArrow s XmlTree XmlTree -- | Version : $Id: DTDProcessing.hs,v 1.9 20060511 14:47:19 hxml -- Exp $ -- -- DTD processing function for including external parts of a DTD -- parameter entity substitution and general entity substitution -- -- Implemtation completely done with arrows module Text.XML.HXT.Arrow.DTDProcessing -- | a filter for DTD processing -- -- inclusion of external parts of DTD, parameter entity substitution -- conditional section evaluation -- -- input tree must represent a complete document including root node processDTD :: IOStateArrow s XmlTree XmlTree instance Eq DTDPart -- | State arrows for document output module Text.XML.HXT.Arrow.DocumentOutput putXmlDocument :: String -> IOStateArrow s XmlTree XmlTree -- | write the tree representation of a document to a file putXmlTree :: String -> IOStateArrow s XmlTree XmlTree -- | write a document with indentaion and line numers putXmlSource :: String -> IOStateArrow s XmlTree XmlTree getOutputEncoding :: String -> IOStateArrow s XmlTree String encodeDocument :: Bool -> String -> IOStateArrow s XmlTree XmlTree -- | Version : $Id: GeneralEntitySubstitution.hs,v 1.13 20060501 -- 18:56:24 hxml Exp $ -- -- general entity substitution module Text.XML.HXT.Arrow.GeneralEntitySubstitution -- | substitution of general entities -- -- input: a complete document tree including root node processGeneralEntities :: IOStateArrow s XmlTree XmlTree -- | Version : $Id: ProcessDocument.hs,v 1.3 20060830 16:20:52 hxml -- Exp $ -- -- Compound arrows for reading, parsing, validating and writing XML -- documents -- -- All arrows use IO and a global state for options, errorhandling, ... module Text.XML.HXT.Arrow.ProcessDocument -- | XML parser -- -- Input tree must be a root tree with a text tree as child containing -- the document to be parsed. The parser generates from the input string -- a tree of a wellformed XML document, processes the DTD (parameter -- substitution, conditional DTD parts, ...) and substitutes all general -- entity references. Next step is character reference substitution. Last -- step is the document validation. Validation can be controlled by an -- extra parameter. -- -- Example: -- --
--   parseXmlDocument True    -- parse and validate document
--   
--   parseXmlDocument False   -- only parse document, don't validate
--   
-- -- This parser is useful for applications processing correct XML -- documents. parseXmlDocument :: Bool -> IOStateArrow s XmlTree XmlTree -- | HTML parser -- -- Input tree must be a root tree with a text tree as child containing -- the document to be parsed. The parser tries to parse everything as -- HTML, if the HTML document is not wellformed XML or if errors occur, -- warnings are generated. The warnings can be issued, or suppressed. -- -- Example: parseHtmlDocument True : parse document and issue -- warnings -- -- This parser is useful for applications like web crawlers, where the -- pages may contain arbitray errors, but the application is only -- interested in parts of the document, e.g. the plain text. parseHtmlDocument :: Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> IOStateArrow s XmlTree XmlTree -- | Document validation -- -- Input must be a complete document tree. The document is validated with -- respect to the DTD spec. Only useful for XML documents containing a -- DTD. -- -- If the document is valid, it is transformed with respect to the DTD, -- normalization of attribute values, adding default values, sorting -- attributes by name,... -- -- If no error was found, result is the normalized tree, else the error -- status is set in the list of attributes of the root node "/" and the -- document content is removed from the tree. validateDocument :: IOStateArrow s XmlTree XmlTree -- | Namespace propagation -- -- Input must be a complete document tree. The namespace declarations are -- evaluated and all element and attribute names are processed by -- splitting the name into prefix, local part and namespace URI. -- -- Naames are checked with respect to the XML namespace definition -- -- If no error was found, result is the unchanged input tree, else the -- error status is set in the list of attributes of the root node "/" and -- the document content is removed from the tree. propagateAndValidateNamespaces :: IOStateArrow s XmlTree XmlTree -- | creates a new document root, adds all options as attributes to the -- document root and calls getXmlContents. -- -- If the document name is the empty string, the document will be read -- from standard input. -- -- For supported protocols see getXmlContents getDocumentContents :: Attributes -> String -> IOStateArrow s b XmlTree -- | Compound arrow for writing XML documents module Text.XML.HXT.Arrow.WriteDocument -- | the main filter for writing documents -- -- this filter can be configured by an option list like -- Text.XML.HXT.Arrow.ReadDocument.readDocument -- -- usage: writeDocument optionList destination -- -- if destination is the empty string or "-", stdout is used -- as output device -- -- available options are -- -- -- -- a minimal main program for copying a document has the following -- structure: -- --
--   module Main
--   where
--   
--   import Text.XML.HXT.Arrow
--   
--   main        :: IO ()
--   main
--       = do
--         runX ( readDocument  [] "hello.xml"
--                >>>
--                writeDocument [] "bye.xml"
--              )
--         return ()
--   
-- -- an example for copying a document to standard output with tracing and -- evaluation of error code is: -- --
--   module Main
--   where
--   
--   import Text.XML.HXT.Arrow
--   import System.Exit
--   
--   main        :: IO ()
--   main
--       = do
--         [rc] <- runX ( readDocument  [ (a_trace, "1")
--                                      ] "hello.xml"
--                        >>>
--                        writeDocument [ (a_output_encoding, isoLatin1)
--                                      ] "-"        -- output to stdout
--                        >>>
--                        getErrStatus
--                      )
--         exitWith ( if rc >= c_err
--                    then ExitFailure 1
--                    else ExitSuccess
--                  )
--   
writeDocument :: Attributes -> String -> IOStateArrow s XmlTree XmlTree -- | Convert a document into a string. Formating is done the same way and -- with the same options as in writeDocument. writeDocumentToString :: Attributes -> IOStateArrow s XmlTree String -- | indent and format output prepareContents :: Attributes -> IOStateArrow s XmlTree XmlTree -- | Validation of a XML document with respect to a valid Relax NG schema -- in simple form. Copied and modified from "An algorithm for RELAX NG -- validation" by James Clark -- (http://www.thaiopensource.com/relaxng/derivative.html). module Text.XML.HXT.RelaxNG.Validation validateWithRelaxAndHandleErrors :: IOSArrow XmlTree XmlTree -> IOSArrow XmlTree XmlTree -- | Validates a xml document with respect to a Relax NG schema -- -- validateDocWithRelax :: IOSArrow XmlTree XmlTree -> Attributes -> String -> IOSArrow XmlTree XmlTree -- | Validates a xml document with respect to a Relax NG schema -- -- validateRelax :: XmlTree -> IOSArrow XmlTree XmlTree validateXMLDoc :: Attributes -> String -> IOSArrow XmlTree XmlTree readForRelax :: Attributes -> String -> IOSArrow b XmlTree -- | normalize a document for validation with Relax NG: remove all -- namespace declaration attributes, remove all processing instructions -- and merge all sequences of text nodes into a single text node normalizeForRelaxValidation :: (ArrowXml a) => a XmlTree XmlTree -- | tests whether a NameClass contains a particular QName contains :: NameClass -> QName -> Bool -- | The modul creates the simplified form of a Relax NG schema. See also -- chapter 4 of the Relax NG specification. module Text.XML.HXT.RelaxNG.Simplification -- | Creates the simple form of a Relax NG schema (see also: -- relaxOptions) createSimpleForm :: Attributes -> Bool -> Bool -> Bool -> IOSArrow XmlTree XmlTree -- | Returns the list of simplification errors or none getErrors :: IOSArrow XmlTree XmlTree -- | This module exports the core functions from the basic validation und -- simplification libraries. It also exports some helper functions for -- easier access to the validation functionality. module Text.XML.HXT.RelaxNG.Validator -- | validate a document with a Relax NG schema -- -- -- -- options evaluated by validateDocumentWithRelaxSchema: -- -- -- -- all other options are propagated to the read functions for schema -- input -- -- example: -- --
--   validateDocumentWithRelaxSchema [(a_check_restrictions, "0")] "testSchema.rng"
--   
validateDocumentWithRelaxSchema :: Attributes -> String -> IOStateArrow s XmlTree XmlTree -- | validate an XML document with respect to a Relax NG schema -- -- validateDocumentWithRelax :: XmlTree -> IOSArrow XmlTree XmlTree -- | normalize a document for Relax NG validation, call the -- validateRelax function for doing the hard work, and issue -- errors -- -- -- -- Document validation -- -- Validates a xml document with respect to a Relax NG schema. -- -- First, the schema is validated with respect to the Relax NG -- Spezification. If no error is found, the xml document is validated -- with respect to the schema. -- -- -- -- available options: -- -- -- -- example: -- --
--   validate [(a_do_not_check_restrictions, "1")] "test.xml" "testSchema.rng"
--   
validate :: Attributes -> String -> String -> IOSArrow n XmlTree -- | Relax NG schema validation -- -- Validates a Relax NG schema with respect to the Relax NG -- Spezification. -- -- validateSchema :: Attributes -> String -> IOSArrow n XmlTree -- | Document validation -- -- Validates a xml document with respect to a Relax NG schema. Similar to -- validate, but the Relax NG Specification is not created. Can be -- used, to check a list of documents more efficiently. -- -- -- -- example: -- --
--   Text.XML.HXT.RelaxNG.Schema.relaxSchemaArrow
--   >>>
--   ( validateWithSpezification [] "foo.xml" "foo.rng"
--     &&&
--     validateWithSpezification [] "bar.xml" "bar.rng"
--   )
--   
validateWithSpezification :: Attributes -> String -> String -> IOSArrow XmlTree XmlTree -- | Relax NG schema validation -- -- see validateSchema and validateWithSpezification -- -- validateSchemaWithSpezification :: Attributes -> String -> IOSArrow XmlTree XmlTree -- | Document validation -- -- Validates a xml document with respect to a Relax NG schema, but the -- schema is not validated with respect to a specification -- first. Should be used only for valid Relax NG schemes. -- -- validateWithoutSpezification :: Attributes -> String -> String -> IOSArrow n XmlTree -- | Version : $Id: ReadDocument.hs,v 1.10 20061124 07:41:37 hxml -- Exp $ -- -- Compound arrows for reading an XML/HTML document or an XML/HTML string module Text.XML.HXT.Arrow.ReadDocument -- | the main document input filter -- -- this filter can be configured by an option list, a value of type -- Attributes -- -- available options: -- -- -- -- All attributes not evaluated by readDocument are stored in the created -- document root node for easy access of the various options in e.g. the -- input/output modules -- -- If the document name is the empty string or an uri of the form -- "stdin:", the document is read from standard input. -- -- examples: -- --
--   readDocument [ ] "test.xml"
--   
-- -- reads and validates a document "test.xml", no namespace propagation, -- only canonicalization is performed -- --
--   readDocument [ (a_validate, "0")
--                , (a_encoding, isoLatin1)
--                , (a_parse_by_mimetype, "1")
--                ] "http://localhost/test.php"
--   
-- -- reads document "test.php", parses it as HTML or XML depending on the -- mimetype given from the server, but without validation, default -- encoding isoLatin1. -- --
--   readDocument [ (a_parse_html, "1")
--                , (a_encoding, isoLatin1)
--                ] ""
--   
-- -- reads a HTML document from standard input, no validation is done when -- parsing HTML, default encoding is isoLatin1, parsing is done -- with tagsoup parser, but input is read strictly -- --
--   readDocument [ (a_encoding, isoLatin1)
--                , (a_mime_type,    "/etc/mime.types")
--                , (a_tagsoup,      "1")
--                , (a_strict_input, "1")
--                ] "test.svg"
--   
-- -- reads an SVG document from standard input, sets the mime type by -- looking in the system mimetype config file, default encoding is -- isoLatin1, parsing is done with the lightweight tagsoup parser, -- which implies no validation. -- --
--   readDocument [ (a_parse_html,     "1")
--                , (a_proxy,          "www-cache:3128")
--                , (a_curl,           "1")
--                , (a_issue_warnings, "0")
--                ] "http://www.haskell.org/"
--   
-- -- reads Haskell homepage with HTML parser ignoring any warnings, with -- http access via external program curl and proxy "www-cache" at port -- 3128 -- --
--   readDocument [ (a_validate,          "1")
--                , (a_check_namespace,   "1")
--                , (a_remove_whitespace, "1")
--                , (a_trace,             "2")
--                ] "http://www.w3c.org/"
--   
-- -- read w3c home page (xhtml), validate and check namespaces, remove -- whitespace between tags, trace activities with level 2 -- -- for minimal complete examples see -- Text.XML.HXT.Arrow.WriteDocument.writeDocument and runX, the -- main starting point for running an XML arrow. readDocument :: Attributes -> String -> IOStateArrow s b XmlTree -- | the arrow version of readDocument, the arrow input is the -- source URI readFromDocument :: Attributes -> IOStateArrow s String XmlTree -- | read a document that is stored in a normal Haskell String -- -- the same function as readDocument, but the parameter forms the input. -- All options available for readDocument are applicable for -- readString. -- -- Default encoding: No encoding is done, the String argument is taken as -- Unicode string readString :: Attributes -> String -> IOStateArrow s b XmlTree -- | the arrow version of readString, the arrow input is the source -- URI readFromString :: Attributes -> IOStateArrow s String XmlTree -- | parse a string as HTML content, substitute all HTML entity refs and -- canonicalize tree (substitute char refs, ...). Errors are ignored. -- -- A simpler version of readFromString but with less -- functionality. Does not run in the IO monad hread :: (ArrowXml a) => a String XmlTree -- | parse a string as XML content, substitute all predefined XML entity -- refs and canonicalize tree (substitute char refs, ...) xread :: (ArrowXml a) => a String XmlTree -- | Pickler functions for converting between user defined data types and -- XmlTree data. Usefull for persistent storage and retreival of arbitray -- data as XML documents -- -- This module is an adaptation of the pickler combinators developed by -- Andrew Kennedy ( -- http://research.microsoft.com/~akenn/fun/picklercombinators.pdf ) -- -- The difference to Kennedys approach is that the target is not a list -- of Chars but a list of XmlTrees. The basic picklers will convert data -- into XML text nodes. New are the picklers for creating elements and -- attributes. -- -- One extension was neccessary: The unpickling may fail. Therefore the -- unpickler has a Maybe result type. Failure is used to unpickle -- optional elements (Maybe data) and lists of arbitray length -- -- There is an example program demonstrating the use of the picklers for -- a none trivial data structure. (see "examples/arrows/pickle" -- directory) module Text.XML.HXT.Arrow.Pickle.Xml data St St :: [XmlTree] -> [XmlTree] -> St attributes :: St -> [XmlTree] contents :: St -> [XmlTree] data PU a PU :: ((a, St) -> St) -> (St -> (Maybe a, St)) -> Schema -> PU a appPickle :: PU a -> (a, St) -> St appUnPickle :: PU a -> St -> (Maybe a, St) theSchema :: PU a -> Schema emptySt :: St addAtt :: XmlTree -> St -> St addCont :: XmlTree -> St -> St dropCont :: St -> St getAtt :: QName -> St -> Maybe XmlTree getCont :: St -> Maybe XmlTree -- | conversion of an arbitrary value into an XML document tree. -- -- The pickler, first parameter, controls the conversion process. Result -- is a complete document tree including a root node pickleDoc :: PU a -> a -> XmlTree -- | Conversion of an XML document tree into an arbitrary data type -- -- The inverse of pickleDoc. This law should hold for all -- picklers: unpickle px . pickle px $ v == Just v . Not every -- possible combination of picklers make sense. For reconverting a value -- from an XML tree, is becomes neccessary, to introduce "enough" markup -- for unpickling the value unpickleDoc :: PU a -> XmlTree -> Maybe a -- | The zero pickler -- -- Encodes nothing, fails always during unpickling xpZero :: PU a xpUnit :: PU () -- | Lift a value to a pickler -- -- When pickling, nothing is encoded, when unpickling, the given value is -- inserted. This pickler always succeeds. xpLift :: a -> PU a -- | Lift a Maybe value to a pickler. -- -- Nothing is mapped to the zero pickler, Just x is -- pickled with xpLift x. xpLiftMaybe :: Maybe a -> PU a -- | pickle/unpickle combinator for sequence and choice. -- -- When the first unpickler fails, the second one is taken, else the -- third one configured with the result from the first is taken. This -- pickler is a generalisation for xpSeq and xpChoice . -- -- The schema must be attached later, e.g. in xpPair or other higher -- level combinators xpCondSeq :: PU b -> (b -> a) -> PU a -> (a -> PU b) -> PU b -- | Combine two picklers sequentially. -- -- If the first fails during unpickling, the whole unpickler fails xpSeq :: (b -> a) -> PU a -> (a -> PU b) -> PU b -- | combine tow picklers with a choice -- -- Run two picklers in sequence like with xpSeq. When during unpickling -- the first one fails, an alternative pickler (first argument) is -- applied. This pickler is only used as combinator for unpickling. xpChoice :: PU b -> PU a -> (a -> PU b) -> PU b -- | map value into another domain and apply pickler there -- -- One of the most often used picklers. xpWrap :: (a -> b, b -> a) -> PU a -> PU b -- | like xpWrap, but if the inverse mapping is undefined, the -- unpickler fails -- -- Map a value into another domain. If the inverse mapping is undefined -- (Nothing), the unpickler fails xpWrapMaybe :: (a -> Maybe b, b -> a) -> PU a -> PU b -- | pickle a pair of values sequentially -- -- Used for pairs or together with wrap for pickling algebraic data types -- with two components xpPair :: PU a -> PU b -> PU (a, b) -- | Like xpPair but for triples xpTriple :: PU a -> PU b -> PU c -> PU (a, b, c) -- | Like xpPair and xpTriple but for 4-tuples xp4Tuple :: PU a -> PU b -> PU c -> PU d -> PU (a, b, c, d) -- | Like xpPair and xpTriple but for 5-tuples xp5Tuple :: PU a -> PU b -> PU c -> PU d -> PU e -> PU (a, b, c, d, e) -- | Like xpPair and xpTriple but for 6-tuples xp6Tuple :: PU a -> PU b -> PU c -> PU d -> PU e -> PU f -> PU (a, b, c, d, e, f) -- | Pickle a string into an XML text node -- -- One of the most often used primitive picklers. Attention: For pickling -- empty strings use xpText0. If the text has a more specific -- datatype than xsd:string, use xpTextDT xpText :: PU String -- | Pickle a string into an XML text node -- -- Text pickler with a description of the structure of the text by a -- schema. A schema for a data type can be defined by scDT. In -- Text.XML.HXT.Arrow.Pickle.Schema there are some more functions for -- creating simple datatype descriptions. xpTextDT :: Schema -> PU String -- | Pickle a possibly empty string into an XML node. -- -- Must be used in all places, where empty strings are legal values. If -- the content of an element can be an empty string, this string -- disapears during storing the DOM into a document and reparse the -- document. So the empty text node becomes nothing, and the pickler must -- deliver an empty string, if there is no text node in the document. xpText0 :: PU String -- | Pickle a possibly empty string with a datatype description into an XML -- node. -- -- Like xpText0 but with extra Parameter for datatype description -- as in xpTextDT. xpText0DT :: Schema -> PU String -- | Pickle an arbitrary value by applyling show during pickling and read -- during unpickling. -- -- Real pickling is then done with xpText. One of the most often -- used pimitive picklers. Applicable for all types which are instances -- of Read and Show xpPrim :: (Read a, Show a) => PU a -- | Pickle an XmlTree by just adding it -- -- Usefull for components of type XmlTree in other data structures xpTree :: PU XmlTree -- | Pickle a whole list of XmlTrees by just adding the list, unpickle is -- done by taking all element contens. -- -- This pickler should always combined with xpElem for taking the -- whole contents of an element. xpTrees :: PU [XmlTree] -- | Pickle a string representing XML contents by inserting the tree -- representation into the XML document. -- -- Unpickling is done by converting the contents with -- xshowEscapeXml into a string, this function will escape all XML -- special chars, such that pickling the value back becomes save. -- Pickling is done with xread xpXmlText :: PU String -- | Encoding of optional data by ignoring the Nothing case during pickling -- and relying on failure during unpickling to recompute the Nothing case -- -- The default pickler for Maybe types xpOption :: PU a -> PU (Maybe a) -- | Optional conversion with default value -- -- The default value is not encoded in the XML document, during -- unpickling the default value is inserted if the pickler fails xpDefault :: (Eq a) => a -> PU a -> PU a -- | Encoding of list values by pickling all list elements sequentially. -- -- Unpickler relies on failure for detecting the end of the list. The -- standard pickler for lists. Can also be used in combination with -- xpWrap for constructing set and map picklers xpList :: PU a -> PU [a] -- | Encoding of a none empty list of values -- -- Attention: when calling this pickler with an empty list, an internal -- error "head of empty list is raised". xpList1 :: PU a -> PU [a] -- | Standard pickler for maps -- -- This pickler converts a map into a list of pairs. All key value pairs -- are mapped to an element with name (1.arg), the key is encoded as an -- attribute named by the 2. argument, the 3. arg is the pickler for the -- keys, the last one for the values xpMap :: (Ord k) => String -> String -> PU k -> PU v -> PU (Map k v) -- | Pickler for sum data types. -- -- Every constructor is mapped to an index into the list of picklers. The -- index is used only during pickling, not during unpickling, there the -- 1. match is taken xpAlt :: (a -> Int) -> [PU a] -> PU a -- | Pickler for wrapping/unwrapping data into an XML element -- -- Extra parameter is the element name given as a QName. THE pickler for -- constructing nested structures -- -- Example: -- --
--   xpElemQN (mkName "number") $ xpickle
--   
-- -- will map an (42::Int) onto -- --
--   <number>42</number>
--   
xpElemQN :: QName -> PU a -> PU a -- | convenient Pickler for xpElemQN -- --
--   xpElem n = xpElemQN (mkName n)
--   
xpElem :: String -> PU a -> PU a -- | Pickler for wrapping/unwrapping data into an XML element with an -- attribute with given value -- -- To make XML structures flexible but limit the number of different -- elements, it's sometimes useful to use a kind of generic element with -- a key value structure -- -- Example: -- --
--   <attr name="key1">value1</attr>
--   <attr name="key2">value2</attr>
--   <attr name="key3">value3</attr>
--   
-- -- the Haskell datatype may look like this -- --
--   type T = T { key1 :: Int ; key2 :: String ; key3 :: Double }
--   
-- -- Then the picker for that type looks like this -- --
--   xpT :: PU T
--   xpT = xpWrap ( uncurry3 T, \ t -> (key1 t, key2 t, key3 t) ) $
--         xpTriple (xpElemWithAttrValue "attr" "name" "key1" $ xpickle)
--                  (xpElemWithAttrValue "attr" "name" "key2" $ xpText0)
--                  (xpElemWithAttrValue "attr" "name" "key3" $ xpickle)
--   
xpElemWithAttrValue :: String -> String -> String -> PU a -> PU a -- | Pickler for storing/retreiving data into/from an attribute value -- -- The attribute is inserted in the surrounding element constructed by -- the xpElem pickler xpAttrQN :: QName -> PU a -> PU a -- | convenient Pickler for xpAttrQN -- --
--   xpAttr n = xpAttrQN (mkName n)
--   
xpAttr :: String -> PU a -> PU a -- | Add an optional attribute for an optional value (Maybe a). xpAttrImplied :: String -> PU a -> PU (Maybe a) xpAttrFixed :: String -> String -> PU () -- | Add an attribute with a fixed value. -- -- Useful e.g. to declare namespaces. Is implemented by -- xpAttrFixed xpAddFixedAttr :: String -> String -> PU a -> PU a -- | The class for overloading xpickle, the default pickler class XmlPickler a xpickle :: (XmlPickler a) => PU a instance (XmlPickler a) => XmlPickler (Maybe a) instance (XmlPickler a) => XmlPickler [a] instance (XmlPickler a, XmlPickler b, XmlPickler c, XmlPickler d, XmlPickler e) => XmlPickler (a, b, c, d, e) instance (XmlPickler a, XmlPickler b, XmlPickler c, XmlPickler d) => XmlPickler (a, b, c, d) instance (XmlPickler a, XmlPickler b, XmlPickler c) => XmlPickler (a, b, c) instance (XmlPickler a, XmlPickler b) => XmlPickler (a, b) instance XmlPickler () instance XmlPickler Integer instance XmlPickler Int -- | Version : $Id$ -- -- Pickler functions for converting between user defined data types and -- XmlTree data. Usefull for persistent storage and retreival of arbitray -- data as XML documents -- -- This module is an adaptation of the pickler combinators developed by -- Andrew Kennedy ( -- http://research.microsoft.com/~akenn/fun/picklercombinators.pdf ) -- -- The difference to Kennedys approach is that the target is not a list -- of Chars but a list of XmlTrees. The basic picklers will convert data -- into XML text nodes. New are the picklers for creating elements and -- attributes. -- -- One extension was neccessary: The unpickling may fail. Therefore the -- unpickler has a Maybe result type. Failure is used to unpickle -- optional elements (Maybe data) and lists of arbitray length -- -- There is an example program demonstrating the use of the picklers for -- a none trivial data structure. (see "examples/arrows/pickle" -- directory) module Text.XML.HXT.Arrow.Pickle -- | store an arbitray value in a persistent XML document -- -- The pickler converts a value into an XML tree, this is written out -- with Text.XML.HXT.Arrow.writeDocument. The option list is passed to -- Text.XML.HXT.Arrow.writeDocument -- -- An option evaluated by this arrow is a_addDTD. If -- a_addDTD is set (v_1), the pickler DTD is added as an -- inline DTD into the document. xpickleDocument :: PU a -> Attributes -> String -> IOStateArrow s a XmlTree -- | read an arbitray value from an XML document -- -- The document is read with Text.XML.HXT.Arrow.readDocument. Options are -- passed to Text.XML.HXT.Arrow.readDocument. The conversion from XmlTree -- is done with the pickler. -- -- xpickleDocument xp al dest >>> xunpickleDocument xp al' -- dest is the identity arrow when applied with the appropriate -- options. When during pickling indentation is switched on, the -- whitespace must be removed during unpickling. xunpickleDocument :: PU a -> Attributes -> String -> IOStateArrow s b a -- | Write out the DTD generated out of a pickler. Calls xpicklerDTD xpickleWriteDTD :: PU b -> Attributes -> String -> IOStateArrow s b XmlTree -- | The arrow for generating the DTD out of a pickler -- -- A DTD is generated from a pickler and check for consistency. Errors -- concerning the DTD are issued. xpickleDTD :: PU b -> IOStateArrow s b XmlTree -- | An arrow for checking picklers -- -- A value is transformed into an XML document by a given pickler, the -- associated DTD is extracted from the pickler and checked, the document -- including the DTD is tranlated into a string, this string is read and -- validated against the included DTD, and unpickled. The last step is -- the equality with the input. -- -- If the check succeeds, the arrow works like this, else it fails. checkPickler :: (Eq a) => PU a -> IOStateArrow s a a -- | The arrow version of the pickler function xpickleVal :: (ArrowXml a) => PU b -> a b XmlTree -- | The arrow version of the unpickler function xunpickleVal :: (ArrowXml a) => PU b -> a XmlTree b -- | Compute the associated DTD of a pickler thePicklerDTD :: PU b -> XmlTrees -- | Option for generating and adding DTD when document is pickled a_addDTD :: String -- | conversion of an arbitrary value into an XML document tree. -- -- The pickler, first parameter, controls the conversion process. Result -- is a complete document tree including a root node pickleDoc :: PU a -> a -> XmlTree -- | Conversion of an XML document tree into an arbitrary data type -- -- The inverse of pickleDoc. This law should hold for all -- picklers: unpickle px . pickle px $ v == Just v . Not every -- possible combination of picklers make sense. For reconverting a value -- from an XML tree, is becomes neccessary, to introduce "enough" markup -- for unpickling the value unpickleDoc :: PU a -> XmlTree -> Maybe a data PU a PU :: ((a, St) -> St) -> (St -> (Maybe a, St)) -> Schema -> PU a appPickle :: PU a -> (a, St) -> St appUnPickle :: PU a -> St -> (Maybe a, St) theSchema :: PU a -> Schema -- | The class for overloading xpickle, the default pickler class XmlPickler a xpickle :: (XmlPickler a) => PU a -- | Like xpPair and xpTriple but for 4-tuples xp4Tuple :: PU a -> PU b -> PU c -> PU d -> PU (a, b, c, d) -- | Like xpPair and xpTriple but for 5-tuples xp5Tuple :: PU a -> PU b -> PU c -> PU d -> PU e -> PU (a, b, c, d, e) -- | Like xpPair and xpTriple but for 6-tuples xp6Tuple :: PU a -> PU b -> PU c -> PU d -> PU e -> PU f -> PU (a, b, c, d, e, f) -- | Add an attribute with a fixed value. -- -- Useful e.g. to declare namespaces. Is implemented by -- xpAttrFixed xpAddFixedAttr :: String -> String -> PU a -> PU a -- | Pickler for sum data types. -- -- Every constructor is mapped to an index into the list of picklers. The -- index is used only during pickling, not during unpickling, there the -- 1. match is taken xpAlt :: (a -> Int) -> [PU a] -> PU a -- | convenient Pickler for xpAttrQN -- --
--   xpAttr n = xpAttrQN (mkName n)
--   
xpAttr :: String -> PU a -> PU a xpAttrFixed :: String -> String -> PU () -- | Add an optional attribute for an optional value (Maybe a). xpAttrImplied :: String -> PU a -> PU (Maybe a) -- | combine tow picklers with a choice -- -- Run two picklers in sequence like with xpSeq. When during unpickling -- the first one fails, an alternative pickler (first argument) is -- applied. This pickler is only used as combinator for unpickling. xpChoice :: PU b -> PU a -> (a -> PU b) -> PU b -- | pickle/unpickle combinator for sequence and choice. -- -- When the first unpickler fails, the second one is taken, else the -- third one configured with the result from the first is taken. This -- pickler is a generalisation for xpSeq and xpChoice . -- -- The schema must be attached later, e.g. in xpPair or other higher -- level combinators xpCondSeq :: PU b -> (b -> a) -> PU a -> (a -> PU b) -> PU b -- | Optional conversion with default value -- -- The default value is not encoded in the XML document, during -- unpickling the default value is inserted if the pickler fails xpDefault :: (Eq a) => a -> PU a -> PU a -- | convenient Pickler for xpElemQN -- --
--   xpElem n = xpElemQN (mkName n)
--   
xpElem :: String -> PU a -> PU a -- | Pickler for wrapping/unwrapping data into an XML element with an -- attribute with given value -- -- To make XML structures flexible but limit the number of different -- elements, it's sometimes useful to use a kind of generic element with -- a key value structure -- -- Example: -- --
--   <attr name="key1">value1</attr>
--   <attr name="key2">value2</attr>
--   <attr name="key3">value3</attr>
--   
-- -- the Haskell datatype may look like this -- --
--   type T = T { key1 :: Int ; key2 :: String ; key3 :: Double }
--   
-- -- Then the picker for that type looks like this -- --
--   xpT :: PU T
--   xpT = xpWrap ( uncurry3 T, \ t -> (key1 t, key2 t, key3 t) ) $
--         xpTriple (xpElemWithAttrValue "attr" "name" "key1" $ xpickle)
--                  (xpElemWithAttrValue "attr" "name" "key2" $ xpText0)
--                  (xpElemWithAttrValue "attr" "name" "key3" $ xpickle)
--   
xpElemWithAttrValue :: String -> String -> String -> PU a -> PU a -- | Lift a value to a pickler -- -- When pickling, nothing is encoded, when unpickling, the given value is -- inserted. This pickler always succeeds. xpLift :: a -> PU a -- | Lift a Maybe value to a pickler. -- -- Nothing is mapped to the zero pickler, Just x is -- pickled with xpLift x. xpLiftMaybe :: Maybe a -> PU a -- | Encoding of list values by pickling all list elements sequentially. -- -- Unpickler relies on failure for detecting the end of the list. The -- standard pickler for lists. Can also be used in combination with -- xpWrap for constructing set and map picklers xpList :: PU a -> PU [a] -- | Encoding of a none empty list of values -- -- Attention: when calling this pickler with an empty list, an internal -- error "head of empty list is raised". xpList1 :: PU a -> PU [a] -- | Standard pickler for maps -- -- This pickler converts a map into a list of pairs. All key value pairs -- are mapped to an element with name (1.arg), the key is encoded as an -- attribute named by the 2. argument, the 3. arg is the pickler for the -- keys, the last one for the values xpMap :: (Ord k) => String -> String -> PU k -> PU v -> PU (Map k v) -- | Encoding of optional data by ignoring the Nothing case during pickling -- and relying on failure during unpickling to recompute the Nothing case -- -- The default pickler for Maybe types xpOption :: PU a -> PU (Maybe a) -- | pickle a pair of values sequentially -- -- Used for pairs or together with wrap for pickling algebraic data types -- with two components xpPair :: PU a -> PU b -> PU (a, b) -- | Pickle an arbitrary value by applyling show during pickling and read -- during unpickling. -- -- Real pickling is then done with xpText. One of the most often -- used pimitive picklers. Applicable for all types which are instances -- of Read and Show xpPrim :: (Read a, Show a) => PU a -- | Combine two picklers sequentially. -- -- If the first fails during unpickling, the whole unpickler fails xpSeq :: (b -> a) -> PU a -> (a -> PU b) -> PU b -- | Pickle a string into an XML text node -- -- One of the most often used primitive picklers. Attention: For pickling -- empty strings use xpText0. If the text has a more specific -- datatype than xsd:string, use xpTextDT xpText :: PU String -- | Pickle a possibly empty string into an XML node. -- -- Must be used in all places, where empty strings are legal values. If -- the content of an element can be an empty string, this string -- disapears during storing the DOM into a document and reparse the -- document. So the empty text node becomes nothing, and the pickler must -- deliver an empty string, if there is no text node in the document. xpText0 :: PU String -- | Pickle a string into an XML text node -- -- Text pickler with a description of the structure of the text by a -- schema. A schema for a data type can be defined by scDT. In -- Text.XML.HXT.Arrow.Pickle.Schema there are some more functions for -- creating simple datatype descriptions. xpTextDT :: Schema -> PU String -- | Pickle a possibly empty string with a datatype description into an XML -- node. -- -- Like xpText0 but with extra Parameter for datatype description -- as in xpTextDT. xpText0DT :: Schema -> PU String -- | Pickle an XmlTree by just adding it -- -- Usefull for components of type XmlTree in other data structures xpTree :: PU XmlTree -- | Pickle a whole list of XmlTrees by just adding the list, unpickle is -- done by taking all element contens. -- -- This pickler should always combined with xpElem for taking the -- whole contents of an element. xpTrees :: PU [XmlTree] -- | Like xpPair but for triples xpTriple :: PU a -> PU b -> PU c -> PU (a, b, c) xpUnit :: PU () -- | map value into another domain and apply pickler there -- -- One of the most often used picklers. xpWrap :: (a -> b, b -> a) -> PU a -> PU b -- | like xpWrap, but if the inverse mapping is undefined, the -- unpickler fails -- -- Map a value into another domain. If the inverse mapping is undefined -- (Nothing), the unpickler fails xpWrapMaybe :: (a -> Maybe b, b -> a) -> PU a -> PU b -- | Pickle a string representing XML contents by inserting the tree -- representation into the XML document. -- -- Unpickling is done by converting the contents with -- xshowEscapeXml into a string, this function will escape all XML -- special chars, such that pickling the value back becomes save. -- Pickling is done with xread xpXmlText :: PU String -- | The zero pickler -- -- Encodes nothing, fails always during unpickling xpZero :: PU a -- | The datatype for modelling the structure of an data Schema type Schemas = [Schema] data DataTypeDescr -- | This helper module exports elements from the basic Relax NG libraries: -- Validator, CreatePattern, PatternToString and DataTypes. It is the -- main entry point to the Relax NG schema validator of the Haskell XML -- Toolbox. -- -- Author : Torben Kuseler -- -- Version : $Id: RelaxNG.hs,v 1.1 20050902 17:09:39 hxml Exp $ module Text.XML.HXT.RelaxNG -- | The module contains the core-functions of the XPath function library. -- All functions are implemented as XFct. Each XFct contains the -- evaluation context, the variable environment and the function -- arguments. module Text.XML.HXT.XPath.XPathFct -- | Type signature for all functions which can be used in the XPath -- module. type XFct = Context -> Env -> [XPathValue] -> XPathValue -- | Evaluates a function. Calculation of the function value is done by -- looking up the function name in the function table, check the number -- of arguments and calculate the funtion, if no argument evaluation -- returns an error. -- -- evalFct :: FctName -> Env -> Context -> [XPathValue] -> XPathValue -- | Converts a list of different XPathValue types in a list of one -- XPathValue type. -- -- toXValue :: XFct -> Context -> Env -> [XPathValue] -> [XPathValue] -- | number number(object?): converts its argument to a number xnumber :: XFct -- | boolean boolean(object): converts its argument to a boolean value xboolean :: XFct -- | string string(object?): converts an object to a string xstring :: XFct -- | Returns the conversion function for the XPath results: string, boolean -- and number A nodeset can not be converted. getConvFct :: XPathValue -> Maybe XFct -- | Returns the string-value of a node, the value of a namespace node is -- not supported stringValue :: NavXmlTree -> XPathValue -- | Filter for removing identical fragment trees in a nodeset remDups :: XPathFilter -- | Check whether a node is not a part of a node list. Needed to implement -- matching & testing in xslt. isNotInNodeList :: NavXmlTree -> [NavXmlTree] -> Bool -- | Filter for ordering a list of Nodes in document order createDocumentOrder :: XPathFilter -- | Filter for ordering a list of Nodes in reverse document order createDocumentOrderReverse :: XPathFilter -- | Returns the table of variables from the environment getVarTab :: Env -> VarTab -- | Returns the table of keys, needed by xslt, from the environment getKeyTab :: Env -> KeyTab instance Show IdPathStep instance Eq IdPathStep instance Ord IdPathStep -- | Version : $Id: XPathEval.hs,v 1.8 20061012 11:51:29 hxml Exp $ -- -- The core functions for evaluating the different types of XPath -- expressions. Each Expr-constructor is mapped to an evaluation -- function. module Text.XML.HXT.XPath.XPathEval -- | Select parts of a document by an XPath expression. -- -- The main filter for selecting parts of a document via XPath. The -- string argument must be a XPath expression with an absolute location -- path, the argument tree must be a complete document tree. Result is a -- possibly empty list of XmlTrees forming the set of selected XPath -- values. XPath values other than XmlTrees (numbers, attributes, -- tagnames, ...) are convertet to text nodes. getXPath :: String -> XmlTree -> XmlTrees -- | Select parts of a document by a namespace aware XPath expression. -- -- Works like getXPath but the prefix:localpart names in the XPath -- expression are interpreted with respect to the given namespace -- environment getXPathWithNsEnv :: Attributes -> String -> XmlTree -> XmlTrees -- | Select parts of an XML tree by a XPath expression. -- -- The main filter for selecting parts of an arbitrary XML tree via -- XPath. The string argument must be a XPath expression with an absolute -- location path, There are no restrictions on the arument tree. -- -- No canonicalization is performed before evaluating the query -- -- Result is a possibly empty list of XmlTrees forming the set of -- selected XPath values. XPath values other than XmlTrees (numbers, -- attributes, tagnames, ...) are convertet to text nodes. getXPathSubTrees :: String -> XmlTree -> XmlTrees -- | Same as getXPathSubTrees but with namespace aware XPath -- expression getXPathSubTreesWithNsEnv :: Attributes -> String -> XmlTree -> XmlTrees -- | compute the node set of an XPath query getXPathNodeSet :: String -> XmlTree -> XmlNodeSet -- | compute the node set of a namespace aware XPath query getXPathNodeSetWithNsEnv :: Attributes -> String -> XmlTree -> XmlNodeSet -- | The main evaluation entry point. Each XPath-Expr is mapped to -- an evaluation function. The Env-parameter contains the set of -- global variables for the evaluator, the Context-parameter the -- root of the tree in which the expression is evaluated. evalExpr :: Env -> Context -> Expr -> XPathFilter -- | This helper module exports elements from the basic libraries: -- XPathEval, XPathToString and XPathParser -- -- Author : Torben Kuseler module Text.XML.HXT.XPath -- | Arrows for working with XPath and XmlNodeSets. -- -- Most of the XPath arrows come in two versions, one without dealing -- with namespaces, element and attribute names in XPath expressions are -- taken as they ar ignoring any prefix:localname structure. -- -- The second variant uses a namespace environment for associating the -- right namespace for the appropriate prefix. an entry for the empty -- prefix defines the default namespace for the expression. -- -- The second variant should be used, when in the application namespaces -- are significant, that means when namespace propagation is done for the -- documents to be processed. -- -- NodeSets are sets of "pointer" into an XML tree to reference subnodes. -- These nodesets can be computed by XPath expressions or normal arrows. -- The nodesets can then be used later for selecting or modifying -- subtrees of this tree in an efficient way. module Text.XML.HXT.Arrow.XPath -- | Select parts of a whole XML document with root node by a XPath -- expression. -- -- The main filter for selecting parts of a document via XPath. -- -- The string argument must be a XPath expression with an absolute -- location path, the argument tree must be a complete document tree. -- -- Before evaluating the xpath query, the document is canonicalized with -- canonicalizeForXPath -- -- Result is a possibly empty list of XmlTrees forming the set of -- selected XPath values. XPath values other than XmlTrees (numbers, -- attributes, tagnames, ...) are convertet to text nodes. getXPathTreesInDoc :: (ArrowXml a) => String -> a XmlTree XmlTree -- | Same as getXPathTreesInDoc but with namespace environment for -- the XPath names getXPathTreesInDocWithNsEnv :: (ArrowXml a) => Attributes -> String -> a XmlTree XmlTree -- | Select parts of an arbitrary XML tree by a XPath expression. -- -- The main filter for selecting parts of an arbitrary XML tree via -- XPath. The string argument must be a XPath expression with an absolute -- location path, There are no restrictions on the argument tree. -- -- No canonicalization is performed before evaluating the query -- -- Result is a possibly empty list of XmlTrees forming the set of -- selected XPath values. XPath values other than XmlTrees (numbers, -- attributes, tagnames, ...) are convertet to text nodes. getXPathTrees :: (ArrowXml a) => String -> a XmlTree XmlTree -- | Same as getXPathTrees but with namespace environment for the -- XPath names getXPathTreesWithNsEnv :: (ArrowXml a) => Attributes -> String -> a XmlTree XmlTree -- | compute a node set from a tree, containing all nodes selected by the -- predicate arrow -- -- computation of the set of element nodes with name "a" is done with -- --
--   getElemNodeSet (hasName "a")
--   
getElemNodeSet :: (ArrowXml a) => a XmlTree XmlTree -> a XmlTree XmlNodeSet -- | compute a node set from a tree, containing all nodes including -- attribute nodes elected by the predicate arrow getElemAndAttrNodeSet :: (ArrowXml a) => a XmlTree XmlTree -> a XmlTree XmlNodeSet -- | Select a set of nodes via an XPath expression from an arbitray XML -- tree -- -- The result is a set of "pointers" to nodes. This set can be used to -- access or modify the values of the subnodes in subsequent calls to -- getFromNodeSet or processFromNodeSet. -- -- This function enables for parsing an XPath expressions and traversing -- the tree for node selection once and reuse this result possibly many -- times for later selection and modification operations. getXPathNodeSet :: (ArrowXml a) => String -> a XmlTree XmlNodeSet -- | select all subtrees specified by a previously computed node set -- -- the following law holds: -- --
--   getFromNodeSet $< getElemNodeSet f == multi f
--   
getFromNodeSet :: (ArrowXml a) => XmlNodeSet -> a XmlTree XmlTree -- | process all subtrees selected by an XPath expression -- -- the following law holds: -- --
--   processXPathTrees p xpathExpr == processFromNodeSet p $< getXPathNodeSet xpathExpr
--   
processXPathTrees :: (ArrowXml a) => a XmlTree XmlTree -> String -> a XmlTree XmlTree -- | Same as processXPathTrees but with namespace environment for -- the XPath names processXPathTreesWithNsEnv :: (ArrowXml a) => a XmlTree XmlTree -> Attributes -> String -> a XmlTree XmlTree -- | process all subtrees specified by a previously computed node set in -- bottom up manner -- -- the follwoing law holds: -- --
--   processFromNodeSet g $< getElemNodeSet f == processBottomUp (g `when` f)
--   
-- -- when attributes are contained in the node set (see -- getElemAndAttrNodeSet), these are processed after the children -- and before the node itself -- -- the advantage of processFromNodeSet is the separation of the selection -- of set of nodes to be processed (e.g. modified) from the real -- proccessing. The selection sometimes can be done once, the processing -- possibly many times. processFromNodeSet :: (ArrowXml a) => a XmlTree XmlTree -> XmlNodeSet -> a XmlTree XmlTree -- | XPath selection for simple XPath expressions with list arrows instead -- of navigatable trees. -- -- It is recomended, that this module is imported qualified, e.g like -- Text.XML.HXT.Arrow.XPathSimple as XS. -- -- The arrows defined in this module have the same functionality as the -- functions in Text.XML.HXT.Arrow.XPath. -- -- The computation modell in XPath is a navigatable tree, that means a -- tree wicht can be traveresed in arbitrary directions, not only from -- the root to the leafs. Sometimes this modell leads to inefficent XPath -- processing for simple queries, which only need a top down tree -- traversal. -- -- When evaluating an XPath expression with these functions, first an -- attempt is made to map the XPath expression to a pure arrow. If this -- is possible due to the siplicity of the XPath expressions, the result -- is computed directly, else the query is processed by the corresponding -- function in Text.XML.HXT.Arrow.XPath. -- -- The simple evaluation is possible, when in the XPath expression only -- the top down axis (self, child, descendant, descendant or self are -- used, when no builtin functions concerning the position of a node are -- used, and no comparison of nodes e.g. in node set union is required. module Text.XML.HXT.Arrow.XPathSimple -- | Same Functionality as Text.XML.HXT.Arrow.XPath.getXPathTreesInDoc getXPathTreesInDoc :: (ArrowXml a) => String -> a XmlTree XmlTree -- | Same Functionality as -- Text.XML.HXT.Arrow.XPath.getXPathTreesInDocWithNsEnv getXPathTreesInDocWithNsEnv :: (ArrowXml a) => Attributes -> String -> a XmlTree XmlTree -- | Same Functionality as Text.XML.HXT.Arrow.XPath.getXPathTrees getXPathTrees :: (ArrowXml a) => String -> a XmlTree XmlTree -- | Same Functionality as Text.XML.HXT.Arrow.XPath.getXPathTreesWithNsEnv getXPathTreesWithNsEnv :: (ArrowXml a) => Attributes -> String -> a XmlTree XmlTree tryGetXPath :: (ArrowXml a) => Attributes -> String -> a XmlTree XmlTree -- | The xpath interpreter for simple xpath expressions. -- -- In case of a too complicated or illegal xpath expression an error node -- is returned, else the list of selected XML trees getXPathTreesWithNsEnvSimple :: (ArrowXml a) => Attributes -> String -> a XmlTree XmlTree getXP :: NsEnv -> String -> LA XmlTree XmlTree type XPArrow b c = Maybe (LA b c) mk :: LA b c -> XPArrow b c unwrap :: XPArrow b b -> LA b b (>>>>) :: XPArrow b b -> XPArrow b b -> XPArrow b b (&&&&) :: XPArrow b b -> XPArrow b b -> XPArrow b (b, b) (<+>>) :: XPArrow b b -> XPArrow b b -> XPArrow b b guards' :: XPArrow b b -> XPArrow b b -> XPArrow b b this' :: XPArrow b b this'' :: XPArrow b b toThis :: XPArrow b b -> XPArrow b b getChildren' :: XPArrow XmlTree XmlTree -> XPArrow XmlTree XmlTree getAttrl' :: XPArrow XmlTree XmlTree -> XPArrow XmlTree XmlTree multi' :: XPArrow XmlTree XmlTree -> XPArrow XmlTree XmlTree deep' :: XPArrow XmlTree XmlTree -> XPArrow XmlTree XmlTree xIndex :: Int -> LA [b] b xString :: XPArrow XmlTree XmlTree -> LA XmlTree String xNumber' :: XPArrow XmlTree XmlTree -> LA XmlTree XPNumber deadEndStreet :: (Monad m) => m a compXPath :: (MonadPlus m) => Expr -> m (LA XmlTree XmlTree) compXP :: (MonadPlus m) => Expr -> m (XPArrow XmlTree XmlTree) compFP :: (MonadPlus m) => [Expr] -> XPArrow XmlTree XmlTree -> m (XPArrow XmlTree XmlTree) compLP :: (MonadPlus m) => [XStep] -> XPArrow XmlTree XmlTree -> m (XPArrow XmlTree XmlTree) compXS :: (MonadPlus m) => XStep -> XPArrow XmlTree XmlTree -> m (XPArrow XmlTree XmlTree) compNTE :: (Monad m) => NodeTest -> m (XPArrow XmlTree XmlTree) compNTA :: (Monad m) => NodeTest -> m (XPArrow XmlTree XmlTree) compNameT :: (Monad m) => LA XmlTree XmlTree -> QName -> m (XPArrow XmlTree XmlTree) compNT :: (Monad m) => NodeTest -> m (XPArrow XmlTree XmlTree) compPred :: (MonadPlus m) => [Expr] -> XPArrow XmlTree XmlTree -> m (XPArrow XmlTree XmlTree) compPred1 :: (MonadPlus m) => Expr -> XPArrow XmlTree XmlTree -> m (XPArrow XmlTree XmlTree) compRelPathExpr :: (MonadPlus m) => Expr -> m (XPArrow XmlTree XmlTree) compStringExpr :: (MonadPlus m) => Expr -> m String compNumberExpr :: (MonadPlus m) => Expr -> m XPNumber compIntExpr :: (MonadPlus m) => Expr -> m Int compBoolExpr :: (MonadPlus m) => Expr -> m Bool compGenExpr :: (MonadPlus m) => Expr -> m (XPArrow XmlTree XmlTree) compString :: (MonadPlus m) => Op -> Expr -> Expr -> m (XPArrow XmlTree XmlTree) compNumber :: (MonadPlus m) => Op -> Expr -> Expr -> m (XPArrow XmlTree XmlTree) compBool :: (MonadPlus m) => Op -> Expr -> Expr -> m (XPArrow XmlTree XmlTree) compPath :: (MonadPlus m) => Op -> Expr -> Expr -> m (XPArrow XmlTree XmlTree) toNumber :: String -> XPNumber equalNodeSet :: (Eq a) => [a] -> [a] -> [a] -- | Common imports and functions for HXSLT module Text.XML.HXT.XSLT.Common filterTree :: (Tree t) => (a -> Bool) -> t a -> Maybe (t a) mapTreeCtx :: (Tree t) => (c -> a -> (c, b)) -> c -> t a -> t b filterTreeCtx :: (Tree t) => (c -> a -> (c, Bool)) -> c -> t a -> Maybe (t a) zipTreeWith :: (Tree t) => (a -> b -> c) -> t a -> t b -> t c zipTree :: (Tree t) => t a -> t b -> t (a, b) unzipTree :: (Functor t) => t (a, b) -> (t a, t b) showTrees :: [XmlTree] -> String isElemType :: (XmlNode n) => QName -> n -> Bool isAttrType :: (XmlNode n) => QName -> n -> Bool isWhitespaceNode :: (XmlNode n) => n -> Bool collectTextnodes :: [XmlTree] -> String tryFetchAttribute :: (XmlNode n) => n -> QName -> Maybe String fetchAttributeWDefault :: (XmlNode n) => n -> QName -> String -> String fetchAttribute :: (XmlNode n) => n -> QName -> String hasAttribute :: (XmlNode n) => n -> QName -> Bool setAttribute :: (XmlNode n) => QName -> String -> n -> n data ExName ExName :: String -> String -> ExName mkExName :: QName -> ExName exLocal :: ExName -> String exUri :: ExName -> String parseExName :: UriMapping -> String -> ExName type UriMapping = Map String String getUriMap :: (XmlNode n) => n -> UriMapping setUriMap :: (XmlNode n) => UriMapping -> n -> n uriMap2Attrs :: UriMapping -> [XmlTree] expandNSDecls :: XmlTree -> XmlTree lookupPrefix :: UriMapping -> String -> String isNsAttr :: XmlTree -> Bool mkLiteralExpr :: String -> Expr mkStringExpr :: Expr -> Expr mkBoolExpr :: Expr -> Expr mkTrueExpr :: Expr concatExpr :: [Expr] -> Expr splitExpr :: Expr -> [Expr] unionExpr :: [Expr] -> Expr splitMatchByPrio :: Expr -> [(Float, Expr)] computePriority :: Expr -> Float computeNTestPriority :: NodeTest -> Float isMatchExpr :: Expr -> Bool fromJustErr :: String -> Maybe a -> a readWDefault :: (Read a) => a -> String -> a instance Show ExName instance Eq ExName instance Ord ExName -- | Version : $Id: Names.hs,v 1.2 20061111 15:36:05 hxml Exp $ -- -- Names and constants for HXSLT module Text.XML.HXT.XSLT.Names xsltPrefix :: String xsltUri :: String mkXsltName :: String -> QName mkXsltAttribName :: String -> QName xsltStylesheet :: QName xsltMessage :: QName xsltForEach :: QName xsltChoose :: QName xsltWhen :: QName xsltOtherwise :: QName xsltIf :: QName xsltElement :: QName xsltAttribute :: QName xsltText :: QName xsltValueOf :: QName xsltComment :: QName xsltProcInstr :: QName xsltInclude :: QName xsltImport :: QName xsltTemplate :: QName xsltApplyTemplates :: QName xsltApplyImports :: QName xsltCallTemplate :: QName xsltVariable :: QName xsltParam :: QName xsltWithParam :: QName xsltAttributeSet :: QName xsltCopy :: QName xsltCopyOf :: QName xsltSort :: QName xsltStripSpace :: QName xsltPreserveSpace :: QName xsltNamespaceAlias :: QName xsltTransform :: QName xsltSelect :: QName xsltTest :: QName xsltName :: QName xsltNamespace :: QName xsltUseAttributeSets :: QName xsltHRef :: QName xsltMatch :: QName xsltPriority :: QName xsltMode :: QName xsltDataType :: QName xsltOrder :: QName xsltElements :: QName xsltStylesheetPrefix :: QName xsltResultPrefix :: QName xsltVersion :: QName xsltExlcudeResultPrefixes :: QName xsltExtensionElementPrefixes :: QName xsltTerminate :: QName xsltVersionLRE :: QName xsltExlcudeResultPrefixesLRE :: QName xsltExtensionElementPrefixesLRE :: QName xsltUseAttributeSetsLRE :: QName xmlSpace :: QName -- | Version : $Id: CompiledStylesheet.hs,v 1.3 20070502 06:41:05 -- hxml Exp $ -- -- Types for compiled stylesheets module Text.XML.HXT.XSLT.CompiledStylesheet data CompiledStylesheet CompStylesheet :: [MatchRule] -> (Map ExName NamedRule) -> (Map ExName Variable) -> (Map ExName [AttributeSet]) -> [Strips] -> NSAliasing -> CompiledStylesheet getMatchRules :: CompiledStylesheet -> [MatchRule] getNamedRules :: CompiledStylesheet -> (Map ExName NamedRule) getVariables :: CompiledStylesheet -> (Map ExName Variable) getAttributeSets :: CompiledStylesheet -> Map ExName [AttributeSet] getStrips :: CompiledStylesheet -> [Strips] getAliases :: CompiledStylesheet -> NSAliasing data MatchRule MatRule :: MatchExpr -> Float -> (Maybe ExName) -> [MatchRule] -> [Variable] -> Template -> MatchRule getRulePrio :: MatchRule -> Float getRuleMode :: MatchRule -> Maybe ExName getRuleImports :: MatchRule -> [MatchRule] data NamedRule NamRule :: ExName -> [Variable] -> Template -> NamedRule getRuleName :: NamedRule -> ExName data Variable MkVar :: Bool -> ExName -> (Either Expr Template) -> Variable getVarName :: Variable -> ExName isParam :: Variable -> Bool newtype UsedAttribSets UsedAttribSets :: [ExName] -> UsedAttribSets data AttributeSet AttribSet :: ExName -> UsedAttribSets -> Template -> AttributeSet type NTest = ExName parseNTest :: UriMapping -> String -> NTest type Strips = Map NTest Bool lookupStrip :: ExName -> [Strips] -> Bool lookupStrip1 :: ExName -> Strips -> Maybe Bool feedSpaces :: Bool -> [NTest] -> Strips -> Strips feedPreserves :: [NTest] -> Strips -> Strips feedStrips :: [NTest] -> Strips -> Strips stripDocument :: [Strips] -> XmlTree -> XmlTree stripStylesheet :: XmlTree -> XmlTree stripSpaces :: (Bool -> XNode -> Bool) -> Bool -> XmlTree -> XmlTree type NSAliasing = Map String String addAlias :: UriMapping -> String -> String -> NSAliasing -> NSAliasing lookupAlias :: NSAliasing -> QName -> QName aliasUriMapping :: NSAliasing -> UriMapping -> UriMapping data Template TemplComposite :: [Template] -> Template TemplForEach :: SelectExpr -> [SortKey] -> Template -> Template TemplChoose :: [When] -> Template TemplMessage :: Bool -> Template -> Template TemplElement :: ComputedQName -> UriMapping -> UsedAttribSets -> Template -> Template TemplAttribute :: ComputedQName -> Template -> Template TemplText :: String -> Template TemplValueOf :: StringExpr -> Template TemplComment :: Template -> Template TemplProcInstr :: StringExpr -> Template -> Template TemplApply :: (Maybe SelectExpr) -> (Maybe ExName) -> (Map ExName Variable) -> [SortKey] -> Template TemplApplyImports :: Template TemplVariable :: Variable -> Template TemplCall :: ExName -> (Map ExName Variable) -> Template TemplCopy :: UsedAttribSets -> Template -> Template TemplCopyOf :: Expr -> Template data SortKey SortK :: StringExpr -> StringExpr -> StringExpr -> SortKey data When WhenPart :: TestExpr -> Template -> When data ComputedQName LiteralQName :: QName -> ComputedQName CompQName :: UriMapping -> StringExpr -> StringExpr -> ComputedQName newtype SelectExpr SelectExpr :: Expr -> SelectExpr newtype TestExpr TestExpr :: Expr -> TestExpr newtype StringExpr StringExpr :: Expr -> StringExpr newtype MatchExpr MatchExpr :: Expr -> MatchExpr instance Show MatchExpr instance Show StringExpr instance Show TestExpr instance Show SelectExpr instance Show ComputedQName instance Show When instance Show SortKey instance Show Template instance Show AttributeSet instance Show UsedAttribSets instance Show Variable instance Show NamedRule instance Show CompiledStylesheet instance Show MatchRule -- | Version : $Id: Application.hs,v 1.7 20070502 06:41:05 hxml Exp -- $ -- -- The transformation functions for XSLT transformation of XML documents -- -- Exports only two pure functions applyStylesheet and -- applyStylesheetWParams module Text.XML.HXT.XSLT.Application applyStylesheet :: CompiledStylesheet -> XmlTree -> [XmlTree] applyStylesheetWParams :: XPathParams -> CompiledStylesheet -> XmlTree -> [XmlTree] type XPathParams = Map ExName Expr -- | The compilation functions for XSLT stylesheets module Text.XML.HXT.XSLT.Compilation prepareXSLTDocument :: XmlTree -> XmlTree assembleStylesheet :: XmlTree -> [CompiledStylesheet] -> CompiledStylesheet -- | Version : $Id: XsltArrows.hs,v 1.1 20061111 15:36:05 hxml Exp $ -- -- The HXT arrow interface for the XSLT module -- -- The application programming interface to the arrow modules of the -- Haskell XML Toolbox. This module exports all important arrows for -- input, output, parsing, validating and transforming XML. It also -- exports all basic datatypes and functions of the toolbox. module Text.XML.HXT.XSLT.XsltArrows -- | Compile a document representing an XSLT stylesheet into an internal -- representation -- -- The internal representation is an abstract syntax tree for the XSLT -- rules. XSLT imports and includes are evaluated and the rules are -- normalized and prepared for easy application. xsltCompileStylesheet :: IOSArrow XmlTree CompiledStylesheet -- | A convinient function for combining reading a stylesheet and -- compilation. -- -- Reading an XSLT stylesheet is always done without validation but with -- namespace propagation. Comments are removed from the stylesheet. xsltCompileStylesheetFromURI :: IOSArrow String CompiledStylesheet -- | apply a compiled XSLT stylesheet to a whole document tree -- -- The compiled stylesheet must have been created with -- xsltCompileStylesheet or xsltCompileStylesheetFromURI xsltApplyStylesheet :: CompiledStylesheet -> IOSArrow XmlTree XmlTree -- | apply an XSLT stylesheet given by an URI to a whole document tree -- -- The string parameter is the URI of the XSLT stylesheet. In case of an -- error during stylesheet compilation or stylesheet application all -- children of the root node are removed and the error status is set in -- the attribute list of the root node of the input document. xsltApplyStylesheetFromURI :: String -> IOSArrow XmlTree XmlTree data CompiledStylesheet -- | Version : $Id: Arrow.hs,v 1.12 20061111 15:36:04 hxml Exp $ -- -- The HXT arrow interface -- -- The application programming interface to the arrow modules of the -- Haskell XML Toolbox. This module exports all important arrows for -- input, output, parsing, validating and transforming XML. It also -- exports all basic datatypes and functions of the toolbox. module Text.XML.HXT.Arrow