Added relaxed option#45
Open
frankarensmeier wants to merge 2 commits into
Open
Conversation
Add ParseOptions to allow duplicate xml:id values
Introduce a ParseOptions struct with an `allow_duplicate_ids` field
that controls whether duplicate xml:id values cause a DuplicateId
error (default) or are silently accepted with first-occurrence-wins
semantics for id() lookups.
New public API:
- ParseOptions { allow_duplicate_ids: bool }
- Xot::parse_with_options(xml, &ParseOptions)
- Xot::parse_with_span_info_and_options(xml, &ParseOptions)
- Xot::parse_fragment_with_span_info_and_options(xml, &ParseOptions)
Existing parse/parse_with_span_info/parse_fragment_with_span_info
methods are unchanged and continue to reject duplicates.
…_syntaxes warnings Applied cargo fix suggestions to add <'_> to return types where elided lifetimes were confusing. Fixes 12 warnings introduced by newer Rust.
976c384 to
5a936ad
Compare
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.
Add
ParseOptionsto allow duplicatexml:idvaluesSome real-world XML documents (e.g. DocBook content management systems) contain duplicate
xml:idattribute values. Currently xot unconditionally rejects these withParseError::DuplicateId, which makes it impossible to process such documents even when the consumer doesn't rely on ID uniqueness.This PR adds a
ParseOptionsstruct that lets callers opt into relaxed parsing behavior:When allow_duplicate_ids is true:
xml:idvalues no longer produce an error[id()]lookups (matching Saxon's behavior)seen_idsset is still maintained to detect duplicates, but only the first node is inserted into id_nodesWhen allow_duplicate_ids is false (the default), behavior is identical to today.