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-Inferred |
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).
- 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)
data Axis
axis specifier
data NodeTest
testing attribute, namespace or element nodes (usually) by name
showNodeTest :: NodeTest -> String
proper string representation (do not use show)
data Step
the stuff of a path between the slashes
isDescOrSelfNode :: Step -> Bool
test for descendant-or-self::node()
step
data PrimKind
indicator for primary expressions
data Expr
expressions where function calls, unary and infix expressions are generic
showInfixExpr :: String -> [Expr] -> String
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
put parens around arguments that have a lower precedence or equal precendence if they are a right argument.
isPrimExpr :: Expr -> Bool
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
starting name character (no unicode)
ncNameChar :: Char -> Bool
name character (without +
) including centered dot (and no other unicode)
the implicit descendant-or-self::node()
step constant
a double or single slash
a step starting with a single or double slash, the latter yielding two steps.
filterExpr :: Parser Expr
parse a filter expresssion as primary expression followed by predicates
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
parse multiple argument expressions separated by an infix symbol
leftAssocExpr :: Parser Expr -> [String] -> Parser Expr
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
isElementNode :: Step -> Bool
may this step have further steps
isLegalPath :: [Step] -> Bool
isPathExpr :: Expr -> Bool