[xquery-talk] XHTML namespace and doc() function
Jason Hunter
jhunter at xquery.com
Wed Jul 7 15:15:02 PDT 2004
> default element namespace = "http://www.w3.org/1999/xhtml"
>
> <html>
> <head><title>Test</title></head>
> <body>
> { doc("DPM0029.xml")//body//p }
> </body>
> </html>
>
> and discovered the problem that the doc() function here returns null
Are you sure the doc() function is returning the empty sequence?
(There's actually no nulls in XQuery, just empty sequences). You can
check what doc's doing with count(doc("DPM0029.xml")) and see if it
returns 1.
I bet doc() is returning the doc but it's the //body//p that's returning
empty due to namespace mismatches on those path steps. The fix is to
declare the namespace e = "" and use //e:body to look for a body in no
namespace.
BTW, a quick test you can use if you're having namespace problems is to
try //*:body//*:p which matches any namespace. That's probably slower
in production on indexed engines, but good for a quick test.
-jh-
More information about the talk
mailing list