Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

odml_to_html.py 972 B

1234567891011121314151617181920212223242526272829
  1. import sys
  2. from lxml import etree
  3. def odml_to_html(odml_filename, html_filename=None):
  4. """
  5. Load an odML xml file containing a full and valid stylesheet tag and
  6. use the stylesheet information to transform the odml document to html.
  7. :param odml_filename: odML XML file containing a full custom XSLT style.
  8. """
  9. dom = etree.parse(odml_filename)
  10. style = dom.xpath("/odML")
  11. if not style:
  12. print("Could not find odML tag")
  13. return
  14. getstyle = style[0].findall("{http://www.w3.org/1999/XSL/Transform}stylesheet")
  15. if not getstyle:
  16. print("Could not find custom stylesheet tag")
  17. return
  18. transform = etree.XSLT(getstyle[0])
  19. newdom = transform(dom)
  20. html = etree.tostring(newdom, pretty_print=True).decode()
  21. if html_filename:
  22. with open(html_filename, "w") as fip:
  23. fip.write(html)
  24. else:
  25. return html
  26. if __name__=='__main__':
  27. import sys
  28. odml_to_html(sys.argv[1:])