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

Update mets_xml_dmd_rdf.jinja2 #556

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cristianvasquez
Copy link

Fixes: #549

I could not clone the repository.

I Tested externally with jinja2 like this:

from jinja2 import Environment, FileSystemLoader, select_autoescape
import os

template_dir = os.path.dirname(os.path.abspath(__file__))
template_file = 'template.xml'

sample_data = {
    'work': {
        'identifier': '123456',
        'oj_identifier': 'OJ/2024/001',
        'do_not_index': 'true',
        'date_document': '2024-10-24',
        'created_by_agent': 'EU-CORP',
        'title': {
            'en': 'Public Procurement',
            'fr': 'Marché Public',
            'es': '<html>Some HTML and a & </html>'

        },
        'dataset_keyword': ['keyword1', 'keyword2', 'keyword3'],
        'datetime_transmission': '2024-10-24T14:30:00',
    },
    'notice': {
        'public_number_document': 'TED123',
        'public_number_edition': '1'
    },
    'expression': {
        'identifier': 'EXP123',
        'title': {
            'en': 'Procurement Document',
            'fr': 'Document de Marché',
            'es': '<html>Some HTML and a & </html>'

        },
        'uses_language': 'EN',
    },
    'manifestation': {
        'identifier': 'MAN123',
        'type': 'PDF',
        'date_publication': '2024-10-24',
        'distribution_has_status_distribution_status': 'PUBLISHED',
        'distribution_has_media_type_concept_media_type': 'FILE_TYPE_PDF',
    }
}

env = Environment(loader=FileSystemLoader(template_dir))
template = env.get_template(template_file)

output = template.render(sample_data)

output_file = os.path.join(template_dir, 'output.xml')
with open(output_file, 'w', encoding='utf-8') as f:
    f.write(output)

print(f"Rendered output saved to {output_file}")

 escape the contents of the field titles
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.

Handle parsing issues in METs packages
2 participants