Steve Lawrence created DAFFODIL-3015:
----------------------------------------

             Summary: UnparseError created when xsi:nil="false" for 
non-nullable elements
                 Key: DAFFODIL-3015
                 URL: https://issues.apache.org/jira/browse/DAFFODIL-3015
             Project: Daffodil
          Issue Type: Bug
          Components: Unparsing
            Reporter: Steve Lawrence


InfosetInputter.scala has code that looks like this to handle nilled elements:

{code:scala}
    if (optNilled.isDefined) {
      if (!erd.isNillable) {
        UnparseError(
          One(elem.erd.schemaFileLocation),
          Nope,
          "Element %s defines nil property, but is not nillable",
          erd.namedQName.toExtendedSyntax
        )
      }
      if (optNilled.get) {
        elem.setNilled()
      }
    }
{code}

This logic means that if an infoset defines the xsi:nil attribute for an 
element that isn't nullable we get an UnparseError, even if xsi:nil="false".

The XSD specification says that defining xsi:nil on non-nullable elements, even 
if false, should be a validation error. So an UnparseError might not be the 
correct thing in this case. This really wants to be a validation error if 
isNilled == Some(false) for non-nullable elements which could allow the unparse 
to proceed. Note that isNilled == Some(true) for non-nullable elements should 
still be an UnparseError, since we do need an actual value to unparse.

Unfortunately, unparse does not support validation so I changing this to a 
validation error is probably not the correct thing to do.

I would suggest two options to resolve this:

1. Close this ticket as won't fix and don't worry about it, this ticket can 
just be a record of our decision to keep this behavior as is. It's unlikely to 
ever be a problem since xsi:nil="false" is very uncommon.
2. Keep this ticket open until we implement validation for unparse (not 
currently on the roadmap), and at that point change this code to correctly 
create a validation error instead of an unparse error



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to