Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
eoa2-xmldb/src/xsl/views.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
31 lines (26 sloc)
963 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from .xsl_lib import xslt | |
from django.http import HttpResponse | |
# from django.shortcuts import render | |
from aldryn_apphooks_config.utils import get_app_instance | |
from pathlib import Path | |
from django.conf import settings | |
from pyexistdb import db | |
XML_DIR = settings.XML_DIR | |
def render( request ): | |
namespace, config = get_app_instance(request) | |
xml_file = \ | |
"/db/apps/eoa/xml" / (Path(config.xml_file) . relative_to( XML_DIR )) | |
stylesheet = \ | |
"/db/apps/eoa/xml" / Path(config.stylesheet) . relative_to( XML_DIR ) | |
params = [] | |
for p in config.xslparam_set.all(): | |
params += [ (p.key, p.value) ] | |
# print( f"xml_file: {xml_file}, stylesheet: {stylesheet}" ) | |
ret_doc = \ | |
xslt( | |
input = f'doc("{xml_file}")', | |
stylesheet = f'doc("{stylesheet}")', | |
params = params, | |
ns_prefixes = [ ("tei", "http://www.tei-c.org/ns/1.0") ] | |
) | |
return HttpResponse( ret_doc ) |