hxt-xpath 8.5.4 → 9.0.0
raw patch · 27 files changed
+2260/−2248 lines, 27 filesdep ~hxtPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: hxt
API changes (from Hackage documentation)
- Text.XML.HXT.XPath.NavTree: instance (Show a) => Show (NavTree a)
+ Text.XML.HXT.XPath.NavTree: instance Show a => Show (NavTree a)
- Text.XML.HXT.XPath.Arrows: getElemAndAttrNodeSet :: (ArrowXml a) => a XmlTree XmlTree -> a XmlTree XmlNodeSet
+ Text.XML.HXT.XPath.Arrows: getElemAndAttrNodeSet :: ArrowXml a => a XmlTree XmlTree -> a XmlTree XmlNodeSet
- Text.XML.HXT.XPath.Arrows: getElemNodeSet :: (ArrowXml a) => a XmlTree XmlTree -> a XmlTree XmlNodeSet
+ Text.XML.HXT.XPath.Arrows: getElemNodeSet :: ArrowXml a => a XmlTree XmlTree -> a XmlTree XmlNodeSet
- Text.XML.HXT.XPath.Arrows: getFromNodeSet :: (ArrowXml a) => XmlNodeSet -> a XmlTree XmlTree
+ Text.XML.HXT.XPath.Arrows: getFromNodeSet :: ArrowXml a => XmlNodeSet -> a XmlTree XmlTree
- Text.XML.HXT.XPath.Arrows: getXPathNodeSet :: (ArrowXml a) => String -> a XmlTree XmlNodeSet
+ Text.XML.HXT.XPath.Arrows: getXPathNodeSet :: ArrowXml a => String -> a XmlTree XmlNodeSet
- Text.XML.HXT.XPath.Arrows: getXPathTrees :: (ArrowXml a) => String -> a XmlTree XmlTree
+ Text.XML.HXT.XPath.Arrows: getXPathTrees :: ArrowXml a => String -> a XmlTree XmlTree
- Text.XML.HXT.XPath.Arrows: getXPathTreesInDoc :: (ArrowXml a) => String -> a XmlTree XmlTree
+ Text.XML.HXT.XPath.Arrows: getXPathTreesInDoc :: ArrowXml a => String -> a XmlTree XmlTree
- Text.XML.HXT.XPath.Arrows: getXPathTreesInDocWithNsEnv :: (ArrowXml a) => Attributes -> String -> a XmlTree XmlTree
+ Text.XML.HXT.XPath.Arrows: getXPathTreesInDocWithNsEnv :: ArrowXml a => Attributes -> String -> a XmlTree XmlTree
- Text.XML.HXT.XPath.Arrows: getXPathTreesWithNsEnv :: (ArrowXml a) => Attributes -> String -> a XmlTree XmlTree
+ Text.XML.HXT.XPath.Arrows: getXPathTreesWithNsEnv :: ArrowXml a => Attributes -> String -> a XmlTree XmlTree
- Text.XML.HXT.XPath.Arrows: processFromNodeSet :: (ArrowXml a) => a XmlTree XmlTree -> XmlNodeSet -> a XmlTree XmlTree
+ Text.XML.HXT.XPath.Arrows: processFromNodeSet :: ArrowXml a => a XmlTree XmlTree -> XmlNodeSet -> a XmlTree XmlTree
- Text.XML.HXT.XPath.Arrows: processXPathTrees :: (ArrowXml a) => a XmlTree XmlTree -> String -> a XmlTree XmlTree
+ Text.XML.HXT.XPath.Arrows: processXPathTrees :: ArrowXml a => a XmlTree XmlTree -> String -> a XmlTree XmlTree
- Text.XML.HXT.XPath.Arrows: processXPathTreesWithNsEnv :: (ArrowXml a) => a XmlTree XmlTree -> Attributes -> String -> a XmlTree XmlTree
+ Text.XML.HXT.XPath.Arrows: processXPathTreesWithNsEnv :: ArrowXml a => a XmlTree XmlTree -> Attributes -> String -> a XmlTree XmlTree
Files
- LICENCE +0/−9
- LICENSE +9/−0
- examples/Makefile +1/−1
- examples/hunit/HUnitExample.hs +30/−30
- examples/hunit/mini1.xml +0/−0
- examples/hunit/mini2.xml +0/−0
- examples/hxpath/HXPath.hs +49/−51
- examples/hxpath/Makefile +1/−1
- examples/hxpath/W3CTestData.hs +1039/−1039
- examples/hxpath/XPathShell.hs +102/−102
- examples/hxpath/example1.xml +0/−0
- examples/hxpath/xhtml/xhtml-special.ent +1/−1
- examples/hxpath/xhtml/xhtml-symbol.ent +6/−6
- examples/hxpath/xhtml/xhtml1-frameset.dtd +6/−6
- examples/hxpath/xhtml/xhtml1-strict.dtd +3/−3
- examples/hxpath/xhtml/xhtml1-transitional.dtd +6/−6
- hxt-xpath.cabal +16/−14
- src/Text/XML/HXT/XPath.hs +19/−19
- src/Text/XML/HXT/XPath/Arrows.hs +78/−78
- src/Text/XML/HXT/XPath/NavTree.hs +81/−81
- src/Text/XML/HXT/XPath/XPathDataTypes.hs +80/−80
- src/Text/XML/HXT/XPath/XPathEval.hs +288/−288
- src/Text/XML/HXT/XPath/XPathFct.hs +295/−292
- src/Text/XML/HXT/XPath/XPathKeywords.hs +35/−26
- src/Text/XML/HXT/XPath/XPathParser.hs +35/−35
- src/Text/XML/HXT/XPath/XPathToNodeSet.hs +26/−26
- src/Text/XML/HXT/XPath/XPathToString.hs +54/−54
− LICENCE
@@ -1,9 +0,0 @@-The MIT License--Copyright (c) 2005 Uwe Schmidt, Martin Schmidt, Torben Kuseler--Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:--The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.--THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ LICENSE view
@@ -0,0 +1,9 @@+The MIT License++Copyright (c) 2005 Uwe Schmidt, Martin Schmidt, Torben Kuseler++Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
examples/Makefile view
@@ -2,7 +2,7 @@ # EXAMPLES = hunit hxpath-MORE_SAMPLES = +MORE_SAMPLES = all : $(foreach i,$(EXAMPLES),$(MAKE) -C $i all ;)
examples/hunit/HUnitExample.hs view
@@ -15,36 +15,36 @@ -- | -- auxiliary function to make haskell string constants with quotes more readable -singleToDoubleQuote :: String -> String+singleToDoubleQuote :: String -> String singleToDoubleQuote = map (\ c -> if c == '\'' then '\"' else c) -testLA :: String -> String -> LA XmlTree XmlTree -> Test+testLA :: String -> String -> LA XmlTree XmlTree -> Test testLA doc expected f = TestCase $ assertEqual "LA XmlTree XmlTree:" [expected] res where res = runLA (xread >>> xshow f) doc -testLAString :: String -> String -> LA XmlTree String -> Test+testLAString :: String -> String -> LA XmlTree String -> Test testLAString doc expected f = TestCase $ assertEqual "LA XmlTree String:" [expected] res where res = runLA (xread >>> f) doc -mkTestSeqLA :: String -> [(String, LA XmlTree XmlTree)] -> [Test]+mkTestSeqLA :: String -> [(String, LA XmlTree XmlTree)] -> [Test] mkTestSeqLA doc = map (\ (res, f) -> testLA doc (singleToDoubleQuote res) f) -nodeSetTests :: Test+nodeSetTests :: Test nodeSetTests = TestList $ [ TestLabel "node set and simple XPath tests with getXPathTrees" $- TestList $- mkTestSeqLA doc (testGetXPathTrees tests)+ TestList $+ mkTestSeqLA doc (testGetXPathTrees tests) , TestLabel "node set and simple XPath tests with getXPathNodeSet" $- TestList $- mkTestSeqLA doc (testGetXPathNodes tests)+ TestList $+ mkTestSeqLA doc (testGetXPathNodes tests) , TestLabel "node set and simple XPath tests with processFromNodeSet" $ TestList $@@ -57,47 +57,47 @@ where doc = "<x p='.'>.0<x p='.1'>.1.0</x>.2<y p='.3'>.3.0<x p='.3.1'>.3.1.0</x></y>.4</x>" - testGetXPathTrees = map (\ (r, xp) -> (r, getXPathTrees xp)) -- these arrows are equivalent- testGetXPathNodes = map (\ (r, xp) -> (r, getFromNodeSet $< getXPathNodeSet xp)) -- except for the ordering of the result set- -- which does not matter for these tests+ testGetXPathTrees = map (\ (r, xp) -> (r, getXPathTrees xp)) -- these arrows are equivalent+ testGetXPathNodes = map (\ (r, xp) -> (r, getFromNodeSet $< getXPathNodeSet xp)) -- except for the ordering of the result set+ -- which does not matter for these tests testProcessXPath = map (\ (r, xp, a) -> (r, processFromNodeSet a $< getXPathNodeSet xp)) testProcessXPath' = map (\ (r, xp, a) -> (r, processXPathTrees a xp)) - tests = [ (doc , "/x" )- , ("<y p='.3'>.3.0<x p='.3.1'>.3.1.0</x></y>" , "/x/y" )- , ("<x p='.3.1'>.3.1.0</x>" , "/x/y/x" )- , (".0.2.4" , "/x/text()" )- , (".3.0" , "/x/y/text()" )- , ("<x p='.1'>.1.0</x><x p='.3.1'>.3.1.0</x>" , "/x//x" )- ]+ tests = [ (doc , "/x" )+ , ("<y p='.3'>.3.0<x p='.3.1'>.3.1.0</x></y>" , "/x/y" )+ , ("<x p='.3.1'>.3.1.0</x>" , "/x/y/x" )+ , (".0.2.4" , "/x/text()" )+ , (".3.0" , "/x/y/text()" )+ , ("<x p='.1'>.1.0</x><x p='.3.1'>.3.1.0</x>" , "/x//x" )+ ] processTests- = [ ("<x p='.'>x<x p='.1'>x</x>x<y p='.3'>x<x p='.3.1'>x</x></y>x</x>", "//text()", changeText (const "x") )- , ("<x p='.'>.0<x p='.1'>.1.0</x>.2<y p='.3'>.3.0<x p='.3.1'>x</x></y>.4</x>", "/x/y/x/text()", changeText (const "x") )- , ("<x p='.'>.0<x p='.1'>.1.0</x>.2<y p='.3'>.3.0</y>.4</x>", "/x/y/x", none )- , ("<x p='.'>.0<x p='.1'>.1.0</x>.2<y p='.3'>.3.0zzz</y>.4</x>", "/x/y/x", txt "zzz" )- , ("<x p='.'>.0<x p='.1'>.1.0</x>.2<y p='.3'>.3.0<x p='.3.1' q='3.2'>.3.1.0</x></y>.4</x>",- "/x/y/x", addAttr "q" "3.2" )- ]+ = [ ("<x p='.'>x<x p='.1'>x</x>x<y p='.3'>x<x p='.3.1'>x</x></y>x</x>", "//text()", changeText (const "x") )+ , ("<x p='.'>.0<x p='.1'>.1.0</x>.2<y p='.3'>.3.0<x p='.3.1'>x</x></y>.4</x>", "/x/y/x/text()", changeText (const "x") )+ , ("<x p='.'>.0<x p='.1'>.1.0</x>.2<y p='.3'>.3.0</y>.4</x>", "/x/y/x", none )+ , ("<x p='.'>.0<x p='.1'>.1.0</x>.2<y p='.3'>.3.0zzz</y>.4</x>", "/x/y/x", txt "zzz" )+ , ("<x p='.'>.0<x p='.1'>.1.0</x>.2<y p='.3'>.3.0<x p='.3.1' q='3.2'>.3.1.0</x></y>.4</x>",+ "/x/y/x", addAttr "q" "3.2" )+ ] -- | -- the complete set of test cases -allTests :: Test+allTests :: Test allTests = TestList [ nodeSetTests ] -main :: IO ()+main :: IO () main = do c <- runTestTT allTests putStrLn $ show c let errs = errors c- fails = failures c+ fails = failures c System.exitWith (codeGet errs fails) -codeGet :: Int -> Int -> ExitCode+codeGet :: Int -> Int -> ExitCode codeGet errs fails | fails > 0 = ExitFailure 2 | errs > 0 = ExitFailure 1
examples/hunit/mini1.xml view
examples/hunit/mini2.xml view
examples/hxpath/HXPath.hs view
@@ -9,10 +9,8 @@ Maintainer : uwe@fh-wedel.de Stability : experimental Portability: portable- Version : $Id: HXPath.hs,v 1.2 2006/05/11 14:47:18 hxml Exp $ -HXPath - XPath Evaluator of the Haskell XML Toolbox (Arrow version)-+ HXPath - XPath Evaluator of the Haskell XML Toolbox (Arrow version) -} -- ------------------------------------------------------------@@ -23,7 +21,7 @@ import Text.XML.HXT.Arrow import Text.XML.HXT.XPath -import System.IO -- import the IO and commandline option stuff+import System.IO -- import the IO and commandline option stuff import System.Environment import System.Console.GetOpt import System.Exit@@ -38,16 +36,16 @@ main :: IO () main = do- argv <- getArgs -- get the commandline arguments- (al, expr, src) <- cmdlineOpts argv -- and evaluate them, return a key-value list- [rc] <- runX (xpath al expr src) -- run the parser arrow- exitProg (rc >= c_err) -- set return code and terminate+ argv <- getArgs -- get the commandline arguments+ (al, expr, src) <- cmdlineOpts argv -- and evaluate them, return a key-value list+ [rc] <- runX (xpath al expr src) -- run the parser arrow+ exitProg (rc >= c_err) -- set return code and terminate -- ------------------------------------------------------------ -exitProg :: Bool -> IO a-exitProg True = exitWith (ExitFailure (-1))-exitProg False = exitWith ExitSuccess+exitProg :: Bool -> IO a+exitProg True = exitWith (ExitFailure (-1))+exitProg False = exitWith ExitSuccess -- ------------------------------------------------------------ @@ -57,7 +55,7 @@ -- runs in the trivial XmlState monad (with user state set to ()) -- so IO and access to global options is possible -xpath :: Attributes -> String -> String -> IOSArrow b Int+xpath :: Attributes -> String -> String -> IOSArrow b Int xpath al expr src = readDocument al src >>>@@ -75,35 +73,35 @@ >>> getErrStatus where- evalXPathExpr :: IOSArrow XmlTree XmlTree+ evalXPathExpr :: IOSArrow XmlTree XmlTree evalXPathExpr- = traceMsg 1 ("evaluating XPath expression: " ++ expr)- >>>- replaceChildren ( getXPathTreesInDoc expr- >>>- filterErrorMsg- )+ = traceMsg 1 ("evaluating XPath expression: " ++ expr)+ >>>+ replaceChildren ( getXPathTreesInDoc expr+ >>>+ filterErrorMsg+ ) - formatXPathResult :: IOSArrow XmlTree XmlTree+ formatXPathResult :: IOSArrow XmlTree XmlTree formatXPathResult- = replaceChildren ( mkelem "xpath-result"- [ sattr "expr" expr, sattr "source" src ]- [ newline, getChildren >>> (this <+> newline) ]- )- where- newline- | isJust . lookup a_indent $ al = txt "\n"- | otherwise = none+ = replaceChildren ( mkelem "xpath-result"+ [ sattr "expr" expr, sattr "source" src ]+ [ newline, getChildren >>> (this <+> newline) ]+ )+ where+ newline+ | isJust . lookup a_indent $ al = txt "\n"+ | otherwise = none -- ------------------------------------------------------------ -- -- the options definition part -- see doc for System.Console.GetOpt -progName :: String-progName = "HXPath"- -options :: [OptDescr (String, String)]+progName :: String+progName = "HXPath"++options :: [OptDescr (String, String)] options = generalOptions ++@@ -111,42 +109,42 @@ ++ outputOptions -usage :: [String] -> IO a+usage :: [String] -> IO a usage errl | null errl- = do- hPutStrLn stdout use- exitProg False+ = do+ hPutStrLn stdout use+ exitProg False | otherwise- = do- hPutStrLn stderr (concat errl ++ "\n" ++ use)- exitProg True+ = do+ hPutStrLn stderr (concat errl ++ "\n" ++ use)+ exitProg True where header = "HXPath - XPath Evaluator of the Haskell XML Toolbox (Arrow Version)\n" ++ "Usage: " ++ progName ++ " [OPTION...] <XPath expr> <URL or FILE>" use = usageInfo header options -cmdlineOpts :: [String] -> IO (Attributes, String, String)+cmdlineOpts :: [String] -> IO (Attributes, String, String) cmdlineOpts argv = case (getOpt Permute options argv) of (ol,n,[] )- -> do- (ex, sa) <- src n- help (lookup a_help ol)- return (ol, ex, sa)+ -> do+ (ex, sa) <- src n+ help (lookup a_help ol)+ return (ol, ex, sa) (_,_,errs)- -> usage errs+ -> usage errs where src [expr, url]- = return (expr, url)+ = return (expr, url) src []- = usage ["XPath expression and input file/url missing"]+ = usage ["XPath expression and input file/url missing"] src [_]- = usage ["input file/url missing"]+ = usage ["input file/url missing"] src _- = usage ["too many arguments"]+ = usage ["too many arguments"] - help Nothing = return ()- help (Just _) = usage []+ help Nothing = return ()+ help (Just _) = usage [] -- ------------------------------------------------------------
examples/hxpath/Makefile view
@@ -1,7 +1,7 @@ # $Id: Makefile,v 1.2 2005/04/14 12:52:51 hxml Exp $ HXT_HOME = ../../..-PKGFLAGS = +PKGFLAGS = GHCFLAGS = -Wall -O2 GHC = ghc $(GHCFLAGS) $(PKGFLAGS)
examples/hxpath/W3CTestData.hs view
@@ -1,1045 +1,1045 @@ module W3CTestData where testListW3C=[- "$h - $i",- "$hotelnode/location/@country",- "$in//text()",- "$l10n.name",- "$lookup/@text",- "$start + $step",- "$texts[position() > 1]",- "$var1|$var2",- "$var1|child::child2",- "$var1|key('key1','Lynne Rosenthal')",- "$x=''",- "$x='foo'",- "$xml-source",- "$y='foo'",- "$zoo:bear",- "' #text'",- "' 6 ' div 2",- "' 6 '*div",- "' x 4'",- "' x 4'",- "'....5....|'",- "'1' and '0'",- "'2'>'1'",- "'200'",- "'ABC'",- "($terms/table/expand[@language=$lang]/gentext[@key=$key])[1]",- "((((((n3+5)*(3)+(((n2)+2)*(n1 - 6)))-(n4 - n2))+(-(4-6)))))",- "(((ancestor::foo)[1])/@att1)",- "((ancestor::foo))[1]/@att1",- "(* - 4) div 2",- "(* - 4)**",- "(2 + number('xxx'))",- "(24 div 3 +2) div (40 div 8 -3)",- "(5 mod 2 = 1) and (5 mod -2 = 1) and (-5 mod 2 = -1) and (-5 mod -2 = -1)",- "(77 mod $anum + n5 mod 8) mod $anum",- "(ancestor-or-self::*)[@att1][1]/@att1",- "(ancestor::foo)[1]/@att1",- "(ancestor::foo[1])/@att1",- "(ancestor::section|ancestor::simplesect |ancestor::articleinfo)[last()]",- "(chapter//footnote)[2]",- "(child::chapter/descendant-or-self::node())/footnote[2]",- "(n1*n2*n3*n4*n5*n6)div n7 div n8 div n9 div n10",- "(n1/@attrib)*(n2/@attrib)",- "(n1/@attrib)+(n2/@attrib)",- "(preceding-sibling::*|following-sibling::*)/ancestor::*[last()]/*[last()]",- "(preceding-sibling::foo)[1]/@att1",- "(preceding::foo)[1]/@att1",- "(section//@title)[7]",- "(xalan:nodeset($rtf)/default:docelem/test:elem3)", -- namespaces noch mal ueberdenken- "* +3",- "*//la | //Bflat | re",- "*/p",- "*[$index]",- "*[$index]",- "*[$index]",- "*[1]",- "*[3]",- "*[4]",- "*[@test and position()=1]",- "*[@test and position()=4]",- "*[@test and position()=7]",- "*[@test and position()=8]",- "*[@test='true']",- "*[@test][1]/num",- "*[@test][position()=1]/num",- "*[last()=position()]",- "*[last()]",- "*[local-name()='bar']",- "*[not(@test)][last()=position()]",- "*[not(@test)][last()]",- "*[position()=1]",- "*[position()=3]",- "*[position()=4]",- "*[starts-with(name(.),'f')]",- "*|@*",- "*|@*|comment()|processing-instruction()|text()",- "-(n-2/@attrib) - -(n-1/@attrib)",- "-(n1|n2)",- "-.0000000000000000000000000000000000000000123456789",- "-.01",- "-n-2 --n-1",- "-n-2/@attrib --n-1/@attrib",- "..",- "../../a/b[1]",- "..//foo",- "../@id",- "../node()",- "./*[name(.) = $sortcol]",- ".//*[@so]",- ".//PERSONA",- ".//a",- ".//center",- ".//center",- ".//comment()",- ".//f",- ".//near-south/preceding-sibling::*|following-sibling::east/ancestor-or-self::*[2]",- ".//text()",- ".//title",- "./@id",- "./@theattrib",- ".0000000000000000000000000000000000000000123456789",- ".01",- ".123456789",- "/", - "/*/@group",- "//*",- "//*",- "//*[count(./*/*) > 0]",- "//*[count(ancestor::*) >= 2]/../parent::*",- "//ACT",- "//ancestor::*",- "//child1[parent::element1]",- "//child1|//child2",- "//child2[ancestor-or-self::element2]",- "//child2[ancestor::element2]",- "//child5|//child2|//child4",- "//comment()",- "//inc/node4",- "//item[@type=current()/@name]",- "//noChild1|//noChild2",- "//north/dup2 | south/preceding-sibling[4] | north/dup1 | north/*",- "//processing-instruction()",- "//xx/descendant::*",- "/doc/*[@test='true']",- "/doc/a/b/@attr",- "/doc/critter[@type='cat']",- "/doc/mid/inner",- "/doc/sub1/child1|/doc/sub2/child2",- "/docs/a",- "/docs/a",- "/page/contents/avail/hotel",- "/sss/sss/i",- "/sss/sss/i",- "0 > -0",- "0 = -0",- "0 div 0 >= 0",- "0 div 0 < 0",- "0 div 0",- "0 or ''",- "0",- "0000000000",- "1 = '001'",- "1 = 1.00",- "1 div -0 = 1 div 0",- "1 div -0 = 2 div -0",- "1>1",- "1<1",- "1<=1",- "1-2",- "10+5+25+20+15+50+35+40",- "10+7",- "100-$anum -5-15-$anum",- "100-9-7-4-17-18-5",- "100-n6 -4-n1 -1-11",- "12",- "123",- "1234",- "12345",- "123456",- "1234567",- "12345678",- "123456789",- "1234567890",- "12345678901",- "123456789012",- "1234567890123",- "12345678901234",- "123456789012345",- "1234567890123456",- "12345678901234567",- "123456789012345678",- "16-div",- "1=1",- "2 * -number('xxx')",- "2 - number('xxx')",- "2 div number('xxx')",- "2 mod number('xxx')",- "2",- "2>1",- "2>=1",- "2>=2",- "2<1",- "2<=1",- "2*3",- "2+n5+7+n3",- "20",- "25-*",- "256",- "3",- "3",- "3*2+5*4-4*2-1",- "3+6",- "3-1",- "32",- "4",- "4",- "444 + $t1num",- "48 mod 17 - 2 mod 9 + 13 mod 5",- "5 mod 2",- "5",- "5",- "5.*.",- "5.+*",- "54 div*",- "555",- "56 mod round(n5*2+1.444) - n6 mod 4 + 7 mod n4",- "6 div -2",- "6 div 2",- "6",- "60",- "7 - -3",- "7",- "7",- "7+-3",- "70 div $anum - 18 div n6 + $anum div n2",- "8",- "80 div n2 + 12 div 2 - n4 div n2",- "9",- "9.87654321012345",- "98.7654321012345",- "987.654321012345",- "9876.54321012345",- "98765.4321012345",- "987654.321012345",- "9876543.21012345",- "98765432.1012345",- "987654321.012345",- "9876543210",- "9876543210.12345",- "98765432101.2345",- "987654321012.345",- "9876543210123.45",- "98765432101234.5",- "FM|PERSONAE|ACT",- "Name/@First",- "OL",- "Personal_Information/Age",- "Spr/State[. = 'Open']",- "a/*[last()]",- "a/child::*[last()]",- "a/child::comment()[last()]",- "a/child::node()[last()]",- "a/child::text()[last()]",- "a/descendant::*[last()]",- "a/x",- "a['3.5' < 4]",- "a['target'!=descendant::*]",- "a['target'=descendant::*]",- "a[('target'=descendant::*) or @squish]",- "a[(@squeesh or @squish) and @squash]",- "a[*=9]",- "a[0 < true()]",- "a[0]",- "a[1 < 2]",- "a[1 < 3]",- "a[1]",- "a[3 > following-sibling::*]",- "a[3 >= following-sibling::*]",- "a[3 < following-sibling::*]",- "a[3 <= following-sibling::*]",- "a[3-2]",- "a[3.0='3.0']",- "a[3=following-sibling::*]",- "a[3]",- "a[4 != following-sibling::*]",- "a[4]",- "a[@squeesh or (@squish and @squash)]",- "a[@squeesh or @squish and @squash]",- "a[descendant::*!='target']",- "a[descendant::*='target']",- "a[div=9]",- "a[false()!=following-sibling::*]",- "a[following-sibling::* != 4]",- "a[following-sibling::* > 3]",- "a[following-sibling::* >= 3]",- "a[following-sibling::* < 3]",- "a[following-sibling::* <= 3]",- "a[following-sibling::*!=false()]",- "a[following-sibling::*=3]",- "a[following-sibling::*=descendant::*]",- "a[following-sibling::*=true()]",- "a[not(('target'=descendant::*) or @squish)]",- "a[not(@*)]",- "a[number('3')]",- "a[position() <=3]",- "a[position()!=2]",- "a[position()>2]",- "a[position()>=2]",- "a[position()<3]",- "a[position()=$first]",- "a[position()=1]",- "a[position()=3]",- "a[position()=4]",- "a[true()='stringwithchars']",- "a[true()=4]",- "a[true()=following-sibling::*]",- "alternate/name/first",- "ancestor-or-self::*",- "ancestor-or-self::*[1]",- "ancestor-or-self::*[1]/text()",- "ancestor-or-self::*[@att1][1]/@att1",- "ancestor-or-self::sub | ancestor-or-self::sub-sub",- "ancestor::*",- "ancestor::*[3]",- "ancestor::*[count(child::*) > 1]/*[not(. = current()/ancestor-or-self::*)]",- "ancestor::foo[1]/@att1",- "ancestor::sub1|ancestor::sub2",- "attribute :: *",- "attribute :: div",- "attribute*(div - 4)",- "attribute::*",- "attribute::*[2]",- "attribute::attr1|attribute::attr2",- "attribute::center-attr-2",- "author/name|author/bibliography/author/chapters",- "author/name|author/bibliography/author/name",- "author/name|author/noElement",- "author[(name/@real='no' and position()=1)]|author[(name/@real='yes' and position()=last())]",- "author[name/@real='no']|author[name/@real='yes']",- "author[name='Mary Brady']|author[name/@real='no']",- "bar | joes:bar",- "bar[(@a='1' and @b='1') or (@c='1' and @d='1')]",- "bar[(@a='1' or @b='1') and (@c='1' or @d='1')]",- "bar[(@a='1' or @b='1') and @c='1']",- "bar[@a='1' and (@b='1' or @c='1') and @d='1']",- "bar[@a='1' and @b='1' or @c='1' and @d='1']",- "bar[@a='1' and @b='1']",- "bar[@a='1' or (@b='1' and @c='1') or @d='1']",- "bar[@a='1' or @b='1' and @c='1' or @d='1']",- "bar[@a='1' or @b='1' or @c='1']",- "boolean($ResultTreeFragTest)",- "boolean($emptyResultTreeFragTest)",- "boolean('')",- "boolean('0')",- "boolean(-0)",- "boolean(0 div 0)",- "boolean(0)",- "boolean(1 div 0)",- "boolean(1)",- "boolean(doc)",- "boolean(foo)",- "ceiling(-1.5)=-1",- "ceiling(0.0)",- "ceiling(1)=1",- "ceiling(1.1)=2",- "ceiling(1.54)",- "ceiling(2.999999)",- "ceiling(n0)",- "ceiling(n1)",- "ceiling(n2)",- "ceiling(number('xxx'))",- "center//*",- "center//child::*",- "center//descendant::*",- "center/child::*",- "center/descendant::*",- "chapter//footnote[1]",- "chapter//footnote[2]",- "chapter/descendant::footnote[6]",- "chapter/note",- "chapter/note",- "child :: sub",- "child1[child::child2]",- "child::*",- "child::*/child::*",- "child::*/descendant::*",- "child::*[2]",- "child::article|key('key1','Carmelo Montanez')",- "child::near-south-west",- "child::node()",- "child::sub",- "child::sub1|child::sub2",- "child[@deep='3']|child[@wide='3']",- "child[@wide='3'] | key('one','3')",- "child[@wide='3']|child[@deep='3']",- "chooser",- "comment ()",- "concat( substring(subj,1,number(not(starts-with(.,'Re: ')))*string-length(subj)), substring(substring-after(subj,'Re: '),1, number(starts-with(.,'Re: '))*string-length(substring-after(subj,'Re: '))))",- "concat($act,' - ',TITLE,' ')",- "concat($mParam,$nParam,$oParam,$pParam)",- "concat($str,'....5....|')",- "concat('id=', string($p2))",- "concat(/*, /*[@attr='whatsup'])",- "concat(a, 34)",- "concat(a, b)",- "concat(a, b, c, d, e)",- "concat(false(),'ly')",- "concat(left,right,orig)",- "concat(left,right,orig)",- "concat(team[1], ' versus ', team[2])",- "concat(team[1]/@score, '-', team[2]/@score)",- "contains( unparsed-entity-uri('hatch-pic'),'grafix/OpenHatch.gif')",- "contains($node,$find)",- "contains('','')",- "contains('ENCYCLOPEDIA', 'CYCL')",- "contains('ENCYCLOPEDIA', 'TEST')",- "contains('ab', 'abc')",- "contains('abc', '')",- "contains('abc', 'bc')",- "contains('abc', 'bcd')",- "contains('foo','o')",- "contains('true()', 'e')",- "contains(., '&')",- "contains(concat(.,'BC'),concat('A','B','C'))",- "contains(doc, 'CYCL')",- "contains(doc, 'TEST')",- "contains(doc/@attr, 'TEST')",- "contains(doc/@attr, 'amwi')",- "contains(main,sub)",- "contains(main,sub)",- "contains(main,sub)",- "contains(main,sub)",- "count($var1)",- "count($var2)",- "count(*)",- "count(*)",- "count(*/z[2])",- "count(.//SPEECH)",- "count(.//comment())",- "count(/doc/alpha[last()]/h)",- "count(/doc/chapter/note)",- "count(a/@*)",- "count(a/attribute::*)",- "count(alpha/*[last()][name()='z'])",- "count(ancestor::section |../ednote|following::title|../bogus)",- "count(ancestor::section |ancestor::simplesect|ancestor::article)",- "count(ancestor::section |ancestor::simplesect|ancestor::articleinfo)",- "count(div)",- "count(following-sibling::*)",- "count(key('mykey', 'Introduction'))",- "count(namespace::*)",- "count(preceding::text())",- "count(preceding::text())",- "count(xalan:nodeset($rtf)/default:docelem/default:elem3)",- "counter:read('index')",- "counter:read('index')",- "critter",- "critter",- "current()",- "current()",- "current()",- "customers/customer",- "d",- "dat",- "date",- "date:getYear()",- "day",- "day",- "day",- "day",- "day",- "descendant-or-self::*",- "descendant-or-self::*",- "descendant-or-self::*[3]",- "descendant-or-self::center",- "descendant-or-self::far-south",- "descendant-or-self::sub1|descendant-or-self::sub2",- "descendant::*",- "descendant::*",- "descendant::*/child::*",- "descendant::*[3]",- "descendant::*[string-length(name(.))=1]",- "descendant::child1|descendant::child2",- "descendant::far-south",- "display",- "display",- "display",- "div +3",- "div div mod",- "div mod mod",- "div",- "div/@attrib div mod/@attrib",- "div/@attrib mod mod/@attrib",- "div/para[lang('en')]",- "doc/element1[2]/child1[last()]",- "document($typefile,/)",- "document('')/*/xsl:template[@name=$whichtmplt]",- "document('')/*/xsl:template[@name=$whichtmplt]",- "document('')/*/xsl:template[@name='qq']/node()",- "document('')/xsl:stylesheet/ped:test[@attrib='yeha']",- "document('')/xsl:stylesheet/ped:test[@attrib='yeha']",- "document('../impincl-test/mdocs11a.xml')//body",--- "document('..\mdocs\compu.xml')/market.participant/address.set/*", -- \ mag er nicht- "document('bib.xml')",- "document('level3/xreluri09a.xml',document('level1/level2/xreluri09b.xml'))",- "document('mdocs01a.xml')//body",- "document('mdocs03a.xml',section)",- "document('select68.xml')//inside",- "document('select68.xml')//inside",- "document('terms.xml')",- "document('variable20.xml')",- "document('x14template.html')",- "document(a)//body",- "document(a)//body",- "document(a)//body",- "document(document(places))",- "document(filename,document('level1/level2/xreluri10b.xml'))/*/body",- "document(places)",- "document(places)//body",- "document(places,second)/*",- "document(pointer/urlref/@urlstr)/market.participant/business.identity.group/business.name",- "element",- "element1[(((((2*10)-4)+9) div 5) mod 3 )]",- "element1[(((((2*10)-4)+9) div 5) mod floor(3))]",- "element1[descendant-or-self::child2]",- "element1[floor(2)]",- "em:foo",- "expense-report/total",- "expense-report/total",- "ext:getPIData(doc/processing-instruction('a-pi'))",- "extn1:getPIData(doc/processing-instruction('a-pi')[1])",- "extn1:getPIData(doc/processing-instruction('b-pi'))",- "fa/../mi | Aflat/natural/la | Csharp//* | /doc/do | *//ti",- "false() and 1 div 0",- "false() and false()",- "false() and true()",- "false() or false()",- "false() or true()",- "false()",- "false()=''",- "false()=0",- "floor(-1.5)",- "floor(-1.5)=-2",- "floor(0.0)",- "floor(1)=1",- "floor(1.9)",- "floor(1.9)=1",- "floor(2.999999)",- "floor(n0)",- "floor(number('xxx'))",- "following-sibling::*",- "following-sibling::*/preceding-sibling::*",- "following-sibling::*[1]",- "following-sibling::*[2]/preceding-sibling::*",- "following-sibling::*[2]/preceding-sibling::*[4]",- "following-sibling::*[2]/preceding-sibling::*[4]/following-sibling::*[5]/preceding-sibling::*[4]/preceding-sibling::*[2]",- "following-sibling::east",- "following-sibling::node()",- "following::*",- "following::*[4]",- "following::*[4]/../*[2]",- "foo[(bar[2])='this']",- "foo[(bar[2][(baz[2])='goodbye'])]",- "format-number('foo','#############')",- "format-number('foo','#############')",- "format-number(-1 div 0,'###############################')",- "format-number(-1 div 0,'###############################')",- "format-number(-26931.4,'!!!,!!!.!!!')",- "format-number(-26931.4,'###,###.###')",- "format-number(-26931.4,'###,###.###','myminus')",- "format-number(-26931.4,'###,###.###;###,###.###')",- "format-number(-26931.4,'###.###,###','periodgroup')",- "format-number(-26931.4,'###.###,###','periodgroup')",- "format-number(-26931.4,'###.###,###','periodgroup')",- "format-number(-26931.4,'###.###,###','periodgroup')",--- "format-number(-26931.4,'+!!,!!!.!!!\-!!!,!!!.!!!')", -- vom W3C auskommentiert- "format-number(-26931.4,'+###,###.###;-###,###.###')",- "format-number(-26931.4,'+###,###.###;_###,###.###')",- "format-number(-26931.4,'-###,###.###')",- "format-number(-26931.4,'-###,###.###','myminus')",- "format-number(-26931.4,'_###,###.###','myminus')",- "format-number(-42857.1,'###,###.###')",- "format-number(-42857.1,'###,###.###','myminus')",- "format-number(-42857.1,'###,###.###','myminus')",- "format-number(-42857.1,'###,###.###','newminus')",- "format-number(-42857.1,'###,###.###','newminus')",- "format-number(-73816.9,'###,###.###')",- "format-number(-73816.9,'###,###.###')",- "format-number(-73816.9,'###,###.###')",- "format-number(-73816.9,'###,###.###')",- "format-number(0.25, '00%')",- "format-number(0.4857,'###.###%')",- "format-number(0.4857,'###.###c')",- "format-number(0.4857,'###.###m')",- "format-number(0.4857,'###.###‰')",- "format-number(1 div 0,'###############################')",- "format-number(1 div 0,'###############################')",- "format-number(1, '#,##0')",- "format-number(1, '00')",- "format-number(1, '00.0')",- "format-number(1000, '###0')",- "format-number(1234.567,'#*###*###!###','foo:decimal1')",- "format-number(12792.14*96.58,'##,###,000.000###')",- "format-number(2.14*86.58,'PREFIX##00.000###SUFFIX')",- "format-number(2392.14*(-36.58),'000,000.000###;###,###.000###')",- "format-number(2392.14*(-36.58),'000,000.000###;-###,###.000###')",- "format-number(2392.14*36.58,'000,000.000000')",- "format-number(2392.14*36.58,'000,000.000000','myminus')",- "format-number(2392.14*36.58,'000,000.000000;###,###.000###')",- "format-number(2392.14*36.58,'000,000.000000;###,###.000###','myminus')",- "format-number(239236.588,'00000.00')",--- "format-number(26931.4,'+!!!,!!!.!!!\-!!,!!!.!!!')", -- vom W3C auskommentiert- "format-number(2792.14*(-36.58),'000,000.000###')",- "format-number(4030201.0506,'#!!!,!!!,aaa.aaaaaa0')",- "format-number(7654321.4857,'### ### ###,#####')",- "format-number(931.4857,'###!###!###')",- "format-number(931.4857,'000.000|###')",- "format-number(95.4857,'¤###.####')",- "format-number(987654321,'###,##0,00.00')",- "generate-id(d)",- "generate-id(xalan:nodeset($rtf)/default:docelem/default:elem4)",- "growth",- "growth",- "human",- "id('c')/@id",- "id('c')/@id",- "id('d b c')",- "id('id0')/a/b",- "id('id0')/c/c/a",- "id('id10')/a",- "id('id13')",- "id('id2')/a | id('id5') | id('id15')/a",- "id('id4')",- "id('id8')/b/b",- "id('id9')",- "id('nomatch')/@id",- "id(main/b)",- "id(main/b)",- "item[$n1]",- "item[position()=$n]",- "java:format($formatter, $date)",- "java:format($formatter, $javadate)",- "java:get ($counter-table, 'index')",- "java:java.lang.Long.parseLong(string(.))",- "java:java.text.SimpleDateFormat.new('yyyy.MM.dd hh:mm')",- "java:java.util.Calendar.getInstance()",- "java:java.util.Date.new($date)",- "java:java.util.Hashtable.new ()",- "key($keysp, 'Expressions')/subdiv/p",- "key($keysp, 'Introduction')/subdiv/p",- "key($keysp, 'Stylesheet Structure')/subdiv/p",- "key('MonthNum',month)",- "key('MonthNum',month)",- "key('baz:mykey', 'Expressions')/p",- "key('baz:mykey', 'Introduction')/p",- "key('baz:mykey', 'Stylesheet Structure')/p",- "key('bib',$lookup)",- "key('bigspace', 'Expressions')/subdiv/p",- "key('bigspace', 'Expressions')/subdiv/p",- "key('bigspace', 'Introduction')/subdiv/p",- "key('bigspace', 'Introduction')/subdiv/p",- "key('bigspace', 'Stylesheet Structure')/subdiv/p",- "key('bigspace', 'Stylesheet Structure')/subdiv/p",- "key('filterspace', 'Expressions')/subdiv/p",- "key('filterspace', 'Expressions')/subdiv/p",- "key('filterspace', 'Introduction')/subdiv/p",- "key('filterspace', 'Introduction')/subdiv/p",- "key('filterspace', 'Stylesheet Structure')/subdiv/p",- "key('filterspace', 'Stylesheet Structure')/subdiv/p",- "key('k','Albany')",- "key('k','Albany')",- "key('k','false')[position()=1]/num",- "key('k','false')[position()=2]/num",- "key('k','true')[1]/num",- "key('k','true')[1]/num",- "key('k','true')[3]/num",- "key('k','true')[3]/num",- "key('k','true')[4]/num",- "key('k','true')[4]/num",- "key('k','true')[last()=position()]",- "key('k','true')[last()]",- "key('k','true')[position()=1]/num",- "key('k','true')[position()=4]/num",- "key('key1','Mary Brady')|key('key2','Rick Rivello')",- "key('marks',key('titles', 'Expressions')/finder)",- "key('mykey', 'Expressions')",- "key('mykey', 'Expressions')/p",- "key('mykey', 'Introduction')/p",- "key('mykey', 'Patterns')",- "key('mykey', 'Second Title in Structure')/p",- "key('mykey', 'Stylesheet Structure')",- "key('mykey', 'Stylesheet Structure')/p",- "key('mykey', 1 )/p",- "key('mykey', 1+1 )/p",- "key('mykey', 3.0 )/p",- "key('mykey', 3.7 )/p",- "key('mykey',' ')/@title",- "key('mykey','')/p",- "key('mykey','Exp Section')/@title",- "key('mykey','Expressions')/p",- "key('mykey','Expressions')/p",- "key('mykey','Intro Section')/@title",- "key('mykey','Introduction')/p",- "key('mykey','Introduction')/p",- "key('mykey','SS Section')/@title",- "key('mykey','Sort Section')/@title",- "key('mykey','Sorting')/p",- "key('mykey','Sorting')/p",- "key('mykey','Stylesheet Structure')/p",- "key('mykey','Stylesheet Structure')/p",- "key('mykey',*//title)",- "key('mykey1','foo' )/p",- "key('mykey2', 1 )/p",- "key('one','3') | key('two','3')",- "key('smallspace', 'Expressions')/p",- "key('smallspace', 'Expressions')/p",- "key('smallspace', 'Introduction')/p",- "key('smallspace', 'Introduction')/p",- "key('smallspace', 'Stylesheet Structure')/p",- "key('smallspace', 'Stylesheet Structure')/p",- "key('test','foey')",- "key('titles', .)",- "key('two','3') | document('select59.xml')/child[@wide='3'] | child[@deep='3']",- "key('which','3')",- "keyword[@tag='sector']",- "keyword[@tag='ticker']",- "keyword[@tag='ticker']",- "keyword[@tag='ticker']",- "keyword[@tag='ticker']",- "lang('en')",- "last()",- "local-name()",- "local-name(.)",- "local-name(baz1:a)",- "local-name(baz2:b)",- "local-name(baz2:b/@baz1:attrib2)",- "local-name(namespace::*[1])",- "local-name(namespace::*[string()='http://www.w3.org/1999/XMLSchema-instance'])",- "local-name(namespace::*[string()='test'])",- "local-name(xalan:nodeset($rtf)/*)",- "main/a/descendant-or-self::*/@*",- "main/size[@for='d']",- "mi | do | fa | re",- "mi[@mi2='mi2'] | do | fa/so/@so | fa | mi/@* | re | fa/@fa | do/@do",- "month",- "month",- "month",- "n",- "n-2 - -n-1",- "n-2 - n-1",- "n-2+-n-1",- "n0 div n1 div n2 div n3 div n4 div n5",- "n0 div n1 div n2 div n3 div n4",- "n0 div n1 div n2 div n3",- "n1 div n2",- "n1 mod n2",- "n1*n2",- "n1*n2*n3*n4",- "n1*n2*n3*n4*n5*n6*n7*n8*n9*n10",- "n1+n2",- "n1/@attrib + n2/@attrib",- "n1/@attrib div n2/@attrib",- "n1/@attrib mod n2/@attrib",- "n2+3+$anum+7+n5",- "n4",- "n6*5-8*n2+5*2",- "name",- "name",- "name",- "name",- "name",- "name",- "name",- "name((ancestor::section|../ednote |following::title|../bogus)[1])",- "name((ancestor::section|ancestor::simplesect |ancestor::article)[last()])",- "name(/descendant-or-self::node()/child::near-north)",- "name(/descendant-or-self::node()/descendant-or-self::north)",- "name(/descendant-or-self::north)",- "name(/descendant-or-self::north/child::near-north)",- "name(/descendant-or-self::north/descendant-or-self::north)",- "name(/descendant::near-north)",- "name(/descendant::near-north/descendant-or-self::near-north)",- "name(/descendant::node()/descendant-or-self::near-north)",- "name(ancestor::*[1])",- "name(ancestor::*[1])",- "name(ancestor::*[2])",- "name(ancestor::*[2])",- "name(ancestor::*[3])",- "name(ancestor::*[3])",- "name(baz1:a)",- "name(baz1:a/@baz2:attrib1)",- "name(baz2:b)",- "name(baz2:b/@baz1:attrib2)",- "name(descendant-or-self::node()/child::near-north)",- "name(descendant-or-self::node()/child::node()/child::far-west)",- "name(descendant-or-self::node()/child::node()/descendant-or-self::near-north)",- "name(descendant-or-self::node()/descendant-or-self::node()/child::near-north)",- "name(descendant-or-self::node()/descendant-or-self::node()/descendant-or-self::north)",- "name(descendant-or-self::node()/descendant-or-self::north)",- "name(descendant-or-self::node()/descendant::near-north)",- "name(descendant-or-self::node()/descendant::node()/child::far-west)",- "name(descendant-or-self::node()/descendant::node()/descendant-or-self::near-north)",- "name(descendant-or-self::north/child::near-north)",- "name(descendant-or-self::north/child::near-north/child::far-west)",- "name(descendant-or-self::north/child::near-north/descendant-or-self::near-north)",- "name(descendant-or-self::north/descendant-or-self::north)",- "name(descendant-or-self::north/descendant-or-self::north/child::near-north)",- "name(descendant-or-self::north/descendant-or-self::north/descendant-or-self::north)",- "name(descendant-or-self::north/descendant::near-north)",- "name(descendant-or-self::north/descendant::near-north/child::far-west)",- "name(descendant-or-self::north/descendant::near-north/descendant-or-self::near-north)",- "name(descendant::near-north/descendant-or-self::near-north)",- "name(descendant::near-north/descendant-or-self::near-north/child::far-west)",- "name(descendant::near-north/descendant-or-self::near-north/descendant-or-self::near-north)",- "name(descendant::near-north/descendant::far-west)",- "name(descendant::near-north/descendant::far-west/descendant-or-self::far-west)",- "name(descendant::node()/descendant-or-self::near-north)",- "name(descendant::node()/descendant-or-self::node()/child::far-west)",- "name(descendant::node()/descendant-or-self::node()/descendant-or-self::near-north)",- "name(descendant::node()/descendant::far-west)",- "name(descendant::node()/descendant::node()/descendant-or-self::far-west)",- "name(namespace::*[1])",- "name(self::node()/descendant-or-self::node()/child::near-north)",- "name(self::node()/descendant-or-self::node()/descendant-or-self::north)",- "name(self::node()/descendant-or-self::north)",- "name(self::node()/descendant-or-self::north/child::near-north)",- "name(self::node()/descendant-or-self::north/descendant-or-self::north)",- "name(self::node()/descendant::near-north)",- "name(self::node()/descendant::near-north/child::far-west)",- "name(self::node()/descendant::near-north/descendant-or-self::far-west)",- "name(self::node()/descendant::node()/child::far-west)",- "name(self::node()/descendant::node()/descendant-or-self::far-west)",- "name(xalan:nodeset($rtf)/*)",- "namespace-uri(baz1:a-two/@attrib1)",- "namespace-uri(baz1:a/@baz2:attrib1)",- "namespace-uri(baz2:b)",- "namespace-uri(baz2:b-three)",- "namespace-uri(baz2:b-three/@baz1:attrib2)",- "namespace-uri(baz2:b-three/c-four)",- "namespace-uri(baz2:b/@baz1:attrib2)",- "namespace-uri(namespace::*[string()='http://www.w3.org/1999/XMLSchema-instance'])",- "namespace-uri(namespace::*[string()='test'])",- "namespace-uri(x)",- "namespace-uri(xalan:nodeset($rtf)/default:docelem)",- "namespace-uri(xalan:nodeset($rtf)/default:docelem/default:elem1)",- "namespace-uri(xalan:nodeset($rtf)/default:docelem/test:elem3)",- "namespace::*",- "namespace::node()",- "nitro:element(.)",- "node",- "node()|@*",- "normalize-space($texts[1])",- "normalize-space($thisvalue)",- "normalize-space(' ab cd ef ')",- "normalize-space()",- "normalize-space(a)",- "north/* | north/dup1 | north/dup2",- "north/dup2 | document('select71.xml')/south/preceding-sibling[4] | north/*",- "north/dup2 | north/dup1 | north/*",- "not($x!='foo')",- "not('')",- "not('0')",- "not(false() = false())",- "not(false())",- "not(true() = false())",- "not(true())",- "note[1]",- "note[1]",- "number($ResultTreeFragTest)",- "number($emptyResultTreeFragTest)",- "number($pvar2)",- "number('')",- "number('3')",- "number('abc')",- "number('xxx') - 10",- "number('xxx') div 3",- "number('xxx') mod 3",- "number('xxx')=0",- "number('xxx')=number('xxx')",- "number()",- "number(2)",- "number(false())=0",- "number(foo)",- "number(n1)",- "number(string(1.0))=1",- "number(true())=1",- "number(xalan:nodeset($rtf)/default:docelem/default:elem3[2])",- "para[@id='1' and lang('en')]",- "parent::*",- "parent::*[1]",- "parent::foo",- "parent::near-north",- "position()",- "position()=1",- "preceding-sibling::*",- "preceding-sibling::*/following-sibling::*",- "preceding-sibling::*[2]",- "preceding-sibling::*[2]",- "preceding-sibling::*[2]/following-sibling::*",- "preceding-sibling::*[2]/following-sibling::*[4]",- "preceding-sibling::*[2]/following-sibling::*[4]/preceding-sibling::*[5]/following-sibling::*[4]/following-sibling::*[2]",- "preceding-sibling::*|following-sibling::*",- "preceding-sibling::child1|//child3",- "preceding-sibling::child1|following-sibling::child3",- "preceding-sibling::foo[1]/@att1",- "preceding-sibling::west",- "preceding::*",- "preceding::*[2]/../descendant::*[10]/following-sibling::east",- "preceding::*[2]/../following::*",- "preceding::*[4]",- "preceding::foo[1]/@att1",- "preceding::out-yonder-west",- "preceding::text()",- "preceding::text()[$this]",- "primary/name/first",- "primary/name/first",- "processing-instruction()",- "pt:xif('test')",- "pt:xif(string($val))",- "round(-1.1)=-1",- "round(-1.5)",- "round(-1.9)=-2",- "round(-2.5)=-2",- "round(0.0)",- "round(1.1)=1",- "round(1.24)",- "round(1.5)=2",- "round(1.9)=2",- "round(2.5)",- "round(2.999999)",- "round(count(.//LINE) div count(.//SPEECH))",- "round(n0)",- "round(n1)",- "round(n2)",- "round(number('xxx'))",- "row",- "self::*",- "self::*",- "self::*[1]",- "self::*[@center-attr-2]",- "self::*[near-south]",- "self::center",- "self::child1|self::child2",- "self::comment()",- "self::foo",- "self::node()",- "self::node()",- "self::node()",- "self::node()",- "self::processing-instruction()",- "self::text()",- "sigs",- "sss//i",- "sss//i",- "sss/sss",- "sss/sss",- "starts-with('','')",- "starts-with('ENCYCLOPEDIA', 'EN')",- "starts-with('ENCYCLOPEDIA', 'ENCY')",- "starts-with('ENCYCLOPEDIA', 'en')",- "starts-with('ab', 'abc')",- "starts-with('abc', '')",- "starts-with('abc', 'bc')",- "starts-with('true()', 'tr')",- "starts-with(doc, 'ENCY')",- "starts-with(doc, 'test')",- "starts-with(doc/@attr, 'slam')",- "starts-with(doc/@attr, 'wich')",- "str:new(string(doc))",- "str:toUpperCase($str-obj)",- "string($ResultTreeFragTest)",- "string($ResultTreeFragTest)",- "string($emptyResultTreeFragTest)",- "string($which)",- "string('!From m!')",- "string('!From n!')",- "string('!From o!')",- "string('!From p!')",- "string('')",- "string('test')",- "string()",- "string()",- "string(0)",- "string(2)",- "string(av//*)",- "string(doc)",- "string(foo)",- "string-length ()",- "string-length($str)",- "string-length('This is a test')",- "string-length()",- "string-length()",- "string-length(.)",- "string-length(doc)",- "string-length(doc/a)",- "sub1/child1|/doc/sub2/child2",- "sub1/child1|sub2/child2",- "subj",- "substring('1999/04/01', 1, 0)",- "substring('1999/04/01', 1, 4)",- "substring('ENCYCLOPEDIA', 8)",- "substring('ENCYCLOPEDIA', 8, 3)",- "substring('abcdefghi',2,4)",- "substring('abcdefghijk',0 div 0, 5)",- "substring('abcdefghijk',4, 6)",- "substring(@key,2,1)",- "substring(doc, 1, 4)",- "substring(doc/@attr, 1, 3)",- "substring(doc/@attr, 2.5, 3.6)",- "substring(doc/@attr, 4)",- "substring(foo, 12, 3)",- "substring(foo, 2, 2)",- "substring-after($words,' ')",- "substring-after('1999/04/01', '/')",- "substring-after('1999/04/01', '1')",- "substring-after('ENCYCLOPEDIA', '/')",- "substring-after('ENCYCLOPEDIA', 'C')",- "substring-after('abcdefghijk','l')",- "substring-after(doc, '/')",- "substring-after(doc/@attr, 'D')",- "substring-after(doc/@attr, 'd')",- "substring-after(doc/@attr, 'z')",- "substring-after(foo, '/')",- "substring-before('1999/04/01', '/')",- "substring-before('ENCYCLOPEDIA', '/')",- "substring-before('ENCYCLOPEDIA', 'C')",- "substring-before('ENCYCLOPEDIA', 'c')",- "substring-before('a','z')",- "substring-before(doc, '/')",- "substring-before(doc/@attr, 'D')",- "substring-before(doc/@attr, 'd')",- "substring-before(doc/@attr, 'z')",- "substring-before(foo, '/')",- "sum($rtf)",- "sum(e)",- "sum(e)",- "sum(n)",- "sum(n/@attrib)",- "sum(x)",- "sum(xalan:nodeset($rtf)/default:docelem/default:elem3)",- "system-property('xsl:vendor')",- "true() and false()",- "true() and true()",- "true() or 1 div 0",- "true() or false()",- "true() or true()",- "true()",- "true()=2",- "width * depth",- "xalan:nodeset($rtf)/default:docelem",- "xalan:nodeset($rtf)/default:docelem/*",- "xalan:nodeset($rtf)/default:docelem/default:elem1",- "xalan:nodeset($rtf)/default:docelem/default:elem1/default:elem1b",- "xalan:nodeset($rtf)/default:docelem/default:elem2/*",- "xalan:nodeset($rtf)/default:docelem/default:elem4",- "xalan:nodeset($rtf)/default:docelem/test:elem3",- "xalan:nodeset($sorted)/item",- "deep-equal(/,foo)"- ]+ "$h - $i",+ "$hotelnode/location/@country",+ "$in//text()",+ "$l10n.name",+ "$lookup/@text",+ "$start + $step",+ "$texts[position() > 1]",+ "$var1|$var2",+ "$var1|child::child2",+ "$var1|key('key1','Lynne Rosenthal')",+ "$x=''",+ "$x='foo'",+ "$xml-source",+ "$y='foo'",+ "$zoo:bear",+ "' #text'",+ "' 6 ' div 2",+ "' 6 '*div",+ "' x 4'",+ "' x 4'",+ "'....5....|'",+ "'1' and '0'",+ "'2'>'1'",+ "'200'",+ "'ABC'",+ "($terms/table/expand[@language=$lang]/gentext[@key=$key])[1]",+ "((((((n3+5)*(3)+(((n2)+2)*(n1 - 6)))-(n4 - n2))+(-(4-6)))))",+ "(((ancestor::foo)[1])/@att1)",+ "((ancestor::foo))[1]/@att1",+ "(* - 4) div 2",+ "(* - 4)**",+ "(2 + number('xxx'))",+ "(24 div 3 +2) div (40 div 8 -3)",+ "(5 mod 2 = 1) and (5 mod -2 = 1) and (-5 mod 2 = -1) and (-5 mod -2 = -1)",+ "(77 mod $anum + n5 mod 8) mod $anum",+ "(ancestor-or-self::*)[@att1][1]/@att1",+ "(ancestor::foo)[1]/@att1",+ "(ancestor::foo[1])/@att1",+ "(ancestor::section|ancestor::simplesect |ancestor::articleinfo)[last()]",+ "(chapter//footnote)[2]",+ "(child::chapter/descendant-or-self::node())/footnote[2]",+ "(n1*n2*n3*n4*n5*n6)div n7 div n8 div n9 div n10",+ "(n1/@attrib)*(n2/@attrib)",+ "(n1/@attrib)+(n2/@attrib)",+ "(preceding-sibling::*|following-sibling::*)/ancestor::*[last()]/*[last()]",+ "(preceding-sibling::foo)[1]/@att1",+ "(preceding::foo)[1]/@att1",+ "(section//@title)[7]",+ "(xalan:nodeset($rtf)/default:docelem/test:elem3)", -- namespaces noch mal ueberdenken+ "* +3",+ "*//la | //Bflat | re",+ "*/p",+ "*[$index]",+ "*[$index]",+ "*[$index]",+ "*[1]",+ "*[3]",+ "*[4]",+ "*[@test and position()=1]",+ "*[@test and position()=4]",+ "*[@test and position()=7]",+ "*[@test and position()=8]",+ "*[@test='true']",+ "*[@test][1]/num",+ "*[@test][position()=1]/num",+ "*[last()=position()]",+ "*[last()]",+ "*[local-name()='bar']",+ "*[not(@test)][last()=position()]",+ "*[not(@test)][last()]",+ "*[position()=1]",+ "*[position()=3]",+ "*[position()=4]",+ "*[starts-with(name(.),'f')]",+ "*|@*",+ "*|@*|comment()|processing-instruction()|text()",+ "-(n-2/@attrib) - -(n-1/@attrib)",+ "-(n1|n2)",+ "-.0000000000000000000000000000000000000000123456789",+ "-.01",+ "-n-2 --n-1",+ "-n-2/@attrib --n-1/@attrib",+ "..",+ "../../a/b[1]",+ "..//foo",+ "../@id",+ "../node()",+ "./*[name(.) = $sortcol]",+ ".//*[@so]",+ ".//PERSONA",+ ".//a",+ ".//center",+ ".//center",+ ".//comment()",+ ".//f",+ ".//near-south/preceding-sibling::*|following-sibling::east/ancestor-or-self::*[2]",+ ".//text()",+ ".//title",+ "./@id",+ "./@theattrib",+ ".0000000000000000000000000000000000000000123456789",+ ".01",+ ".123456789",+ "/",+ "/*/@group",+ "//*",+ "//*",+ "//*[count(./*/*) > 0]",+ "//*[count(ancestor::*) >= 2]/../parent::*",+ "//ACT",+ "//ancestor::*",+ "//child1[parent::element1]",+ "//child1|//child2",+ "//child2[ancestor-or-self::element2]",+ "//child2[ancestor::element2]",+ "//child5|//child2|//child4",+ "//comment()",+ "//inc/node4",+ "//item[@type=current()/@name]",+ "//noChild1|//noChild2",+ "//north/dup2 | south/preceding-sibling[4] | north/dup1 | north/*",+ "//processing-instruction()",+ "//xx/descendant::*",+ "/doc/*[@test='true']",+ "/doc/a/b/@attr",+ "/doc/critter[@type='cat']",+ "/doc/mid/inner",+ "/doc/sub1/child1|/doc/sub2/child2",+ "/docs/a",+ "/docs/a",+ "/page/contents/avail/hotel",+ "/sss/sss/i",+ "/sss/sss/i",+ "0 > -0",+ "0 = -0",+ "0 div 0 >= 0",+ "0 div 0 < 0",+ "0 div 0",+ "0 or ''",+ "0",+ "0000000000",+ "1 = '001'",+ "1 = 1.00",+ "1 div -0 = 1 div 0",+ "1 div -0 = 2 div -0",+ "1>1",+ "1<1",+ "1<=1",+ "1-2",+ "10+5+25+20+15+50+35+40",+ "10+7",+ "100-$anum -5-15-$anum",+ "100-9-7-4-17-18-5",+ "100-n6 -4-n1 -1-11",+ "12",+ "123",+ "1234",+ "12345",+ "123456",+ "1234567",+ "12345678",+ "123456789",+ "1234567890",+ "12345678901",+ "123456789012",+ "1234567890123",+ "12345678901234",+ "123456789012345",+ "1234567890123456",+ "12345678901234567",+ "123456789012345678",+ "16-div",+ "1=1",+ "2 * -number('xxx')",+ "2 - number('xxx')",+ "2 div number('xxx')",+ "2 mod number('xxx')",+ "2",+ "2>1",+ "2>=1",+ "2>=2",+ "2<1",+ "2<=1",+ "2*3",+ "2+n5+7+n3",+ "20",+ "25-*",+ "256",+ "3",+ "3",+ "3*2+5*4-4*2-1",+ "3+6",+ "3-1",+ "32",+ "4",+ "4",+ "444 + $t1num",+ "48 mod 17 - 2 mod 9 + 13 mod 5",+ "5 mod 2",+ "5",+ "5",+ "5.*.",+ "5.+*",+ "54 div*",+ "555",+ "56 mod round(n5*2+1.444) - n6 mod 4 + 7 mod n4",+ "6 div -2",+ "6 div 2",+ "6",+ "60",+ "7 - -3",+ "7",+ "7",+ "7+-3",+ "70 div $anum - 18 div n6 + $anum div n2",+ "8",+ "80 div n2 + 12 div 2 - n4 div n2",+ "9",+ "9.87654321012345",+ "98.7654321012345",+ "987.654321012345",+ "9876.54321012345",+ "98765.4321012345",+ "987654.321012345",+ "9876543.21012345",+ "98765432.1012345",+ "987654321.012345",+ "9876543210",+ "9876543210.12345",+ "98765432101.2345",+ "987654321012.345",+ "9876543210123.45",+ "98765432101234.5",+ "FM|PERSONAE|ACT",+ "Name/@First",+ "OL",+ "Personal_Information/Age",+ "Spr/State[. = 'Open']",+ "a/*[last()]",+ "a/child::*[last()]",+ "a/child::comment()[last()]",+ "a/child::node()[last()]",+ "a/child::text()[last()]",+ "a/descendant::*[last()]",+ "a/x",+ "a['3.5' < 4]",+ "a['target'!=descendant::*]",+ "a['target'=descendant::*]",+ "a[('target'=descendant::*) or @squish]",+ "a[(@squeesh or @squish) and @squash]",+ "a[*=9]",+ "a[0 < true()]",+ "a[0]",+ "a[1 < 2]",+ "a[1 < 3]",+ "a[1]",+ "a[3 > following-sibling::*]",+ "a[3 >= following-sibling::*]",+ "a[3 < following-sibling::*]",+ "a[3 <= following-sibling::*]",+ "a[3-2]",+ "a[3.0='3.0']",+ "a[3=following-sibling::*]",+ "a[3]",+ "a[4 != following-sibling::*]",+ "a[4]",+ "a[@squeesh or (@squish and @squash)]",+ "a[@squeesh or @squish and @squash]",+ "a[descendant::*!='target']",+ "a[descendant::*='target']",+ "a[div=9]",+ "a[false()!=following-sibling::*]",+ "a[following-sibling::* != 4]",+ "a[following-sibling::* > 3]",+ "a[following-sibling::* >= 3]",+ "a[following-sibling::* < 3]",+ "a[following-sibling::* <= 3]",+ "a[following-sibling::*!=false()]",+ "a[following-sibling::*=3]",+ "a[following-sibling::*=descendant::*]",+ "a[following-sibling::*=true()]",+ "a[not(('target'=descendant::*) or @squish)]",+ "a[not(@*)]",+ "a[number('3')]",+ "a[position() <=3]",+ "a[position()!=2]",+ "a[position()>2]",+ "a[position()>=2]",+ "a[position()<3]",+ "a[position()=$first]",+ "a[position()=1]",+ "a[position()=3]",+ "a[position()=4]",+ "a[true()='stringwithchars']",+ "a[true()=4]",+ "a[true()=following-sibling::*]",+ "alternate/name/first",+ "ancestor-or-self::*",+ "ancestor-or-self::*[1]",+ "ancestor-or-self::*[1]/text()",+ "ancestor-or-self::*[@att1][1]/@att1",+ "ancestor-or-self::sub | ancestor-or-self::sub-sub",+ "ancestor::*",+ "ancestor::*[3]",+ "ancestor::*[count(child::*) > 1]/*[not(. = current()/ancestor-or-self::*)]",+ "ancestor::foo[1]/@att1",+ "ancestor::sub1|ancestor::sub2",+ "attribute :: *",+ "attribute :: div",+ "attribute*(div - 4)",+ "attribute::*",+ "attribute::*[2]",+ "attribute::attr1|attribute::attr2",+ "attribute::center-attr-2",+ "author/name|author/bibliography/author/chapters",+ "author/name|author/bibliography/author/name",+ "author/name|author/noElement",+ "author[(name/@real='no' and position()=1)]|author[(name/@real='yes' and position()=last())]",+ "author[name/@real='no']|author[name/@real='yes']",+ "author[name='Mary Brady']|author[name/@real='no']",+ "bar | joes:bar",+ "bar[(@a='1' and @b='1') or (@c='1' and @d='1')]",+ "bar[(@a='1' or @b='1') and (@c='1' or @d='1')]",+ "bar[(@a='1' or @b='1') and @c='1']",+ "bar[@a='1' and (@b='1' or @c='1') and @d='1']",+ "bar[@a='1' and @b='1' or @c='1' and @d='1']",+ "bar[@a='1' and @b='1']",+ "bar[@a='1' or (@b='1' and @c='1') or @d='1']",+ "bar[@a='1' or @b='1' and @c='1' or @d='1']",+ "bar[@a='1' or @b='1' or @c='1']",+ "boolean($ResultTreeFragTest)",+ "boolean($emptyResultTreeFragTest)",+ "boolean('')",+ "boolean('0')",+ "boolean(-0)",+ "boolean(0 div 0)",+ "boolean(0)",+ "boolean(1 div 0)",+ "boolean(1)",+ "boolean(doc)",+ "boolean(foo)",+ "ceiling(-1.5)=-1",+ "ceiling(0.0)",+ "ceiling(1)=1",+ "ceiling(1.1)=2",+ "ceiling(1.54)",+ "ceiling(2.999999)",+ "ceiling(n0)",+ "ceiling(n1)",+ "ceiling(n2)",+ "ceiling(number('xxx'))",+ "center//*",+ "center//child::*",+ "center//descendant::*",+ "center/child::*",+ "center/descendant::*",+ "chapter//footnote[1]",+ "chapter//footnote[2]",+ "chapter/descendant::footnote[6]",+ "chapter/note",+ "chapter/note",+ "child :: sub",+ "child1[child::child2]",+ "child::*",+ "child::*/child::*",+ "child::*/descendant::*",+ "child::*[2]",+ "child::article|key('key1','Carmelo Montanez')",+ "child::near-south-west",+ "child::node()",+ "child::sub",+ "child::sub1|child::sub2",+ "child[@deep='3']|child[@wide='3']",+ "child[@wide='3'] | key('one','3')",+ "child[@wide='3']|child[@deep='3']",+ "chooser",+ "comment ()",+ "concat( substring(subj,1,number(not(starts-with(.,'Re: ')))*string-length(subj)), substring(substring-after(subj,'Re: '),1, number(starts-with(.,'Re: '))*string-length(substring-after(subj,'Re: '))))",+ "concat($act,' - ',TITLE,' ')",+ "concat($mParam,$nParam,$oParam,$pParam)",+ "concat($str,'....5....|')",+ "concat('id=', string($p2))",+ "concat(/*, /*[@attr='whatsup'])",+ "concat(a, 34)",+ "concat(a, b)",+ "concat(a, b, c, d, e)",+ "concat(false(),'ly')",+ "concat(left,right,orig)",+ "concat(left,right,orig)",+ "concat(team[1], ' versus ', team[2])",+ "concat(team[1]/@score, '-', team[2]/@score)",+ "contains( unparsed-entity-uri('hatch-pic'),'grafix/OpenHatch.gif')",+ "contains($node,$find)",+ "contains('','')",+ "contains('ENCYCLOPEDIA', 'CYCL')",+ "contains('ENCYCLOPEDIA', 'TEST')",+ "contains('ab', 'abc')",+ "contains('abc', '')",+ "contains('abc', 'bc')",+ "contains('abc', 'bcd')",+ "contains('foo','o')",+ "contains('true()', 'e')",+ "contains(., '&')",+ "contains(concat(.,'BC'),concat('A','B','C'))",+ "contains(doc, 'CYCL')",+ "contains(doc, 'TEST')",+ "contains(doc/@attr, 'TEST')",+ "contains(doc/@attr, 'amwi')",+ "contains(main,sub)",+ "contains(main,sub)",+ "contains(main,sub)",+ "contains(main,sub)",+ "count($var1)",+ "count($var2)",+ "count(*)",+ "count(*)",+ "count(*/z[2])",+ "count(.//SPEECH)",+ "count(.//comment())",+ "count(/doc/alpha[last()]/h)",+ "count(/doc/chapter/note)",+ "count(a/@*)",+ "count(a/attribute::*)",+ "count(alpha/*[last()][name()='z'])",+ "count(ancestor::section |../ednote|following::title|../bogus)",+ "count(ancestor::section |ancestor::simplesect|ancestor::article)",+ "count(ancestor::section |ancestor::simplesect|ancestor::articleinfo)",+ "count(div)",+ "count(following-sibling::*)",+ "count(key('mykey', 'Introduction'))",+ "count(namespace::*)",+ "count(preceding::text())",+ "count(preceding::text())",+ "count(xalan:nodeset($rtf)/default:docelem/default:elem3)",+ "counter:read('index')",+ "counter:read('index')",+ "critter",+ "critter",+ "current()",+ "current()",+ "current()",+ "customers/customer",+ "d",+ "dat",+ "date",+ "date:getYear()",+ "day",+ "day",+ "day",+ "day",+ "day",+ "descendant-or-self::*",+ "descendant-or-self::*",+ "descendant-or-self::*[3]",+ "descendant-or-self::center",+ "descendant-or-self::far-south",+ "descendant-or-self::sub1|descendant-or-self::sub2",+ "descendant::*",+ "descendant::*",+ "descendant::*/child::*",+ "descendant::*[3]",+ "descendant::*[string-length(name(.))=1]",+ "descendant::child1|descendant::child2",+ "descendant::far-south",+ "display",+ "display",+ "display",+ "div +3",+ "div div mod",+ "div mod mod",+ "div",+ "div/@attrib div mod/@attrib",+ "div/@attrib mod mod/@attrib",+ "div/para[lang('en')]",+ "doc/element1[2]/child1[last()]",+ "document($typefile,/)",+ "document('')/*/xsl:template[@name=$whichtmplt]",+ "document('')/*/xsl:template[@name=$whichtmplt]",+ "document('')/*/xsl:template[@name='qq']/node()",+ "document('')/xsl:stylesheet/ped:test[@attrib='yeha']",+ "document('')/xsl:stylesheet/ped:test[@attrib='yeha']",+ "document('../impincl-test/mdocs11a.xml')//body",+-- "document('..\mdocs\compu.xml')/market.participant/address.set/*", -- \ mag er nicht+ "document('bib.xml')",+ "document('level3/xreluri09a.xml',document('level1/level2/xreluri09b.xml'))",+ "document('mdocs01a.xml')//body",+ "document('mdocs03a.xml',section)",+ "document('select68.xml')//inside",+ "document('select68.xml')//inside",+ "document('terms.xml')",+ "document('variable20.xml')",+ "document('x14template.html')",+ "document(a)//body",+ "document(a)//body",+ "document(a)//body",+ "document(document(places))",+ "document(filename,document('level1/level2/xreluri10b.xml'))/*/body",+ "document(places)",+ "document(places)//body",+ "document(places,second)/*",+ "document(pointer/urlref/@urlstr)/market.participant/business.identity.group/business.name",+ "element",+ "element1[(((((2*10)-4)+9) div 5) mod 3 )]",+ "element1[(((((2*10)-4)+9) div 5) mod floor(3))]",+ "element1[descendant-or-self::child2]",+ "element1[floor(2)]",+ "em:foo",+ "expense-report/total",+ "expense-report/total",+ "ext:getPIData(doc/processing-instruction('a-pi'))",+ "extn1:getPIData(doc/processing-instruction('a-pi')[1])",+ "extn1:getPIData(doc/processing-instruction('b-pi'))",+ "fa/../mi | Aflat/natural/la | Csharp//* | /doc/do | *//ti",+ "false() and 1 div 0",+ "false() and false()",+ "false() and true()",+ "false() or false()",+ "false() or true()",+ "false()",+ "false()=''",+ "false()=0",+ "floor(-1.5)",+ "floor(-1.5)=-2",+ "floor(0.0)",+ "floor(1)=1",+ "floor(1.9)",+ "floor(1.9)=1",+ "floor(2.999999)",+ "floor(n0)",+ "floor(number('xxx'))",+ "following-sibling::*",+ "following-sibling::*/preceding-sibling::*",+ "following-sibling::*[1]",+ "following-sibling::*[2]/preceding-sibling::*",+ "following-sibling::*[2]/preceding-sibling::*[4]",+ "following-sibling::*[2]/preceding-sibling::*[4]/following-sibling::*[5]/preceding-sibling::*[4]/preceding-sibling::*[2]",+ "following-sibling::east",+ "following-sibling::node()",+ "following::*",+ "following::*[4]",+ "following::*[4]/../*[2]",+ "foo[(bar[2])='this']",+ "foo[(bar[2][(baz[2])='goodbye'])]",+ "format-number('foo','#############')",+ "format-number('foo','#############')",+ "format-number(-1 div 0,'###############################')",+ "format-number(-1 div 0,'###############################')",+ "format-number(-26931.4,'!!!,!!!.!!!')",+ "format-number(-26931.4,'###,###.###')",+ "format-number(-26931.4,'###,###.###','myminus')",+ "format-number(-26931.4,'###,###.###;###,###.###')",+ "format-number(-26931.4,'###.###,###','periodgroup')",+ "format-number(-26931.4,'###.###,###','periodgroup')",+ "format-number(-26931.4,'###.###,###','periodgroup')",+ "format-number(-26931.4,'###.###,###','periodgroup')",+-- "format-number(-26931.4,'+!!,!!!.!!!\-!!!,!!!.!!!')", -- vom W3C auskommentiert+ "format-number(-26931.4,'+###,###.###;-###,###.###')",+ "format-number(-26931.4,'+###,###.###;_###,###.###')",+ "format-number(-26931.4,'-###,###.###')",+ "format-number(-26931.4,'-###,###.###','myminus')",+ "format-number(-26931.4,'_###,###.###','myminus')",+ "format-number(-42857.1,'###,###.###')",+ "format-number(-42857.1,'###,###.###','myminus')",+ "format-number(-42857.1,'###,###.###','myminus')",+ "format-number(-42857.1,'###,###.###','newminus')",+ "format-number(-42857.1,'###,###.###','newminus')",+ "format-number(-73816.9,'###,###.###')",+ "format-number(-73816.9,'###,###.###')",+ "format-number(-73816.9,'###,###.###')",+ "format-number(-73816.9,'###,###.###')",+ "format-number(0.25, '00%')",+ "format-number(0.4857,'###.###%')",+ "format-number(0.4857,'###.###c')",+ "format-number(0.4857,'###.###m')",+ "format-number(0.4857,'###.###‰')",+ "format-number(1 div 0,'###############################')",+ "format-number(1 div 0,'###############################')",+ "format-number(1, '#,##0')",+ "format-number(1, '00')",+ "format-number(1, '00.0')",+ "format-number(1000, '###0')",+ "format-number(1234.567,'#*###*###!###','foo:decimal1')",+ "format-number(12792.14*96.58,'##,###,000.000###')",+ "format-number(2.14*86.58,'PREFIX##00.000###SUFFIX')",+ "format-number(2392.14*(-36.58),'000,000.000###;###,###.000###')",+ "format-number(2392.14*(-36.58),'000,000.000###;-###,###.000###')",+ "format-number(2392.14*36.58,'000,000.000000')",+ "format-number(2392.14*36.58,'000,000.000000','myminus')",+ "format-number(2392.14*36.58,'000,000.000000;###,###.000###')",+ "format-number(2392.14*36.58,'000,000.000000;###,###.000###','myminus')",+ "format-number(239236.588,'00000.00')",+-- "format-number(26931.4,'+!!!,!!!.!!!\-!!,!!!.!!!')", -- vom W3C auskommentiert+ "format-number(2792.14*(-36.58),'000,000.000###')",+ "format-number(4030201.0506,'#!!!,!!!,aaa.aaaaaa0')",+ "format-number(7654321.4857,'### ### ###,#####')",+ "format-number(931.4857,'###!###!###')",+ "format-number(931.4857,'000.000|###')",+ "format-number(95.4857,'¤###.####')",+ "format-number(987654321,'###,##0,00.00')",+ "generate-id(d)",+ "generate-id(xalan:nodeset($rtf)/default:docelem/default:elem4)",+ "growth",+ "growth",+ "human",+ "id('c')/@id",+ "id('c')/@id",+ "id('d b c')",+ "id('id0')/a/b",+ "id('id0')/c/c/a",+ "id('id10')/a",+ "id('id13')",+ "id('id2')/a | id('id5') | id('id15')/a",+ "id('id4')",+ "id('id8')/b/b",+ "id('id9')",+ "id('nomatch')/@id",+ "id(main/b)",+ "id(main/b)",+ "item[$n1]",+ "item[position()=$n]",+ "java:format($formatter, $date)",+ "java:format($formatter, $javadate)",+ "java:get ($counter-table, 'index')",+ "java:java.lang.Long.parseLong(string(.))",+ "java:java.text.SimpleDateFormat.new('yyyy.MM.dd hh:mm')",+ "java:java.util.Calendar.getInstance()",+ "java:java.util.Date.new($date)",+ "java:java.util.Hashtable.new ()",+ "key($keysp, 'Expressions')/subdiv/p",+ "key($keysp, 'Introduction')/subdiv/p",+ "key($keysp, 'Stylesheet Structure')/subdiv/p",+ "key('MonthNum',month)",+ "key('MonthNum',month)",+ "key('baz:mykey', 'Expressions')/p",+ "key('baz:mykey', 'Introduction')/p",+ "key('baz:mykey', 'Stylesheet Structure')/p",+ "key('bib',$lookup)",+ "key('bigspace', 'Expressions')/subdiv/p",+ "key('bigspace', 'Expressions')/subdiv/p",+ "key('bigspace', 'Introduction')/subdiv/p",+ "key('bigspace', 'Introduction')/subdiv/p",+ "key('bigspace', 'Stylesheet Structure')/subdiv/p",+ "key('bigspace', 'Stylesheet Structure')/subdiv/p",+ "key('filterspace', 'Expressions')/subdiv/p",+ "key('filterspace', 'Expressions')/subdiv/p",+ "key('filterspace', 'Introduction')/subdiv/p",+ "key('filterspace', 'Introduction')/subdiv/p",+ "key('filterspace', 'Stylesheet Structure')/subdiv/p",+ "key('filterspace', 'Stylesheet Structure')/subdiv/p",+ "key('k','Albany')",+ "key('k','Albany')",+ "key('k','false')[position()=1]/num",+ "key('k','false')[position()=2]/num",+ "key('k','true')[1]/num",+ "key('k','true')[1]/num",+ "key('k','true')[3]/num",+ "key('k','true')[3]/num",+ "key('k','true')[4]/num",+ "key('k','true')[4]/num",+ "key('k','true')[last()=position()]",+ "key('k','true')[last()]",+ "key('k','true')[position()=1]/num",+ "key('k','true')[position()=4]/num",+ "key('key1','Mary Brady')|key('key2','Rick Rivello')",+ "key('marks',key('titles', 'Expressions')/finder)",+ "key('mykey', 'Expressions')",+ "key('mykey', 'Expressions')/p",+ "key('mykey', 'Introduction')/p",+ "key('mykey', 'Patterns')",+ "key('mykey', 'Second Title in Structure')/p",+ "key('mykey', 'Stylesheet Structure')",+ "key('mykey', 'Stylesheet Structure')/p",+ "key('mykey', 1 )/p",+ "key('mykey', 1+1 )/p",+ "key('mykey', 3.0 )/p",+ "key('mykey', 3.7 )/p",+ "key('mykey',' ')/@title",+ "key('mykey','')/p",+ "key('mykey','Exp Section')/@title",+ "key('mykey','Expressions')/p",+ "key('mykey','Expressions')/p",+ "key('mykey','Intro Section')/@title",+ "key('mykey','Introduction')/p",+ "key('mykey','Introduction')/p",+ "key('mykey','SS Section')/@title",+ "key('mykey','Sort Section')/@title",+ "key('mykey','Sorting')/p",+ "key('mykey','Sorting')/p",+ "key('mykey','Stylesheet Structure')/p",+ "key('mykey','Stylesheet Structure')/p",+ "key('mykey',*//title)",+ "key('mykey1','foo' )/p",+ "key('mykey2', 1 )/p",+ "key('one','3') | key('two','3')",+ "key('smallspace', 'Expressions')/p",+ "key('smallspace', 'Expressions')/p",+ "key('smallspace', 'Introduction')/p",+ "key('smallspace', 'Introduction')/p",+ "key('smallspace', 'Stylesheet Structure')/p",+ "key('smallspace', 'Stylesheet Structure')/p",+ "key('test','foey')",+ "key('titles', .)",+ "key('two','3') | document('select59.xml')/child[@wide='3'] | child[@deep='3']",+ "key('which','3')",+ "keyword[@tag='sector']",+ "keyword[@tag='ticker']",+ "keyword[@tag='ticker']",+ "keyword[@tag='ticker']",+ "keyword[@tag='ticker']",+ "lang('en')",+ "last()",+ "local-name()",+ "local-name(.)",+ "local-name(baz1:a)",+ "local-name(baz2:b)",+ "local-name(baz2:b/@baz1:attrib2)",+ "local-name(namespace::*[1])",+ "local-name(namespace::*[string()='http://www.w3.org/1999/XMLSchema-instance'])",+ "local-name(namespace::*[string()='test'])",+ "local-name(xalan:nodeset($rtf)/*)",+ "main/a/descendant-or-self::*/@*",+ "main/size[@for='d']",+ "mi | do | fa | re",+ "mi[@mi2='mi2'] | do | fa/so/@so | fa | mi/@* | re | fa/@fa | do/@do",+ "month",+ "month",+ "month",+ "n",+ "n-2 - -n-1",+ "n-2 - n-1",+ "n-2+-n-1",+ "n0 div n1 div n2 div n3 div n4 div n5",+ "n0 div n1 div n2 div n3 div n4",+ "n0 div n1 div n2 div n3",+ "n1 div n2",+ "n1 mod n2",+ "n1*n2",+ "n1*n2*n3*n4",+ "n1*n2*n3*n4*n5*n6*n7*n8*n9*n10",+ "n1+n2",+ "n1/@attrib + n2/@attrib",+ "n1/@attrib div n2/@attrib",+ "n1/@attrib mod n2/@attrib",+ "n2+3+$anum+7+n5",+ "n4",+ "n6*5-8*n2+5*2",+ "name",+ "name",+ "name",+ "name",+ "name",+ "name",+ "name",+ "name((ancestor::section|../ednote |following::title|../bogus)[1])",+ "name((ancestor::section|ancestor::simplesect |ancestor::article)[last()])",+ "name(/descendant-or-self::node()/child::near-north)",+ "name(/descendant-or-self::node()/descendant-or-self::north)",+ "name(/descendant-or-self::north)",+ "name(/descendant-or-self::north/child::near-north)",+ "name(/descendant-or-self::north/descendant-or-self::north)",+ "name(/descendant::near-north)",+ "name(/descendant::near-north/descendant-or-self::near-north)",+ "name(/descendant::node()/descendant-or-self::near-north)",+ "name(ancestor::*[1])",+ "name(ancestor::*[1])",+ "name(ancestor::*[2])",+ "name(ancestor::*[2])",+ "name(ancestor::*[3])",+ "name(ancestor::*[3])",+ "name(baz1:a)",+ "name(baz1:a/@baz2:attrib1)",+ "name(baz2:b)",+ "name(baz2:b/@baz1:attrib2)",+ "name(descendant-or-self::node()/child::near-north)",+ "name(descendant-or-self::node()/child::node()/child::far-west)",+ "name(descendant-or-self::node()/child::node()/descendant-or-self::near-north)",+ "name(descendant-or-self::node()/descendant-or-self::node()/child::near-north)",+ "name(descendant-or-self::node()/descendant-or-self::node()/descendant-or-self::north)",+ "name(descendant-or-self::node()/descendant-or-self::north)",+ "name(descendant-or-self::node()/descendant::near-north)",+ "name(descendant-or-self::node()/descendant::node()/child::far-west)",+ "name(descendant-or-self::node()/descendant::node()/descendant-or-self::near-north)",+ "name(descendant-or-self::north/child::near-north)",+ "name(descendant-or-self::north/child::near-north/child::far-west)",+ "name(descendant-or-self::north/child::near-north/descendant-or-self::near-north)",+ "name(descendant-or-self::north/descendant-or-self::north)",+ "name(descendant-or-self::north/descendant-or-self::north/child::near-north)",+ "name(descendant-or-self::north/descendant-or-self::north/descendant-or-self::north)",+ "name(descendant-or-self::north/descendant::near-north)",+ "name(descendant-or-self::north/descendant::near-north/child::far-west)",+ "name(descendant-or-self::north/descendant::near-north/descendant-or-self::near-north)",+ "name(descendant::near-north/descendant-or-self::near-north)",+ "name(descendant::near-north/descendant-or-self::near-north/child::far-west)",+ "name(descendant::near-north/descendant-or-self::near-north/descendant-or-self::near-north)",+ "name(descendant::near-north/descendant::far-west)",+ "name(descendant::near-north/descendant::far-west/descendant-or-self::far-west)",+ "name(descendant::node()/descendant-or-self::near-north)",+ "name(descendant::node()/descendant-or-self::node()/child::far-west)",+ "name(descendant::node()/descendant-or-self::node()/descendant-or-self::near-north)",+ "name(descendant::node()/descendant::far-west)",+ "name(descendant::node()/descendant::node()/descendant-or-self::far-west)",+ "name(namespace::*[1])",+ "name(self::node()/descendant-or-self::node()/child::near-north)",+ "name(self::node()/descendant-or-self::node()/descendant-or-self::north)",+ "name(self::node()/descendant-or-self::north)",+ "name(self::node()/descendant-or-self::north/child::near-north)",+ "name(self::node()/descendant-or-self::north/descendant-or-self::north)",+ "name(self::node()/descendant::near-north)",+ "name(self::node()/descendant::near-north/child::far-west)",+ "name(self::node()/descendant::near-north/descendant-or-self::far-west)",+ "name(self::node()/descendant::node()/child::far-west)",+ "name(self::node()/descendant::node()/descendant-or-self::far-west)",+ "name(xalan:nodeset($rtf)/*)",+ "namespace-uri(baz1:a-two/@attrib1)",+ "namespace-uri(baz1:a/@baz2:attrib1)",+ "namespace-uri(baz2:b)",+ "namespace-uri(baz2:b-three)",+ "namespace-uri(baz2:b-three/@baz1:attrib2)",+ "namespace-uri(baz2:b-three/c-four)",+ "namespace-uri(baz2:b/@baz1:attrib2)",+ "namespace-uri(namespace::*[string()='http://www.w3.org/1999/XMLSchema-instance'])",+ "namespace-uri(namespace::*[string()='test'])",+ "namespace-uri(x)",+ "namespace-uri(xalan:nodeset($rtf)/default:docelem)",+ "namespace-uri(xalan:nodeset($rtf)/default:docelem/default:elem1)",+ "namespace-uri(xalan:nodeset($rtf)/default:docelem/test:elem3)",+ "namespace::*",+ "namespace::node()",+ "nitro:element(.)",+ "node",+ "node()|@*",+ "normalize-space($texts[1])",+ "normalize-space($thisvalue)",+ "normalize-space(' ab cd ef ')",+ "normalize-space()",+ "normalize-space(a)",+ "north/* | north/dup1 | north/dup2",+ "north/dup2 | document('select71.xml')/south/preceding-sibling[4] | north/*",+ "north/dup2 | north/dup1 | north/*",+ "not($x!='foo')",+ "not('')",+ "not('0')",+ "not(false() = false())",+ "not(false())",+ "not(true() = false())",+ "not(true())",+ "note[1]",+ "note[1]",+ "number($ResultTreeFragTest)",+ "number($emptyResultTreeFragTest)",+ "number($pvar2)",+ "number('')",+ "number('3')",+ "number('abc')",+ "number('xxx') - 10",+ "number('xxx') div 3",+ "number('xxx') mod 3",+ "number('xxx')=0",+ "number('xxx')=number('xxx')",+ "number()",+ "number(2)",+ "number(false())=0",+ "number(foo)",+ "number(n1)",+ "number(string(1.0))=1",+ "number(true())=1",+ "number(xalan:nodeset($rtf)/default:docelem/default:elem3[2])",+ "para[@id='1' and lang('en')]",+ "parent::*",+ "parent::*[1]",+ "parent::foo",+ "parent::near-north",+ "position()",+ "position()=1",+ "preceding-sibling::*",+ "preceding-sibling::*/following-sibling::*",+ "preceding-sibling::*[2]",+ "preceding-sibling::*[2]",+ "preceding-sibling::*[2]/following-sibling::*",+ "preceding-sibling::*[2]/following-sibling::*[4]",+ "preceding-sibling::*[2]/following-sibling::*[4]/preceding-sibling::*[5]/following-sibling::*[4]/following-sibling::*[2]",+ "preceding-sibling::*|following-sibling::*",+ "preceding-sibling::child1|//child3",+ "preceding-sibling::child1|following-sibling::child3",+ "preceding-sibling::foo[1]/@att1",+ "preceding-sibling::west",+ "preceding::*",+ "preceding::*[2]/../descendant::*[10]/following-sibling::east",+ "preceding::*[2]/../following::*",+ "preceding::*[4]",+ "preceding::foo[1]/@att1",+ "preceding::out-yonder-west",+ "preceding::text()",+ "preceding::text()[$this]",+ "primary/name/first",+ "primary/name/first",+ "processing-instruction()",+ "pt:xif('test')",+ "pt:xif(string($val))",+ "round(-1.1)=-1",+ "round(-1.5)",+ "round(-1.9)=-2",+ "round(-2.5)=-2",+ "round(0.0)",+ "round(1.1)=1",+ "round(1.24)",+ "round(1.5)=2",+ "round(1.9)=2",+ "round(2.5)",+ "round(2.999999)",+ "round(count(.//LINE) div count(.//SPEECH))",+ "round(n0)",+ "round(n1)",+ "round(n2)",+ "round(number('xxx'))",+ "row",+ "self::*",+ "self::*",+ "self::*[1]",+ "self::*[@center-attr-2]",+ "self::*[near-south]",+ "self::center",+ "self::child1|self::child2",+ "self::comment()",+ "self::foo",+ "self::node()",+ "self::node()",+ "self::node()",+ "self::node()",+ "self::processing-instruction()",+ "self::text()",+ "sigs",+ "sss//i",+ "sss//i",+ "sss/sss",+ "sss/sss",+ "starts-with('','')",+ "starts-with('ENCYCLOPEDIA', 'EN')",+ "starts-with('ENCYCLOPEDIA', 'ENCY')",+ "starts-with('ENCYCLOPEDIA', 'en')",+ "starts-with('ab', 'abc')",+ "starts-with('abc', '')",+ "starts-with('abc', 'bc')",+ "starts-with('true()', 'tr')",+ "starts-with(doc, 'ENCY')",+ "starts-with(doc, 'test')",+ "starts-with(doc/@attr, 'slam')",+ "starts-with(doc/@attr, 'wich')",+ "str:new(string(doc))",+ "str:toUpperCase($str-obj)",+ "string($ResultTreeFragTest)",+ "string($ResultTreeFragTest)",+ "string($emptyResultTreeFragTest)",+ "string($which)",+ "string('!From m!')",+ "string('!From n!')",+ "string('!From o!')",+ "string('!From p!')",+ "string('')",+ "string('test')",+ "string()",+ "string()",+ "string(0)",+ "string(2)",+ "string(av//*)",+ "string(doc)",+ "string(foo)",+ "string-length ()",+ "string-length($str)",+ "string-length('This is a test')",+ "string-length()",+ "string-length()",+ "string-length(.)",+ "string-length(doc)",+ "string-length(doc/a)",+ "sub1/child1|/doc/sub2/child2",+ "sub1/child1|sub2/child2",+ "subj",+ "substring('1999/04/01', 1, 0)",+ "substring('1999/04/01', 1, 4)",+ "substring('ENCYCLOPEDIA', 8)",+ "substring('ENCYCLOPEDIA', 8, 3)",+ "substring('abcdefghi',2,4)",+ "substring('abcdefghijk',0 div 0, 5)",+ "substring('abcdefghijk',4, 6)",+ "substring(@key,2,1)",+ "substring(doc, 1, 4)",+ "substring(doc/@attr, 1, 3)",+ "substring(doc/@attr, 2.5, 3.6)",+ "substring(doc/@attr, 4)",+ "substring(foo, 12, 3)",+ "substring(foo, 2, 2)",+ "substring-after($words,' ')",+ "substring-after('1999/04/01', '/')",+ "substring-after('1999/04/01', '1')",+ "substring-after('ENCYCLOPEDIA', '/')",+ "substring-after('ENCYCLOPEDIA', 'C')",+ "substring-after('abcdefghijk','l')",+ "substring-after(doc, '/')",+ "substring-after(doc/@attr, 'D')",+ "substring-after(doc/@attr, 'd')",+ "substring-after(doc/@attr, 'z')",+ "substring-after(foo, '/')",+ "substring-before('1999/04/01', '/')",+ "substring-before('ENCYCLOPEDIA', '/')",+ "substring-before('ENCYCLOPEDIA', 'C')",+ "substring-before('ENCYCLOPEDIA', 'c')",+ "substring-before('a','z')",+ "substring-before(doc, '/')",+ "substring-before(doc/@attr, 'D')",+ "substring-before(doc/@attr, 'd')",+ "substring-before(doc/@attr, 'z')",+ "substring-before(foo, '/')",+ "sum($rtf)",+ "sum(e)",+ "sum(e)",+ "sum(n)",+ "sum(n/@attrib)",+ "sum(x)",+ "sum(xalan:nodeset($rtf)/default:docelem/default:elem3)",+ "system-property('xsl:vendor')",+ "true() and false()",+ "true() and true()",+ "true() or 1 div 0",+ "true() or false()",+ "true() or true()",+ "true()",+ "true()=2",+ "width * depth",+ "xalan:nodeset($rtf)/default:docelem",+ "xalan:nodeset($rtf)/default:docelem/*",+ "xalan:nodeset($rtf)/default:docelem/default:elem1",+ "xalan:nodeset($rtf)/default:docelem/default:elem1/default:elem1b",+ "xalan:nodeset($rtf)/default:docelem/default:elem2/*",+ "xalan:nodeset($rtf)/default:docelem/default:elem4",+ "xalan:nodeset($rtf)/default:docelem/test:elem3",+ "xalan:nodeset($sorted)/item",+ "deep-equal(/,foo)"+ ] -- die folgenden tests wurden vom W3C auskommentiert
examples/hxpath/XPathShell.hs view
@@ -29,69 +29,69 @@ import System.Console.Editline.Readline import System.Environment -import Text.ParserCombinators.Parsec ( runParser )+import Text.ParserCombinators.Parsec ( runParser ) -type NsEnv' = AssocList String String+type NsEnv' = AssocList String String -main :: IO()+main :: IO() main = do args <- getArgs (path, env, doc) <- evalArgs args if not (null path) && not (null doc)- then evalXPath path env (head doc)- else evalLoop env doc+ then evalXPath path env (head doc)+ else evalLoop env doc -evalArgs :: [String] -> IO (String, NsEnv', XmlTrees)-evalArgs [] = evalArgs ("" : "[]" : "" : [])-evalArgs [doc] = evalArgs ("" : "[]" : doc : [])-evalArgs [path, doc] = evalArgs (path : "[]" : doc : [])-evalArgs [path, env, ""] = return (path, buildEnv env, [])-evalArgs [path, env, doc] = do- (d, ne) <- loadDoc doc- return (path, addEntries ne . buildEnv $ env, d)-evalArgs al = evalArgs (take 3 al)+evalArgs :: [String] -> IO (String, NsEnv', XmlTrees)+evalArgs [] = evalArgs ("" : "[]" : "" : [])+evalArgs [doc] = evalArgs ("" : "[]" : doc : [])+evalArgs [path, doc] = evalArgs (path : "[]" : doc : [])+evalArgs [path, env, ""] = return (path, buildEnv env, [])+evalArgs [path, env, doc] = do+ (d, ne) <- loadDoc doc+ return (path, addEntries ne . buildEnv $ env, d)+evalArgs al = evalArgs (take 3 al) -buildEnv :: String -> NsEnv'-buildEnv env = (addEntries . read $ env) $ defaultEnv+buildEnv :: String -> NsEnv'+buildEnv env = (addEntries . read $ env) $ defaultEnv -loadDoc :: String -> IO ([XmlTree], NsEnv')+loadDoc :: String -> IO ([XmlTree], NsEnv') loadDoc doc = do d <- runX ( readDocument [ (a_tagsoup, v_0)- , (a_parse_by_mimetype, v_1)- , (a_check_namespaces, v_1)- , (a_remove_whitespace, v_1)- , (a_validate, v_0)- , (a_canonicalize, v_1)- ] doc- >>>- (documentStatusOk `guards` this)- )+ , (a_parse_by_mimetype, v_1)+ , (a_check_namespaces, v_1)+ , (a_remove_whitespace, v_1)+ , (a_validate, v_0)+ , (a_canonicalize, v_1)+ ] doc+ >>>+ (documentStatusOk `guards` this)+ ) let env = runLA (unlistA >>> collectNamespaceDecl) d return (d, env) -showDoc :: XmlTree -> IO ()+showDoc :: XmlTree -> IO () showDoc doc = runX ( constA doc- >>>- writeDocument [ (a_indent, v_1)- , (a_no_xml_pi, v_1)- ] ""- )+ >>>+ writeDocument [ (a_indent, v_1)+ , (a_no_xml_pi, v_1)+ ] ""+ ) >> return () -showTree :: XmlTree -> IO ()+showTree :: XmlTree -> IO () showTree doc = runX ( constA doc- >>>- writeDocument [ (a_show_tree, v_1)- , (a_no_xml_pi, v_1)- ] ""- )+ >>>+ writeDocument [ (a_show_tree, v_1)+ , (a_no_xml_pi, v_1)+ ] ""+ ) >> return () -evalXPath :: String -> NsEnv' -> XmlTree -> IO()+evalXPath :: String -> NsEnv' -> XmlTree -> IO() evalXPath path env doc = putStrLn . unlines $ [ "start xpath evaluation: " ++ pathS@@ -103,76 +103,76 @@ [ "end xpath evaluation: " ++ pathS ] where- pathS = show $ path- pathEx = runParser parseXPath (toNsEnv env) "" $ path- pathString = either show show $ pathEx- pathTree = either show formatXPathTree $ pathEx- xr = runLA ( xshow $ getXPathTreesWithNsEnv env path) doc+ pathS = show $ path+ pathEx = runParser parseXPath (toNsEnv env) "" $ path+ pathString = either show show $ pathEx+ pathTree = either show formatXPathTree $ pathEx+ xr = runLA ( xshow $ getXPathTreesWithNsEnv env path) doc -evalLoop :: NsEnv' -> XmlTrees -> IO ()+evalLoop :: NsEnv' -> XmlTrees -> IO () evalLoop env doc = do maybeLine <- readline "xpath> "- case maybeLine of - Nothing -> return () -- EOF / control-d- Just ":q" -> return ()- Just line -> do- let ws = words line- if null ws- then evalLoop env doc- else do- addHistory line- evalCmd (words line)+ case maybeLine of+ Nothing -> return () -- EOF / control-d+ Just ":q" -> return ()+ Just line -> do+ let ws = words line+ if null ws+ then evalLoop env doc+ else do+ addHistory line+ evalCmd (words line) where- evalCmd [] = evalLoop env doc- evalCmd [":ns",uri] = evalCmd [":ns", "", uri]+ evalCmd [] = evalLoop env doc+ evalCmd [":ns",uri] = evalCmd [":ns", "", uri] evalCmd [":ns", ns, uri]- = evalLoop (addEntry ns uri env) doc- evalCmd (":?":_) = do- putStrLn . unlines $- [ "XPath Tester"- , "Commands:"- , ":l <document>\tload a document"- , ":ns <uri>\tset default namespace"- , ":ns <px> <uri>\tset namespace"- , ":q\t\tquit"- , ":s\t\tshow current document"- , ":t\t\tshow current document in tree format"- , ":x\t\tshow current namespace environment"- , ":?\t\tthis message"- , "<xpath-expr>\tevaluate XPath expression"- ]- evalLoop env doc- evalCmd [":x"] = do- putStrLn . unlines . map show $ env- evalLoop env doc- evalCmd [":s"] = do- M.when (not . null $ doc) (showDoc . head $ doc)- evalLoop env doc- evalCmd [":t"] = do- M.when (not . null $ doc) (showTree . head $ doc)- evalLoop env doc- evalCmd [":l",n] = do- (nd, nv) <- loadDoc n- if null nd- then do- putStrLn ("error when loading " ++ show n)- evalLoop env doc- else evalLoop (addEntries nv env) nd+ = evalLoop (addEntry ns uri env) doc+ evalCmd (":?":_) = do+ putStrLn . unlines $+ [ "XPath Tester"+ , "Commands:"+ , ":l <document>\tload a document"+ , ":ns <uri>\tset default namespace"+ , ":ns <px> <uri>\tset namespace"+ , ":q\t\tquit"+ , ":s\t\tshow current document"+ , ":t\t\tshow current document in tree format"+ , ":x\t\tshow current namespace environment"+ , ":?\t\tthis message"+ , "<xpath-expr>\tevaluate XPath expression"+ ]+ evalLoop env doc+ evalCmd [":x"] = do+ putStrLn . unlines . map show $ env+ evalLoop env doc+ evalCmd [":s"] = do+ M.when (not . null $ doc) (showDoc . head $ doc)+ evalLoop env doc+ evalCmd [":t"] = do+ M.when (not . null $ doc) (showTree . head $ doc)+ evalLoop env doc+ evalCmd [":l",n] = do+ (nd, nv) <- loadDoc n+ if null nd+ then do+ putStrLn ("error when loading " ++ show n)+ evalLoop env doc+ else evalLoop (addEntries nv env) nd evalCmd ws@((':':_):_)- = do- putStrLn ("unknown command (:? for help): " ++ (show . unwords $ ws))- evalLoop env doc- evalCmd ws = do- let path = unwords ws- if null doc- then putStrLn "no document loaded"- else evalXPath path env (head doc)- evalLoop env doc+ = do+ putStrLn ("unknown command (:? for help): " ++ (show . unwords $ ws))+ evalLoop env doc+ evalCmd ws = do+ let path = unwords ws+ if null doc+ then putStrLn "no document loaded"+ else evalXPath path env (head doc)+ evalLoop env doc -defaultEnv :: NsEnv'-defaultEnv = [ ("xml",xmlNamespace)- , ("xmlns",xmlnsNamespace)- ]+defaultEnv :: NsEnv'+defaultEnv = [ ("xml",xmlNamespace)+ , ("xmlns",xmlnsNamespace)+ ] -- ----------------------------------------
examples/hxpath/example1.xml view
examples/hxpath/xhtml/xhtml-special.ent view
@@ -18,7 +18,7 @@ existing ISO 8879 entity names. ISO 10646 character numbers are given for each character, in hex. values are decimal conversions of the ISO 10646 values and refer to the document- character set. Names are Unicode names. + character set. Names are Unicode names. --> <!-- C0 Controls and Basic Latin -->
examples/hxpath/xhtml/xhtml-symbol.ent view
@@ -18,7 +18,7 @@ existing ISO 8879 entity names. ISO 10646 character numbers are given for each character, in hex. values are decimal conversions of the ISO 10646 values and refer to the document- character set. Names are Unicode names. + character set. Names are Unicode names. --> <!-- Latin Extended-B -->@@ -144,7 +144,7 @@ <!ENTITY uArr "⇑"> <!-- upwards double arrow, U+21D1 ISOamsa --> <!ENTITY rArr "⇒"> <!-- rightwards double arrow, U+21D2 ISOtech -->-<!-- Unicode does not say this is the 'implies' character but does not have +<!-- Unicode does not say this is the 'implies' character but does not have another character with this function so ? rArr can be used for 'implies' as ISOtech suggests --> <!ENTITY dArr "⇓"> <!-- downwards double arrow, U+21D3 ISOamsa -->@@ -197,9 +197,9 @@ U+2265 ISOtech --> <!ENTITY sub "⊂"> <!-- subset of, U+2282 ISOtech --> <!ENTITY sup "⊃"> <!-- superset of, U+2283 ISOtech -->-<!-- note that nsup, 'not a superset of, U+2283' is not covered by the Symbol +<!-- note that nsup, 'not a superset of, U+2283' is not covered by the Symbol font encoding and is not included. Should it be, for symmetry?- It is in ISOamsn --> + It is in ISOamsn --> <!ENTITY nsub "⊄"> <!-- not a subset of, U+2284 ISOamsn --> <!ENTITY sube "⊆"> <!-- subset of or equal to, U+2286 ISOtech --> <!ENTITY supe "⊇"> <!-- superset of or equal to,@@ -222,11 +222,11 @@ <!ENTITY rfloor "⌋"> <!-- right floor, U+230B ISOamsc --> <!ENTITY lang "〈"> <!-- left-pointing angle bracket = bra, U+2329 ISOtech -->-<!-- lang is NOT the same character as U+003C 'less than' +<!-- lang is NOT the same character as U+003C 'less than' or U+2039 'single left-pointing angle quotation mark' --> <!ENTITY rang "〉"> <!-- right-pointing angle bracket = ket, U+232A ISOtech -->-<!-- rang is NOT the same character as U+003E 'greater than' +<!-- rang is NOT the same character as U+003E 'greater than' or U+203A 'single right-pointing angle quotation mark' --> <!-- Geometric Shapes -->
examples/hxpath/xhtml/xhtml1-frameset.dtd view
@@ -9,7 +9,7 @@ For further information, see: http://www.w3.org/TR/xhtml1 Copyright (c) 1998-2000 W3C (MIT, INRIA, Keio),- All Rights Reserved. + All Rights Reserved. This DTD module is identified by the PUBLIC and SYSTEM identifiers: @@ -525,14 +525,14 @@ start %Number; #IMPLIED > -<!-- single column list (DEPRECATED) --> +<!-- single column list (DEPRECATED) --> <!ELEMENT menu (li)+> <!ATTLIST menu %attrs; compact (compact) #IMPLIED > -<!-- multiple column list (DEPRECATED) --> +<!-- multiple column list (DEPRECATED) --> <!ELEMENT dir (li)+> <!ATTLIST dir %attrs;@@ -591,7 +591,7 @@ <!--=================== Preformatted Text ================================--> -<!-- content is %Inline; excluding +<!-- content is %Inline; excluding "img|object|applet|big|small|sub|sup|font|basefont" --> <!ELEMENT pre %pre.content;>@@ -1021,7 +1021,7 @@ <!-- Content is %Flow; excluding a, form, form controls, iframe---> +--> <!ELEMENT button %button.content;> <!-- push button --> <!ATTLIST button %attrs;@@ -1065,7 +1065,7 @@ --> <!ENTITY % TRules "(none | groups | rows | cols | all)">- + <!-- horizontal placement of table relative to document --> <!ENTITY % TAlign "(left|center|right)">
examples/hxpath/xhtml/xhtml1-strict.dtd view
@@ -9,7 +9,7 @@ For further information, see: http://www.w3.org/TR/xhtml1 Copyright (c) 1998-2000 W3C (MIT, INRIA, Keio),- All Rights Reserved. + All Rights Reserved. This DTD module is identified by the PUBLIC and SYSTEM identifiers: @@ -803,7 +803,7 @@ <!-- Content is %Flow; excluding a, form and form controls---> +--> <!ELEMENT button %button.content;> <!-- push button --> <!ATTLIST button %attrs;@@ -839,7 +839,7 @@ --> <!ENTITY % TRules "(none | groups | rows | cols | all)">- + <!-- horizontal placement of table relative to document --> <!ENTITY % TAlign "(left|center|right)">
examples/hxpath/xhtml/xhtml1-transitional.dtd view
@@ -9,7 +9,7 @@ For further information, see: http://www.w3.org/TR/xhtml1 Copyright (c) 1998-2000 W3C (MIT, INRIA, Keio),- All Rights Reserved. + All Rights Reserved. This DTD module is identified by the PUBLIC and SYSTEM identifiers: @@ -497,14 +497,14 @@ start %Number; #IMPLIED > -<!-- single column list (DEPRECATED) --> +<!-- single column list (DEPRECATED) --> <!ELEMENT menu (li)+> <!ATTLIST menu %attrs; compact (compact) #IMPLIED > -<!-- multiple column list (DEPRECATED) --> +<!-- multiple column list (DEPRECATED) --> <!ELEMENT dir (li)+> <!ATTLIST dir %attrs;@@ -563,7 +563,7 @@ <!--=================== Preformatted Text ================================--> -<!-- content is %Inline; excluding +<!-- content is %Inline; excluding "img|object|applet|big|small|sub|sup|font|basefont" --> <!ELEMENT pre %pre.content;>@@ -992,7 +992,7 @@ <!-- Content is %Flow; excluding a, form, form controls, iframe---> +--> <!ELEMENT button %button.content;> <!-- push button --> <!ATTLIST button %attrs;@@ -1036,7 +1036,7 @@ --> <!ENTITY % TRules "(none | groups | rows | cols | all)">- + <!-- horizontal placement of table relative to document --> <!ENTITY % TAlign "(left|center|right)">
hxt-xpath.cabal view
@@ -1,17 +1,19 @@ -- arch-tag: Haskell XML Toolbox XPath Package-name: hxt-xpath-version: 8.5.4-license: OtherLicense-license-file: LICENCE-maintainer: Uwe Schmidt <uwe@fh-wedel.de>-stability: stable-category: XML-synopsis: The XPath modules for HXT.-description: The Haskell XML Toolbox XPath library. Since version 8.5 this library is packed in a separate package.-homepage: http://www.fh-wedel.de/~si/HXmlToolbox/index.html-copyright: Copyright (c) 2005-2010 Uwe Schmidt-build-type: Simple-cabal-version: >=1.6+Name: hxt-xpath+Version: 9.0.0+Synopsis: The XPath modules for HXT.+Description: The Haskell XML Toolbox XPath library.+ Since version 8.5 this library is packed in a separate package.+License: OtherLicense+License-file: LICENSE+Author: Torben Kuseler+Maintainer: Uwe Schmidt <uwe@fh-wedel.de>+Stability: Stable+Category: XML+Homepage: http://www.fh-wedel.de/~si/HXmlToolbox/index.html+Copyright: Copyright (c) 2005-2010 Torben Kuseler, Uwe Schmidt+Build-type: Simple+Cabal-version: >=1.6 extra-source-files: examples/hunit/HUnitExample.hs@@ -57,5 +59,5 @@ directory >= 1 && < 2, filepath >= 1 && < 2, parsec >= 2.1 && < 4,- hxt >= 8.5 && < 9+ hxt >= 9 && < 10
src/Text/XML/HXT/XPath.hs view
@@ -1,19 +1,19 @@--- | --- This helper module exports elements from the basic libraries: --- XPathEval, XPathToString and XPathParser --- --- Author : Torben Kuseler - - -module Text.XML.HXT.XPath - ( module Text.XML.HXT.XPath.XPathEval - , module Text.XML.HXT.XPath.XPathToString - , module Text.XML.HXT.XPath.XPathParser - , module Text.XML.HXT.XPath.Arrows - ) -where - -import Text.XML.HXT.XPath.XPathEval -import Text.XML.HXT.XPath.XPathToString -import Text.XML.HXT.XPath.XPathParser -import Text.XML.HXT.XPath.Arrows +-- |+-- This helper module exports elements from the basic libraries:+-- XPathEval, XPathToString and XPathParser+--+-- Author : Torben Kuseler+++module Text.XML.HXT.XPath+ ( module Text.XML.HXT.XPath.XPathEval+ , module Text.XML.HXT.XPath.XPathToString+ , module Text.XML.HXT.XPath.XPathParser+ , module Text.XML.HXT.XPath.Arrows+ )+where++import Text.XML.HXT.XPath.XPathEval+import Text.XML.HXT.XPath.XPathToString+import Text.XML.HXT.XPath.XPathParser+import Text.XML.HXT.XPath.Arrows
src/Text/XML/HXT/XPath/Arrows.hs view
@@ -48,14 +48,14 @@ import Control.Arrow.ListArrows -import Text.XML.HXT.XPath.XPathEval ( getXPathSubTreesWithNsEnv+import Text.XML.HXT.XPath.XPathEval ( getXPathSubTreesWithNsEnv , getXPathNodeSetWithNsEnv' , addRoot' ) import Text.XML.HXT.DOM.Interface import Text.XML.HXT.Arrow.XmlArrow-import Text.XML.HXT.Arrow.Edit ( canonicalizeForXPath )+import Text.XML.HXT.Arrow.Edit ( canonicalizeForXPath ) -- ------------------------------------------------------------ @@ -74,15 +74,15 @@ -- XPath values other than XmlTrees (numbers, attributes, tagnames, ...) -- are convertet to text nodes. -getXPathTreesInDoc :: ArrowXml a => String -> a XmlTree XmlTree-getXPathTreesInDoc = getXPathTreesInDocWithNsEnv []+getXPathTreesInDoc :: ArrowXml a => String -> a XmlTree XmlTree+getXPathTreesInDoc = getXPathTreesInDocWithNsEnv [] -- | Same as 'getXPathTreesInDoc' but with namespace environment for the XPath names -getXPathTreesInDocWithNsEnv :: ArrowXml a => Attributes -> String -> a XmlTree XmlTree-getXPathTreesInDocWithNsEnv env query = canonicalizeForXPath- >>>- arrL (getXPathSubTreesWithNsEnv env query)+getXPathTreesInDocWithNsEnv :: ArrowXml a => Attributes -> String -> a XmlTree XmlTree+getXPathTreesInDocWithNsEnv env query = canonicalizeForXPath+ >>>+ arrL (getXPathSubTreesWithNsEnv env query) -- | -- Select parts of an arbitrary XML tree by a XPath expression.@@ -97,13 +97,13 @@ -- XPath values other than XmlTrees (numbers, attributes, tagnames, ...) -- are convertet to text nodes. -getXPathTrees :: ArrowXml a => String -> a XmlTree XmlTree-getXPathTrees = getXPathTreesWithNsEnv []+getXPathTrees :: ArrowXml a => String -> a XmlTree XmlTree+getXPathTrees = getXPathTreesWithNsEnv [] -- | Same as 'getXPathTrees' but with namespace environment for the XPath names -getXPathTreesWithNsEnv :: ArrowXml a => Attributes -> String -> a XmlTree XmlTree-getXPathTreesWithNsEnv env query = arrL (getXPathSubTreesWithNsEnv env query)+getXPathTreesWithNsEnv :: ArrowXml a => Attributes -> String -> a XmlTree XmlTree+getXPathTreesWithNsEnv env query = arrL (getXPathSubTreesWithNsEnv env query) -- | Select a set of nodes via an XPath expression from an arbitray XML tree --@@ -113,37 +113,37 @@ -- 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-getXPathNodeSet = getXPathNodeSetWithNsEnv []+getXPathNodeSet :: ArrowXml a => String -> a XmlTree XmlNodeSet+getXPathNodeSet = getXPathNodeSetWithNsEnv [] -- | Same as 'getXPathNodeSet' but with namespace environment for the XPath names -getXPathNodeSetWithNsEnv :: ArrowXml a => Attributes -> String -> a XmlTree XmlNodeSet-getXPathNodeSetWithNsEnv nsEnv query = arr (getXPathNodeSetWithNsEnv' nsEnv query)+getXPathNodeSetWithNsEnv :: ArrowXml a => Attributes -> String -> a XmlTree XmlNodeSet+getXPathNodeSetWithNsEnv nsEnv query = arr (getXPathNodeSetWithNsEnv' nsEnv query) -- ------------------------------------------------------------ -getNodeSet :: ArrowXml a => a XmlTree QName -> a XmlTree XmlTree -> a XmlTree XmlNodeSet-getNodeSet af f = ( ( listA ( getChildren- >>>- getNodeSet af f- )- >>>- arr filterNodeSet- )- &&&- listA af- &&&- listA f+getNodeSet :: ArrowXml a => a XmlTree QName -> a XmlTree XmlTree -> a XmlTree XmlNodeSet+getNodeSet af f = ( ( listA ( getChildren+ >>>+ getNodeSet af f+ )+ >>>+ arr filterNodeSet+ )+ &&&+ listA af+ &&&+ listA f ) >>^ (\ ~(cl, (al, n)) -> XNS (not . null $ n) al cl) where- filterNodeSet :: [XmlNodeSet] -> ChildNodes- filterNodeSet = concat . zipWith filterIx [0..]+ filterNodeSet :: [XmlNodeSet] -> ChildNodes+ filterNodeSet = concat . zipWith filterIx [0..] - filterIx :: Int -> XmlNodeSet -> ChildNodes- filterIx _ix (XNS False [] []) = []- filterIx ix ps = [(ix, ps)]+ filterIx :: Int -> XmlNodeSet -> ChildNodes+ filterIx _ix (XNS False [] []) = []+ filterIx ix ps = [(ix, ps)] -- | -- compute a node set from a tree, containing all nodes selected by the predicate arrow@@ -152,18 +152,18 @@ -- -- > getElemNodeSet (hasName "a") -getElemNodeSet :: ArrowXml a => a XmlTree XmlTree -> a XmlTree XmlNodeSet-getElemNodeSet f = getNodeSet none f+getElemNodeSet :: ArrowXml a => a XmlTree XmlTree -> a XmlTree XmlNodeSet+getElemNodeSet f = getNodeSet none f -- | -- 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-getElemAndAttrNodeSet f = getNodeSet ( getAttrl- >>>- ( f `guards` getAttrName )- ) f+getElemAndAttrNodeSet :: ArrowXml a => a XmlTree XmlTree -> a XmlTree XmlNodeSet+getElemAndAttrNodeSet f = getNodeSet ( getAttrl+ >>>+ ( f `guards` getAttrName )+ ) f -- ------------------------------------------------------------ @@ -174,11 +174,11 @@ -- -- > getFromNodeSet $< getElemNodeSet f == multi f -getFromNodeSet :: ArrowXml a => XmlNodeSet -> a XmlTree XmlTree-getFromNodeSet xns = fromLA $+getFromNodeSet :: ArrowXml a => XmlNodeSet -> a XmlTree XmlTree+getFromNodeSet xns = fromLA $ arr addRoot' >>> getFromNodeSet' xns -getFromNodeSet' :: XmlNodeSet -> LA XmlTree XmlTree+getFromNodeSet' :: XmlNodeSet -> LA XmlTree XmlTree getFromNodeSet' (XNS t al cl) = fromLA $ ( if t then this else none )@@ -188,22 +188,22 @@ ( getFromChildren (0-1) cl $< listA getChildren ) where - getFromAttrl :: [QName] -> LA XmlTree XmlTree+ getFromAttrl :: [QName] -> LA XmlTree XmlTree getFromAttrl l- = ( catA . map hasQName $ l)- `guards`- this+ = ( catA . map hasQName $ l)+ `guards`+ this - getFromChildren :: Int -> ChildNodes -> XmlTrees -> LA XmlTree XmlTree+ getFromChildren :: Int -> ChildNodes -> XmlTrees -> LA XmlTree XmlTree getFromChildren _ [] _- = none+ = none getFromChildren i' ((i, sp) : sps) ts- = ( arrL (const t') >>> getFromNodeSet' sp )- <+>- getFromChildren i sps ts'- where- (t', ts') = splitAt 1 . drop (i-i'-1) $ ts+ = ( arrL (const t') >>> getFromNodeSet' sp )+ <+>+ getFromChildren i sps ts'+ where+ (t', ts') = splitAt 1 . drop (i-i'-1) $ ts -- ------------------------------------------------------------ @@ -214,12 +214,12 @@ -- -- > processXPathTrees p xpathExpr == processFromNodeSet p $< getXPathNodeSet xpathExpr -processXPathTrees :: ArrowXml a => a XmlTree XmlTree -> String -> a XmlTree XmlTree-processXPathTrees f = processXPathTreesWithNsEnv f []+processXPathTrees :: ArrowXml a => a XmlTree XmlTree -> String -> a XmlTree XmlTree+processXPathTrees f = processXPathTreesWithNsEnv f [] -- | Same as 'processXPathTrees' but with namespace environment for the XPath names -processXPathTreesWithNsEnv :: ArrowXml a => a XmlTree XmlTree -> Attributes -> String -> a XmlTree XmlTree+processXPathTreesWithNsEnv :: ArrowXml a => a XmlTree XmlTree -> Attributes -> String -> a XmlTree XmlTree processXPathTreesWithNsEnv f nsEnv query = choiceA [ isRoot :-> processChildren pns@@ -242,8 +242,8 @@ -- 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-processFromNodeSet f xns = ( isRoot+processFromNodeSet :: ArrowXml a => a XmlTree XmlTree -> XmlNodeSet -> a XmlTree XmlTree+processFromNodeSet f xns = ( isRoot `guards` processFromNodeSet' f xns ) `orElse`@@ -253,40 +253,40 @@ ) -processFromNodeSet' :: ArrowXml a => a XmlTree XmlTree -> XmlNodeSet -> a XmlTree XmlTree+processFromNodeSet' :: ArrowXml a => a XmlTree XmlTree -> XmlNodeSet -> a XmlTree XmlTree processFromNodeSet' f (XNS t al cl) = ( if null cl- then this- else replaceChildren ( processC (0-1) cl $< listA getChildren )+ then this+ else replaceChildren ( processC (0-1) cl $< listA getChildren ) ) >>> ( if null al- then this- else processAttrl (processA al)+ then this+ else processAttrl (processA al) ) >>> ( if not t- then this- else f+ then this+ else f ) where - -- processA :: ChildNodes -> a XmlTree XmlTree+ -- processA :: ChildNodes -> a XmlTree XmlTree processA l- = f `when` ( catA . map hasQName $ l)+ = f `when` ( catA . map hasQName $ l) - -- processC :: ChildNodes -> XmlTrees -> a XmlTree XmlTree+ -- processC :: ChildNodes -> XmlTrees -> a XmlTree XmlTree processC _ [] ts- = arrL (const ts)+ = arrL (const ts) processC i' ((i, sp) : sps) ts- = arrL (const ts1)- <+>- ( arrL (const ti) >>> processFromNodeSet' f sp)- <+>- processC i sps ts21- where- (ts1, ts2) = splitAt (i-i'-1) ts- (ti, ts21) = splitAt 1 ts2+ = arrL (const ts1)+ <+>+ ( arrL (const ti) >>> processFromNodeSet' f sp)+ <+>+ processC i sps ts21+ where+ (ts1, ts2) = splitAt (i-i'-1) ts+ (ti, ts21) = splitAt 1 ts2 -- ------------------------------------------------------------
@@ -13,15 +13,15 @@ import Data.Maybe import Data.Tree.NTree.TypeDefs -import Text.XML.HXT.DOM.Interface ( XNode- , xmlnsNamespace- , namespaceUri- )-import Text.XML.HXT.DOM.XmlNode ( isRoot- , isElem- , getName- , getAttrl- )+import Text.XML.HXT.DOM.Interface ( XNode+ , xmlnsNamespace+ , namespaceUri+ )+import Text.XML.HXT.DOM.XmlNode ( isRoot+ , isElem+ , getName+ , getAttrl+ ) -- ----------------------------------------------------------------------------- @@ -33,13 +33,13 @@ -- a navigable tree for all ancestors, and two n-ary trees for -- the previous- and following siblings -data NavTree a = NT { self :: (NTree a)- , selfIndex :: Int- , ancestors :: [NavTree a]- , previousSiblings :: [NTree a]- , followingSiblings :: [NTree a]- }- deriving (Show) -- deriving not reasonable for Eq and Ord+data NavTree a = NT { self :: (NTree a)+ , selfIndex :: Int+ , ancestors :: [NavTree a]+ , previousSiblings :: [NTree a]+ , followingSiblings :: [NTree a]+ }+ deriving (Show) -- deriving not reasonable for Eq and Ord -- ----------------------------------------------------------------------------- @@ -47,40 +47,40 @@ -- | -- converts a n-ary tree in a navigable tree -ntree :: NTree a -> NavTree a-ntree nd = NT nd (-1) [] [] []+ntree :: NTree a -> NavTree a+ntree nd = NT nd (-1) [] [] [] -- | -- converts a navigable tree in a n-ary tree -subtreeNT :: NavTree a -> NTree a-subtreeNT (NT nd _ _ _ _) = nd+subtreeNT :: NavTree a -> NTree a+subtreeNT (NT nd _ _ _ _) = nd -- | -- function for selecting the value of the current fragment tree -dataNT :: NavTree a -> a+dataNT :: NavTree a -> a dataNT (NT (NTree a _) _ _ _ _) = a -- | -- function for selecting all children of a tree -childrenNT :: NavTree a -> [NTree a]+childrenNT :: NavTree a -> [NTree a] childrenNT (NT (NTree _ cs) _ _ _ _)- = cs+ = cs -- | -- position of tree in parent -indexNT :: NavTree a -> Int-indexNT (NT _ ix _ _ _) = ix+indexNT :: NavTree a -> Int+indexNT (NT _ ix _ _ _) = ix -- | -- path (index list) of a navigatable tree -pathNT :: NavTree a -> [Int]-pathNT = tail . reverse . map selfIndex . ancestorOrSelfAxis+pathNT :: NavTree a -> [Int]+pathNT = tail . reverse . map selfIndex . ancestorOrSelfAxis -- ----------------------------------------------------------------------------- @@ -89,36 +89,36 @@ upNT , downNT , leftNT- , rightNT :: NavTree a -> Maybe (NavTree a)+ , rightNT :: NavTree a -> Maybe (NavTree a) -upNT (NT _ _ (p:_) _ _) = Just p-upNT (NT _ _ [] _ _) = Nothing-downNT t@(NT (NTree _ (c:cs)) _ u _ _) = Just (NT c 0 (t:u) [] cs)-downNT (NT (NTree _ [] ) _ _ _ _) = Nothing-leftNT (NT s ix u (l:ls) r) = Just (NT l (ix - 1) u ls (s:r))-leftNT (NT _ _ _ [] _) = Nothing-rightNT (NT s ix u l (r:rs)) = Just (NT r (ix + 1) u (s:l) rs)-rightNT (NT _ _ _ _ [] ) = Nothing+upNT (NT _ _ (p:_) _ _) = Just p+upNT (NT _ _ [] _ _) = Nothing+downNT t@(NT (NTree _ (c:cs)) _ u _ _) = Just (NT c 0 (t:u) [] cs)+downNT (NT (NTree _ [] ) _ _ _ _) = Nothing+leftNT (NT s ix u (l:ls) r) = Just (NT l (ix - 1) u ls (s:r))+leftNT (NT _ _ _ [] _) = Nothing+rightNT (NT s ix u l (r:rs)) = Just (NT r (ix + 1) u (s:l) rs)+rightNT (NT _ _ _ _ [] ) = Nothing -- preorderNT t = t : concatMap preorderNT (children t) -- where children = maybe [] (maybeStar rightNT) . downNT -preorderNT :: NavTree a -> [NavTree a]-preorderNT = visit []+preorderNT :: NavTree a -> [NavTree a]+preorderNT = visit [] where- visit k t = t : maybe k (visit' k) (downNT t)- visit' k t = visit (maybe k (visit' k) (rightNT t)) t+ visit k t = t : maybe k (visit' k) (downNT t)+ visit' k t = visit (maybe k (visit' k) (rightNT t)) t -revPreorderNT :: NavTree a -> [NavTree a]-revPreorderNT t = t : concatMap revPreorderNT (reverse (children t))+revPreorderNT :: NavTree a -> [NavTree a]+revPreorderNT t = t : concatMap revPreorderNT (reverse (children t)) where- children = maybe [] (maybeStar rightNT) . downNT+ children = maybe [] (maybeStar rightNT) . downNT -getChildrenNT :: NavTree a -> [NavTree a]-getChildrenNT node = maybe [] follow (downNT node)+getChildrenNT :: NavTree a -> [NavTree a]+getChildrenNT node = maybe [] follow (downNT node) where- follow n = n : maybe [] follow (rightNT n)+ follow n = n : maybe [] follow (rightNT n) -- ----------------------------------------------------------------------------- -- Miscellaneous useful combinators@@ -126,65 +126,65 @@ -- | -- Kleisli composition: -o' :: (b -> [c]) -> (a -> [b]) -> (a -> [c])-f `o'` g = \x -> g x >>= f+o' :: (b -> [c]) -> (a -> [b]) -> (a -> [c])+f `o'` g = \x -> g x >>= f -- Some useful anamorphisms: -maybeStar, maybePlus :: (a -> Maybe a) -> a -> [a]-maybeStar f a = a : maybe [] (maybeStar f) (f a)-maybePlus f a = maybe [] (maybeStar f) (f a)+maybeStar, maybePlus :: (a -> Maybe a) -> a -> [a]+maybeStar f a = a : maybe [] (maybeStar f) (f a)+maybePlus f a = maybe [] (maybeStar f) (f a) -- ----------------------------------------------------------------------------- -- functions for representing XPath axes. All axes except the namespace-axis are supported -parentAxis :: NavTree a -> [NavTree a]-parentAxis = maybeToList . upNT+parentAxis :: NavTree a -> [NavTree a]+parentAxis = maybeToList . upNT -ancestorAxis :: NavTree a -> [NavTree a]-ancestorAxis = ancestors -- or: maybePlus upNT+ancestorAxis :: NavTree a -> [NavTree a]+ancestorAxis = ancestors -- or: maybePlus upNT -ancestorOrSelfAxis :: NavTree a -> [NavTree a]-ancestorOrSelfAxis t = t : ancestors t -- or: maybeStar upNT+ancestorOrSelfAxis :: NavTree a -> [NavTree a]+ancestorOrSelfAxis t = t : ancestors t -- or: maybeStar upNT -childAxis :: NavTree a -> [NavTree a]-childAxis = maybe [] (maybeStar rightNT) . downNT+childAxis :: NavTree a -> [NavTree a]+childAxis = maybe [] (maybeStar rightNT) . downNT -descendantAxis :: NavTree a -> [NavTree a]-descendantAxis = tail . preorderNT -- concatMap preorderNT . childAxis+descendantAxis :: NavTree a -> [NavTree a]+descendantAxis = tail . preorderNT -- concatMap preorderNT . childAxis -descendantOrSelfAxis :: NavTree a -> [NavTree a]-descendantOrSelfAxis = preorderNT+descendantOrSelfAxis :: NavTree a -> [NavTree a]+descendantOrSelfAxis = preorderNT -followingSiblingAxis :: NavTree a -> [NavTree a]-followingSiblingAxis = maybePlus rightNT+followingSiblingAxis :: NavTree a -> [NavTree a]+followingSiblingAxis = maybePlus rightNT -precedingSiblingAxis :: NavTree a -> [NavTree a]-precedingSiblingAxis = maybePlus leftNT+precedingSiblingAxis :: NavTree a -> [NavTree a]+precedingSiblingAxis = maybePlus leftNT -selfAxis :: NavTree a -> [NavTree a]-selfAxis = (:[])+selfAxis :: NavTree a -> [NavTree a]+selfAxis = (:[]) -followingAxis :: NavTree a -> [NavTree a]-followingAxis = preorderNT `o'` followingSiblingAxis `o'` ancestorOrSelfAxis+followingAxis :: NavTree a -> [NavTree a]+followingAxis = preorderNT `o'` followingSiblingAxis `o'` ancestorOrSelfAxis -precedingAxis :: NavTree a -> [NavTree a]-precedingAxis = revPreorderNT `o'` precedingSiblingAxis `o'` ancestorOrSelfAxis+precedingAxis :: NavTree a -> [NavTree a]+precedingAxis = revPreorderNT `o'` precedingSiblingAxis `o'` ancestorOrSelfAxis -attributeAxis :: NavTree XNode -> [NavTree XNode]+attributeAxis :: NavTree XNode -> [NavTree XNode] attributeAxis t@(NT xt _ a _ _) | isElem xt &&- not (isRoot xt) = foldr (\ (ix, attr) -> ((NT attr ix (t:a) [] []):)) [] al- | otherwise = []+ not (isRoot xt) = foldr (\ (ix, attr) -> ((NT attr ix (t:a) [] []):)) [] al+ | otherwise = [] where- aix xs = zip [(0 - length xs) .. (-1)] xs- al = filter ((/= xmlnsNamespace) . maybe "" namespaceUri . getName . snd)- . aix- . fromMaybe []- . getAttrl $ xt+ aix xs = zip [(0 - length xs) .. (-1)] xs+ al = filter ((/= xmlnsNamespace) . maybe "" namespaceUri . getName . snd)+ . aix+ . fromMaybe []+ . getAttrl $ xt -- attributes are indexed in the path with negative indices -- this corresponds to document order and makes the index paths
src/Text/XML/HXT/XPath/XPathDataTypes.hs view
@@ -23,10 +23,10 @@ ) where -import Data.Function ( on )-import Data.Map ( Map )+import Data.Function ( on )+import Data.Map ( Map ) import qualified- Data.Map as M+ Data.Map as M import Text.XML.HXT.XPath.NavTree import Text.XML.HXT.DOM.Interface@@ -36,13 +36,13 @@ -- Expr -- | Represents expression--- +-- data Expr = GenExpr Op [Expr] -- ^ generic expression with an operator and one or more operands | PathExpr (Maybe Expr) (Maybe LocationPath)- -- ^ a path expression contains an optional filter-expression- -- or an optional locationpath. one expression is urgently- -- necessary, both are possible+ -- ^ a path expression contains an optional filter-expression+ -- or an optional locationpath. one expression is urgently+ -- necessary, both are possible | FilterExpr [Expr] -- ^ filter-expression with zero or more predicates | VarExpr VarName -- ^ variable | LiteralExpr Literal -- ^ string@@ -113,7 +113,7 @@ _ < NaN = False _ < NegInf = False- NegInf < _ = True+ NegInf < _ = True Neg0 < Neg0 = False Pos0 < Pos0 = False@@ -140,23 +140,23 @@ deriving (Show, Eq) --- ----------------------------------------------------------------------------- +-- ----------------------------------------------------------------------------- -- | -- A location path is either a relative or an absolute path. data Path = Rel- | Abs+ | Abs deriving (Show, Eq)- + -- | Represents location step--- +-- -- A location step consists of an axis, a node-test and zero or more predicates. data XStep = Step AxisSpec NodeTest [Expr] deriving (Show, Eq) - + -- ----------------------------------------------------------------------------- -- -- AxisSpec@@ -164,18 +164,18 @@ -- | Represents XPath axis data AxisSpec = Ancestor- | AncestorOrSelf- | Attribute- | Child- | Descendant + | AncestorOrSelf+ | Attribute+ | Child+ | Descendant | DescendantOrSelf- | Following- | FollowingSibling+ | Following+ | FollowingSibling | Namespace- | Parent- | Preceding- | PrecedingSibling- | Self+ | Parent+ | Preceding+ | PrecedingSibling+ | Self deriving (Show, Eq) -- -----------------------------------------------------------------------------@@ -208,33 +208,33 @@ -- -- useful type definitions -type Name = (NamePrefix, LocalName)-type NamePrefix = String-type LocalName = String+type Name = (NamePrefix, LocalName)+type NamePrefix = String+type LocalName = String -- | Variable name-type VarName = Name+type VarName = Name -- | a string-type Literal = String +type Literal = String -- | Function name-type FctName = String+type FctName = String -- | Function arguments-type FctArguments = [Expr]+type FctArguments = [Expr] -- | Evaluation context-type Context = (ConPos ,ConLen, ConNode)+type Context = (ConPos ,ConLen, ConNode) -- | Context position-type ConPos = Int+type ConPos = Int -- | Context length-type ConLen = Int+type ConLen = Int -- | Context node-type ConNode = NavXmlTree+type ConNode = NavXmlTree -- -----------------------------------------------------------------------------@@ -256,81 +256,81 @@ -- | Node of navigable tree representation -type NavXmlTree = NavTree XNode+type NavXmlTree = NavTree XNode -- | List of nodes of navigable tree representation -type NavXmlTrees = [NavXmlTree]+type NavXmlTrees = [NavXmlTree] -- | Set of navigable trees identified by their document position (NodePath) -newtype NodeSet = NS { unNS :: Map NodePath NavXmlTree }- deriving (Show)+newtype NodeSet = NS { unNS :: Map NodePath NavXmlTree }+ deriving (Show) -- | path represented as list of indices starting at root -type NodePath = [Int]+type NodePath = [Int] -- | A functions that takes a XPath result and returns a XPath result -type XPathFilter = XPathValue -> XPathValue+type XPathFilter = XPathValue -> XPathValue -- ----------------------------------------------------------------------------- -withXPVNode :: String -> (NodeSet -> XPathValue) -> XPathFilter-withXPVNode s f n = case n of- XPVNode ns -> f ns- e@(XPVError _) -> e- _ -> XPVError s+withXPVNode :: String -> (NodeSet -> XPathValue) -> XPathFilter+withXPVNode s f n = case n of+ XPVNode ns -> f ns+ e@(XPVError _) -> e+ _ -> XPVError s -- ----------------------------------------------------------------------------- -- | node set functions -emptyNodeSet :: NodeSet-emptyNodeSet = NS M.empty+emptyNodeSet :: NodeSet+emptyNodeSet = NS M.empty -singletonNodeSet :: NavXmlTree -> NodeSet-singletonNodeSet = toNodeSet . (:[])+singletonNodeSet :: NavXmlTree -> NodeSet+singletonNodeSet = toNodeSet . (:[]) -nullNodeSet :: NodeSet -> Bool-nullNodeSet = M.null . unNS+nullNodeSet :: NodeSet -> Bool+nullNodeSet = M.null . unNS -cardNodeSet :: NodeSet -> Int-cardNodeSet = M.size . unNS+cardNodeSet :: NodeSet -> Int+cardNodeSet = M.size . unNS -deleteNodeSet :: NodePath -> NodeSet -> NodeSet-deleteNodeSet p = NS . M.delete p . unNS+deleteNodeSet :: NodePath -> NodeSet -> NodeSet+deleteNodeSet p = NS . M.delete p . unNS -insertNodeSet :: NavXmlTree -> NodeSet -> NodeSet-insertNodeSet t = NS . M.insert (pathNT t) t . unNS+insertNodeSet :: NavXmlTree -> NodeSet -> NodeSet+insertNodeSet t = NS . M.insert (pathNT t) t . unNS -unionNodeSet :: NodeSet -> NodeSet -> NodeSet-unionNodeSet ns1 = NS . M.union (unNS ns1) . unNS+unionNodeSet :: NodeSet -> NodeSet -> NodeSet+unionNodeSet ns1 = NS . M.union (unNS ns1) . unNS -unionsNodeSet :: [NodeSet] -> NodeSet-unionsNodeSet = NS . foldl (\ res ns -> M.union res $ unNS ns) M.empty+unionsNodeSet :: [NodeSet] -> NodeSet+unionsNodeSet = NS . foldl (\ res ns -> M.union res $ unNS ns) M.empty -elemsNodeSet :: NodeSet -> [(NodePath, NavXmlTree)]-elemsNodeSet = M.toList . unNS+elemsNodeSet :: NodeSet -> [(NodePath, NavXmlTree)]+elemsNodeSet = M.toList . unNS -fromNodeSet :: NodeSet -> NavXmlTrees-fromNodeSet = M.elems . unNS+fromNodeSet :: NodeSet -> NavXmlTrees+fromNodeSet = M.elems . unNS -toNodeSet :: NavXmlTrees -> NodeSet-toNodeSet = NS . foldl (\ m t -> M.insert (pathNT t) t m) M.empty+toNodeSet :: NavXmlTrees -> NodeSet+toNodeSet = NS . foldl (\ m t -> M.insert (pathNT t) t m) M.empty -headNodeSet :: NodeSet -> NavXmlTree-headNodeSet = head . fromNodeSet+headNodeSet :: NodeSet -> NavXmlTree+headNodeSet = head . fromNodeSet -withNodeSet :: (NavXmlTrees -> NavXmlTrees) -> NodeSet -> NodeSet-withNodeSet f = toNodeSet . f . fromNodeSet+withNodeSet :: (NavXmlTrees -> NavXmlTrees) -> NodeSet -> NodeSet+withNodeSet f = toNodeSet . f . fromNodeSet instance Eq NodeSet where- (==) = (==) `on` (M.keys . unNS)+ (==) = (==) `on` (M.keys . unNS) instance Ord NodeSet where- compare = compare `on` (M.keys . unNS)+ compare = compare `on` (M.keys . unNS) -- ----------------------------------------------------------------------------- --@@ -341,14 +341,14 @@ -- 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 VarTab = [(VarName, XPathValue)]+type KeyTab = [(QName, String, NavXmlTree)] -type Env = (VarTab, KeyTab)+type Env = (VarTab, KeyTab) -varEnv :: Env-varEnv = ( [ (("", "name"), XPVNumber NaN) ]- , []- )+varEnv :: Env+varEnv = ( [ (("", "name"), XPVNumber NaN) ]+ , []+ ) -- -----------------------------------------------------------------------------
src/Text/XML/HXT/XPath/XPathEval.hs view
@@ -37,25 +37,25 @@ ) where -import Data.List ( partition )-import Data.Maybe ( fromJust, fromMaybe )+import Data.List ( partition )+import Data.Maybe ( fromJust, fromMaybe ) import Text.XML.HXT.XPath.XPathFct import Text.XML.HXT.XPath.XPathDataTypes import Text.XML.HXT.XPath.XPathArithmetic- ( xPathAdd- , xPathDiv- , xPathMod- , xPathMulti- , xPathUnary- )-import Text.XML.HXT.XPath.XPathParser ( parseXPath )-import Text.XML.HXT.XPath.XPathToString ( xPValue2XmlTrees )+ ( xPathAdd+ , xPathDiv+ , xPathMod+ , xPathMulti+ , xPathUnary+ )+import Text.XML.HXT.XPath.XPathParser ( parseXPath )+import Text.XML.HXT.XPath.XPathToString ( xPValue2XmlTrees ) import Text.XML.HXT.XPath.XPathToNodeSet( xPValue2XmlNodeSet- , emptyXmlNodeSet- )+ , emptyXmlNodeSet+ ) -import Text.ParserCombinators.Parsec ( runParser )+import Text.ParserCombinators.Parsec ( runParser ) -- ---------------------------------------- @@ -68,15 +68,15 @@ -- the list arrow functions -import Control.Arrow ( (>>>), (>>^), left )-import Control.Arrow.ArrowList ( arrL, isA )-import Control.Arrow.ArrowIf ( filterA )-import Control.Arrow.ListArrow ( runLA )+import Control.Arrow ( (>>>), (>>^), left )+import Control.Arrow.ArrowList ( arrL, isA )+import Control.Arrow.ArrowIf ( filterA )+import Control.Arrow.ListArrow ( runLA ) import qualified- Control.Arrow.ArrowTree as AT+ Control.Arrow.ArrowTree as AT -import Text.XML.HXT.Arrow.XmlArrow ( ArrowDTD, isDTD, getDTDAttrl )-import Text.XML.HXT.Arrow.Edit ( canonicalizeForXPath )+import Text.XML.HXT.Arrow.XmlArrow ( ArrowDTD, isDTD, getDTDAttrl )+import Text.XML.HXT.Arrow.Edit ( canonicalizeForXPath ) -- ----------------------------------------------------------------------------- -- |@@ -89,18 +89,18 @@ -- XPath values other than XmlTrees (numbers, attributes, tagnames, ...) -- are converted to text nodes. -getXPath :: String -> XmlTree -> XmlTrees-getXPath = getXPathWithNsEnv []+getXPath :: String -> XmlTree -> XmlTrees+getXPath = getXPathWithNsEnv [] -- ----------------------------------------------------------------------------- -- | -- Select parts of a document by an already parsed XPath expression -getXPath' :: Expr -> XmlTree -> XmlTrees-getXPath' e = runLA $+getXPath' :: Expr -> XmlTree -> XmlTrees+getXPath' e = runLA $ canonicalizeForXPath- >>>- arrL (getXPathValues' xPValue2XmlTrees e)+ >>>+ arrL (getXPathValues' xPValue2XmlTrees e) -- ----------------------------------------------------------------------------- -- |@@ -109,11 +109,11 @@ -- 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-getXPathWithNsEnv env s = runLA ( canonicalizeForXPath- >>>- arrL (getXPathValues xPValue2XmlTrees xPathErr env s)- )+getXPathWithNsEnv :: Attributes -> String -> XmlTree -> XmlTrees+getXPathWithNsEnv env s = runLA ( canonicalizeForXPath+ >>>+ arrL (getXPathValues xPValue2XmlTrees xPathErr env s)+ ) -- ----------------------------------------------------------------------------- -- |@@ -129,207 +129,207 @@ -- XPath values other than XmlTrees (numbers, attributes, tagnames, ...) -- are convertet to text nodes. -getXPathSubTrees :: String -> XmlTree -> XmlTrees-getXPathSubTrees = getXPathSubTreesWithNsEnv []+getXPathSubTrees :: String -> XmlTree -> XmlTrees+getXPathSubTrees = getXPathSubTreesWithNsEnv [] -- ----------------------------------------------------------------------------- -- | -- Select parts of an XML tree by an XPath expression. -getXPathSubTrees' :: Expr -> XmlTree -> XmlTrees-getXPathSubTrees' = getXPathValues' xPValue2XmlTrees+getXPathSubTrees' :: Expr -> XmlTree -> XmlTrees+getXPathSubTrees' = getXPathValues' xPValue2XmlTrees -- ----------------------------------------------------------------------------- -- | Same as 'getXPathSubTrees' but with namespace aware XPath expression -getXPathSubTreesWithNsEnv :: Attributes -> String -> XmlTree -> XmlTrees+getXPathSubTreesWithNsEnv :: Attributes -> String -> XmlTree -> XmlTrees getXPathSubTreesWithNsEnv nsEnv xpStr = getXPathValues xPValue2XmlTrees xPathErr nsEnv xpStr -- ----------------------------------------------------------------------------- -- | -- compute the node set of an XPath query -getXPathNodeSet' :: String -> XmlTree -> XmlNodeSet-getXPathNodeSet' = getXPathNodeSetWithNsEnv' []+getXPathNodeSet' :: String -> XmlTree -> XmlNodeSet+getXPathNodeSet' = getXPathNodeSetWithNsEnv' [] -- ----------------------------------------------------------------------------- -- | -- compute the node set of an XPath query for an already parsed XPath expr -getXPathNodeSet'' :: Expr -> XmlTree -> XmlNodeSet-getXPathNodeSet'' = getXPathValues' xPValue2XmlNodeSet+getXPathNodeSet'' :: Expr -> XmlTree -> XmlNodeSet+getXPathNodeSet'' = getXPathValues' xPValue2XmlNodeSet -- ----------------------------------------------------------------------------- -- | compute the node set of a namespace aware XPath query -getXPathNodeSetWithNsEnv' :: Attributes -> String -> XmlTree -> XmlNodeSet+getXPathNodeSetWithNsEnv' :: Attributes -> String -> XmlTree -> XmlNodeSet getXPathNodeSetWithNsEnv' nsEnv xpStr = getXPathValues xPValue2XmlNodeSet (const emptyXmlNodeSet) nsEnv xpStr -- ----------------------------------------------------------------------------- -- | parse xpath, evaluate xpath expr and prepare results -getXPathValues :: (XPathValue -> a) -> (String -> a) -> Attributes -> String -> XmlTree -> a+getXPathValues :: (XPathValue -> a) -> (String -> a) -> Attributes -> String -> XmlTree -> a getXPathValues cvRes cvErr nsEnv xpStr t- = case parseXPathExprWithNsEnv nsEnv xpStr of- Left parseError -> cvErr parseError- Right xpExpr -> getXPathValues' cvRes xpExpr t+ = case parseXPathExprWithNsEnv nsEnv xpStr of+ Left parseError -> cvErr parseError+ Right xpExpr -> getXPathValues' cvRes xpExpr t -xPathErr :: String -> [XmlTree]-xPathErr parseError = [ XN.mkError c_err parseError ]+xPathErr :: String -> [XmlTree]+xPathErr parseError = [ XN.mkError c_err parseError ] -- ----------------------------------------------------------------------------- -- | parse xpath, evaluate xpath expr and prepare results -getXPathValues' :: (XPathValue -> a) -> Expr -> XmlTree -> a-getXPathValues' cvRes xpExpr t = cvRes xpRes+getXPathValues' :: (XPathValue -> a) -> Expr -> XmlTree -> a+getXPathValues' cvRes xpExpr t = cvRes xpRes where- t' = addRoot' t -- we need a root node for starting xpath eval- idAttr = ( ("", "idAttr") -- id attributes from DTD (if there)- , idAttributesToXPathValue . getIdAttributes $ t'- )- navTD = ntree t'- xpRes = evalExpr (idAttr:(getVarTab varEnv),[]) (1, 1, navTD) xpExpr (XPVNode . singletonNodeSet $ navTD)+ t' = addRoot' t -- we need a root node for starting xpath eval+ idAttr = ( ("", "idAttr") -- id attributes from DTD (if there)+ , idAttributesToXPathValue . getIdAttributes $ t'+ )+ navTD = ntree t'+ xpRes = evalExpr (idAttr:(getVarTab varEnv),[]) (1, 1, navTD) xpExpr (XPVNode . singletonNodeSet $ navTD) -addRoot' :: XmlTree -> XmlTree+addRoot' :: XmlTree -> XmlTree addRoot' t- | XN.isRoot t = t- | otherwise = XN.mkRoot [] [t]+ | XN.isRoot t = t+ | otherwise = XN.mkRoot [] [t] -- ----------------------------------------------------------------------------- --- | parse an XPath expr string +-- | parse an XPath expr string -- and return an expr tree or an error message. -- Namespaces are not taken into account. -parseXPathExpr :: String -> Either String Expr-parseXPathExpr = parseXPathExprWithNsEnv []+parseXPathExpr :: String -> Either String Expr+parseXPathExpr = parseXPathExprWithNsEnv [] -- | parse an XPath expr string with a namespace environment for qualified names in the XPath expr -- and return an expr tree or an error message -parseXPathExprWithNsEnv :: Attributes -> String -> Either String Expr-parseXPathExprWithNsEnv nsEnv xpStr = left fmtErr . runParser parseXPath (toNsEnv nsEnv) "" $ xpStr+parseXPathExprWithNsEnv :: Attributes -> String -> Either String Expr+parseXPathExprWithNsEnv nsEnv xpStr = left fmtErr . runParser parseXPath (toNsEnv nsEnv) "" $ xpStr where- fmtErr parseError = "Syntax error in XPath expression " ++- show xpStr ++ ": " ++- show parseError+ fmtErr parseError = "Syntax error in XPath expression " +++ show xpStr ++ ": " +++ show parseError -- ----------------------------------------------------------------------------- -- |--- The main evaluation entry point. +-- 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-evalExpr env cont (GenExpr Or ex) = boolEval env cont Or ex-evalExpr env cont (GenExpr And ex) = boolEval env cont And ex-evalExpr env cont (GenExpr Eq ex) = relEqEval env cont Eq . evalExprL env cont ex-evalExpr env cont (GenExpr NEq ex) = relEqEval env cont NEq . evalExprL env cont ex-evalExpr env cont (GenExpr Less ex) = relEqEval env cont Less . evalExprL env cont ex-evalExpr env cont (GenExpr LessEq ex) = relEqEval env cont LessEq . evalExprL env cont ex-evalExpr env cont (GenExpr Greater ex) = relEqEval env cont Greater . evalExprL env cont ex+evalExpr :: Env -> Context -> Expr -> XPathFilter+evalExpr env cont (GenExpr Or ex) = boolEval env cont Or ex+evalExpr env cont (GenExpr And ex) = boolEval env cont And ex+evalExpr env cont (GenExpr Eq ex) = relEqEval env cont Eq . evalExprL env cont ex+evalExpr env cont (GenExpr NEq ex) = relEqEval env cont NEq . evalExprL env cont ex+evalExpr env cont (GenExpr Less ex) = relEqEval env cont Less . evalExprL env cont ex+evalExpr env cont (GenExpr LessEq ex) = relEqEval env cont LessEq . evalExprL env cont ex+evalExpr env cont (GenExpr Greater ex) = relEqEval env cont Greater . evalExprL env cont ex evalExpr env cont (GenExpr GreaterEq ex)- = relEqEval env cont GreaterEq . evalExprL env cont ex-evalExpr env cont (GenExpr Plus ex) = numEval xPathAdd Plus . toXValue xnumber cont env . evalExprL env cont ex-evalExpr env cont (GenExpr Minus ex) = numEval xPathAdd Minus . toXValue xnumber cont env . evalExprL env cont ex-evalExpr env cont (GenExpr Div ex) = numEval xPathDiv Div . toXValue xnumber cont env . evalExprL env cont ex-evalExpr env cont (GenExpr Mod ex) = numEval xPathMod Mod . toXValue xnumber cont env . evalExprL env cont ex-evalExpr env cont (GenExpr Mult ex) = numEval xPathMulti Mult . toXValue xnumber cont env . evalExprL env cont ex-evalExpr env cont (GenExpr Unary ex) = xPathUnary . xnumber cont env . evalExprL env cont ex-evalExpr env cont (GenExpr Union ex) = unionEval . evalExprL env cont ex-evalExpr env cont (FctExpr name args) = fctEval env cont name args+ = relEqEval env cont GreaterEq . evalExprL env cont ex+evalExpr env cont (GenExpr Plus ex) = numEval xPathAdd Plus . toXValue xnumber cont env . evalExprL env cont ex+evalExpr env cont (GenExpr Minus ex) = numEval xPathAdd Minus . toXValue xnumber cont env . evalExprL env cont ex+evalExpr env cont (GenExpr Div ex) = numEval xPathDiv Div . toXValue xnumber cont env . evalExprL env cont ex+evalExpr env cont (GenExpr Mod ex) = numEval xPathMod Mod . toXValue xnumber cont env . evalExprL env cont ex+evalExpr env cont (GenExpr Mult ex) = numEval xPathMulti Mult . toXValue xnumber cont env . evalExprL env cont ex+evalExpr env cont (GenExpr Unary ex) = xPathUnary . xnumber cont env . evalExprL env cont ex+evalExpr env cont (GenExpr Union ex) = unionEval . evalExprL env cont ex+evalExpr env cont (FctExpr name args) = fctEval env cont name args evalExpr env _ (PathExpr Nothing (Just lp))- = locPathEval env lp+ = locPathEval env lp evalExpr env cont (PathExpr (Just fe) (Just lp))- = locPathEval env lp . evalExpr env cont fe+ = locPathEval env lp . evalExpr env cont fe -evalExpr env cont (FilterExpr ex) = filterEval env cont ex-evalExpr env _ ex = evalSpezExpr env ex+evalExpr env cont (FilterExpr ex) = filterEval env cont ex+evalExpr env _ ex = evalSpezExpr env ex -- ----------------------------------------------------------------------------- -evalExprL :: Env -> Context -> [Expr] -> XPathValue -> [XPathValue]-evalExprL env cont ex ns = map (\e -> evalExpr env cont e ns) ex+evalExprL :: Env -> Context -> [Expr] -> XPathValue -> [XPathValue]+evalExprL env cont ex ns = map (\e -> evalExpr env cont e ns) ex -- ----------------------------------------------------------------------------- -evalSpezExpr :: Env -> Expr -> XPathFilter+evalSpezExpr :: Env -> Expr -> XPathFilter evalSpezExpr _ (NumberExpr (Float 0)) _ = XPVNumber Pos0 evalSpezExpr _ (NumberExpr (Float f)) _ = XPVNumber (Float f)-evalSpezExpr _ (LiteralExpr s) _ = XPVString s-evalSpezExpr env (VarExpr name) v = getVariable env name v-evalSpezExpr _ _ _ = XPVError "Call to evalExpr with a wrong argument"+evalSpezExpr _ (LiteralExpr s) _ = XPVString s+evalSpezExpr env (VarExpr name) v = getVariable env name v+evalSpezExpr _ _ _ = XPVError "Call to evalExpr with a wrong argument" -- ----------------------------------------------------------------------------- -- | -- filter for evaluating a filter-expression -filterEval :: Env -> Context -> [Expr] -> XPathFilter+filterEval :: Env -> Context -> [Expr] -> XPathFilter filterEval env cont (prim:predicates) ns- = case evalExpr env cont prim ns of- new_ns@(XPVNode _) -> evalPredL env predicates new_ns- _ -> XPVError "Return of a filterexpression is not a nodeset"-filterEval _ _ _ _ = XPVError "Call to filterEval without an expression"+ = case evalExpr env cont prim ns of+ new_ns@(XPVNode _) -> evalPredL env predicates new_ns+ _ -> XPVError "Return of a filterexpression is not a nodeset"+filterEval _ _ _ _ = XPVError "Call to filterEval without an expression" -- ----------------------------------------------------------------------------- -- | -- returns the union of its arguments, the arguments have to be node-sets. -unionEval :: [XPathValue] -> XPathValue+unionEval :: [XPathValue] -> XPathValue unionEval vs- | not (null evs) = case head evs of- e@(XPVError _) -> e- _ -> XPVError "A value of a union ( | ) is not a nodeset"- | otherwise = XPVNode . unionsNodeSet . map theNode $ nvs+ | not (null evs) = case head evs of+ e@(XPVError _) -> e+ _ -> XPVError "A value of a union ( | ) is not a nodeset"+ | otherwise = XPVNode . unionsNodeSet . map theNode $ nvs where- (nvs, evs) = partition isNode vs+ (nvs, evs) = partition isNode vs - isNode (XPVNode _) = True- isNode _ = False+ isNode (XPVNode _) = True+ isNode _ = False - theNode (XPVNode ns) = ns- theNode _ = error "illegal argument in unionEval"+ theNode (XPVNode ns) = ns+ theNode _ = error "illegal argument in unionEval" -- ----------------------------------------------------------------------------- -- | -- Equality or relational test for node-sets, numbers, boolean values or strings, -- each computation of two operands is done by relEqEv' -relEqEval :: Env -> Context -> Op -> [XPathValue] -> XPathValue-relEqEval env cont op = foldl1 (relEqEv' env cont op) +relEqEval :: Env -> Context -> Op -> [XPathValue] -> XPathValue+relEqEval env cont op = foldl1 (relEqEv' env cont op) -relEqEv' :: Env -> Context -> Op -> XPathValue -> XPathFilter-relEqEv' _ _ _ e@(XPVError _) _ = e-relEqEv' _ _ _ _ e@(XPVError _) = e+relEqEv' :: Env -> Context -> Op -> XPathValue -> XPathFilter+relEqEv' _ _ _ e@(XPVError _) _ = e+relEqEv' _ _ _ _ e@(XPVError _) = e -- two node-sets relEqEv' env cont op a@(XPVNode _)- b@(XPVNode _) = relEqTwoNodes env cont op a b+ b@(XPVNode _) = relEqTwoNodes env cont op a b -- one node-set -relEqEv' env cont op a b@(XPVNode _) = relEqOneNode env cont (fromJust $ getOpFct op) a b+relEqEv' env cont op a b@(XPVNode _) = relEqOneNode env cont (fromJust $ getOpFct op) a b relEqEv' env cont op a@(XPVNode _) b = relEqOneNode env cont (flip $ fromJust $ getOpFct op) b a -- test without a node-set and equality or not-equality operator -relEqEv' env cont Eq a b = eqEv env cont (==) a b-relEqEv' env cont NEq a b = eqEv env cont (/=) a b+relEqEv' env cont Eq a b = eqEv env cont (==) a b+relEqEv' env cont NEq a b = eqEv env cont (/=) a b -- test without a node-set and less, less-equal, greater or greater-equal operator -relEqEv' env cont op a b = XPVBool ((fromJust $ getOpFct op) (toXNumber a) (toXNumber b))+relEqEv' env cont op a b = XPVBool ((fromJust $ getOpFct op) (toXNumber a) (toXNumber b)) where- toXNumber x = xnumber cont env [x]+ toXNumber x = xnumber cont env [x] -- ----------------------------------------------------------------------------- @@ -339,15 +339,15 @@ -- and a node in the second node-set such that the result of performing the -- comparison on the string-values of the two nodes is true -relEqTwoNodes :: Env -> Context -> Op -> XPathValue -> XPathFilter+relEqTwoNodes :: Env -> Context -> Op -> XPathValue -> XPathFilter relEqTwoNodes _ _ op (XPVNode ns)- (XPVNode ms) = XPVBool $- foldr (\n -> (any (fct op n) (getStrValues ms) ||)) False $- fromNodeSet ns- where- fct op' n' = (fromJust $ getOpFct op') (stringValue n')- getStrValues = map stringValue . fromNodeSet-relEqTwoNodes _ _ _ _ _ = XPVError "Call to relEqTwoNodes without a nodeset"+ (XPVNode ms) = XPVBool $+ foldr (\n -> (any (fct op n) (getStrValues ms) ||)) False $+ fromNodeSet ns+ where+ fct op' n' = (fromJust $ getOpFct op') (stringValue n')+ getStrValues = map stringValue . fromNodeSet+relEqTwoNodes _ _ _ _ _ = XPVError "Call to relEqTwoNodes without a nodeset" -- ----------------------------------------------------------------------------- -- |@@ -356,15 +356,15 @@ -- If the argument is of type number, the node-set is converted in a number, otherwise it is converted -- in a string value. -relEqOneNode :: Env -> Context ->- (XPathValue -> XPathValue -> Bool) -> XPathValue -> XPathFilter+relEqOneNode :: Env -> Context ->+ (XPathValue -> XPathValue -> Bool) -> XPathValue -> XPathFilter -relEqOneNode env cont fct arg = withXPVNode "Call to relEqOneNode without a nodeset" $- \ ns -> XPVBool (any (fct arg) (getStrValues arg ns))+relEqOneNode env cont fct arg = withXPVNode "Call to relEqOneNode without a nodeset" $+ \ ns -> XPVBool (any (fct arg) (getStrValues arg ns)) where- getStrValues arg' = map ((fromJust $ getConvFct arg') cont env . (:[])) .- map stringValue .- fromNodeSet+ getStrValues arg' = map ((fromJust $ getConvFct arg') cont env . (:[])) .+ map stringValue .+ fromNodeSet -- ----------------------------------------------------------------------------- @@ -374,39 +374,39 @@ -- then it is the boolean type. If a number is involved, the arguments have to converted in numbers, -- else the string type is the common type. -eqEv :: Env -> Context -> (XPathValue -> XPathValue -> Bool) -> XPathValue -> XPathFilter-eqEv env cont fct f@(XPVBool _) g = XPVBool (f `fct` xboolean cont env [g])-eqEv env cont fct f g@(XPVBool _) = XPVBool (xboolean cont env [f] `fct` g)-eqEv env cont fct f@(XPVNumber _) g = XPVBool (f `fct` xnumber cont env [g])-eqEv env cont fct f g@(XPVNumber _) = XPVBool (xnumber cont env [f] `fct` g)-eqEv env cont fct f g = XPVBool (xstring cont env [f] `fct` xstring cont env [g])+eqEv :: Env -> Context -> (XPathValue -> XPathValue -> Bool) -> XPathValue -> XPathFilter+eqEv env cont fct f@(XPVBool _) g = XPVBool (f `fct` xboolean cont env [g])+eqEv env cont fct f g@(XPVBool _) = XPVBool (xboolean cont env [f] `fct` g)+eqEv env cont fct f@(XPVNumber _) g = XPVBool (f `fct` xnumber cont env [g])+eqEv env cont fct f g@(XPVNumber _) = XPVBool (xnumber cont env [f] `fct` g)+eqEv env cont fct f g = XPVBool (xstring cont env [f] `fct` xstring cont env [g]) -- ----------------------------------------------------------------------------- -getOpFct :: Op -> Maybe (XPathValue -> XPathValue -> Bool)-getOpFct Eq = Just (==)-getOpFct NEq = Just (/=)-getOpFct Less = Just (<)-getOpFct LessEq = Just (<=)-getOpFct Greater = Just (>)-getOpFct GreaterEq = Just (>=)-getOpFct _ = Nothing+getOpFct :: Op -> Maybe (XPathValue -> XPathValue -> Bool)+getOpFct Eq = Just (==)+getOpFct NEq = Just (/=)+getOpFct Less = Just (<)+getOpFct LessEq = Just (<=)+getOpFct Greater = Just (>)+getOpFct GreaterEq = Just (>=)+getOpFct _ = Nothing -- ----------------------------------------------------------------------------- -- | -- Filter for accessing the root element of a document tree -getRoot :: XPathFilter-getRoot = withXPVNode "Call to getRoot without a nodeset" $ getRoot'+getRoot :: XPathFilter+getRoot = withXPVNode "Call to getRoot without a nodeset" $ getRoot' where getRoot' ns- | nullNodeSet ns = XPVError "Call to getRoot with empty nodeset"- | otherwise = XPVNode . singletonNodeSet . getRoot'' . headNodeSet $ ns+ | nullNodeSet ns = XPVError "Call to getRoot with empty nodeset"+ | otherwise = XPVNode . singletonNodeSet . getRoot'' . headNodeSet $ ns - getRoot'' tree = case upNT tree of- Nothing -> tree- Just t -> getRoot'' t+ getRoot'' tree = case upNT tree of+ Nothing -> tree+ Just t -> getRoot'' t -- ----------------------------------------------------------------------------- @@ -415,116 +415,116 @@ -- -- * 1.parameter as : axis specifier ---getAxisNodes :: AxisSpec -> XPathFilter-getAxisNodes as = withXPVNode "Call to getAxis without a nodeset" evalAxis+getAxisNodes :: AxisSpec -> XPathFilter+getAxisNodes as = withXPVNode "Call to getAxis without a nodeset" evalAxis where- evalAxis = XPVNode .- withNodeSet (concatMap (fromJust $ lookup as axisFctL))+ evalAxis = XPVNode .+ withNodeSet (concatMap (fromJust $ lookup as axisFctL)) -- | -- Axis-Function-Table. -- Each XPath axis-specifier is mapped to the corresponding axis-function -axisFctL :: [(AxisSpec, (NavXmlTree -> NavXmlTrees))]-axisFctL = [ (Ancestor , ancestorAxis)- , (AncestorOrSelf , ancestorOrSelfAxis)- , (Attribute , attributeAxis)- , (Child , childAxis)- , (Descendant , descendantAxis)- , (DescendantOrSelf , descendantOrSelfAxis)- , (Following , followingAxis)- , (FollowingSibling , followingSiblingAxis)- , (Parent , parentAxis)- , (Preceding , precedingAxis)- , (PrecedingSibling , precedingSiblingAxis)- , (Self , selfAxis)- ]+axisFctL :: [(AxisSpec, (NavXmlTree -> NavXmlTrees))]+axisFctL = [ (Ancestor , ancestorAxis)+ , (AncestorOrSelf , ancestorOrSelfAxis)+ , (Attribute , attributeAxis)+ , (Child , childAxis)+ , (Descendant , descendantAxis)+ , (DescendantOrSelf , descendantOrSelfAxis)+ , (Following , followingAxis)+ , (FollowingSibling , followingSiblingAxis)+ , (Parent , parentAxis)+ , (Preceding , precedingAxis)+ , (PrecedingSibling , precedingSiblingAxis)+ , (Self , selfAxis)+ ] -- ----------------------------------------------------------------------------- -- | -- evaluates a location path,--- evaluation of an absolute path starts at the document root, +-- evaluation of an absolute path starts at the document root, -- the relative path at the context node -locPathEval :: Env -> LocationPath -> XPathFilter-locPathEval env (LocPath Rel steps) = evalSteps env steps-locPathEval env (LocPath Abs steps) = evalSteps env steps . getRoot+locPathEval :: Env -> LocationPath -> XPathFilter+locPathEval env (LocPath Rel steps) = evalSteps env steps+locPathEval env (LocPath Abs steps) = evalSteps env steps . getRoot -- ----------------------------------------------------------------------------- -evalSteps :: Env -> [XStep] -> XPathFilter-evalSteps env steps ns = foldl (evalStep env) ns steps+evalSteps :: Env -> [XStep] -> XPathFilter+evalSteps env steps ns = foldl (evalStep env) ns steps -- | -- evaluate a single XPath step -- namespace-axis is not supported -evalStep :: Env -> XPathValue -> XStep -> XPathValue+evalStep :: Env -> XPathValue -> XStep -> XPathValue -evalStep _ _ (Step Namespace _ _) = XPVError "namespace-axis not supported"-evalStep _ ns (Step Attribute nt _) = evalAttr nt (getAxisNodes Attribute ns)-evalStep env ns (Step axisSpec nt pr) = evalStep' env pr nt (getAxisNodes axisSpec ns)+evalStep _ _ (Step Namespace _ _) = XPVError "namespace-axis not supported"+evalStep _ ns (Step Attribute nt _) = evalAttr nt (getAxisNodes Attribute ns)+evalStep env ns (Step axisSpec nt pr) = evalStep' env pr nt (getAxisNodes axisSpec ns) -- ----------------------------------------------------------------------------- -evalAttr :: NodeTest -> XPathFilter-evalAttr nt = withXPVNode "Call to evalAttr without a nodeset" $+evalAttr :: NodeTest -> XPathFilter+evalAttr nt = withXPVNode "Call to evalAttr without a nodeset" $ evalTest where- evalTest = XPVNode .- withNodeSet (concatMap . evalAttrNodeTest $ nt)+ evalTest = XPVNode .+ withNodeSet (concatMap . evalAttrNodeTest $ nt) -evalAttrNodeTest :: NodeTest -> NavXmlTree -> NavXmlTrees+evalAttrNodeTest :: NodeTest -> NavXmlTree -> NavXmlTrees evalAttrNodeTest (NameTest qn) ns@(NT (NTree (XAttr qn1) _) _ix _ _ _)- = if ( ( uri == uri1 && lp == lp1)- || - ((uri == "" || uri == uri1) && lp == "*") - )- then [ns]- else []+ = if ( ( uri == uri1 && lp == lp1)+ ||+ ((uri == "" || uri == uri1) && lp == "*")+ )+ then [ns]+ else [] where- uri = namespaceUri qn- uri1 = namespaceUri qn1- lp = localPart qn- lp1 = localPart qn1+ uri = namespaceUri qn+ uri1 = namespaceUri qn1+ lp = localPart qn+ lp1 = localPart qn1 evalAttrNodeTest (TypeTest XPNode) ns@(NT (NTree (XAttr _) _) _ix _ _ _)- = [ns]-evalAttrNodeTest _ _ = []+ = [ns]+evalAttrNodeTest _ _ = [] -evalStep' :: Env -> [Expr] -> NodeTest -> XPathFilter-evalStep' env pr nt = evalPredL env pr . nodeTest nt+evalStep' :: Env -> [Expr] -> NodeTest -> XPathFilter+evalStep' env pr nt = evalPredL env pr . nodeTest nt -- ----------------------------------------------------------------------------- -evalPredL :: Env -> [Expr] -> XPathFilter-evalPredL env pr n = withXPVNode "Call to evalPredL without a nodeset" evalPl n+evalPredL :: Env -> [Expr] -> XPathFilter+evalPredL env pr n = withXPVNode "Call to evalPredL without a nodeset" evalPl n where- evalPl ns = foldl (evalPred env 1 (cardNodeSet ns)) n pr+ evalPl ns = foldl (evalPred env 1 (cardNodeSet ns)) n pr -evalPred :: Env -> Int -> Int -> XPathValue -> Expr -> XPathValue+evalPred :: Env -> Int -> Int -> XPathValue -> Expr -> XPathValue evalPred env pos len nv@(XPVNode ns) ex- | nullNodeSet ns = nv- | otherwise = case testPredicate env (pos, len, x) ex (XPVNode . singletonNodeSet $ x) of- e@(XPVError _) -> e- XPVBool True -> XPVNode $ insertNodeSet x n- XPVBool False -> nextNode- _ -> XPVError "Value of testPredicate is not a boolean"- where- (xp, x) = head . elemsNodeSet $ ns- xs = deleteNodeSet xp ns- nextNode@(XPVNode n) = evalPred env (pos + 1) len (XPVNode xs) ex-evalPred _ _ _ _ _ = XPVError "Call to evalPred without a nodeset"+ | nullNodeSet ns = nv+ | otherwise = case testPredicate env (pos, len, x) ex (XPVNode . singletonNodeSet $ x) of+ e@(XPVError _) -> e+ XPVBool True -> XPVNode $ insertNodeSet x n+ XPVBool False -> nextNode+ _ -> XPVError "Value of testPredicate is not a boolean"+ where+ (xp, x) = head . elemsNodeSet $ ns+ xs = deleteNodeSet xp ns+ nextNode@(XPVNode n) = evalPred env (pos + 1) len (XPVNode xs) ex+evalPred _ _ _ _ _ = XPVError "Call to evalPred without a nodeset" -testPredicate :: Env -> Context -> Expr -> XPathFilter-testPredicate env context@(pos, _, _) ex ns = case evalExpr env context ex ns of- XPVNumber (Float f) -> XPVBool (f == fromIntegral pos)- XPVNumber _ -> XPVBool False- _ -> xboolean context env [evalExpr env context ex ns]+testPredicate :: Env -> Context -> Expr -> XPathFilter+testPredicate env context@(pos, _, _) ex ns = case evalExpr env context ex ns of+ XPVNumber (Float f) -> XPVBool (f == fromIntegral pos)+ XPVNumber _ -> XPVBool False+ _ -> xboolean context env [evalExpr env context ex ns] -- ----------------------------------------------------------------------------- -- |@@ -536,58 +536,58 @@ -- -- Bugfix : "*" (or any other name-test) must not match the root node -nodeTest :: NodeTest -> XPathFilter+nodeTest :: NodeTest -> XPathFilter -- nodeTest (NameTest (QN "" "*" "")) = filterNodes (\n -> isXTagNode n && not (isRootNode n)) -- nodeTest (NameTest (QN _ "*" uri)) = filterNodes (filterd uri) nodeTest (NameTest q)- | isWildcardTest = filterNodes (wildcardTest q)- | otherwise = filterNodes (nameTest q) -- old: (isOfTagNode1 q)+ | isWildcardTest = filterNodes (wildcardTest q)+ | otherwise = filterNodes (nameTest q) -- old: (isOfTagNode1 q) where- isWildcardTest = localPart q == "*"+ isWildcardTest = localPart q == "*" nodeTest (PI n) = filterNodes isPiNode- where- isPiNode = maybe False ((== n) . qualifiedName) . XN.getPiName+ where+ isPiNode = maybe False ((== n) . qualifiedName) . XN.getPiName nodeTest (TypeTest t) = typeTest t -- ----------------------------------------------------------------------------- -nameTest :: QName -> XNode -> Bool+nameTest :: QName -> XNode -> Bool nameTest xpName (XTag elemName _)- | namespaceAware = localPart xpName == localPart elemName- &&- namespaceUri xpName == namespaceUri elemName- | otherwise = qualifiedName xpName == qualifiedName elemName+ | namespaceAware = localPart xpName == localPart elemName+ &&+ namespaceUri xpName == namespaceUri elemName+ | otherwise = qualifiedName xpName == qualifiedName elemName where- namespaceAware = not . null . namespaceUri $ xpName+ namespaceAware = not . null . namespaceUri $ xpName -nameTest _ _ = False+nameTest _ _ = False -- ----------------------------------------------------------------------------- -wildcardTest :: QName -> XNode -> Bool+wildcardTest :: QName -> XNode -> Bool wildcardTest xpName (XTag elemName _)- | namespaceAware = namespaceUri xpName == namespaceUri elemName- | prefixMatch = namePrefix xpName == namePrefix elemName- | otherwise = localPart elemName /= t_root -- all names except the root name "/"+ | namespaceAware = namespaceUri xpName == namespaceUri elemName+ | prefixMatch = namePrefix xpName == namePrefix elemName+ | otherwise = localPart elemName /= t_root -- all names except the root name "/" where- namespaceAware = not . null . namespaceUri $ xpName- prefixMatch = not . null . namePrefix $ xpName+ namespaceAware = not . null . namespaceUri $ xpName+ prefixMatch = not . null . namePrefix $ xpName -wildcardTest _ _ = False+wildcardTest _ _ = False -- ----------------------------------------------------------------------------- -- | -- tests whether a node is of a special type ---typeTest :: XPathNode -> XPathFilter-typeTest XPNode = id-typeTest XPCommentNode = filterNodes XN.isCmt-typeTest XPPINode = filterNodes XN.isPi-typeTest XPTextNode = filterNodes XN.isText+typeTest :: XPathNode -> XPathFilter+typeTest XPNode = id+typeTest XPCommentNode = filterNodes XN.isCmt+typeTest XPPINode = filterNodes XN.isPi+typeTest XPTextNode = filterNodes XN.isText -- ----------------------------------------------------------------------------- -- |@@ -596,43 +596,43 @@ -- -- * 1.parameter fct : filter function from the XmlTreeFilter module which tests the type of a node -filterNodes :: (XNode -> Bool) -> XPathFilter-filterNodes fct = withXPVNode "Call to filterNodes without a nodeset" $- (XPVNode . withNodeSet (filter (fct . dataNT)))+filterNodes :: (XNode -> Bool) -> XPathFilter+filterNodes fct = withXPVNode "Call to filterNodes without a nodeset" $+ (XPVNode . withNodeSet (filter (fct . dataNT))) -- ----------------------------------------------------------------------------- -- | -- evaluates a boolean expression, the evaluation is non-strict -boolEval :: Env -> Context -> Op -> [Expr] -> XPathFilter-boolEval _ _ op [] _ = XPVBool (op == And)-boolEval env cont Or (x:xs) ns = case xboolean cont env [evalExpr env cont x ns] of- e@(XPVError _) -> e- XPVBool True -> XPVBool True- _ -> boolEval env cont Or xs ns+boolEval :: Env -> Context -> Op -> [Expr] -> XPathFilter+boolEval _ _ op [] _ = XPVBool (op == And)+boolEval env cont Or (x:xs) ns = case xboolean cont env [evalExpr env cont x ns] of+ e@(XPVError _) -> e+ XPVBool True -> XPVBool True+ _ -> boolEval env cont Or xs ns -boolEval env cont And (x:xs) ns = case xboolean cont env [evalExpr env cont x ns] of- e@(XPVError _) -> e- XPVBool True -> boolEval env cont And xs ns- _ -> XPVBool False-boolEval _ _ _ _ _ = XPVError "Call to boolEval with a wrong argument"+boolEval env cont And (x:xs) ns = case xboolean cont env [evalExpr env cont x ns] of+ e@(XPVError _) -> e+ XPVBool True -> boolEval env cont And xs ns+ _ -> XPVBool False+boolEval _ _ _ _ _ = XPVError "Call to boolEval with a wrong argument" -- ----------------------------------------------------------------------------- -- | -- returns the value of a variable-getVariable :: Env -> VarName -> XPathFilter-getVariable env name _ = fromMaybe (XPVError ("Variable: " ++ show name ++ " not found")) $- lookup name (getVarTab env)+getVariable :: Env -> VarName -> XPathFilter+getVariable env name _ = fromMaybe (XPVError ("Variable: " ++ show name ++ " not found")) $+ lookup name (getVarTab env) -- ----------------------------------------------------------------------------- -- |--- evaluates a function, +-- evaluates a function, -- computation is done by 'XPathFct.evalFct' which is defined in "XPathFct". -fctEval :: Env -> Context -> FctName -> [Expr] -> XPathFilter-fctEval env cont name args = evalFct name env cont . evalExprL env cont args+fctEval :: Env -> Context -> FctName -> [Expr] -> XPathFilter+fctEval env cont name args = evalFct name env cont . evalExprL env cont args -- ----------------------------------------------------------------------------- -- |@@ -640,41 +640,41 @@ -- -- 1.parameter f : arithmetic function from "XPathArithmetic" ---numEval :: (Op -> XPathValue -> XPathValue -> XPathValue) ->- Op -> [XPathValue] -> XPathValue-numEval f op = foldl1 (f op)+numEval :: (Op -> XPathValue -> XPathValue -> XPathValue) ->+ Op -> [XPathValue] -> XPathValue+numEval f op = foldl1 (f op) -- ----------------------------------------------------------------------------- -- | -- Convert list of ID attributes from DTD into a space separated 'XPVString' -- -idAttributesToXPathValue :: XmlTrees -> XPathValue-idAttributesToXPathValue ts = XPVString (foldr (\ n -> ( (valueOfDTD a_value n ++ " ") ++)) [] ts)+idAttributesToXPathValue :: XmlTrees -> XPathValue+idAttributesToXPathValue ts = XPVString (foldr (\ n -> ( (valueOfDTD a_value n ++ " ") ++)) [] ts) -- ----------------------------------------------------------------------------- -- | -- Extracts all ID-attributes from the document type definition (DTD). -- -getIdAttributes :: XmlTree -> XmlTrees-getIdAttributes = runLA $- AT.getChildren- >>>- isDTD- >>>- AT.deep (isIdAttrType)+getIdAttributes :: XmlTree -> XmlTrees+getIdAttributes = runLA $+ AT.getChildren+ >>>+ isDTD+ >>>+ AT.deep (isIdAttrType) -- ---------------------------------------- -isIdAttrType :: ArrowDTD a => a XmlTree XmlTree-isIdAttrType = hasDTDAttrValue a_type (== k_id)+isIdAttrType :: ArrowDTD a => a XmlTree XmlTree+isIdAttrType = hasDTDAttrValue a_type (== k_id) -valueOfDTD :: String -> XmlTree -> String-valueOfDTD n = concat . runLA ( getDTDAttrl >>^ lookup1 n )+valueOfDTD :: String -> XmlTree -> String+valueOfDTD n = concat . runLA ( getDTDAttrl >>^ lookup1 n ) -hasDTDAttrValue :: ArrowDTD a => String -> (String -> Bool) -> a XmlTree XmlTree-hasDTDAttrValue an p = filterA $- getDTDAttrl >>> isA (p . lookup1 an)+hasDTDAttrValue :: ArrowDTD a => String -> (String -> Bool) -> a XmlTree XmlTree+hasDTDAttrValue an p = filterA $+ getDTDAttrl >>> isA (p . lookup1 an) -- ------------------------------------------------------------
src/Text/XML/HXT/XPath/XPathFct.hs view
@@ -45,28 +45,31 @@ ( xPathAdd ) -import Control.Arrow ( (>>>), (<+>) )-import Control.Arrow.ArrowList ( constA )-import Control.Arrow.ArrowIf ( ifA )-import Control.Arrow.ArrowTree ( deep )-import Control.Arrow.ListArrow ( LA, runLA )+import Control.Arrow ( (>>>), (<+>) )+import Control.Arrow.ArrowList ( constA )+import Control.Arrow.ArrowIf ( ifA )+import Control.Arrow.ArrowTree ( deep )+import Control.Arrow.ListArrow ( LA, runLA ) import Text.XML.HXT.Arrow.XmlArrow-import Text.XML.HXT.Arrow.ReadDocument (readDocument)-import Text.XML.HXT.Arrow.XmlIOStateArrow (runX)+import Text.XML.HXT.Arrow.ReadDocument ( readDocument )+import Text.XML.HXT.Arrow.XmlState ( runX+ , withValidate+ , no+ ) import Text.XML.HXT.DOM.Interface import qualified Text.XML.HXT.DOM.XmlNode as XN -import System.IO.Unsafe ( unsafePerformIO- )+import System.IO.Unsafe ( unsafePerformIO+ ) -import Data.Char ( isAscii- , isUpper- , isLower- , isDigit- , ord- )+import Data.Char ( isAscii+ , isUpper+ , isLower+ , isDigit+ , ord+ ) import Data.Maybe @@ -155,10 +158,10 @@ ("round",(xround, one)), ("key",(xkey, two)), ("format-number",(xformatNumber, twoOrThree)),- + ("document", (xdocument, one)),-- extension functions for xslt 1.0 ("generate-id", (xgenerateId, zeroOrOne))- + ] -- -----------------------------------------------------------------------------@@ -208,23 +211,23 @@ -- - Attributes are identified by their QName (they do not have previous siblings) -- - Elements are identified by their relative position (# of previous siblings) -data IdPathStep = IdRoot String- | IdPos Int- | IdAttr QName- deriving (Show, Eq, Ord)+data IdPathStep = IdRoot String+ | IdPos Int+ | IdAttr QName+ deriving (Show, Eq, Ord) -nodeID :: Maybe NavXmlTree -> [IdPathStep]-nodeID = maybe [] nodeID'+nodeID :: Maybe NavXmlTree -> [IdPathStep]+nodeID = maybe [] nodeID' -nodeID' :: NavXmlTree -> [IdPathStep]+nodeID' :: NavXmlTree -> [IdPathStep] nodeID' t@(NT (NTree (XAttr qn) _) _ix _ _ _)- = IdAttr qn : nodeID (upNT t)+ = IdAttr qn : nodeID (upNT t) nodeID' t@(NT node ix _ _ _)- | XN.isRoot node = return $ IdRoot (getRootId node) - | otherwise = IdPos ix : nodeID (upNT t)+ | XN.isRoot node = return $ IdRoot (getRootId node)+ | otherwise = IdPos ix : nodeID (upNT t) where- getRootId = concat . runLA (getAttrValue "rootId")+ getRootId = concat . runLA (getAttrValue "rootId") -- ----------------------------------------------------------------------------- -- |@@ -257,8 +260,8 @@ -- * 1.parameter fct : the conversion function -- -toXValue :: XFct -> Context -> Env -> [XPathValue] -> [XPathValue]-toXValue fct c env args = [fct c env [x] | x <- args]+toXValue :: XFct -> Context -> Env -> [XPathValue] -> [XPathValue]+toXValue fct c env args = [fct c env [x] | x <- args] -- ----------------------------------------------------------------------------- -- core-funktions library@@ -268,37 +271,37 @@ -- | -- number last(): returns a number equal to the context size from the expression evaluation context -xlast :: XFct-xlast (_, len , _) _ _ = XPVNumber $ int2XPNumber len+xlast :: XFct+xlast (_, len , _) _ _ = XPVNumber $ int2XPNumber len -- ----------------------------------------------------------------------------- -- | -- number position(): returns a number equal to the context position from the expression evaluation context -xposition :: XFct-xposition (pos, _ , _) _ _ = XPVNumber $ int2XPNumber pos+xposition :: XFct+xposition (pos, _ , _) _ _ = XPVNumber $ int2XPNumber pos -- ----------------------------------------------------------------------------- -- | -- number count(node-set): returns the number of nodes in the argument node-set -xcount :: XFct-xcount _ _ [XPVNode ns] = XPVNumber . int2XPNumber . cardNodeSet $ ns-xcount _ _ _ = XPVError "Call to function count with wrong arguments"+xcount :: XFct+xcount _ _ [XPVNode ns] = XPVNumber . int2XPNumber . cardNodeSet $ ns+xcount _ _ _ = XPVError "Call to function count with wrong arguments" -- ----------------------------------------------------------------------------- -- | -- node-set id(object): selects elements by their unique ID -xid :: XFct-xid (_, _, cn) env [XPVNode ns] = isInId (getIds env) (strValues ns) [cn]+xid :: XFct+xid (_, _, cn) env [XPVNode ns] = isInId (getIds env) (strValues ns) [cn] where- strValues = map ((\ (XPVString str) -> str) . stringValue) . fromNodeSet+ strValues = map ((\ (XPVString str) -> str) . stringValue) . fromNodeSet -xid c@(_, _, cn) env arg = isInId (getIds env) ( (\(XPVString s) -> words s) (xstring c env arg)) [cn]+xid c@(_, _, cn) env arg = isInId (getIds env) ( (\(XPVString s) -> words s) (xstring c env arg)) [cn] @@ -307,44 +310,44 @@ -- returns all IDs from the variable environment as a list of strings. -- the IDs are stored in the variable: idAttr -getIds :: Env -> [String]-getIds env = words $ -- hier muss noch auf prefix getestet werden- (\ (XPVString str) -> str) . fromJust $ lookup ("", "idAttr") $- getVarTab env +getIds :: Env -> [String]+getIds env = words $ -- hier muss noch auf prefix getestet werden+ (\ (XPVString str) -> str) . fromJust $ lookup ("", "idAttr") $+ getVarTab env -- ----------------------------------------------------------------------------- -isInId :: [String] -> [String] -> NavXmlTrees -> XPathValue-isInId ids str = XPVNode . toNodeSet . concatMap (filterNS ids str . descendantOrSelfAxis)+isInId :: [String] -> [String] -> NavXmlTrees -> XPathValue+isInId ids str = XPVNode . toNodeSet . concatMap (filterNS ids str . descendantOrSelfAxis) -- ----------------------------------------------------------------------------- -filterNS :: [String] -> [String] -> NavXmlTrees -> NavXmlTrees-filterNS ids str ns = [ n | n@(NT a _ _ _ _) <- ns- , or $ map (idInIdList a str) ids- ]+filterNS :: [String] -> [String] -> NavXmlTrees -> NavXmlTrees+filterNS ids str ns = [ n | n@(NT a _ _ _ _) <- ns+ , or $ map (idInIdList a str) ids+ ] where- idInIdList :: XmlTree -> [String] -> String -> Bool- idInIdList al str' b = (getValue b al) `elem` str'+ idInIdList :: XmlTree -> [String] -> String -> Bool+ idInIdList al str' b = (getValue b al) `elem` str' -- ----------------------------------------------------------------------------- -- | -- string local-name(node-set?): -- returns the local part of the expanded-name of the node in the argument node-set--- that is first in document order. --- If the argument node-set is empty or the first node has no expanded-name, an empty string is returned. +-- that is first in document order.+-- If the argument node-set is empty or the first node has no expanded-name, an empty string is returned. -- If the argument is omitted, it defaults to a node-set with the context node as its only member -- Bugfix: name(\/) is "" not "\/"! -xlocalName :: XFct-xlocalName (_, _, cn) _ [] = XPVString (xpLocalPartOf . subtreeNT $ cn)+xlocalName :: XFct+xlocalName (_, _, cn) _ [] = XPVString (xpLocalPartOf . subtreeNT $ cn) xlocalName _ _ [XPVNode ns]- | nullNodeSet ns = XPVString ""- | otherwise = XPVString (xpLocalPartOf . subtreeNT . headNodeSet $ ns)-xlocalName _ _ _ = XPVError "Call to function local-name with wrong arguments"+ | nullNodeSet ns = XPVString ""+ | otherwise = XPVString (xpLocalPartOf . subtreeNT . headNodeSet $ ns)+xlocalName _ _ _ = XPVError "Call to function local-name with wrong arguments" -- ----------------------------------------------------------------------------- -- |@@ -356,74 +359,74 @@ -- is null, an empty string is returned. If the argument is omitted, -- it defaults to a node-set with the context node as its only member -xnamespaceUri :: XFct-xnamespaceUri (_, _, cn) _ [] = XPVString (xpNamespaceOf . subtreeNT $ cn)+xnamespaceUri :: XFct+xnamespaceUri (_, _, cn) _ [] = XPVString (xpNamespaceOf . subtreeNT $ cn) xnamespaceUri _ _ [XPVNode ns]- | nullNodeSet ns = XPVString ""- | otherwise = XPVString (xpNamespaceOf . subtreeNT . headNodeSet $ ns)-xnamespaceUri _ _ _ = XPVError "Call to function namespace-uri with wrong arguments"+ | nullNodeSet ns = XPVString ""+ | otherwise = XPVString (xpNamespaceOf . subtreeNT . headNodeSet $ ns)+xnamespaceUri _ _ _ = XPVError "Call to function namespace-uri with wrong arguments" -- ----------------------------------------------------------------------------- -- |--- string name(node-set?): +-- string name(node-set?): -- returns a string containing a QName representing the expanded-name of the node--- in the argument node-set +-- in the argument node-set -- that is first in document order. If the argument node-set is empty or the first--- node has no expanded-name, +-- node has no expanded-name, -- an empty string is returned. If the argument it omitted, it defaults to a node-set -- with the context node as its only member.--- Tim Walkenhorst: +-- Tim Walkenhorst: -- Bugfix: name(\/) is "" not "\/"! -xname :: XFct-xname (_, _, cn) _ [] = XPVString (xpNameOf . subtreeNT $ cn)+xname :: XFct+xname (_, _, cn) _ [] = XPVString (xpNameOf . subtreeNT $ cn) xname _ _ [XPVNode ns]- | nullNodeSet ns = XPVString ""- | otherwise = XPVString (xpNameOf . subtreeNT . headNodeSet $ ns)-xname _ _ _ = XPVError "Call to function name with wrong arguments"+ | nullNodeSet ns = XPVString ""+ | otherwise = XPVString (xpNameOf . subtreeNT . headNodeSet $ ns)+xname _ _ _ = XPVError "Call to function name with wrong arguments" -- ------------------------------------------------------------ -- string functions -- | -- some helper functions-getFirstPos :: String -> String -> Int-getFirstPos s sub = if (getFirstPos' s sub) > length s- then -1- else getFirstPos' s sub+getFirstPos :: String -> String -> Int+getFirstPos s sub = if (getFirstPos' s sub) > length s+ then -1+ else getFirstPos' s sub -- ----------------------------------------------------------------------------- -getFirstPos' :: String -> String -> Int-getFirstPos' [] _ = 2-getFirstPos' (x:xs) sub = if strStartsWith (x:xs) sub- then 0- else 1 + getFirstPos' xs sub+getFirstPos' :: String -> String -> Int+getFirstPos' [] _ = 2+getFirstPos' (x:xs) sub = if strStartsWith (x:xs) sub+ then 0+ else 1 + getFirstPos' xs sub -- ----------------------------------------------------------------------------- -strStartsWith :: String -> String -> Bool-strStartsWith a b = take (length b) a == b+strStartsWith :: String -> String -> Bool+strStartsWith a b = take (length b) a == b -- ----------------------------------------------------------------------------- -- | -- Returns the string-value of a node, -- the value of a namespace node is not supported -stringValue :: NavXmlTree -> XPathValue-stringValue = XPVString . xpTextOf . self+stringValue :: NavXmlTree -> XPathValue+stringValue = XPVString . xpTextOf . self {-- textFilter + textFilter = getXCmt `orElse` -- getXNamespace `orElse` multi isXText- + -- = (isXTag `guards` multi isXText) `orElse` -- (isXPi `guards` multi isXText) `orElse`--- (isXAttr `guards` multi isXText) `orElse` +-- (isXAttr `guards` multi isXText) `orElse` -- (isXText `guards` multi isXText) `orElse` -- getXCmt -}@@ -433,41 +436,41 @@ -- | -- string string(object?): converts an object to a string -xstring :: XFct+xstring :: XFct xstring _ _ [XPVNode ns]- | nullNodeSet ns = XPVString ""- | otherwise = stringValue . headNodeSet $ ns-xstring (_, _, cn) _ [] = stringValue cn+ | nullNodeSet ns = XPVString ""+ | otherwise = stringValue . headNodeSet $ ns+xstring (_, _, cn) _ [] = stringValue cn xstring _ _ [XPVNumber (Float a)]- | a == (fromInteger $ round a) = XPVString (show ((round a)::Integer))- | otherwise = XPVString (show a)-xstring _ _ [XPVNumber s] = XPVString (show s)+ | a == (fromInteger $ round a) = XPVString (show ((round a)::Integer))+ | otherwise = XPVString (show a)+xstring _ _ [XPVNumber s] = XPVString (show s) -xstring _ _ [XPVBool True] = XPVString "true"-xstring _ _ [XPVBool False] = XPVString "false"+xstring _ _ [XPVBool True] = XPVString "true"+xstring _ _ [XPVBool False] = XPVString "false" -xstring _ _ [XPVString s] = XPVString s-xstring _ _ [XPVError e] = XPVError e-xstring _ _ _ = XPVError "Call to xstring with a wrong argument"+xstring _ _ [XPVString s] = XPVString s+xstring _ _ [XPVError e] = XPVError e+xstring _ _ _ = XPVError "Call to xstring with a wrong argument" -- ----------------------------------------------------------------------------- -- | -- string concat(string, string, string*): returns the concatenation of its arguments -xconcat :: XFct-xconcat c env args = XPVString (foldr (\ (XPVString s) -> (s ++)) "" (toXValue xstring c env args))+xconcat :: XFct+xconcat c env args = XPVString (foldr (\ (XPVString s) -> (s ++)) "" (toXValue xstring c env args)) -- ----------------------------------------------------------------------------- -- |--- boolean starts-with(string, string): --- returns true if the first argument string starts +-- boolean starts-with(string, string):+-- returns true if the first argument string starts -- with the second argument string, and otherwise returns false -xstartsWith :: XFct-xstartsWith c env args = XPVBool $- (\ ((XPVString a):[XPVString b]) -> strStartsWith a b) $- toXValue xstring c env args+xstartsWith :: XFct+xstartsWith c env args = XPVBool $+ (\ ((XPVString a):[XPVString b]) -> strStartsWith a b) $+ toXValue xstring c env args -- ----------------------------------------------------------------------------- -- |@@ -475,139 +478,139 @@ -- returns true if the first argument string contains the second argument string, -- and otherwise returns false -xcontains :: XFct-xcontains c env args = XPVBool $- (\ ((XPVString s):[XPVString sub]) -> getFirstPos s sub /= -1) $- toXValue xstring c env args+xcontains :: XFct+xcontains c env args = XPVBool $+ (\ ((XPVString s):[XPVString sub]) -> getFirstPos s sub /= -1) $+ toXValue xstring c env args -- ----------------------------------------------------------------------------- -- | -- string substring-before(string, string): -- returns the substring of the first argument string that precedes the first occurrence of--- the second argument string +-- the second argument string -- in the first argument string, or the empty string if the first argument string does not -- contain the second argument string -xsubstringBefore :: XFct-xsubstringBefore c env args = xsubstringBefore' c env (toXValue xstring c env args)+xsubstringBefore :: XFct+xsubstringBefore c env args = xsubstringBefore' c env (toXValue xstring c env args) -xsubstringBefore' :: XFct-xsubstringBefore' _ _ ((XPVString _):[XPVString []]) = XPVString ""-xsubstringBefore' _ _ ((XPVString s):[XPVString sub]) = XPVString (take (getFirstPos s sub) s)-xsubstringBefore' _ _ _ = XPVError "Call to xsubstringBefore' with a wrong argument"+xsubstringBefore' :: XFct+xsubstringBefore' _ _ ((XPVString _):[XPVString []]) = XPVString ""+xsubstringBefore' _ _ ((XPVString s):[XPVString sub]) = XPVString (take (getFirstPos s sub) s)+xsubstringBefore' _ _ _ = XPVError "Call to xsubstringBefore' with a wrong argument" -- ----------------------------------------------------------------------------- -- | -- string substring-after(string, string): -- returns the substring of the first argument string that follows the first occurrence of--- the second argument string +-- the second argument string -- in the first argument string, or the empty string if the first argument string does not -- contain the second argument string -xsubstringAfter :: XFct-xsubstringAfter c env args = xsubstringAfter' c env (toXValue xstring c env args)+xsubstringAfter :: XFct+xsubstringAfter c env args = xsubstringAfter' c env (toXValue xstring c env args) -xsubstringAfter' :: XFct-xsubstringAfter' _ _ ((XPVString s):[XPVString []]) = XPVString s-xsubstringAfter' _ _ ((XPVString s):[XPVString sub]) = if getFirstPos s sub == -1- then (XPVString "")- else XPVString (drop ((getFirstPos s sub)+length sub) s)-xsubstringAfter' _ _ _ = XPVError "Call to xsubstringAfter' with a wrong argument"+xsubstringAfter' :: XFct+xsubstringAfter' _ _ ((XPVString s):[XPVString []]) = XPVString s+xsubstringAfter' _ _ ((XPVString s):[XPVString sub]) = if getFirstPos s sub == -1+ then (XPVString "")+ else XPVString (drop ((getFirstPos s sub)+length sub) s)+xsubstringAfter' _ _ _ = XPVError "Call to xsubstringAfter' with a wrong argument" -- ----------------------------------------------------------------------------- -- | -- string substring(string, number, number?): -- returns the substring of the first argument starting at the position specified--- in the second argument +-- in the second argument -- with length specified in the third argument. If the third argument is not specified,--- it returns the substring +-- it returns the substring -- starting at the position specified in the second argument and continuing to the end of the string. -xsubstring :: XFct-xsubstring c env (x:xs) = xsubstring' c env ((toXValue xstring c env [x])++(toXValue xnumber c env xs))-xsubstring _ _ _ = XPVError "Call to xsubstring with a wrong argument"+xsubstring :: XFct+xsubstring c env (x:xs) = xsubstring' c env ((toXValue xstring c env [x])++(toXValue xnumber c env xs))+xsubstring _ _ _ = XPVError "Call to xsubstring with a wrong argument" -xsubstring' :: XFct+xsubstring' :: XFct xsubstring' c env ((XPVString s):start:[])- = case xround c env [start] of- XPVNumber NaN -> XPVString ""- XPVNumber PosInf -> XPVString ""- XPVNumber (Float f) -> XPVString (drop ((round f)-1) s)- XPVNumber _ -> XPVString s- _ -> XPVError "Call to xsubstring' with a wrong argument"+ = case xround c env [start] of+ XPVNumber NaN -> XPVString ""+ XPVNumber PosInf -> XPVString ""+ XPVNumber (Float f) -> XPVString (drop ((round f)-1) s)+ XPVNumber _ -> XPVString s+ _ -> XPVError "Call to xsubstring' with a wrong argument" xsubstring' c env ((XPVString s):start:[end])- = case xPathAdd Plus (xround c env [start]) (xround c env [end]) of- XPVNumber (Float f) -> xsubstring' c env ( (XPVString (take ((round f) -1) s)):[start])- XPVNumber PosInf -> xsubstring' c env ( (XPVString s):[start])- XPVNumber _ -> XPVString ""- _ -> XPVError "Call to xsubstring' with a wrong argument"-xsubstring' _ _ _ = XPVError "Call to xsubstring' with a wrong argument"+ = case xPathAdd Plus (xround c env [start]) (xround c env [end]) of+ XPVNumber (Float f) -> xsubstring' c env ( (XPVString (take ((round f) -1) s)):[start])+ XPVNumber PosInf -> xsubstring' c env ( (XPVString s):[start])+ XPVNumber _ -> XPVString ""+ _ -> XPVError "Call to xsubstring' with a wrong argument"+xsubstring' _ _ _ = XPVError "Call to xsubstring' with a wrong argument" -- ----------------------------------------------------------------------------- -- | -- number string-length(string?): -- returns the number of characters in the string. If the argument is omitted,--- it defaults to the context node +-- it defaults to the context node -- converted to a string, in other words the string-value of the context node. -xstringLength :: XFct-xstringLength c@(_, _, cn) env [] = XPVNumber (Float (fromIntegral $ length s))- where- XPVString s = xstring c env [XPVNode $ singletonNodeSet cn]+xstringLength :: XFct+xstringLength c@(_, _, cn) env [] = XPVNumber (Float (fromIntegral $ length s))+ where+ XPVString s = xstring c env [XPVNode $ singletonNodeSet cn] -xstringLength c env args = XPVNumber $- (\[XPVString s] -> int2XPNumber $ length s) $- toXValue xstring c env args+xstringLength c env args = XPVNumber $+ (\[XPVString s] -> int2XPNumber $ length s) $+ toXValue xstring c env args -- ----------------------------------------------------------------------------- -- | -- string normalize-space(string?): -- returns the argument string with whitespace normalized by stripping leading--- and trailing whitespace and replacing sequences +-- and trailing whitespace and replacing sequences -- of whitespace characters by a single space. If the argument is omitted,--- it defaults to the context node converted to a string, +-- it defaults to the context node converted to a string, -- in other words the string-value of the context node. -- The string is parsed by a function parseStr from XPathParser module. <-- No longer! Tim Walkenhorst -xnormalizeSpace :: XFct-xnormalizeSpace c@(_, _, cn) env [] = (\ (XPVString s) -> XPVString $ normStr s) $- xstring c env [XPVNode $ singletonNodeSet cn]-xnormalizeSpace c env args = (\ [XPVString s] -> XPVString $ normStr s) $- toXValue xstring c env args+xnormalizeSpace :: XFct+xnormalizeSpace c@(_, _, cn) env [] = (\ (XPVString s) -> XPVString $ normStr s) $+ xstring c env [XPVNode $ singletonNodeSet cn]+xnormalizeSpace c env args = (\ [XPVString s] -> XPVString $ normStr s) $+ toXValue xstring c env args -- Tim Walkenhorst normStr replaces the use of parseStr...-normStr :: String -> String-normStr = unwords . words+normStr :: String -> String+normStr = unwords . words -- ----------------------------------------------------------------------------- -- | -- string translate(string, string, string):--- returns the first argument string with occurrences of characters in the second argument string replaced by the character at +-- returns the first argument string with occurrences of characters in the second argument string replaced by the character at -- the corresponding position in the third argument string -xtranslate :: XFct-xtranslate c env args = xtranslate' c env (toXValue xstring c env args)+xtranslate :: XFct+xtranslate c env args = xtranslate' c env (toXValue xstring c env args) -xtranslate' :: XFct+xtranslate' :: XFct xtranslate' _ _ ((XPVString a):(XPVString b):[XPVString c])- = XPVString (replace a b c)-xtranslate' _ _ _ = XPVError "Call to xtranslate' with a wrong argument"+ = XPVString (replace a b c)+xtranslate' _ _ _ = XPVError "Call to xtranslate' with a wrong argument" -replace :: String -> String -> String -> String-replace str [] _ = str+replace :: String -> String -> String -> String+replace str [] _ = str -- remove all characters, if there is no corresponding character in the third argument-replace str (x:xs) [] = replace [ s | s <- str, x /= s] xs []+replace str (x:xs) [] = replace [ s | s <- str, x /= s] xs [] -replace str (x:xs) (y:ys) = replace (rep x y str) xs ys- where -- replace all characters in the first argument- rep :: Char -> Char -> String -> String- rep a b = foldr (\c -> if c == a then (b:) else (c:)) ""+replace str (x:xs) (y:ys) = replace (rep x y str) xs ys+ where -- replace all characters in the first argument+ rep :: Char -> Char -> String -> String+ rep a b = foldr (\c -> if c == a then (b:) else (c:)) "" -- ------------------------------------------------------------ -- boolean functions@@ -615,45 +618,45 @@ -- | -- boolean boolean(object): converts its argument to a boolean value -xboolean :: XFct-xboolean _ _ [XPVNumber a] = XPVBool (a/= NaN && a/= Neg0 && a/= Pos0)-xboolean _ _ [XPVString s] = XPVBool (length s /= 0)-xboolean _ _ [XPVBool b] = XPVBool b-xboolean _ _ [XPVNode ns] = XPVBool (not . nullNodeSet $ ns)-xboolean _ _ [XPVError e] = XPVError e-xboolean _ _ _ = XPVError "Call to xboolean with a wrong argument"+xboolean :: XFct+xboolean _ _ [XPVNumber a] = XPVBool (a/= NaN && a/= Neg0 && a/= Pos0)+xboolean _ _ [XPVString s] = XPVBool (length s /= 0)+xboolean _ _ [XPVBool b] = XPVBool b+xboolean _ _ [XPVNode ns] = XPVBool (not . nullNodeSet $ ns)+xboolean _ _ [XPVError e] = XPVError e+xboolean _ _ _ = XPVError "Call to xboolean with a wrong argument" -- ----------------------------------------------------------------------------- -- | -- boolean not(boolean): returns true if its argument is false, and false otherwise-xnot :: XFct-xnot c env args = XPVBool ( (\ (XPVBool b) -> not b) (xboolean c env args) )+xnot :: XFct+xnot c env args = XPVBool ( (\ (XPVBool b) -> not b) (xboolean c env args) ) -- ----------------------------------------------------------------------------- -- | -- boolean true(): returns true-xtrue :: XFct-xtrue _ _ _ = XPVBool True+xtrue :: XFct+xtrue _ _ _ = XPVBool True -- ----------------------------------------------------------------------------- -- | -- boolean false(): returns false-xfalse :: XFct-xfalse _ _ _ = XPVBool False+xfalse :: XFct+xfalse _ _ _ = XPVBool False -- ----------------------------------------------------------------------------- -- | -- boolean lang(string):--- returns true or false depending on whether the language of the context node as specified by xml:lang attributes +-- returns true or false depending on whether the language of the context node as specified by xml:lang attributes -- is the same as or is a sublanguage of the language specified by the argument string -- ----------------------------------------------------------------------------- -- -- function needs namespaces which are not supported by the toolbox (???) -xlang :: XFct-xlang _ _ _ = XPVError "namespaces are not supported"+xlang :: XFct+xlang _ _ _ = XPVError "namespaces are not supported" -- xlang c env args -- = (\ (_, _, cn) [XPVString s] -> ...) c (toXValue xstring c env args)@@ -663,84 +666,84 @@ -- | -- number number(object?): converts its argument to a number-xnumber :: XFct-xnumber c@(_, _, cn) env [] = (\ (XPVString s) -> parseNumber s) (xstring c env [XPVNode $ singletonNodeSet cn])-xnumber c env [n@(XPVNode _)] = (\ (XPVString s) -> parseNumber s) (xstring c env [n])+xnumber :: XFct+xnumber c@(_, _, cn) env [] = (\ (XPVString s) -> parseNumber s) (xstring c env [XPVNode $ singletonNodeSet cn])+xnumber c env [n@(XPVNode _)] = (\ (XPVString s) -> parseNumber s) (xstring c env [n]) xnumber _ _ [XPVBool b]- | b = XPVNumber (Float 1)- | otherwise = XPVNumber Pos0+ | b = XPVNumber (Float 1)+ | otherwise = XPVNumber Pos0 -xnumber _ _ [XPVString s] = parseNumber s-xnumber _ _ [XPVNumber a] = XPVNumber a-xnumber _ _ [XPVError e] = XPVError e-xnumber _ _ _ = XPVError "Call to xnumber with a wrong argument"+xnumber _ _ [XPVString s] = parseNumber s+xnumber _ _ [XPVNumber a] = XPVNumber a+xnumber _ _ [XPVError e] = XPVError e+xnumber _ _ _ = XPVError "Call to xnumber with a wrong argument" -- ----------------------------------------------------------------------------- -- |--- number sum(node-set): --- returns the sum, for each node in the argument node-set, of the result of +-- number sum(node-set):+-- returns the sum, for each node in the argument node-set, of the result of -- converting the string-values of the node to a number -xsum :: XFct+xsum :: XFct xsum c env [XPVNode ns]- | nullNodeSet ns = XPVNumber NaN- | otherwise = foldr1 (\ a b -> (xPathAdd Plus a b)) (getValues ns)+ | nullNodeSet ns = XPVNumber NaN+ | otherwise = foldr1 (\ a b -> (xPathAdd Plus a b)) (getValues ns) where- getValues :: NodeSet -> [XPathValue]- getValues = foldr (\ n -> ([xnumber c env $ [stringValue n] ] ++) ) [] . fromNodeSet+ getValues :: NodeSet -> [XPathValue]+ getValues = foldr (\ n -> ([xnumber c env $ [stringValue n] ] ++) ) [] . fromNodeSet -xsum _ _ _ = XPVError "The value of the function sum is not a nodeset"+xsum _ _ _ = XPVError "The value of the function sum is not a nodeset" -- ----------------------------------------------------------------------------- -- |--- number floor(number): returns the largest (closest to positive infinity) number that is not greater +-- number floor(number): returns the largest (closest to positive infinity) number that is not greater -- than the argument and that is an integer -xfloor :: XFct-xfloor c env args = xfloor' (toXValue xnumber c env args)+xfloor :: XFct+xfloor c env args = xfloor' (toXValue xnumber c env args) where xfloor' [XPVNumber (Float f)]- | f > 0 && f < 1 = XPVNumber Pos0- | otherwise = XPVNumber (Float (fromInteger $ floor f))- xfloor' [XPVNumber a] = XPVNumber a- xfloor' _ = XPVError "Call to xfloor' without a number"+ | f > 0 && f < 1 = XPVNumber Pos0+ | otherwise = XPVNumber (Float (fromInteger $ floor f))+ xfloor' [XPVNumber a] = XPVNumber a+ xfloor' _ = XPVError "Call to xfloor' without a number" -- ----------------------------------------------------------------------------- -- |--- number ceiling(number): returns the smallest (closest to negative infinity) number that is not less +-- number ceiling(number): returns the smallest (closest to negative infinity) number that is not less -- than the argument and that is an integer -xceiling :: XFct-xceiling c env args = xceiling' (toXValue xnumber c env args)+xceiling :: XFct+xceiling c env args = xceiling' (toXValue xnumber c env args) where xceiling' [XPVNumber (Float f)]- | f < 0 && f > -1 = XPVNumber Pos0- | otherwise = XPVNumber (Float (fromInteger $ ceiling f))- xceiling' [XPVNumber a] = XPVNumber a- xceiling' _ = XPVError "Call to xceiling' without a number"+ | f < 0 && f > -1 = XPVNumber Pos0+ | otherwise = XPVNumber (Float (fromInteger $ ceiling f))+ xceiling' [XPVNumber a] = XPVNumber a+ xceiling' _ = XPVError "Call to xceiling' without a number" -- ----------------------------------------------------------------------------- -- | -- number round(number):--- returns the number that is closest to the argument and that is an integer. +-- returns the number that is closest to the argument and that is an integer. -- If there are two such numbers, then the one that is closest to positive infinity is returned. -xround :: XFct-xround c env args = xround' c env (toXValue xnumber c env args)+xround :: XFct+xround c env args = xround' c env (toXValue xnumber c env args) -xround' :: XFct+xround' :: XFct xround' _ _ [XPVNumber (Float f)]- | f < 0 && f >= -0.5 = XPVNumber Neg0- | f >= 0 && f < 0.5 = XPVNumber Pos0- | otherwise = XPVNumber (Float (fromInteger $ xPathRound f))+ | f < 0 && f >= -0.5 = XPVNumber Neg0+ | f >= 0 && f < 0.5 = XPVNumber Pos0+ | otherwise = XPVNumber (Float (fromInteger $ xPathRound f)) where- xPathRound a = if a - (fromInteger $ floor a) < 0.5- then floor a- else floor (a+1)+ xPathRound a = if a - (fromInteger $ floor a) < 0.5+ then floor a+ else floor (a+1) -xround' _ _ [XPVNumber a] = XPVNumber a-xround' _ _ _ = XPVError "Call to xround' without a number"+xround' _ _ [XPVNumber a] = XPVNumber a+xround' _ _ _ = XPVError "Call to xround' without a number" -- ----------------------------------------------------------------------------- -- |@@ -751,38 +754,38 @@ -- union of the result of applying the key function to the string value -- of each of the nodes in the argument node-set. -- When the second argument is of any other type, the argument is--- converted to a string -xkey :: XFct+-- converted to a string+xkey :: XFct xkey _ env ((XPVString s) : [XPVNode ns])- = isInKey (getKeyTab env) s (strValues . fromNodeSet $ ns)+ = isInKey (getKeyTab env) s (strValues . fromNodeSet $ ns) where- strValues = map ((\ (XPVString str) -> str) . stringValue)+ strValues = map ((\ (XPVString str) -> str) . stringValue) -xkey c env ((XPVString s) : arg) -- = isInKey (getKeyTab env) s ( (\(XPVString s) -> words s) (xstring c env arg))- = isInKey (getKeyTab env) s [str]- where- XPVString str = xstring c env arg+xkey c env ((XPVString s) : arg) -- = isInKey (getKeyTab env) s ( (\(XPVString s) -> words s) (xstring c env arg))+ = isInKey (getKeyTab env) s [str]+ where+ XPVString str = xstring c env arg -xkey _ _ _ = XPVError "Call to xkey with a wrong argument"+xkey _ _ _ = XPVError "Call to xkey with a wrong argument" -isInKey :: KeyTab -> String -> [String] -> XPathValue-isInKey kt kn kv = XPVNode . toNodeSet $ ts+isInKey :: KeyTab -> String -> [String] -> XPathValue+isInKey kt kn kv = XPVNode . toNodeSet $ ts where- (_, _, ts) = unzip3 $ concat $ map (isKeyVal (isKeyName kt kn)) kv+ (_, _, ts) = unzip3 $ concat $ map (isKeyVal (isKeyName kt kn)) kv -isKeyName :: KeyTab -> String -> KeyTab-isKeyName kt kn = filter (isOfKeyName kn) kt+isKeyName :: KeyTab -> String -> KeyTab+isKeyName kt kn = filter (isOfKeyName kn) kt -isKeyVal :: KeyTab -> String -> KeyTab-isKeyVal kt kv = filter (isOfKeyValue kv) kt+isKeyVal :: KeyTab -> String -> KeyTab+isKeyVal kt kv = filter (isOfKeyValue kv) kt -isOfKeyName :: String -> (QName, String, NavXmlTree) -> Bool-isOfKeyName kn (qn, _, _) = localPart qn == kn+isOfKeyName :: String -> (QName, String, NavXmlTree) -> Bool+isOfKeyName kn (qn, _, _) = localPart qn == kn -isOfKeyValue :: String -> (QName, String, NavXmlTree) -> Bool-isOfKeyValue kv (_, v, _) = v == kv+isOfKeyValue :: String -> (QName, String, NavXmlTree) -> Bool+isOfKeyValue kv (_, v, _) = v == kv -- -----------------------------------------------------------------------------@@ -792,48 +795,48 @@ -- specified by the second argument and the decimal-format named by the -- third argument, or the default decimal-format, if there is no third argument -xformatNumber :: XFct-xformatNumber c env (x:xs) = xsubstring' c env (toXValue xstring c env [x] ++ toXValue xnumber c env xs)-xformatNumber _ _ _ = XPVError "Call to xformatNumber with a wrong argument"+xformatNumber :: XFct+xformatNumber c env (x:xs) = xsubstring' c env (toXValue xstring c env [x] ++ toXValue xnumber c env xs)+xformatNumber _ _ _ = XPVError "Call to xformatNumber with a wrong argument" -- ----------------------------------------------------------------------------- --- Poor man's document(...) function. Opens exactly one document. +-- Poor man's document(...) function. Opens exactly one document. -- Does not support "fragment identifiers". "Base-URI" is always current directory. -- Should still be good enough for home use. -xdocument :: XFct-xdocument c e val = XPVNode . toNodeSet . (\ (XPVString s) -> xdocument' s) . xstring c e $ val+xdocument :: XFct+xdocument c e val = XPVNode . toNodeSet . (\ (XPVString s) -> xdocument' s) . xstring c e $ val -xdocument' :: String -> [NavXmlTree]-xdocument' uri = map ntree $- unsafePerformIO $- runX ( readDocument [(a_validate, v_0)] uri- >>>- addAttr "rootId" ("doc " ++ uri)- )+xdocument' :: String -> [NavXmlTree]+xdocument' uri = map ntree $+ unsafePerformIO $+ runX ( readDocument [withValidate no] uri+ >>>+ addAttr "rootId" ("doc " ++ uri)+ ) -- ----------------------------------------------------------------------------- -- generate-id, should be fully compliant with XSLT specification. -xgenerateId :: XFct+xgenerateId :: XFct xgenerateId _ _ [XPVNode ns]- | not (nullNodeSet ns) = xgenerateId' . headNodeSet $ ns+ | not (nullNodeSet ns) = xgenerateId' . headNodeSet $ ns xgenerateId (_, _, node) _ [] = xgenerateId' node xgenerateId _ _ _ = error "illegal arguments in xgenerateId" -xgenerateId' :: NavXmlTree -> XPathValue-xgenerateId' = XPVString . ("id_"++) . str2XmlId . show . nodeID . Just+xgenerateId' :: NavXmlTree -> XPathValue+xgenerateId' = XPVString . ("id_"++) . str2XmlId . show . nodeID . Just -str2XmlId :: String -> String-str2XmlId = concatMap convert+str2XmlId :: String -> String+str2XmlId = concatMap convert where- convert c = if isAscii c && (isUpper c || isLower c || isDigit c)- then [c]- else "_" ++ (show $ ord c) ++ "_"+ convert c = if isAscii c && (isUpper c || isLower c || isDigit c)+ then [c]+ else "_" ++ (show $ ord c) ++ "_" -- ------------------------------------------------------------ @@ -842,23 +845,23 @@ = concat . runLA ( ifA isRoot- (constA "")- getNp- )+ (constA "")+ getNp+ ) -xpLocalPartOf :: XmlTree -> String-xpLocalPartOf = xpNamePart getLocalPart+xpLocalPartOf :: XmlTree -> String+xpLocalPartOf = xpNamePart getLocalPart -xpNamespaceOf :: XmlTree -> String-xpNamespaceOf = xpNamePart getNamespaceUri+xpNamespaceOf :: XmlTree -> String+xpNamespaceOf = xpNamePart getNamespaceUri -xpNameOf :: XmlTree -> String-xpNameOf = xpNamePart getName+xpNameOf :: XmlTree -> String+xpNameOf = xpNamePart getName -getValue :: String -> XmlTree -> String-getValue n = concat . runLA (getAttrValue n)+getValue :: String -> XmlTree -> String+getValue n = concat . runLA (getAttrValue n) -xpTextOf :: XmlTree -> String-xpTextOf = concat . runLA (xshow ((getCmt >>> mkText) <+> deep isText))+xpTextOf :: XmlTree -> String+xpTextOf = concat . runLA (xshow ((getCmt >>> mkText) <+> deep isText)) -- ------------------------------------------------------------
src/Text/XML/HXT/XPath/XPathKeywords.hs view
@@ -1,10 +1,19 @@--- |--- $Id: XPathKeywords.hs,v 1.1 2004/09/02 19:12:05 hxml Exp $------ the XPath keywords---+-- ------------------------------------------------------------ +{- |+ Module : Text.XML.HXT.XPath.XPathKeywords+ Copyright : Copyright (C) 2010 Uwe Schmidt+ License : MIT + Maintainer : Uwe Schmidt (uwe@fh-wedel.de)+ Stability : experimental+ Portability: portable++ xpath keywords+-}++-- ------------------------------------------------------------+ module Text.XML.HXT.XPath.XPathKeywords where @@ -12,7 +21,7 @@ -- -- string constants for representing XPath keywords and axis -a_ancestor, -- axisNames+a_ancestor, -- axisNames a_ancestor_or_self, a_attribute, a_child,@@ -24,34 +33,34 @@ a_parent, a_preceding, a_preceding_sibling,- a_self :: String+ a_self :: String -n_comment, -- nodeTypes+n_comment, -- nodeTypes n_text, n_processing_instruction,- n_node :: String+ n_node :: String -- ------------------------------------------------------------ -a_ancestor = "ancestor" -a_ancestor_or_self = "ancestor-or-self" -a_attribute = "attribute" -a_child = "child" -a_descendant = "descendant" -a_descendant_or_self = "descendant-or-self" -a_following = "following" -a_following_sibling = "following-sibling" -a_namespace = "namespace" -a_parent = "parent" -a_preceding = "preceding" -a_preceding_sibling = "preceding-sibling" -a_self = "self" +a_ancestor = "ancestor"+a_ancestor_or_self = "ancestor-or-self"+a_attribute = "attribute"+a_child = "child"+a_descendant = "descendant"+a_descendant_or_self = "descendant-or-self"+a_following = "following"+a_following_sibling = "following-sibling"+a_namespace = "namespace"+a_parent = "parent"+a_preceding = "preceding"+a_preceding_sibling = "preceding-sibling"+a_self = "self" -n_comment = "comment"-n_text = "text"-n_processing_instruction = "processing-instruction"-n_node = "node"+n_comment = "comment"+n_text = "text"+n_processing_instruction = "processing-instruction"+n_node = "node" -- ------------------------------------------------------------
src/Text/XML/HXT/XPath/XPathParser.hs view
@@ -28,7 +28,7 @@ import Text.XML.HXT.XPath.XPathKeywords import Text.XML.HXT.XPath.XPathDataTypes -import Text.XML.HXT.Parser.XmlTokenParser ( separator+import Text.XML.HXT.Parser.XmlTokenParser ( separator , systemLiteral , skipS0 , ncName@@ -37,28 +37,28 @@ -- ------------------------------------------------------------ -lookupNs :: NsEnv -> XName -> Maybe XName+lookupNs :: NsEnv -> XName -> Maybe XName lookupNs uris prefix- | null uris = Just nullXName -- not namespace aware XPath- | isNullXName prefix = maybe (Just nullXName) Just $ -- no default namespace given+ | null uris = Just nullXName -- not namespace aware XPath+ | isNullXName prefix = maybe (Just nullXName) Just $ -- no default namespace given lookup prefix uris- | otherwise = lookup prefix uris -- namespace aware+ | otherwise = lookup prefix uris -- namespace aware -enhanceAttrQName :: NsEnv -> QName -> Maybe QName+enhanceAttrQName :: NsEnv -> QName -> Maybe QName enhanceAttrQName uris qn- | isNullXName (namePrefix' qn) = Just qn- | otherwise = enhanceQName uris qn+ | isNullXName (namePrefix' qn) = Just qn+ | otherwise = enhanceQName uris qn -enhanceQName :: NsEnv -> QName -> Maybe QName-enhanceQName uris qn = do- nsu <- lookupNs uris (namePrefix' qn)+enhanceQName :: NsEnv -> QName -> Maybe QName+enhanceQName uris qn = do+ nsu <- lookupNs uris (namePrefix' qn) return $ setNamespaceUri' nsu qn -enhanceQN :: AxisSpec -> NsEnv -> QName -> Maybe QName-enhanceQN Attribute = enhanceAttrQName-enhanceQN _ = enhanceQName+enhanceQN :: AxisSpec -> NsEnv -> QName -> Maybe QName+enhanceQN Attribute = enhanceAttrQName+enhanceQN _ = enhanceQName -type XParser a = GenParser Char NsEnv a+type XParser a = GenParser Char NsEnv a -- ------------------------------------------------------------ -- parse functions which are used in the XPathFct module@@ -105,7 +105,7 @@ -- some useful token and symbol parser-lpar, rpar, lbra, rbra, slash, dslash :: XParser ()+lpar, rpar, lbra, rbra, slash, dslash :: XParser () lpar = tokenParser (symbol "(") rpar = tokenParser (symbol ")")@@ -140,11 +140,11 @@ orOp, andOp, eqOp, relOp, addOp, multiOp, unionOp :: XParser Op orOp = symbolParser ("or", Or)-andOp = symbolParser ("and", And)+andOp = symbolParser ("and", And) eqOp = symbolParser ("=", Eq)- <|> + <|> symbolParser ("!=", NEq) relOp@@ -156,7 +156,7 @@ addOp = symbolParser ("+", Plus)- <|> + <|> symbolParser ("-", Minus) @@ -167,19 +167,19 @@ ] -unionOp = symbolParser ("|", Union)+unionOp = symbolParser ("|", Union) -- ------------------------------------------------------------ mkExprNode :: Expr -> [(Op, Expr)] -> Expr mkExprNode e1 [] = e1-mkExprNode e1 l@((op, _): _) = +mkExprNode e1 l@((op, _): _) = if null rest then GenExpr op (e1:(map snd l)) else GenExpr op $ (e1:(map snd $ init same)) ++ [mkExprNode (snd $ last same) rest]- where + where (same, rest) = span ((==op) . fst) l- + -- Tim Walkenhorst, original expr. below: -- It seems mkExprNode is called only with operators of the same precedence, that should make it fixable -- FIXED, see above!@@ -200,18 +200,18 @@ -- ------------------------------------------------------------ -- abbreviation of "//"-descOrSelfStep :: XStep +descOrSelfStep :: XStep descOrSelfStep = (Step DescendantOrSelf (TypeTest XPNode) []) -- ------------------------------------------------------------ -- Location Paths (2) --- [1] LocationPath +-- [1] LocationPath locPath :: XParser LocationPath locPath = absLocPath- <|> + <|> relLocPath' @@ -222,7 +222,7 @@ dslash s <- relLocPath return (LocPath Abs ([descOrSelfStep] ++ s))- <|> + <|> do slash s <- option [] relLocPath@@ -346,7 +346,7 @@ -- [8] Predicate -- [9] PredicateExpr predicate :: XParser Expr-predicate +predicate = do ex <- between lbra rbra expr return ex@@ -359,7 +359,7 @@ -- [12] AbbreviatedStep abbrStep :: XParser XStep-abbrStep +abbrStep = do tokenParser (symbol "..") return (Step Parent (TypeTest XPNode) [])@@ -397,7 +397,7 @@ do li <- literal return (LiteralExpr li)- <|> + <|> do num <- number return (NumberExpr (Float $ read num))@@ -579,7 +579,7 @@ -- Change in String encoding for function name -- -- previoulsy: new:--- +-- -- name name -- pref:name {http://uri-for-pref}name @@ -621,7 +621,7 @@ enhanceName axs $ mkPrefixLocalPart pre local <?> "nameTest" -enhanceName :: AxisSpec -> QName -> XParser QName+enhanceName :: AxisSpec -> QName -> XParser QName enhanceName axs qn = do uris <- getState case enhanceQN axs uris qn of@@ -631,16 +631,16 @@ -- [38] NodeType nodeType' :: XParser XPathNode-nodeType' +nodeType' = do nt <- nodeType lpar rpar return nt <?> "nodeType'"- + nodeType :: XParser XPathNode-nodeType +nodeType = choice [ symbolParser (n_comment, XPCommentNode) , symbolParser (n_text, XPTextNode) , symbolParser (n_processing_instruction, XPPINode)
src/Text/XML/HXT/XPath/XPathToNodeSet.hs view
@@ -19,49 +19,49 @@ -- The XmlNodeSet can be used to traverse a tree an process all -- marked nodes. -xPValue2XmlNodeSet :: XPathValue -> XmlNodeSet-xPValue2XmlNodeSet (XPVNode ns) = toNodeSet' ns+xPValue2XmlNodeSet :: XPathValue -> XmlNodeSet+xPValue2XmlNodeSet (XPVNode ns) = toNodeSet' ns -xPValue2XmlNodeSet _ = emptyXmlNodeSet+xPValue2XmlNodeSet _ = emptyXmlNodeSet -emptyXmlNodeSet :: XmlNodeSet-emptyXmlNodeSet = XNS False [] []+emptyXmlNodeSet :: XmlNodeSet+emptyXmlNodeSet = XNS False [] [] -leafNodeSet :: XmlNodeSet-leafNodeSet = XNS True [] []+leafNodeSet :: XmlNodeSet+leafNodeSet = XNS True [] [] -toNodeSet' :: NodeSet -> XmlNodeSet-toNodeSet' = pathListToNodeSet . map toPath . fromNodeSet+toNodeSet' :: NodeSet -> XmlNodeSet+toNodeSet' = pathListToNodeSet . map toPath . fromNodeSet -toPath :: NavXmlTree -> XmlNodeSet-toPath = upTree leafNodeSet+toPath :: NavXmlTree -> XmlNodeSet+toPath = upTree leafNodeSet -upTree :: XmlNodeSet -> NavXmlTree -> XmlNodeSet-upTree ps (NT _ _ [] _ _) = ps -- root node reached+upTree :: XmlNodeSet -> NavXmlTree -> XmlNodeSet+upTree ps (NT _ _ [] _ _) = ps -- root node reached upTree ps (NT (NTree n _)- ix par _left _right) = upTree ps' $ head par+ ix par _left _right) = upTree ps' $ head par where- ps' = pix n+ ps' = pix n - pix (XAttr qn) = XNS False [qn] []- pix _ = XNS False [] [(ix, ps)]+ pix (XAttr qn) = XNS False [qn] []+ pix _ = XNS False [] [(ix, ps)] -pathListToNodeSet ::[XmlNodeSet] -> XmlNodeSet-pathListToNodeSet = foldr mergePaths emptyXmlNodeSet+pathListToNodeSet ::[XmlNodeSet] -> XmlNodeSet+pathListToNodeSet = foldr mergePaths emptyXmlNodeSet where mergePaths (XNS p1 al1 cl1)- (XNS p2 al2 cl2) = XNS (p1 || p2) (al1 ++ al2) (mergeSubPaths cl1 cl2)+ (XNS p2 al2 cl2) = XNS (p1 || p2) (al1 ++ al2) (mergeSubPaths cl1 cl2) - mergeSubPaths [] sp2 = sp2- mergeSubPaths (s1:sp1) sp2 = mergeSubPath s1 (mergeSubPaths sp1 sp2)+ mergeSubPaths [] sp2 = sp2+ mergeSubPaths (s1:sp1) sp2 = mergeSubPath s1 (mergeSubPaths sp1 sp2) - mergeSubPath s1 [] = [s1]+ mergeSubPath s1 [] = [s1] mergeSubPath s1@(ix1,p1) sl@(s2@(ix2, p2) : sl')- | ix1 < ix2 = s1 : sl- | ix1 > ix2 = s2 : mergeSubPath s1 sl' -- ordered insert of s1 - | otherwise = (ix1, mergePaths p1 p2) : sl' -- same ix merge subpaths+ | ix1 < ix2 = s1 : sl+ | ix1 > ix2 = s2 : mergeSubPath s1 sl' -- ordered insert of s1+ | otherwise = (ix1, mergePaths p1 p2) : sl' -- same ix merge subpaths -- -----------------------------------------------------------------------------
src/Text/XML/HXT/XPath/XPathToString.hs view
@@ -29,29 +29,29 @@ -- import Text.XML.HXT.DOM.XmlTree import Text.XML.HXT.DOM.Interface-import Text.XML.HXT.DOM.XmlNode ( mkText- , mkError- )-import Text.XML.HXT.DOM.FormatXmlTree ( formatXmlTree )+import Text.XML.HXT.DOM.XmlNode ( mkText+ , mkError+ )+import Text.XML.HXT.DOM.FormatXmlTree ( formatXmlTree ) import Text.XML.HXT.XPath.XPathDataTypes -import Data.Char ( toLower )+import Data.Char ( toLower ) -- ------------------------------------------------------------ -type XPathTree = NTree String+type XPathTree = NTree String -- ----------------------------------------------------------------------------- -- | -- Convert an navigable tree in a xmltree ---toXPathTree :: [NavTree a] -> [NTree a]-toXPathTree = map subtreeNT+toXPathTree :: [NavTree a] -> [NTree a]+toXPathTree = map subtreeNT -- ----------------------------------------------------------------------------- -formatXPathTree :: Expr -> String-formatXPathTree = formatTree id . expr2XPathTree+formatXPathTree :: Expr -> String+formatXPathTree = formatTree id . expr2XPathTree -- ----------------------------------------------------------------------------- -- |@@ -60,31 +60,31 @@ -- all other values are represented as strings. -- -xPValue2String :: XPathValue -> String-xPValue2String (XPVNode ns) = foldr (\ t -> ((formatXmlTree t ++ "\n") ++)) "" (toXPathTree . fromNodeSet $ ns)-xPValue2String (XPVBool b) = map toLower (show b)-xPValue2String (XPVNumber (Float f)) = show f-xPValue2String (XPVNumber s) = show s-xPValue2String (XPVString s) = s-xPValue2String (XPVError s) = "Error: " ++ s+xPValue2String :: XPathValue -> String+xPValue2String (XPVNode ns) = foldr (\ t -> ((formatXmlTree t ++ "\n") ++)) "" (toXPathTree . fromNodeSet $ ns)+xPValue2String (XPVBool b) = map toLower (show b)+xPValue2String (XPVNumber (Float f)) = show f+xPValue2String (XPVNumber s) = show s+xPValue2String (XPVString s) = s+xPValue2String (XPVError s) = "Error: " ++ s -- ----------------------------------------------------------------------------- -- | -- Convert a a XPath-value into XmlTrees. -- -xPValue2XmlTrees :: XPathValue -> XmlTrees-xPValue2XmlTrees (XPVNode ns) = toXPathTree . fromNodeSet $ ns-xPValue2XmlTrees (XPVBool b) = xtext (show b)-xPValue2XmlTrees (XPVNumber (Float f)) = xtext (show f)-xPValue2XmlTrees (XPVNumber s) = xtext (show s)-xPValue2XmlTrees (XPVString s) = xtext s-xPValue2XmlTrees (XPVError s) = xerr s+xPValue2XmlTrees :: XPathValue -> XmlTrees+xPValue2XmlTrees (XPVNode ns) = toXPathTree . fromNodeSet $ ns+xPValue2XmlTrees (XPVBool b) = xtext (show b)+xPValue2XmlTrees (XPVNumber (Float f)) = xtext (show f)+xPValue2XmlTrees (XPVNumber s) = xtext (show s)+xPValue2XmlTrees (XPVString s) = xtext s+xPValue2XmlTrees (XPVError s) = xerr s -xtext, xerr :: String -> XmlTrees-xtext = (:[]) . mkText+xtext, xerr :: String -> XmlTrees+xtext = (:[]) . mkText -xerr = (:[]) . mkError c_err+xerr = (:[]) . mkError c_err -- -----------------------------------------------------------------------------@@ -92,44 +92,44 @@ -- Format a parsed XPath-expression in tree representation. -- Text output is done by 'formatXmlTree' ---expr2XPathTree :: Expr -> XPathTree-expr2XPathTree (GenExpr op ex) = NTree (show op) (map expr2XPathTree ex)-expr2XPathTree (NumberExpr f) = NTree (show f) []-expr2XPathTree (LiteralExpr s) = NTree s []-expr2XPathTree (VarExpr name) = NTree ("Var: " ++ show name) []-expr2XPathTree (FctExpr n arg) = NTree ("Fct: " ++ n) (map expr2XPathTree arg)+expr2XPathTree :: Expr -> XPathTree+expr2XPathTree (GenExpr op ex) = NTree (show op) (map expr2XPathTree ex)+expr2XPathTree (NumberExpr f) = NTree (show f) []+expr2XPathTree (LiteralExpr s) = NTree s []+expr2XPathTree (VarExpr name) = NTree ("Var: " ++ show name) []+expr2XPathTree (FctExpr n arg) = NTree ("Fct: " ++ n) (map expr2XPathTree arg) -expr2XPathTree (FilterExpr []) = NTree "" []+expr2XPathTree (FilterExpr []) = NTree "" [] expr2XPathTree (FilterExpr (primary:predicate))- = NTree "FilterExpr" [expr2XPathTree primary, pred2XPathTree predicate]+ = NTree "FilterExpr" [expr2XPathTree primary, pred2XPathTree predicate] expr2XPathTree (PathExpr Nothing (Just lp))- = locpath2XPathTree lp+ = locpath2XPathTree lp expr2XPathTree (PathExpr (Just fe) (Just lp))- = NTree "PathExpr" [expr2XPathTree fe, locpath2XPathTree lp]-expr2XPathTree (PathExpr _ _) = NTree "" []+ = NTree "PathExpr" [expr2XPathTree fe, locpath2XPathTree lp]+expr2XPathTree (PathExpr _ _) = NTree "" [] -locpath2XPathTree :: LocationPath -> XPathTree-locpath2XPathTree (LocPath rel steps) = NTree (show rel ++ "LocationPath") (map step2XPathTree steps)+locpath2XPathTree :: LocationPath -> XPathTree+locpath2XPathTree (LocPath rel steps) = NTree (show rel ++ "LocationPath") (map step2XPathTree steps) -step2XPathTree :: XStep -> XPathTree-step2XPathTree (Step axis nt []) = NTree (show axis) [nt2XPathTree nt]-step2XPathTree (Step axis nt expr) = NTree (show axis) [nt2XPathTree nt, pred2XPathTree expr]+step2XPathTree :: XStep -> XPathTree+step2XPathTree (Step axis nt []) = NTree (show axis) [nt2XPathTree nt]+step2XPathTree (Step axis nt expr) = NTree (show axis) [nt2XPathTree nt, pred2XPathTree expr] -nt2XPathTree :: NodeTest -> XPathTree-nt2XPathTree (TypeTest s) = NTree ("TypeTest: "++ typeTest2String s) []-nt2XPathTree (PI s) = NTree ("TypeTest: processing-instruction("++ show s ++ ")") []-nt2XPathTree (NameTest s) = NTree ("NameTest: "++ show s) []+nt2XPathTree :: NodeTest -> XPathTree+nt2XPathTree (TypeTest s) = NTree ("TypeTest: "++ typeTest2String s) []+nt2XPathTree (PI s) = NTree ("TypeTest: processing-instruction("++ show s ++ ")") []+nt2XPathTree (NameTest s) = NTree ("NameTest: "++ show s) [] -pred2XPathTree :: [Expr] -> XPathTree-pred2XPathTree exprL = NTree "Predicates" (map expr2XPathTree exprL)+pred2XPathTree :: [Expr] -> XPathTree+pred2XPathTree exprL = NTree "Predicates" (map expr2XPathTree exprL) -typeTest2String :: XPathNode -> String-typeTest2String XPNode = "node()"-typeTest2String XPCommentNode = "comment()"-typeTest2String XPPINode = "processing-instruction()"-typeTest2String XPTextNode = "text()"+typeTest2String :: XPathNode -> String+typeTest2String XPNode = "node()"+typeTest2String XPCommentNode = "comment()"+typeTest2String XPPINode = "processing-instruction()"+typeTest2String XPTextNode = "text()" -- ------------------------------------------------------------