xslt with python

varun bhatnagar varun292006 at gmail.com
Tue Jul 15 10:10:57 CEST 2014


I am trying to merge two xmls using xslt in python but the content of first
xml is not getting copied. The rules written in xsl file created are
correct because if I am executing it without python (directly from eclipse
as I have xslt plugin installed) it is getting merged fine. Can anybody
help me? I am pasting my code snippet below:

*import lxml.etree as ET*

*dom = ET.parse(r'test_file_2.xml')*
*xslt = ET.parse(r'TestMergeRules.xsl')*
*transform = ET.XSLT(xslt)*
*print transform*
*newdom = transform(dom)*
*print(ET.tostring(newdom, pretty_print=True))*

I am opening other xml file (test_file_1.xml) in xsl file using
"document()" function.
Once this code is executed I can see only the content of test_file_2.xml.
Am I doing something wrong? Is there any other way to do this because my
xslt rules are working fine without python.

Thanks,
BR,
Varun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140715/2be6c108/attachment.html>


More information about the Python-list mailing list