FasterXML / woodstox

The gold standard Stax XML API implementation. Now at Github.
Apache License 2.0
220 stars 81 forks source link

WstxValidationException: Unknown reason (at end element </nl:nillableIntElement>) when validating a document with nillable elements #187

Open ppalaga opened 5 months ago

ppalaga commented 5 months ago

fix #179 fix #190

ppalaga commented 5 months ago

@cowtowncoder here is the first sketch of what could become a real fix. Any feedback would be appreciated.

cowtowncoder commented 5 months ago

With a quick look that makes sense.

My one concern is that the attributes should only be tracked when information is needed (validation enabled, or duplicate check), and avoided otherwise. This because keeping track with a Maps will add measurable overhead for common case where validation is not enabled.

ppalaga commented 5 months ago

Thank for the feedback, @cowtowncoder!

My one concern is that the attributes should only be tracked when information is needed (validation enabled, or duplicate check), and avoided otherwise. This because keeping track with a Maps will add measurable overhead for common case where validation is not enabled.

+1. If SimpleOutputElement is the right place to implement the attribute tracking, then I can gladly have a look to make the implementation more performant.

ppalaga commented 5 months ago

My one concern is that the attributes should only be tracked when information is needed (validation enabled, or duplicate check)

That's actually the case already. All calls of SimpleOutputElement.checkAttrWrite(String, String, String, String) are guarded by either BaseStreamWriter.mCheckAttrs or by BaseStreamWriter.mValidator != null.

ppalaga commented 5 months ago

Only the last commit is relevant. The rest is also available in https://github.com/FasterXML/woodstox/pull/191 where we can discuss it separately.

@cowtowncoder could you please review?