Utility functions for XPaths.
recP :: String recP = "record" idP :: String idP = "identifier" recFromRootP :: String recFromRootP = root // recP idFromRootP :: String idFromRootP = recFromRootP // idP -- idFromRootP == "/record/identifier"
This mode of usage is particularly handy when dealing with subtleties sometimes present in XPath evaluation strategies dealing with namespaces. For examples of how this might be used in practice see examples in the tests for purescript-web-dom-xpath
recP :: String recP = "record" idP :: String idP = "identifier" recFromRootP :: String recFromRootP = root /? recP idFromRootP :: String idFromRootP = recFromRootP /? idP -- idFromRootP == "/x:record/x:identifier"
If you want more safety you can use an
XPath newtype like this, instead of
String directly, but so far, I haven't seen any advantage in
standardizing this (open an issue if you have thoughts):
newtype XPath = XPath String derive instance newtypeXPath :: Newtype XPath _
We could also probably go further by typing Attributes vs Non-attribute paths, etc.
bower install purescript-xpath-like
Module documentation is published on Pursuit.
npm run test