Add xs:id and xs:idref resolution#1222
Open
pahjbo wants to merge 12 commits into
Open
Conversation
the key attribute is a list of strings that are the attribute names that when concatenated make up the XMLID for the class
fix the test fixture
This is only a step on the way as it is doing IDREF sweeps at the end of the parse - it would more efficient to do the resolution during the parse.
in order to test multiple unresolved idrefs
to check that is still working after list was supported. also sort the imports
avoids clash with another test class
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1222 +/- ##
===========================================
- Coverage 100.00% 99.81% -0.19%
===========================================
Files 116 117 +1
Lines 9376 9478 +102
Branches 1439 1462 +23
===========================================
+ Hits 9376 9460 +84
- Misses 0 10 +10
- Partials 0 8 +8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.



📒 Description
This pull request adds support for XML IDREF fields in dataclass models, and adds functionality that is similar to Java's JAXB handling of
@XmlIDand@XmlIDREFannotations in that when serialising an attribute that is marked as an IDREF, then only ID is emitted, and then when parsing such an XML instance the ID is replaced with the full dataclass instance.This is related to the discussion item #1221
🔗 What I've Done
I have added two extra metadata items
idrefasboolthat signifies if the attribute is anxs:IDREFkeyas alist[str]that lists the attribute names that when the values are concatenated make up thexs:IDThis second one might seem a little complex, but I have a use case where I need such a thing, and hopefully the unit test example makes this plausible.
Once the data model has been set up, the render and parse are transparent to the caller with the conversion to an xs:ID and the instantiation of the appropriate object happening automatically
💬 Comments
I know that this is an unsolicited new feature, that you might not want to spend time on, but I believe that it is valuable to people with complex XML structures.
There are probably more tests that you might want, but I would need a bit more help with using your harness to do them.
Also If you like the idea, then I can spend some more time on documentation.
🛫 Checklist