[Haskell-cafe] HXT Namespaces and XPath
Mads Lindstrøm
mads_lindstroem at yahoo.dk
Sun Apr 4 14:34:24 EDT 2010
Hi all,
In HXT, namespace prefixes bound by an XML document are valid in the
context of an XPath. How do avoid that?
An example program will clarify:
simpleXml :: String
simpleXml = "<soap:Body xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\"/>"
nsEnv :: [(String, String)]
nsEnv = [ ("s" , "http://www.w3.org/2003/05/soap-envelope") ]
evalXPath :: String -> String -> [XmlTree]
evalXPath xpath xml =
runLA ( xread
>>> propagateNamespaces
>>> getXPathTreesWithNsEnv nsEnv xpath
) xml
Here:
evalXPath "//s:Body" simpleXml ==
evalXPath "//soap:Body" simpleXml
Even though I only mentions the prefix "s" (and not "soap") in the
function nsEnv.
I do not want the XPath to see prefixes declared in the xml-document, as
it means that two semantically similar XML documents can get different
results when applied to the same XPath.
Also, is there any way to get 'getXPathTreesWithNsEnv' to recognize
XPath namespace declarations? I am thinking about declarations like:
declare namespace foobar='http://foobar.org/foobar'
Greetings,
Mads Lindstrøm
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20100404/cb6bb498/attachment.bin
More information about the Haskell-Cafe
mailing list