| Copyright | (c) Christian Maeder DFKI GmbH 2010 | 
|---|---|
| License | GPLv2 or higher, see LICENSE.txt | 
| Maintainer | Christian.Maeder@dfki.de | 
| Stability | provisional | 
| Portability | portable | 
| Safe Haskell | Safe | 
Common.XPath
Description
XPath utilities independent of xml package. references: http://www.w3.org/TR/xpath/ http://www.galiel.net/el/study/XPath_Overview.html http://www.fh-wedel.de/~si/HXmlToolbox/hxpath/diplomarbeit.pdf http://hackage.haskell.org/package/hxt-xpath (modules XPathParser, XPathDataTypes) http://hackage.haskell.org/package/hxt-8.5.0 (modules Text.XML.HXT.DOM.Unicode, Text.XML.HXT.Parser.XmlCharParser) http://www.w3.org/TR/REC-xml/#NT-Name
Unicode is not fully supported. A qualified name is an ncName or two ncNames separated by a colon (different from OWL uris).
Synopsis
- data Axis
 - allAxis :: [Axis]
 - lowerShow :: Show a => a -> String
 - showAxis :: Axis -> String
 - data NodeTest
 - nodeTypes :: [NodeTest]
 - pIS :: String
 - paren :: String -> String
 - showNodeTest :: NodeTest -> String
 - data Step = Step Axis NodeTest [Expr]
 - showStep :: Step -> String
 - isDescOrSelfNode :: Step -> Bool
 - data Path = Path Bool [Step]
 - showSteps :: Bool -> [Step] -> String
 - data PrimKind
 - data Expr
 - showPred :: Expr -> String
 - showExpr :: Expr -> String
 - showInfixExpr :: String -> [Expr] -> String
 - parenExpr :: Bool -> Maybe Int -> Expr -> String
 - isPrimExpr :: Expr -> Bool
 - eqOps :: [String]
 - relOps :: [String]
 - addOps :: [String]
 - multOps :: [String]
 - inOps :: [[String]]
 - skips :: Parser a -> Parser a
 - symbol :: String -> Parser String
 - lpar :: Parser ()
 - rpar :: Parser ()
 - axis :: Parser Axis
 - abbrAxis :: Parser Axis
 - ncNameStart :: Char -> Bool
 - ncNameChar :: Char -> Bool
 - ncName :: Parser String
 - literal :: Parser String
 - localName :: Parser String
 - nodeTest :: Parser NodeTest
 - abbrStep :: Parser Step
 - predicate :: Parser Expr
 - step :: Parser Step
 - descOrSelfStep :: Step
 - doubleSlash :: Parser Bool
 - slashStep :: Parser [Step]
 - relPath :: Parser [Step]
 - path :: Parser Path
 - number :: Parser String
 - qualName :: Parser String
 - primExpr :: Parser Expr
 - fct :: Parser Expr
 - filterExpr :: Parser Expr
 - pathExpr :: Parser Expr
 - singleInfixExpr :: Parser Expr -> String -> Parser Expr
 - unionExpr :: Parser Expr
 - unaryExpr :: Parser Expr
 - leftAssocExpr :: Parser Expr -> [String] -> Parser Expr
 - multExpr :: Parser Expr
 - addExpr :: Parser Expr
 - relExpr :: Parser Expr
 - eqExpr :: Parser Expr
 - andExpr :: Parser Expr
 - expr :: Parser Expr
 - data PrincipalNodeType
 - principalNodeType :: Axis -> PrincipalNodeType
 - isElementNode :: Step -> Bool
 - isLegalPath :: [Step] -> Bool
 - finalStep :: Path -> Maybe Step
 - finalPrincipalNodeType :: Path -> PrincipalNodeType
 - data BasicType
 - type FctEnv = [(String, (BasicType, [BasicType]))]
 - type VarEnv = [(String, BasicType)]
 - coreFcts :: FctEnv
 - basicType :: Expr -> BasicType
 - isPathExpr :: Expr -> Bool
 - parseExpr :: String -> Either String Expr
 - getPaths :: Expr -> [Path]
 
data types and pretty printing (via show)
axis specifier
lowerShow :: Show a => a -> String Source #
utility to show (constant) constructors as lower case strings
testing attribute, namespace or element nodes (usually) by name
showNodeTest :: NodeTest -> String Source #
proper string representation (do not use show)
the stuff of a path between the slashes
isDescOrSelfNode :: Step -> Bool Source #
test for descendant-or-self::node() step
only absolute paths may be empty
indicator for primary expressions
expressions where function calls, unary and infix expressions are generic
showInfixExpr :: String -> [Expr] -> String Source #
show arguments with minimal parens interspersed with the infix operator.
Also treat the unary minus where the argument list is a singleton.
Alphanumeric operators are shown with spaces, which looks bad for mod and
div in conjunction with additive, relational, or equality operators.  The
unary minus gets a leading blank if the preceding character is a
ncNameChar. 
parenExpr :: Bool -> Maybe Int -> Expr -> String Source #
put parens around arguments that have a lower precedence or equal precendence if they are a right argument.
isPrimExpr :: Expr -> Bool Source #
test if expression is primary
infix operators
all infix operators. Lowest precedence for or followed by and,
highest is union(|).  Only these three operators may get more than two
arguments. 
parsers
ncNameStart :: Char -> Bool Source #
starting name character (no unicode)
ncNameChar :: Char -> Bool Source #
name character (without +) including centered dot (and no other unicode)
descOrSelfStep :: Step Source #
the implicit descendant-or-self::node() step constant
doubleSlash :: Parser Bool Source #
a double or single slash
slashStep :: Parser [Step] Source #
a step starting with a single or double slash, the latter yielding two steps.
filterExpr :: Parser Expr Source #
parse a filter expresssion as primary expression followed by predicates
pathExpr :: Parser Expr Source #
a path expression is either a filter expression followed by a (non-empty)
     absoulte path or an ordinary path. 
singleInfixExpr :: Parser Expr -> String -> Parser Expr Source #
parse multiple argument expressions separated by an infix symbol
leftAssocExpr :: Parser Expr -> [String] -> Parser Expr Source #
parse as many arguments separated by any infix symbol as possible but construct left-associative binary application trees.
all final infix parsers using leftAssocExpr or singleInfixExpr
checking sanity of paths
data PrincipalNodeType Source #
Constructors
| TAttribute | |
| TNamespace | |
| TElement | 
Instances
| Eq PrincipalNodeType Source # | |
Defined in Common.XPath Methods (==) :: PrincipalNodeType -> PrincipalNodeType -> Bool (/=) :: PrincipalNodeType -> PrincipalNodeType -> Bool  | |
isElementNode :: Step -> Bool Source #
may this step have further steps
isLegalPath :: [Step] -> Bool Source #
isPathExpr :: Expr -> Bool Source #