Project

Profile

Help

Bug #6033

closed

Invalid warning about field in xs:key

Added by Octavian Nadolu 12 months ago. Updated 8 months 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 12 months ago

Yes, you're right.

Actions #2

Updated by Michael Kay 12 months 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 12 months 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 12 months 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 10 months 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 10 months ago

  • Status changed from Closed to Resolved

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

Actions #7

Updated by Debbie Lockett 8 months 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