Introduce two-pass processing for direct attribute parsing#2627
Open
GuntherRademacher wants to merge 4 commits intoBaseXdb:mainfrom
Open
Introduce two-pass processing for direct attribute parsing#2627GuntherRademacher wants to merge 4 commits intoBaseXdb:mainfrom
GuntherRademacher wants to merge 4 commits intoBaseXdb:mainfrom
Conversation
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.
This PR introduces a two-pass strategy for processing attribute lists in direct element constructors.
In the first pass, only
xmlnsattributes are processed, updating the namespace context. In the second pass, all remaining attributes are parsed. This ensures that namespace declarations are available to embedded expressions, even if those expressions precede the correspondingxmlnsattributes.An alternative approach based on deferred QName resolution (via
QNmResolver) was considered. While this works for static function names (which are resolved after parsing), it does not extend well to:The two-pass strategy avoids these issues entirely and allows QName resolution to occur immediately. As a result,
QNmResolveris no longer needed and has been removed.The main challenge is skipping attribute values during the first or second pass without triggering parsing side effects. Direct attribute values can contain complex nested constructs, including enclosed expressions, literals, comments, direct constructors, pragmas, and templates. Reusing existing parsing code for skipping is not feasible due to its side effects. Instead, skipping is implemented using a parser generated from a simplified grammar derived from the XQuery 4.0 specification.
There are 4 commits in this PR:
QNmResolverand switch to immediate QName resolutionThis change fixes the following QT4 test cases:
K2-Axes-9K2-Axes-10union-type-009union-type-010Constr-namespace-30K2-DirectConElemNamespace-8K2-DirectConElemNamespace-14K2-DirectConElemNamespace-19K2-DirectConElemNamespace-20K2-DirectConElemNamespace-21K2-DirectConElemNamespace-22K2-DirectConElemNamespace-29K2-DirectConElemNamespace-30K2-DirectConElemNamespace-31K2-DirectConElemNamespace-32K2-DirectConElemNamespace-33function-decl-40-035function-decl-40-036K2-NamespaceProlog-13try-catch-err-code-variable-13