[xquery-talk] Default namespace best practices?

David Sewell dsewell at virginia.edu
Tue Mar 8 13:59:06 PST 2005

A question for people using XQuery to produce XHTML output directly.
Do you declare the XHTML namespace as your query default, i.e.

  declare default element namespace "http://www.w3.org/1999/xhtml";

or do you instead use as the default namespace the primary namespace
used by your data?

I realize that from one point of view it's an arbitrary decision, but
the choice has implications for readability and maintainability of code
in some cases. Also, if the XML documents you're working with are in no
namespace, declaring the XHTML namespace as the default means that you
have no way to address them in path expressions inside element
constructors without using wildcard namespace prefixes:

   <p>{ data($mydoc/*:text/*:body/*:title) }</p>

Any thoughts on pros and cons will be appreciated,


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