Re: [realXtend] If there is any tools to parse XML files in JavaScript environment in realXtend Tundra?
Hi, Here's another example that I wrote quite recently when testing and debugging QtScript + QtXml. As you can see the script bindings created by QtScriptGenerator are not perfect there probably might be even more gotchas to encounter along the way. I might also throw this to the Tundra repository in the near future as well. Sorry for the missing indentation (GMail seems to strip it away). // Loads the plugin.xml from Tundra/bin twice, first by using both plain QFile, and the second time using QFile and QXmlInputSource. function QtXmlTest() { var file = new QFile(plugins.xml); var errorMsg; var errorLine; var errorColumn; var domDocFromFile = new QDomDocument(); // The following line should work to my knowledge, but for some (non-apparent) reason it doens't: // var fileOk = domDocFromFile[setContent(QIODevice,bool,QString,int,int)](file, true, errorMsg, errorLine, errorColumn); // I'm suspecting it has something to do with the fact that QDomDocument doesn't inherit QObject (I have encountered some mysterious // behavior with e.g. QTreeWidgetItem also), and the fact that the actual C++ function implementation uses default argument values: // bool setContent(QIODevice *dev, bool namespaceProcessing, QString * errorMsg = 0, int * errorLine = 0, int * errorColumn = 0); // My guess is that that passing C-type pointers (or references for that matter) which are used for output is not simply // supported/understood by QtScript(Generator). // Probably QtScriptGenerator doesn't generate function signatures for all cases (the function at hand would yield four different possible signatures). // Hence the function call must be done with none of the optional arguments provided. // So, the following works without problems (let's try bool setContent(QIODevice * dev)): var fileOk = domDocFromFile.setContent(file); if (fileOk) { // Should work ok! // Simply dump the whole file contents to stdout. print(File contents:); print(domDocFromFile.toString()); print(); } file.close(); // Remember to close the file handle. // So, the setContent function seems to be working by omitting the default arguments from the signatures // (http://developer.qt.nokia.com/doc/qt-4.7/qdomdocument.html) alltogether, and the following signatures/overloads should work: // bool setContent(const QByteArray data, bool namespaceProcessing) // bool setContent(const QString text, bool namespaceProcessing) // bool setContent(QIODevice * dev, bool namespaceProcessing) // bool setContent(QXmlInputSource * source, bool namespaceProcessing) // bool setContent(const QString text) // bool setContent(const QByteArray buffer) // bool setContent(QIODevice * dev) - which we usesd previously // bool setContent(QXmlInputSource * source, QXmlReader * reader) var file2 = new QFile(plugins.xml); var source = new QXmlInputSource(file2); var domDocFromInputSource = new QDomDocument(); // Utilize the Qt XML/DOM API and print the names of the C++ plugins defined int the XML file individually. // Let's try bool setContent(QXmlInputSource * source, bool namespaceProcessing). var sourceOk = domDocFromInputSource.setContent(source, true); if (sourceOk) { // Should work ok! var pluginElems = domDocFromInputSource.elementsByTagName(plugin); print(pluginElems.length() + C++ plugins found. The plugins are:); for(var i = 0; i pluginElems.length(); ++i) print(* + pluginElems.item(i).toElement().attribute(path)); } file2.close(); } } -- http://groups.google.com/group/realxtend http://www.realxtend.org
Re: [realXtend] If there is any tools to parse XML files in JavaScript environment in realXtend Tundra?
wow! Thank you Toni! This really amazing! On Fri, Feb 24, 2012 at 3:03 PM, Toni Alatalo t...@playsign.net wrote: On Fri, 2012-02-24 at 14:44 -0500, 赵柏萱 wrote: Thank you for the detailed reply! I made a quick / test example that should get you going: https://github.com/realXtend/naali/blob/tundra2/bin/jsmodules/apitest/qtxml.js Can run with: ./Tundra --headless --run jsmodules/apitest/qtxml.js it walks the xml doc and prints tags. is made to run from the Tundra bin directory (or the root in release) as expects the plugins.xml to be there. ~Toni On Fri, Feb 24, 2012 at 2:27 PM, Toni Alatalo t...@playsign.net wrote: On Fri, 2012-02-24 at 10:37 -0800, Zhao Boxuan wrote: I'm going to make a demo using realXtend tundra, and there are some Cool! xml files to parse. I try to use new ActiveXObject('Microsoft.XMLDOM') to do the parse job but it seems that the parser is not supported in the tundra JavaSript environment. Heh, no that certainly is not expected to work out of the box. I don't know what API that actually is even. Browsers which have active-x support, any browser on Windows perhaps? Could anyone tell me if there's any tools I can use to parse the XML files? Tundra itself uses Qt XML, and that is I think available to Javascript (QtScript) too. The qt.xml extension. I can make a test / little demo later, have never actually used that yet (but it does seem nice on the c++ side with the XML DocumentObjects or so). I think the same ImportExtension thing that's used to load qt.core and qt.gui in the examples in e.g. scenes/ dir should work for that too, and then the Qt API docs (for c++ but the API is the same) should tell how it works. It is also possible to use pure Javascript libraries, if for example JQuery has nice XML tools, but that Qt XML is native c++ code so should be fast and I think nice too. ~Toni P.S. I think we have the ActiveX support enabled in Qt too ('ActiveQt'), so if that's needed for something else it's possible to use too. Not needed for XML, but I think e.g. Flash works that way. (on windows when Flash active-x plugin installed) -- http://groups.google.com/group/realxtend http://www.realxtend.org -- http://groups.google.com/group/realxtend http://www.realxtend.org -- http://groups.google.com/group/realxtend http://www.realxtend.org -- http://groups.google.com/group/realxtend http://www.realxtend.org
[realXtend] If there is any tools to parse XML files in JavaScript environment in realXtend Tundra?
Hi, everyone, I'm going to make a demo using realXtend tundra, and there are some xml files to parse. I try to use new ActiveXObject('Microsoft.XMLDOM') to do the parse job but it seems that the parser is not supported in the tundra JavaSript environment. Could anyone tell me if there's any tools I can use to parse the XML files? Thank you! -- http://groups.google.com/group/realxtend http://www.realxtend.org
Re: [realXtend] If there is any tools to parse XML files in JavaScript environment in realXtend Tundra?
On Fri, 2012-02-24 at 10:37 -0800, Zhao Boxuan wrote: I'm going to make a demo using realXtend tundra, and there are some Cool! xml files to parse. I try to use new ActiveXObject('Microsoft.XMLDOM') to do the parse job but it seems that the parser is not supported in the tundra JavaSript environment. Heh, no that certainly is not expected to work out of the box. I don't know what API that actually is even. Browsers which have active-x support, any browser on Windows perhaps? Could anyone tell me if there's any tools I can use to parse the XML files? Tundra itself uses Qt XML, and that is I think available to Javascript (QtScript) too. The qt.xml extension. I can make a test / little demo later, have never actually used that yet (but it does seem nice on the c++ side with the XML DocumentObjects or so). I think the same ImportExtension thing that's used to load qt.core and qt.gui in the examples in e.g. scenes/ dir should work for that too, and then the Qt API docs (for c++ but the API is the same) should tell how it works. It is also possible to use pure Javascript libraries, if for example JQuery has nice XML tools, but that Qt XML is native c++ code so should be fast and I think nice too. ~Toni P.S. I think we have the ActiveX support enabled in Qt too ('ActiveQt'), so if that's needed for something else it's possible to use too. Not needed for XML, but I think e.g. Flash works that way. (on windows when Flash active-x plugin installed) -- http://groups.google.com/group/realxtend http://www.realxtend.org
Re: [realXtend] If there is any tools to parse XML files in JavaScript environment in realXtend Tundra?
Thank you for the detailed reply! On Fri, Feb 24, 2012 at 2:27 PM, Toni Alatalo t...@playsign.net wrote: On Fri, 2012-02-24 at 10:37 -0800, Zhao Boxuan wrote: I'm going to make a demo using realXtend tundra, and there are some Cool! xml files to parse. I try to use new ActiveXObject('Microsoft.XMLDOM') to do the parse job but it seems that the parser is not supported in the tundra JavaSript environment. Heh, no that certainly is not expected to work out of the box. I don't know what API that actually is even. Browsers which have active-x support, any browser on Windows perhaps? Could anyone tell me if there's any tools I can use to parse the XML files? Tundra itself uses Qt XML, and that is I think available to Javascript (QtScript) too. The qt.xml extension. I can make a test / little demo later, have never actually used that yet (but it does seem nice on the c++ side with the XML DocumentObjects or so). I think the same ImportExtension thing that's used to load qt.core and qt.gui in the examples in e.g. scenes/ dir should work for that too, and then the Qt API docs (for c++ but the API is the same) should tell how it works. It is also possible to use pure Javascript libraries, if for example JQuery has nice XML tools, but that Qt XML is native c++ code so should be fast and I think nice too. ~Toni P.S. I think we have the ActiveX support enabled in Qt too ('ActiveQt'), so if that's needed for something else it's possible to use too. Not needed for XML, but I think e.g. Flash works that way. (on windows when Flash active-x plugin installed) -- http://groups.google.com/group/realxtend http://www.realxtend.org -- http://groups.google.com/group/realxtend http://www.realxtend.org
Re: [realXtend] If there is any tools to parse XML files in JavaScript environment in realXtend Tundra?
On Fri, 2012-02-24 at 14:44 -0500, 赵柏萱 wrote: Thank you for the detailed reply! I made a quick / test example that should get you going: https://github.com/realXtend/naali/blob/tundra2/bin/jsmodules/apitest/qtxml.js Can run with: ./Tundra --headless --run jsmodules/apitest/qtxml.js it walks the xml doc and prints tags. is made to run from the Tundra bin directory (or the root in release) as expects the plugins.xml to be there. ~Toni On Fri, Feb 24, 2012 at 2:27 PM, Toni Alatalo t...@playsign.net wrote: On Fri, 2012-02-24 at 10:37 -0800, Zhao Boxuan wrote: I'm going to make a demo using realXtend tundra, and there are some Cool! xml files to parse. I try to use new ActiveXObject('Microsoft.XMLDOM') to do the parse job but it seems that the parser is not supported in the tundra JavaSript environment. Heh, no that certainly is not expected to work out of the box. I don't know what API that actually is even. Browsers which have active-x support, any browser on Windows perhaps? Could anyone tell me if there's any tools I can use to parse the XML files? Tundra itself uses Qt XML, and that is I think available to Javascript (QtScript) too. The qt.xml extension. I can make a test / little demo later, have never actually used that yet (but it does seem nice on the c++ side with the XML DocumentObjects or so). I think the same ImportExtension thing that's used to load qt.core and qt.gui in the examples in e.g. scenes/ dir should work for that too, and then the Qt API docs (for c++ but the API is the same) should tell how it works. It is also possible to use pure Javascript libraries, if for example JQuery has nice XML tools, but that Qt XML is native c++ code so should be fast and I think nice too. ~Toni P.S. I think we have the ActiveX support enabled in Qt too ('ActiveQt'), so if that's needed for something else it's possible to use too. Not needed for XML, but I think e.g. Flash works that way. (on windows when Flash active-x plugin installed) -- http://groups.google.com/group/realxtend http://www.realxtend.org -- http://groups.google.com/group/realxtend http://www.realxtend.org -- http://groups.google.com/group/realxtend http://www.realxtend.org