Bug #4974

XQuery Update: namespace propagation is not working

Added by Michael Kay 9 months ago. Updated 2 months ago.

In Progress
XQuery Update
Start date:
Due date:
% Done:


Estimated time:
Legacy ID:
Applies to branch:
10, 9.9, trunk
Fix Committed on Branch:
Fixed in Maintenance Release:


XQuery Update test case id-insert-expr-086 is failing on the 11.x branch, and I suspect it probably fails on 10.x as well.

When we add a namespaced attribute p:att to an element E, we are adding a namespace binding for prefix p to element E, but we are not propagating it to descendants of E. In the past, we didn't need to do anything to achieve this propagation, but with namespaces now being held with each element as a NamespaceMap, it needs to be done explicitly.

Related issues

Has duplicate Saxon - Support #5173: Certain XQuery update operations seem to be failing with Saxon 10New2021-11-24

<a title="Actions" class="icon-only icon-actions js-contextmenu" href="#">Actions</a>


#1 Updated by Michael Kay 9 months ago

Also affects test id-rename-expr-033/034

Also id-replace-expr-045

Also mergeUpdates-001

#2 Updated by Michael Kay 9 months ago

I've now run these tests against 10.3 using the 10.x UpdateTestSuiteDriver, and surprisingly the tests appear to succeed.

More careful examination shows that this is a false positive. The comparison of actual results with expected results is actually failing with an IndexOutOfBoundsException, which is being ignored, so the test is reported as a pass when it should have reported a failure.

#3 Updated by Michael Kay 9 months ago

With this bug in UpdateTestSuiteDriver fixed, the following tests now fail on 10.3:


(But not merge-updates-001, so that might be a different problem).

#4 Updated by Michael Kay 9 months ago

When child elements are inserted, the InsertExpression and InsertAction object contain a flag to indicate whether namespace inheritance is in force (in the query static context), and it looks like the logic has been changed for the 10.0 namespace model to reflect this: the instruction ends up calling (or not calling) ((ElementImpl) child).fixupInsertedNamespaces(inherit); to handle the namespace inheritance.

By contrast, InsertAttributeAction has no flag for namespace inheritance. I suspect that under the old namespace model, namespace inheritance was always happening implicitly, and it is now never happening in the case of attribute insertion.

But RenameAction also has no flag for this.

#5 Updated by Michael Kay 9 months ago

So, I've been trying to find out how this ever worked, and I've discovered it never did. Looking back at 9.9, the RenameAction makes no attempt to distinguish between the inherit/no-inherit cases. It always (in effect) does "inherit", and the reason the no-inherit tests appear to work is because of the same bug in the UpdateTestSuiteDriver: the compare() method returns "true" when comparing an empty string with a non-empty string.

#6 Updated by Michael Kay 9 months ago

  • Status changed from New to Resolved
  • Applies to branch 10, 9.9, trunk added
  • Fix Committed on Branch trunk added

I've fixed this in the development (11.x) branch.

I've decided not to fix it for 10.x or earlier releases. The problem has been present for years without anyone noticing, and the fix involves changes to the MutableNodeInfo interface which people might be using, so on balance it's probably better to leave 10.x alone.

#7 Updated by O'Neil Delpratt 4 months ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 10.6 added

Bug fix applied in the Saxon 10.6 maintenance release

Update: no, see comments above, the problem was not fixed in 10.6.

#8 Updated by Michael Kay 2 months ago

  • Status changed from Closed to In Progress

This has now been raised as an external bug on the 10.x branch (see bug #5173) so I am re-opening this as it seems reasonable to fix it on the 10.x branch if possible.

#9 Updated by Michael Kay about 2 months ago

  • Has duplicate Support #5173: Certain XQuery update operations seem to be failing with Saxon 10 added

Please register to edit this issue

Also available in: Atom PDF