- if c.xml_select(u"//xi:include[@xpointer]"):
- exe.append("xptr="+c.xpointer)
- xml = subprocess.Popen(exe,stdout=subprocess.PIPE)
- xstr = bindery.parse(str(xml.stdout.read()))
- idp = c.xml_index_on_parent
- for x in xstr.xml_children:
- c.xml_parent.xml_insert(idp,x)
- c.xml_parent.xml_remove(c)
+ if xpointer:
+ exe.append("xptr="+xpointer)
+ print " executing %15s" % (href),
+ ts = time()
+ os.chdir(dirname)
+ xml = subprocess.Popen(exe,stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ (stdout, stderr) = xml.communicate()
+ if stderr:
+ print " ".join(exe)+" ERROR : [ "+stderr+" ]"
+ os.chdir(cwd)
+ te = time()
+ print " [%5.2f s] (%s)" % (round(te-ts,2),xpointer)
+ xstr = etree.fromstring(stdout)
+# inserting the generated code and remove the xinclude reference
+ idp = c.getparent()
+ idp.insert(idp.index(c)+1,xstr)
+ idp.remove(c)