summaryrefslogtreecommitdiff
path: root/docs/tutorials/lxmlgraph/step04/myapp/views.py
blob: f079cea8c5dd9f80a32feac058c8c5220d3057a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
from repoze.bfg.xslt import render_transform_to_response

# Some constants
XML_NAMESPACE='http://www.w3.org/XML/1998/namespace'
XML_PREFIX= '{%s}' % XML_NAMESPACE

def xslt_view(context, request):
    # Grab the root of the tree, which should be a <site>
    site = context.getroottree().getroot()
    # Jot down which node we're sitting on as the <context>
    contextid = "'%s'" % context.get(XML_PREFIX+'id')
    return render_transform_to_response("xsltview.xsl", site, 
                                        contextid=contextid)