Skip to content

Implement declare decimal-format for XQuery 3.1#6217

Open
joewiz wants to merge 2 commits intoeXist-db:developfrom
joewiz:v2/declare-decimal-format
Open

Implement declare decimal-format for XQuery 3.1#6217
joewiz wants to merge 2 commits intoeXist-db:developfrom
joewiz:v2/declare-decimal-format

Conversation

@joewiz
Copy link
Copy Markdown
Member

@joewiz joewiz commented Apr 6, 2026

Summary

Implements declare decimal-format and declare default decimal-format prolog 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

  • NumberTests: 161 run, 0 failures
  • Codacy: 0 issues

Supersedes

Test plan

  • exist-core unit tests pass (NumberTests 161 run, 0 failures)
  • All format-number tests with decimal-format declarations pass
  • Error codes: XQST0097 (duplicate), FODF1310 (invalid zero-digit)

🤖 Generated with Claude Code

joewiz and others added 2 commits April 13, 2026 09:25
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>
@joewiz joewiz force-pushed the v2/declare-decimal-format branch from c4344b7 to 8febcfd Compare April 13, 2026 13:26
@line-o
Copy link
Copy Markdown
Member

line-o commented Apr 14, 2026

@joewiz what is needed for this PR to be ready?

@line-o line-o added enhancement new features, suggestions, etc. xquery issue is related to xquery implementation labels Apr 14, 2026
@joewiz joewiz marked this pull request as ready for review April 14, 2026 13:43
@joewiz joewiz requested a review from a team as a code owner April 14, 2026 13:43
@joewiz
Copy link
Copy Markdown
Member Author

joewiz commented Apr 14, 2026

[This response was co-authored with Claude Code. -Joe]

CI state: 5/9 checks pass. Of the 4 failures:

  • 3 are pre-existing integration test hangs (ubuntu, windows, macOS)
  • 1 ("Test and Publish Container Images") was a transient HTTP 502 from exist-db.org's public XAR repo — not a code issue

Dependencies: Wave 3. Must merge after v2/w3c-xquery-update-3.0 (#6214), v2/xqft-phase2 (#6215), and v2/xquery-4.0-parser (#6216) — this PR's grammar base depends on all three. It is the last of the four grammar PRs.

For full context on all 7.0 PRs and the merge order, see the Reviewer Guide.

@duncdrum duncdrum added the blocked blocked by a 3rd party label Apr 14, 2026
@duncdrum duncdrum added this to v7.0.0 Apr 14, 2026
@duncdrum duncdrum added this to the eXist-7.0.0 milestone Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked blocked by a 3rd party enhancement new features, suggestions, etc. xquery issue is related to xquery implementation

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants