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

[16.0][IMP] edi_xml_oca: replace xmlschema by lxml #129

Draft
wants to merge 1 commit into
base: 16.0
Choose a base branch
from

Conversation

Ricardoalso
Copy link

@Ricardoalso Ricardoalso commented Dec 11, 2024

Addressing the issue #127

@OCA-git-bot
Copy link
Contributor

Hi @simahawk,
some modules you are maintaining are being modified, check this out!

@Ricardoalso Ricardoalso marked this pull request as draft December 11, 2024 11:20
@Ricardoalso Ricardoalso force-pushed the lxml branch 3 times, most recently from b6a65ac to cd9d00e Compare December 11, 2024 15:14
try:
return self.schema.validate(xml_content)
except self._validate_swallable_exceptions() as err:
validate_xml_from_attachment(self.env, xml_content, xsd_name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this method is doing what we want? Have you checked it's implementation?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This public function validates the XML content with an XSD attachment; making a call to the private function _check_with_xsd that you pointed here. Actually validate_xml_from_attachment acts as a wrapper to validate XML content against an XSD schema while handling exceptions gracefully.

The method implementation can be seen here

Unless I'm missing something, yes I think the function does what we want 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you read the docstring of that method?

If the XSD attachment cannot be found in database, skip validation without raising.

We do not have any attachment here. IMO we can use _check_with_xsd by passing directrly the stream of the XSD.
Then if we want to support attachments too, ok but this is not the case today.

Copy link
Author

@Ricardoalso Ricardoalso Dec 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed I missed the point that it was not being stored. I refactored the code and added a new test to check if XML validation was done correctly

@Ricardoalso Ricardoalso force-pushed the lxml branch 5 times, most recently from fe4b0bc to aee5cb8 Compare December 13, 2024 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants