Several namespace declarations are "understood":
xml = http://www.w3.org/XML/1998/namespace
xs = http://www.w3.org/2001/XMLSchema
xsi = http://www.w3.org/2001/XMLSchema-instance
fn = http://www.w3.org/2003/11/xpath-functions
xdt = http://www.w3.org/2003/11/xpath-datatypes
local = http://www.w3.org/2003/11/xquery-local-functions
Customary namespace declarations can be used in element constructors, much as in XSLT. For example,
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:html="http://www.w3.org/1999/xhtml">
<head>
{
let $title := doc('http://www.cafeconleche.org/')//html:title
return $title
}
</head>
</html>
Alternately, you can declare the namespace in the query's prolog, like so:
declare namespace html= "http://www.w3.org/1999/xhtml";
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
{
let $title := doc('http://www.cafeconleche.org/')//html:title
return $title
}
</head>
</html>
Usual rules about the nearest conflicting namespace declaration taking precedence apply
Output:
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Cafe con Leche XML News and Resources</title>
</head>
</html>