2 #include "XMLPythonConv.hxx"
3 #include "TypeConversions.hxx"
5 #include <libxml/parser.h>
10 #include "YacsTrace.hxx"
12 using namespace YACS::ENGINE;
15 XmlPython::XmlPython(InputPyPort* p)
16 : ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode())
20 void XmlPython::put(const void *data) throw(ConversionException)
22 DEBTRACE((const char *)data);
23 put((const char *)data);
26 //!Convert a XML (char *) to PyObject and push it into proxy port
28 * \param data : Xml::char *
31 void XmlPython::put(const char *data) throw(ConversionException)
38 InterpreterUnlocker l;
39 doc = xmlParseMemory(data, strlen(data));
43 msg << "Problem in conversion: XML Document not parsed successfully ";
44 msg << " (" << __FILE__ << ":" << __LINE__ << ")";
45 throw ConversionException(msg.str());
47 cur = xmlDocGetRootElement(doc);
52 msg << "Problem in conversion: empty XML Document";
53 msg << " (" << __FILE__ << ":" << __LINE__ << ")";
54 throw ConversionException(msg.str());
58 if ((!xmlStrcmp(cur->name, (const xmlChar *)"value")))
60 ob=convertXmlPyObject(edGetType(),doc,cur);
69 msg << "Problem in conversion: incorrect XML value";
70 msg << " (" << __FILE__ << ":" << __LINE__ << ")";
71 throw ConversionException(msg.str());
73 // xmlCleanupParser();
75 PyObject_Print(ob,stderr,Py_PRINT_RAW);
80 DEBTRACE("ob refcnt: " << ob->ob_refcnt);
81 _port->setStringRef(data);