Let the configured number limit reach schema compilation - #100
Merged
pjfanning merged 1 commit intoAug 27, 2026
Merged
Conversation
maxNumberOfCharsForNumbers did not reach the numbers in a schema document. StscTranslator.buildBigInt, which reads totalDigits, maxLength and the other numeric facets, parsed with the hardcoded default, and SchemaTypeSystemCompiler validated the schema documents under a fresh XmlOptions carrying only the error listener, so raising the limit did not raise it for a schema and lowering it did not lower it. Two paths also threw rather than reported. Validator.validateAtomicType parsed the decimal outside the ValidationContext, so a number past the limit came out of XmlObject.validate() as a raw IllegalArgumentException instead of a validation error - for any document, not only a schema. And buildBigInt materialised the facet's text outside its own try, so a schema loaded with a lower limit than the number it declares threw XmlValueOutOfRangeException out of compileXsd. Note the schema document has to be parsed with the same options for a raised limit to apply to it, since the limit is fixed when the document is loaded. The tooling paths already pass one XmlOptions to both. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Started as the
StscTranslator.buildBigIntitem — parse the numeric facets of a schema under the configured limit rather than the hardcoded default. Tracing it showedbuildBigIntwas never even reached, and two paths on the way to it threw instead of reporting.1.
buildBigIntused the default limit —StscTranslator:1515totalDigits,maxLengthand the other numeric facets are numbers in a schema document, and schemas are input too — inscomp,xsd2instand downloaded imports, not always trusted ones.StscState.setOptionsalready receives theXmlOptionsand keeps a handful of fields, so_maxNumberOfCharsForNumbersjoins them.2. Schema validation dropped the options —
SchemaTypeSystemCompiler:228A fresh
XmlOptionscarrying the error listener and one flag, so the limit never reached the validation pass that runs over the schema documents. This is what made 1 unreachable: validation failed on the facet before compilation looked at it.3.
validate()threw instead of reporting —Validator:1113Not schema-specific.
validateAtomicTypeparsed the decimal outside theValidationContext:xs:doublebehaves correctly becauseJavaDoubleHolderEx.validateLexicaltakes the limit and reports through the context. The decimal branch never got the same treatment: the lexical check preceding it validates characters but not length, so nothing is reported and the parse throws.validate()is the method that says what is wrong with a document — a number past the limit is bad input like any other and now comes back as an error.4.
buildBigIntthrew while materialising the facet —StscTranslator:1512value.getStringValue()sat outside the method's owntry, and it can fail in its own right: it triggers the lazyset_texton the facet's typed value under the schema document's limit. A schema loaded with a lower limit than the number it declares threwXmlValueOutOfRangeExceptionout ofcompileXsd. Moved inside.Note on raising the limit
The limit is fixed when a document is loaded, so a schema has to be parsed with the raised options as well as compiled with them. Passing raised options only to
compileXsdleaves the schema document itself on the default, and the facet is rejected when its text is materialised — now as a reported error rather than a thrown one. The tooling paths already pass oneXmlOptionsto both.Tests
testValidateReportsAnOverLongNumbercovers 3 forxs:integerandxs:decimal.testSchemaCompileHonoursLimitcovers 1 and 2 — a schema whosemaxLengthfacet is 2000 digits compiles undermaxChars(4096)and is reported invalid under the default.Full suite: 3090 tests, 0 failures.
🤖 Generated with Claude Code