Question: Patch: Use Xml Includes When Parsing Xml
0
James Casbon • 370 wrote:
Hi,
I have inlined a patch that allows xinclude statements in xml files.
I presume I cannot send attachments to the list?
Motivation: I have my own tools I am developing managed in
tools/my_tools. I want to version that directory, etc, but want to be
able to include new tools without editing the tools_conf.xml in
galaxy_dist each time which would not get versioned.
Solution: use xinclude to include an xml file that contains tool
definitions.
Example tool_conf.xml:
<toolbox xmlns:xi="<a href=" http:="" www.w3.org="" 2001="" XInclude"="" rel="nofollow">http://www.w3.org/2001/XInclude">
....
<xi:include href="tools/my_tools/tool_conf.xml" parse="xml"/>
</toolbox>
Patch below,
cheers,
James
==============
diff -r 3b6771227a43 lib/galaxy/util/__init__.py
+++ b/lib/galaxy/util/__init__.py Mon Sep 29 15:50:20 2008 +0100
@@ -12,7 +12,7 @@
from galaxy.util.docutils_ext.htmlfrag import Writer as
HTMLFragWriter
pkg_resources.require( 'elementtree' )
-from elementtree import ElementTree
+from elementtree import ElementTree, ElementInclude
log = logging.getLogger(__name__)
_lock = threading.RLock()
@@ -64,6 +64,8 @@
def parse_xml(fname):
"""Returns an parsed xml tree"""
tree = ElementTree.parse(fname)
+ root = tree.getroot()
+ ElementInclude.include(root)
return tree
def xml_to_string(elem):
================