hxt-9.3.1.22: A collection of tools for processing XML with Haskell.

Copyright | Copyright (C) 2008 Uwe Schmidt
License | MIT
Maintainer | Uwe Schmidt (uwe@fh-wedel.de)
Stability | experimental
Portability | portable
Safe Haskell | Safe-Inferred
Language | Haskell2010

Text.XML.HXT.Arrow.XmlRegex

Description

Regular Expression Matcher working on lists of XmlTrees

It's intended to import this module with an explicit import declaration for not spoiling the namespace with these somewhat special arrows

Synopsis

- data XmlRegex
- mkZero :: String -> XmlRegex
- mkUnit :: XmlRegex
- mkPrim :: (XmlTree -> Bool) -> XmlRegex
- mkPrim' :: (XmlTree -> Bool) -> String -> XmlRegex
- mkPrimA :: LA XmlTree XmlTree -> XmlRegex
- mkDot :: XmlRegex
- mkStar :: XmlRegex -> XmlRegex
- mkAlt :: XmlRegex -> XmlRegex -> XmlRegex
- mkAlts :: [XmlRegex] -> XmlRegex
- mkSeq :: XmlRegex -> XmlRegex -> XmlRegex
- mkSeqs :: [XmlRegex] -> XmlRegex
- mkRep :: Int -> XmlRegex -> XmlRegex
- mkRng :: Int -> Int -> XmlRegex -> XmlRegex
- mkOpt :: XmlRegex -> XmlRegex
- mkPerm :: XmlRegex -> XmlRegex -> XmlRegex
- mkPerms :: [XmlRegex] -> XmlRegex
- mkMerge :: XmlRegex -> XmlRegex -> XmlRegex
- nullable :: XmlRegex -> Bool
- delta :: XmlRegex -> XmlTree -> XmlRegex
- matchXmlRegex :: XmlRegex -> XmlTrees -> Maybe String
- splitXmlRegex :: XmlRegex -> XmlTrees -> Maybe (XmlTrees, XmlTrees)
- scanXmlRegex :: XmlRegex -> XmlTrees -> Maybe [XmlTrees]
- matchRegexA :: XmlRegex -> LA XmlTree XmlTree -> LA XmlTree XmlTrees
- splitRegexA :: XmlRegex -> LA XmlTree XmlTree -> LA XmlTree (XmlTrees, XmlTrees)
- scanRegexA :: XmlRegex -> LA XmlTree XmlTree -> LA XmlTree XmlTrees

# Documentation

data XmlRegex Source #

#### Instances

Instances details

Show XmlRegex Source # |
Instance details Defined in Text.XML.HXT.Arrow.XmlRegex Methods showsPrec :: Int -> XmlRegex -> ShowS Source # show :: XmlRegex -> String Source # showList :: [XmlRegex] -> ShowS Source #

mkZero :: String -> XmlRegex Source #

mkUnit :: XmlRegex Source #

mkPrim :: (XmlTree -> Bool) -> XmlRegex Source #

mkPrim' :: (XmlTree -> Bool) -> String -> XmlRegex Source #

mkPrimA :: LA XmlTree XmlTree -> XmlRegex Source #

mkDot :: XmlRegex Source #

mkStar :: XmlRegex -> XmlRegex Source #

mkAlt :: XmlRegex -> XmlRegex -> XmlRegex Source #

mkAlts :: [XmlRegex] -> XmlRegex Source #

mkSeq :: XmlRegex -> XmlRegex -> XmlRegex Source #

mkSeqs :: [XmlRegex] -> XmlRegex Source #

mkRep :: Int -> XmlRegex -> XmlRegex Source #

mkRng :: Int -> Int -> XmlRegex -> XmlRegex Source #

mkOpt :: XmlRegex -> XmlRegex Source #

mkPerm :: XmlRegex -> XmlRegex -> XmlRegex Source #

mkPerms :: [XmlRegex] -> XmlRegex Source #

mkMerge :: XmlRegex -> XmlRegex -> XmlRegex Source #

nullable :: XmlRegex -> Bool Source #

delta :: XmlRegex -> XmlTree -> XmlRegex Source #

matchXmlRegex :: XmlRegex -> XmlTrees -> Maybe String Source #

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

splitXmlRegex :: XmlRegex -> XmlTrees -> Maybe (XmlTrees, XmlTrees) Source #

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

scanXmlRegex :: XmlRegex -> XmlTrees -> Maybe [XmlTrees] Source #

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

matchRegexA :: XmlRegex -> LA XmlTree XmlTree -> LA XmlTree XmlTrees Source #

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`)

splitRegexA :: XmlRegex -> LA XmlTree XmlTree -> LA XmlTree (XmlTrees, XmlTrees) Source #

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

scanRegexA :: XmlRegex -> LA XmlTree XmlTree -> LA XmlTree XmlTrees Source #

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`.