Author: hwright
Date: Tue Jul 27 19:50:56 2010
New Revision: 979830

URL: http://svn.apache.org/viewvc?rev=979830&view=rev
Log:
Make Mouse actually do xslt transformations.

* mouse.py
  (transform_xslt): Implement.

Modified:
    labs/mouse/mouse.py

Modified: labs/mouse/mouse.py
URL: 
http://svn.apache.org/viewvc/labs/mouse/mouse.py?rev=979830&r1=979829&r2=979830&view=diff
==============================================================================
--- labs/mouse/mouse.py (original)
+++ labs/mouse/mouse.py Tue Jul 27 19:50:56 2010
@@ -120,10 +120,24 @@ def process_report(report):
   return ElementTree.tostring(root)
 
 
-def transform_xslt(output_xml, stylesheet):
+def transform_xslt(input_xml, stylesheet):
   '''Transform OUTPUT_XML, which should be valid xml (usually the result of
   calling process_report_xml()), according to the rules given in STYLESHEET.'''
 
+  # Do the import here so that if people don't want
+  import libxml2
+  import libxslt
+
+  styledoc = libxml2.parseFile(stylesheet)
+  style = libxslt.parseStylesheetDoc(styledoc)
+  doc = libxml2.parseMemory(input_xml, len(input_xml))
+  result = style.applyStylesheet(doc, None)
+  output_xml = style.saveResultToString(result)
+
+  style.freeStylesheet()
+  doc.freeDoc()
+  result.freeDoc()
+
   return output_xml
 
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to