Project

Profile

Help

Bug #6033

closed

Invalid warning about field in xs:key

Added by Octavian Nadolu over 1 year ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Schema-Aware processing
Sprint/Milestone:
-
Start date:
2023-05-11
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
11, 12, trunk
Fix Committed on Branch:
11, 12, trunk
Fixed in Maintenance Release:
Platforms:
.NET, Java

Description

When I validate the attached XSD file with Saxon 11.4 I get an warning: "The field expression (t:UnitName) may select no nodes, which would make the instance document invalid"

I think that Saxon should not display this warning.

The attached file is a small example from an Oxygen user that has a bigger schema.


Files

bleep2.xsd (1.76 KB) bleep2.xsd Octavian Nadolu, 2023-05-11 16:06
Actions #1

Updated by Michael Kay over 1 year ago

Yes, you're right.

Actions #2

Updated by Michael Kay over 1 year ago

What's happening here is that that the field expression child::t:UnitName gets rewritten as child::t:UnitName[1]. I'm not sure exactly why that happens but it's not unreasonable. But the computed cardinality of a FirstItemExpression is zero-or-one, even if the base expression has cardinality one-or-more.

However, I've tweaked FirstItemExpression.computeCardinality() to be a bit smarter and the problem remains. That's because the computed cardinality of child::t:UnitName is itself wrong.

Actions #3

Updated by Michael Kay over 1 year ago

  • Status changed from New to In Progress

Well, I'm very puzzled, because AxisExpression.computeCardinality() seems to make no attempt to calculate a schema-aware cardinality for the child axis. It does so for the attribute and descendant axis (which is much more complicated) but the code for the child axis seems to be missing. Of course there are few symptoms of calculating a cardinality that's not as precise as it could be.

Actions #4

Updated by Michael Kay over 1 year ago

  • Category set to Schema-Aware processing
  • Status changed from In Progress to Resolved
  • Assignee set to Michael Kay
  • Priority changed from Low to Normal
  • Applies to branch 11, 12, trunk added
  • Fix Committed on Branch 11, 12, trunk added
  • Platforms .NET, Java added

Added JUnit test case to TestValidator

Actions #5

Updated by O'Neil Delpratt over 1 year ago

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

Bug fix applied in the Saxon 12.3 maintenance release.

Actions #6

Updated by O'Neil Delpratt over 1 year ago

  • Status changed from Closed to Resolved

Leaving this bug issue as resolved until resolved against Saxon 11.

Actions #7

Updated by Debbie Lockett about 1 year ago

  • Status changed from Resolved to Closed
  • Fixed in Maintenance Release 11.6 added

Bug fix applied in the Saxon 11.6 maintenance release.

Please register to edit this issue

Also available in: Atom PDF