Add Hook Interface for Customizable XSD Parsing and Code Generation #112
Closed
eleenmohd-wk wants to merge 21 commits intoxuri:masterfrom
Closed
Add Hook Interface for Customizable XSD Parsing and Code Generation #112eleenmohd-wk wants to merge 21 commits intoxuri:masterfrom
eleenmohd-wk wants to merge 21 commits intoxuri:masterfrom
Conversation
…used dependency from go.mod
Add Hook Interface for Customizable XSD Parsing and Code Generation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #112 +/- ##
==========================================
+ Coverage 81.92% 84.29% +2.36%
==========================================
Files 37 37
Lines 1870 1636 -234
==========================================
- Hits 1532 1379 -153
+ Misses 246 163 -83
- Partials 92 94 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Add TestOnAddContentCoverage to test OnAddContent calls across different type generators - Add TestOnAddContentForAllTypes to verify hook integration with existing fixtures - Create hook-coverage.xsd fixture to exercise SimpleType (list/union/basic), ComplexType, Group, and AttributeGroup generators - These tests cover lines 162, 190, 203, 282, 323, and 351 in genGo.go - Ensures all OnAddContent hook calls are properly tested and can modify generated code
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.
PR Details
This PR introduces am optional plugin system via the Hook interface that allows users to customize the XSD parsing and code generation process without modifying xgen's core logic.
There are 5 interception points:
During XML parsing (parsing.go), the hook intercepts the XML token stream before xgen processes it. Each hook method returns a next boolean - if false, xgen skips that element, allowing custom filtering or preprocessing.
The hook intercepts code generation (genGo.go) at two points:
Description
Adds Parser.Hooks
map[string]Hookfor handling custom logic on specific elementsRelated Issue
Motivation and Context
expands functionality w/o major changes to the core code. the hook is optional and all existing code continues to work without modification so there's no changes in the existing functionality
How Has This Been Tested
unit tests
Types of changes
Checklist