Implement declare decimal-format for XQuery 3.1#6217
Conversation
Add parser support for the XQuery 3.1 `declare decimal-format` and `declare default decimal-format` prolog declarations (spec section 4.10), enabling users to customize number formatting via fn:format-number. The runtime infrastructure (DecimalFormat class, XQueryContext storage, FnFormatNumbers 3-arg support) was already in place — this adds the missing parser recognition and tree walker processing. Changes: - XQuery.g: Add DECIMAL_FORMAT_DECL/DEF_DECIMAL_FORMAT_DECL tokens, grammar rules for named and default forms, property keywords - XQueryTree.g: Walk AST, validate properties (single-char, zero-digit, distinctness), register formats in XQueryContext - ErrorCodes.java: Add XQST0097 (duplicate) and XQST0098 (invalid) - XQueryContext.java: Add setDefaultStaticDecimalFormat() convenience - format-numbers.xql: Add tests for named/default formats, custom NaN/infinity, and error cases Closes eXist-db#56 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…dd Javadoc Rename the three decimal-format validation helper methods in XQueryTree.g with a `df` prefix to clarify their scope: - requireSingleChar → dfRequireSingleChar - validateZeroDigit → dfValidateZeroDigit - validateDistinctPictureChars → dfValidateDistinctPictureChars Add Javadoc comments on DecimalFormat.UNNAMED and UNNAMED_DECIMAL_FORMAT explaining the XPath 3.1 spec origin of the "unnamed" terminology. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
c4344b7 to
8febcfd
Compare
|
@joewiz what is needed for this PR to be ready? |
|
[This response was co-authored with Claude Code. -Joe] CI state: 5/9 checks pass. Of the 4 failures:
Dependencies: Wave 3. Must merge after For full context on all 7.0 PRs and the merge order, see the Reviewer Guide. |
|
Does this PR close #56 ? |
…-format # Conflicts: # exist-core/src/main/java/org/exist/xquery/ErrorCodes.java
Address @reinhapa's review comment on PR eXist-db#6217: convert the property-name dispatch in the decimal-format AST handler from a traditional switch/break statement into arrow-syntax cases. No behavioural change; NumberTests still pass (161 run, 0 failures). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
[This response was co-authored with Claude Code. -Joe] Per the 2026-05-10 v2/* extraction audit, the four commits in this branch are entirely XQ 3.1-mandatory (W3C XPath/XQuery 3.1 §4.16) with no dependency on Saxon 12, the new parser, or XQ 4.0 grammar extensions. Extracted to a new PR against The extraction was done as a clean cherry-pick of the three substantive commits (skipping the develop merge commit). One additive conflict in Recommend closing this PR as superseded once #6339 merges. |
Address @reinhapa's review comment on PR #6217: convert the property-name dispatch in the decimal-format AST handler from a traditional switch/break statement into arrow-syntax cases. No behavioural change; NumberTests still pass (161 run, 0 failures). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
superseded by #6339 |
Summary
Implements
declare decimal-formatanddeclare default decimal-formatprolog declarations per XQuery 3.1. Addresses review comments from @line-o on PR #6077.Note: This branch is based on the merged grammar (requires v2/w3c-xquery-update-3.0 + v2/xqft-phase2 + v2/xquery-4.0-parser to be merged first).
Spec References
Tests
Supersedes
Test plan
🤖 Generated with Claude Code