File tree Expand file tree Collapse file tree 2 files changed +44
-10
lines changed
Expand file tree Collapse file tree 2 files changed +44
-10
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,42 @@ evaluate ::
3030evaluate xpath ctxt nsres resType res doc =
3131 evaluateInternal xpath ctxt (toNullable nsres) resType (toNullable res) doc
3232
33+ -- | Convenience function to avoid two funciton calls and possibly mismatched types.
34+ evaluateNumber ::
35+ String
36+ -> Node
37+ -> Maybe NSResolver
38+ -> Maybe XPathResult
39+ -> Document
40+ -> Effect Number
41+ evaluateNumber xpath ctxt nsres res doc = do
42+ xr <- evaluateInternal xpath ctxt (toNullable nsres) RT .number_type (toNullable res) doc
43+ numberValue xr
44+
45+ -- | Convenience function to avoid two funciton calls and possibly mismatched types.
46+ evaluateString ::
47+ String
48+ -> Node
49+ -> Maybe NSResolver
50+ -> Maybe XPathResult
51+ -> Document
52+ -> Effect String
53+ evaluateString xpath ctxt nsres res doc = do
54+ xr <- evaluateInternal xpath ctxt (toNullable nsres) RT .string_type (toNullable res) doc
55+ stringValue xr
56+
57+ -- | Convenience function to avoid two funciton calls and possibly mismatched types.
58+ evaluateBoolean ::
59+ String
60+ -> Node
61+ -> Maybe NSResolver
62+ -> Maybe XPathResult
63+ -> Document
64+ -> Effect Boolean
65+ evaluateBoolean xpath ctxt nsres res doc = do
66+ xr <- evaluateInternal xpath ctxt (toNullable nsres) RT .boolean_type (toNullable res) doc
67+ booleanValue xr
68+
3369foreign import evaluateInternal ::
3470 String
3571 -> Node
@@ -72,7 +108,8 @@ snapshotItem :: XPathResult -> Natural -> Effect (Maybe Node)
72108snapshotItem xpres ix = map toMaybe $
73109 snapshotItemInternal xpres (toNumber $ natToInt $ ix)
74110
75- -- | High level wrapper around `snapshotItem` and `snapshotLength`
111+ -- | High level wrapper around [snapshotItem](#v:snapshotItem)
112+ -- | and [snapshotLength](#v:snapshotLength)
76113-- | that directly returns an `Array` of `Node`s.
77114snapshot :: XPathResult -> Effect (Array Node )
78115snapshot xpres = case snapMay of
Original file line number Diff line number Diff line change @@ -68,15 +68,12 @@ getMetajeloResolver node doc = do
6868 Just ns -> ns
6969
7070mkCdYear :: Document -> Node -> Aff String
71- mkCdYear doc node = liftEffect $ do
72- cdRes <- XP .evaluate
73- " YEAR"
74- node
75- Nothing
76- RT .string_type
77- Nothing
78- doc
79- XP .stringValue cdRes
71+ mkCdYear doc node = liftEffect $ XP .evaluateString
72+ " YEAR"
73+ node
74+ Nothing
75+ Nothing
76+ doc
8077
8178main :: Effect Unit
8279main = runTest do
You can’t perform that action at this time.
0 commit comments