Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ Contributors
Changelog
=========

* Make saxonche dependency optional

* Version 4.3 dated 2026-05-26 (`OCA code sprint Santander <https://www.aeodoo.org/event/spanish-oca-days-2026-143/page/introduccion-spanish-oca-days-2026>`_)

* Restore compatibility with lxml 4.6.5
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ license = {file = "LICENSE.txt"}
dependencies = [
"pypdf>=5.3.0",
"lxml",
"saxonche",
]
requires-python = ">=3.9"
dynamic = ["version"]

[project.optional-dependencies]
schematron = ["saxonche"]
test = [
"saxonche",
"pytest",
"coverage[toml]",
]
Expand Down
8 changes: 7 additions & 1 deletion src/facturx/facturx.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
from io import BytesIO, IOBase
from tempfile import NamedTemporaryFile

import saxonche
try:
import saxonche
except ImportError:
saxonche = None
from lxml import etree
from pypdf import PdfReader, PdfWriter
from pypdf.generic import (
Expand Down Expand Up @@ -242,6 +245,9 @@ def xml_check_schematron(xml, flavor="autodetect", level="autodetect"):
:return: True if the XML is valid against the schematron
raise an error if it is not valid against the schematron
"""
if not saxonche:
logger.info("Missing saxonche module, schematron validation skipped")
return True
logger.debug("xml_check_schematron with factur-x lib %s", VERSION)
if not isinstance(flavor, str):
raise ValueError("Wrong type for flavor argument")
Expand Down