[Haskell-cafe] Re: HXT Namespaces and XPath

Mads Lindstrøm mads_lindstroem at yahoo.dk
Wed Apr 7 06:27:42 EDT 2010


Hi Uwe

> Hi Mads,
> 
> > Replying to myself:
> > 
> > > 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"
> 
> this line contains the problem:
> 
> getXPathTreesWithNsEnv assumes, that for all prefixes used in the XPath expr,
> the nsEnv contains an entry. Furthermore the default namespace
> can be given by an entry for the empty prefix "".
> 
> So you'll only get reasonable results, when nsEnv contains at least an entry for "a", e.g.
> 
> nsEnv = [ ("a", "http://x.y"), ... ]
> 
> when you use the XPath expr "//a:Foo".
> 
> You may argue, that in your example, an error should be raised by the XPath parser, instead
> of accepting "//a:Foo". But currently it's assumed, that getXPathTreesWithNsEnv is used
> only in an innocent way.

Yes, that was what I would have expected.

>  
> Cheers,
> 
>   Uwe

/Mads
-------------- 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/20100407/743f270a/attachment.bin


More information about the Haskell-Cafe mailing list