Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#327 Default namespace scope in XQuery

v8.3
closed
Michael Kay
5
2012-10-08
2005-03-10
Michael Kay
No

If a default namespace is defined in an XQuery direct
element constructor (a xmlns="some.uri"), then when the
end tag for the direct element constructor is
encountered, if there is no outer element constructor
with a declaration of the default namespace, the
default namespace is reset to the non-namespace, not to
the default namespace declared in the query prolog.

This only affects the default namespace as used in
element names appearing in path expressions, it does
not affect the default namespace used for constructed
elements.

Source fix: replace the method undeclareNamespace() at
line 391 of net.sf.saxon.query.StaticQueryContext with:

public void undeclareNamespace() {
    ActiveNamespace entry =

(ActiveNamespace)activeNamespaces.pop();
if (entry.prefix.equals("")) {
for (int i=activeNamespaces.size()-1; i>=0;
i--) {
if
(((ActiveNamespace)activeNamespaces.get(i)).prefix.equals(""))
{
defaultElementNamespace =
(short)(((ActiveNamespace)activeNamespaces.get(i)).code
& 0xffff);
return;
}
}
String defaultNS =
(String)passiveNamespaces.get("");
if ("".equals(defaultNS)) {
defaultElementNamespace =
NamespaceConstant.NULL_CODE;
} else {
defaultElementNamespace =
getNamePool().getCodeForURI(defaultNS);
}
}
}

Discussion