Skip to content

Commit 64dcfc7

Browse files
committed
tests and notes pertaining to xs:boolean vs boolean_type
1 parent f863b51 commit 64dcfc7

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/Web/DOM/XPath.purs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ foreign import numberValue :: XPathResult -> Effect Number
8686

8787
foreign import stringValue :: XPathResult -> Effect String
8888

89+
-- | Not to be confused with retrieving xs:boolean values,
90+
-- | this is to be used with the XPath boolean() function call.
8991
foreign import booleanValue :: XPathResult -> Effect Boolean
9092

9193
foreign import singleNodeValueInternal :: XPathResult -> Effect (Nullable Node)

test/Main.purs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,5 +195,33 @@ main = runTest do
195195
Assert.equal RT.string_type (XP.resultType metajeloIdRes)
196196
Assert.equal "OjlTjf" metajeloId
197197

198+
prod0pol0xpath <- pure $
199+
"/x:record/x:supplementaryProducts/x:supplementaryProduct[1]" <>
200+
"/x:location/x:institutionPolicies/x:institutionPolicy[1]"
201+
202+
mjProd0Pol0Res <- liftEffect $ XP.evaluate
203+
(prod0pol0xpath <> "/x:refPolicy")
204+
metajelo
205+
(Just mjNSresolver)
206+
RT.string_type
207+
Nothing
208+
metajeloDoc
209+
mjProd0Pol0 <- liftEffect $ XP.stringValue mjProd0Pol0Res
210+
tlog $ "got metajelo ref policy " <> mjProd0Pol0
211+
Assert.equal RT.string_type (XP.resultType mjProd0Pol0Res)
212+
Assert.equal "http://skGHargw/" mjProd0Pol0
213+
--
214+
mjProd0Pol0AppliesRes <- liftEffect $ XP.evaluate
215+
(prod0pol0xpath <> "/@appliesToProduct")
216+
metajelo
217+
(Just mjNSresolver)
218+
RT.string_type
219+
Nothing
220+
metajeloDoc
221+
mjProd0Pol0Applies <- liftEffect $ XP.stringValue mjProd0Pol0AppliesRes
222+
tlog $ "got metajelo policy appliesToProduct: " <> (show mjProd0Pol0Applies)
223+
Assert.equal RT.string_type (XP.resultType mjProd0Pol0AppliesRes)
224+
Assert.equal "0" mjProd0Pol0Applies
225+
198226
tlog :: forall a. Show a => a -> Aff Unit
199227
tlog = liftEffect <<< logShow

0 commit comments

Comments
 (0)