Skip to content
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

Add XML Schema Validation #171

Open
kehoecj opened this issue Oct 3, 2024 · 9 comments
Open

Add XML Schema Validation #171

kehoecj opened this issue Oct 3, 2024 · 9 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed validator-core Issues that relate to the core validator functionality

Comments

@kehoecj
Copy link
Collaborator

kehoecj commented Oct 3, 2024

Breaking #40 into smaller chunks for Hacktoberfest. We'd really like to start adding schema validation in addition to syntax validation. XML seems like a good one to start with. We'd like to support validation against DTD as well as XSD.

@kehoecj kehoecj added enhancement New feature or request help wanted Extra attention is needed validator-core Issues that relate to the core validator functionality hacktoberfest 🎃 Hacktoberfest 2024 labels Oct 3, 2024
@timwehrle
Copy link
Contributor

@kehoecj Looking into this and see what’s possible.

@timwehrle
Copy link
Contributor

@kehoecj Can you please assign it to me? Just so I don't lose track :)

@timwehrle
Copy link
Contributor

@kehoecj Do you have a specific file naming convention for the schema and syntax validators to differentiate them? Or should I create a new directory of schema validators? Just getting some information to keep it maintainable for everyone. Thanks 😄

@kehoecj
Copy link
Collaborator Author

kehoecj commented Oct 14, 2024

Schema validation should be in the validator package and inside the xml.go validator

@timwehrle
Copy link
Contributor

@kehoecj Sorry if I'm bombarding you, but I need some guidance. If we want to enable validation against XSD or DTD, we would also need to provide a way for the user to specify a path to the schema file, right? But this would end up in a new flag? Or am I thinking the wrong way?

@timwehrle
Copy link
Contributor

@kehoecj Just tagging you so that you can give me a little hint as to how I might do it. Thanks :)

@kehoecj
Copy link
Collaborator Author

kehoecj commented Oct 23, 2024

@kehoecj Sorry if I'm bombarding you, but I need some guidance. If we want to enable validation against XSD or DTD, we would also need to provide a way for the user to specify a path to the schema file, right? But this would end up in a new flag? Or am I thinking the wrong way?

You're on the right track. With XML the XSD/DTD URL or local path can be declared in the XML. We may want to just start with that as the MVP/POC. It's likely one of the go XML libraries already does some of this. Here's what I'm thinking:

  1. If there is not XSD/DTD attribute declared in the file just check the syntax
  2. If there is is an XSD/DTD declared AND the file can be obtained then validate schema and syntax. Prioritize outputting the syntax error first then schema issue.
  3. Add a flag to just check the syntax, i.e. the current behavior. Something like --syntax-only

@timwehrle Does that help?

@timwehrle
Copy link
Contributor

@kehoecj Ah, yes. Thank you. I was probably overthinking it and missed the simpler solution.

@timwehrle
Copy link
Contributor

@kehoecj So basically my code can retrieve the XSD/DTD schema file (had to implement a custom function using regex because the go xml libraries don't provide a way). But the problem is that I can't read the file because I would need to locate it first. But I can't manage to use the already implemented FileFinder that is in the project because it would resolve in import cycle errors. How would you proceed from here? Should I implement a function myself? Thanks for helping out :)

@kehoecj kehoecj removed the hacktoberfest 🎃 Hacktoberfest 2024 label Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed validator-core Issues that relate to the core validator functionality
Projects
None yet
Development

No branches or pull requests

2 participants