Mageia Bugzilla – Attachment 9260 Details for
Bug 20760
libxslt new security issue CVE-2017-5029
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
libxml_xslt_transform_example.py
libxml_xslt_transform_example.py (text/plain), 1.56 KB, created by
Dave Hodgins
on 2017-05-02 04:41:26 CEST
(
hide
)
Description:
libxml_xslt_transform_example.py
Filename:
MIME Type:
Creator:
Dave Hodgins
Created:
2017-05-02 04:41:26 CEST
Size:
1.56 KB
patch
obsolete
>#!/usr/bin/env python ># this is libxml_xslt_transform_example.py > >""" >Example XSLT transformation script that uses the Gnome libxml XML C parser and toolkit > >On Windows, Python can make use of the libxml2 and libxslt C libraries (http://www.xmlsoft.org/) through the >following Python bindings http://users.skynet.be/sbi/libxml-python/. Other bindings can be found here >http://codespeak.net/lxml/. The Windows installer includes the C libraries in form of DLLs. >Most Linux distributions already include the C libraries. > >Usage: > >Python 2.6 >Wolfgang Grunberg >Arizona Geological Survey >11/09/2009 >""" > ># Library Imports >import sys >import libxml2 # binding to C library of same name http://www.xmlsoft.org >import libxslt # binding to C library of same name http://www.xmlsoft.org > > ># Some variables >transform_xslt = "cdcatalog.xsl" >source_xml = "cdcatalog.xml" >out_xml = "output.xml" > >def xslt_transform(): > styledoc = libxml2.parseFile(transform_xslt) > style = libxslt.parseStylesheetDoc(styledoc) > doc = libxml2.parseFile(source_xml) > # XSLT transform with parameters > #result = style.applyStylesheet(doc, {"parameter1":"'1'","parameter2":"'string'"}) > # XSLT transform without parameters > result = style.applyStylesheet(doc, None) # > style.saveResultToFilename(out_xml, result, 0) # save to file > result_xml = style.saveResultToString(result) # save to string > > # cleanup - you are dealing with C libraries > style.freeStylesheet() > doc.freeDoc() > result.freeDoc() > > print result_xml > >if __name__=="__main__": > xslt_transform()
#!/usr/bin/env python # this is libxml_xslt_transform_example.py """ Example XSLT transformation script that uses the Gnome libxml XML C parser and toolkit On Windows, Python can make use of the libxml2 and libxslt C libraries (http://www.xmlsoft.org/) through the following Python bindings http://users.skynet.be/sbi/libxml-python/. Other bindings can be found here http://codespeak.net/lxml/. The Windows installer includes the C libraries in form of DLLs. Most Linux distributions already include the C libraries. Usage: Python 2.6 Wolfgang Grunberg Arizona Geological Survey 11/09/2009 """ # Library Imports import sys import libxml2 # binding to C library of same name http://www.xmlsoft.org import libxslt # binding to C library of same name http://www.xmlsoft.org # Some variables transform_xslt = "cdcatalog.xsl" source_xml = "cdcatalog.xml" out_xml = "output.xml" def xslt_transform(): styledoc = libxml2.parseFile(transform_xslt) style = libxslt.parseStylesheetDoc(styledoc) doc = libxml2.parseFile(source_xml) # XSLT transform with parameters #result = style.applyStylesheet(doc, {"parameter1":"'1'","parameter2":"'string'"}) # XSLT transform without parameters result = style.applyStylesheet(doc, None) # style.saveResultToFilename(out_xml, result, 0) # save to file result_xml = style.saveResultToString(result) # save to string # cleanup - you are dealing with C libraries style.freeStylesheet() doc.freeDoc() result.freeDoc() print result_xml if __name__=="__main__": xslt_transform()
View Attachment As Raw
Actions:
View
Attachments on
bug 20760
:
9258
|
9259
| 9260