xslt

Merge and manipulate xslt file using python lxml

Merge and manipulate xslt file using python lxml Question: im a newbie in python and i have a difficult task to cope. Suppose we have two xslt files, the first one is like this: <xsl:stylesheet version="1.0"> <xsl:function name="grp:MapToCD538A_var107"> <xsl:param name="var106_cur" as="node()"/> </xsl:function> <xsl:template match="/"> <CD123> <xsl:attribute name="xsi:schemaLocation" namespace="http://www.w3.org/2001/XMLSchema-instance"/> <xsl:for-each select="(./ns0:CD538C)[fn:not(fn:exists(*:ExportOperation[fn:namespace-uri() eq ”]/*:requestRejectionReasonCode[fn:namespace-uri() eq ”]))]"> <SynIde …

Total answers: 2

Using conditional includes/static parameters in Saxon/C?

Using conditional includes/static parameters in Saxon/C? Question: I’m trying to use XSLT conditional includes/static parameters with Saxon/C HE, but I’m getting the following error: Error Parameter $some_param cannot be supplied dynamically because it is declared as static To reproduce, I’ve used an example from a couple of answers I added a few years ago. (Here …

Total answers: 2

Use saxon with python

Use saxon with python Question: I need to process XSLT using python, currently I’m using lxml which only support XSLT 1, now I need to process XSLT 2 is there any way to use saxon XSLT processor with python? Asked By: Maliq || Source Answers: There are two possible approaches: set up an HTTP service …

Total answers: 6

How to debug lxml.etree.XSLTParseError: Invalid expression error

How to debug lxml.etree.XSLTParseError: Invalid expression error Question: I’m trying to find out why lxml cannot parse an XSL document which consists of a “root” document with various xml:includes. I get an error: Traceback (most recent call last): File “s.py”, line 10, in <module> xslt = ET.XSLT(ET.parse(d)) File “xslt.pxi”, line 409, in lxml.etree.XSLT.__init__ (src/lxml/lxml.etree.c:151978) lxml.etree.XSLTParseError: …

Total answers: 2

lxml not performing xslt transform

lxml not performing xslt transform Question: With this code: from lxml import etree with open( ‘C:\Python33\projects\xslt’, ‘r’ ) as xslt, open( ‘C:\Python33\projects\result’, ‘a+’ ) as result, open( ‘C:\Python33\projects\xml’, ‘r’ ) as xml: s_xml = xml.read() s_xslt = xslt.read() transform = etree.XSLT(etree.XML(s_xslt)) out = transform(etree.XML(s_xml)) result.write(out) I get this error: Traceback (most recent call last): File …

Total answers: 3

How to transform an XML file using XSLT in Python?

How to transform an XML file using XSLT in Python? Question: Good day! Need to convert xml using xslt in Python. I have a sample code in php. How to implement this in Python or where to find something similar? Thank you! $xmlFileName = dirname(__FILE__).”example.fb2″; $xml = new DOMDocument(); $xml->load($xmlFileName); $xslFileName = dirname(__FILE__).”example.xsl”; $xsl = …

Total answers: 3

Extract attribute's value with XPath in Python

Extract attribute's value with XPath in Python Question: I have the HTML: <table> <tbody> <tr> <td align=”left” valign=”top” style=”padding: 0 10px 0 60px;”> <img src=”/files/39.jpg” width=”64″ height=”64″> </td> <td align=”left” valign=”middle”><h1>30 Rock</h1></td> </tr> </tbody> </table> Using Python and LXML I need to extract the value from the attribute src of the <img> element. Here’s what …

Total answers: 1

How can I create a Word document using Python?

How can I create a Word document using Python? Question: I’d like to create a Word document using Python, however, I want to re-use as much of my existing document-creation code as possible. I am currently using an XSLT to generate an HTML file that I programatically convert to a PDF file. However, my client …

Total answers: 5