Make pretty_print work for XMP file

This commit is contained in:
Alexis de Lattre 2018-06-10 22:35:20 +02:00
parent df78d61c36
commit 0a5ff44826
3 changed files with 9 additions and 2 deletions

View File

@ -56,6 +56,10 @@ Contributors
Changelog
=========
* Version 0.8 dated 2018-06-10
* Make pretty_print work for XMP file, for better readability of that file
* Version 0.7 dated 2018-05-24
* Fix XMP structure under /x:xmpmeta/rdf:RDF/rdf:Description (use XML tags instead of XML attributes)

View File

@ -1 +1 @@
__version__ = '0.7'
__version__ = '0.8'

View File

@ -291,7 +291,10 @@ def _prepare_pdf_metadata_xml(facturx_level, pdf_metadata):
xmp_file = resource_filename(
__name__, 'xmp/Factur-X_extension_schema.xmp')
facturx_ext_schema_root = etree.parse(open(xmp_file))
# Reason for defining a parser below:
# http://lxml.de/FAQ.html#why-doesn-t-the-pretty-print-option-reformat-my-xml-output
parser = etree.XMLParser(remove_blank_text=True)
facturx_ext_schema_root = etree.parse(open(xmp_file), parser)
# The Factur-X extension schema must be embedded into each PDF document
facturx_ext_schema_desc_xpath = facturx_ext_schema_root.xpath(
'//rdf:Description', namespaces=nsmap_rdf)