[xquery-talk] XHTML namespace and doc() function

David Sewell dsewell at virginia.edu
Thu Jul 8 14:07:19 PDT 2004


On Wed, 7 Jul 2004, Jason Hunter wrote:

> > 	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.

Thanks, this fix works,

David

-- 
David Sewell, Editorial and Technical Manager
Electronic Imprint, The University of Virginia Press
PO Box 400318, Charlottesville, VA 22904-4318 USA
Courier: 310 Old Ivy Way, Suite 302, Charlottesville VA 22903
Email: dsewell at virginia.edu   Tel: +1 434 924 9973
Web: http://www.ei.virginia.edu/


More information about the talk mailing list