Can I use XSLT in Django?

后端 未结 1 633
天涯浪人
天涯浪人 2021-01-06 05:19

We use Django for writing our new project. Our designer wants to write templates with XSLT. As you know Django has its own template system, and I don\'t have any arguments w

相关标签:
1条回答
  • 2021-01-06 05:44

    1). Yes, why not.

    import libxslt
    import libxml2
    
    from django http import HttpResponse
    
    def your_view(request):
        xsl = libxslt.parseStyleSheetDoc(libxml2.parseFile('stylesheet.xml'))
        data = # your xml here
        result = xsl.applyStylesheet(data)
        response = HttpResponse()
        xsl.saveResultToFile(response, result)
        return response
    

    2). This will likely solicit opinion, debate, arguments, polling, or extended discussion. :-)

    0 讨论(0)
提交回复
热议问题