Hi Uwe I read your reply multiple times, but I am still confused. I think either I misunderstand you or I did not explain myself properly in the first mail.
> Hi Mads, > > > 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. > > When working with namespaces in XML, the prefixes are not longer significant. > After namespace propagation every name in the XML document is identified > by a qualified name. This is a pair consisting of the namespace URI and the > local part. > The prefixes become irrelevant. This is my point. Prefixes are relevant in the current implementation of HXT. > A namespace aware XPath expression needs a namespace environment, > as given in the example, to construct these qualified names for the names > in the XPath expression. > So the results of both evalXPath calls in your example must be the same. Yes, but in the namespace environment I give to getXPathTreesWithNsEnv I only mention the prefix s, yet I am still able to evaluate the xpath "//soap:Body". Furthermore "//s:body" and "//soap:Body" gives the same results. Why? I think another example will clarify my point. The code: simpleXmlOne, simpleXmlTwo :: String simpleXmlOne = "<a:Foo xmlns:a=\"http://foo.org\"/>" simpleXmlTwo = "<b:Foo xmlns:b=\"http://foo.org\"/>" nsEnv :: [(String, String)] nsEnv = [ ("notFoo" , "http://notfoo.org") ] evalXPath :: String -> [XmlTree] evalXPath xml = runLA ( xread >>> propagateNamespaces >>> getXPathTreesWithNsEnv nsEnv "//a:Foo" ) xml Now notice that simpleXmlOne and simpleXmlTwo are equivalent. Yes, they have a different prefix for "http://foo.org", but the documents means the same. And as you write yourself, "... the prefix is no longer releavant ..." Yet: evalXPath simpleXmlOne /= evalXPath simpleXmlTwo Hope that clarifies things. Regards, Mads
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
