-
-
Notifications
You must be signed in to change notification settings - Fork 103
Add Hook Interface for Customizable XSD Parsing and Code Generation #114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…used dependency from go.mod
Add Hook Interface for Customizable XSD Parsing and Code Generation
- 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
|
@xuri Im not sure why you're not getting assigned as a reviewer to my PR. I tried to close it and reopen it, but it's still not working. Do you think you can take a look at these changes? |
|
@xuri friendly bump: would you be able to take a look at this PR? |
xuri
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Thanks for your contribution.
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