XSD: XML Data Binding for Qt
-
I am looking for a XML Schema (XSD) to C++ data binding compiler for Qt. I found some tools like CodeSynthesis XSD and others. My question is, if someone knows something similar for Qt. With for Qt I mean that it shall use QtXml for reading/wrtiting and parsing xml and not some third party xml library like Xerces-C++ or Expat.
-
did you look at "QXmlEdit":http://qt-apps.org/content/show.php/QXmlEdit?content=88878 ?
-
Andreas, while there's no such parser available, it's a good opportunity for you to create it and share with us ;)
-
"An Explanation":http://www.artima.com/cppsource/xml_data_binding.html
-
I find this a very interesting topic. I have been thinking about the possibilities for such a thing for Qt as well for a while now. In my opinion, a real solution would have to be much broader than just XML. It would have to be a data framework for strongly typed data that can work with basically data backends: xml files, (sql) databases, webservices, and even custom file formats. There are partial solutions available, but nothing that unifies them or works in a flexible and sane way.
Anyway, such a thing is more of a topic for the brainstorming forum, I guess...
-
Does that bring us to domain specific language since XML is a DSL for instance.
The DSL could solve any aspect as far that we provide the language description,XTEXT does that very well.
example :
@datatype String
datatype Boolentity Session {
title: String
isTutorial : Bool
}entity Conference {
name : String
attendees : Person*
speakers : Speaker*
}entity Person {
name : String
}entity Speaker extends Person {
sessions : Session*
}
@the transformation then could produce the code that you need since we control and define what an entity mean, Xtext take care to produce the grammar for you.
"XTEXT DOC":http://www.eclipse.org/Xtext/documentation/1_0_1/xtext.html#HowDoesItWork
Sure they are many DSL engine out there.
I hope it's not out of scope , xml bindind question where related to DSL to be generic enough and able to express differents concerns...
what do you think ? -
[quote author="Andre" date="1294231224"]I find this a very interesting topic. I have been thinking about the possibilities for such a thing for Qt as well for a while now. In my opinion, a real solution would have to be much broader than just XML. It would have to be a data framework for strongly typed data that can work with basically data backends: xml files, (sql) databases, webservices, and even custom file formats. There are partial solutions available, but nothing that unifies them or works in a flexible and sane way.
Anyway, such a thing is more of a topic for the brainstorming forum, I guess...[/quote]
Andre: This sounds a lot like the .Net DataSet. I think some solution like this would be great and I have thought about starting one but haven't found the time. I am working on a project that can consume "the same" data from Sql database, web service and/or xml file but it is not Qt.
I like the approach of a tool that can generate (and regenerate) source code based on xsd file and/or sql database structure.
-
Hi ,
i did a tools that generate database layer coming from domain objects definition or webservice ( rest base on json only for now ).
i will share it shortly as it need a more descent packaging.
It enable CRUD generation of course but also custom query with parameters .All the method are expose in a databaseManager classes.I started by an xsd like blend 4 does but in the end i replace it by a domain definition witch allow me to define the business service layer more easily.I will do as fast as i could maybe it will interest you as it save to me a looooooooooooot of time. -
[quote author="fcrochik" date="1294235871"]Andre: This sounds a lot like the .Net DataSet.[/quote]
No, I see more in a code-generating solution. I think such an approach would result in much better and easier to read and maintain code, as you end up with specialized classes with appropriate methods for reading and writing data. I think something like@
Person p = datasource.createPerson();
p.setName("Andre");
p.setAge(35);
p.store();
@is more readable than something like:
@
Table persons = datasource.tables("persons");
persons.addRow();
persons.setField("name", "Andre");
persons.setField("age", 35);
persons.commit();
@or something along those lines...
-
[quote author="Andre" date="1294237714"]
@
Person p = datasource.createPerson();
p.setName("Andre");
p.setAge(35);
p.store();
@
[/quote]That is exactly how the "strong type"/dataset works on .net. The main difference is that you use "adapters" to store/read the data so you separate the data classes from how you store the data and can use the same "data" classes with different "storage". In fact, because of the .net properties it would be more like:
@
Person p = datasource.Person.New();
// in qt/c++ we would need to use p.setName(...) so we could validate
// the new value and fire signals if needed
p.Name = "Andre";
p.Age = 35;
datasource.Person.Add(p);PersonDbAdptr adptr;
adptr.Update(datasource.Person);
@Also, my previous post was not very clear: Visual Studio DOES generate the code and that is one of the things I like about it. Of course, the generated classes inherit the base/common functionality from other classes and do not include every single function needed.
-
[quote author="dguimard" date="1294237203"]Hi ,
i did a tools that generate database layer coming from domain objects definition or webservice ( rest base on json only for now ).
i will share it shortly as it need a more descent packaging.
It enable CRUD generation of course but also custom query with parameters .All the method are expose in a databaseManager classes.I started by an xsd like blend 4 does but in the end i replace it by a domain definition witch allow me to define the business service layer more easily.I will do as fast as i could maybe it will interest you as it save to me a looooooooooooot of time.[/quote]dguimard: Keep us posted. I would like very much to see what you have done.
-
[quote author="fcrochik" date="1294238802"][quote author="Andre" date="1294237714"]
@
Person p = datasource.createPerson();
p.setName("Andre");
p.setAge(35);
p.store();
@
[/quote]That is exactly how the "strong type"/dataset works on .net. The main difference is that you use "adapters" to store/read the data so you separate the data classes from how you store the data and can use the same "data" classes with different "storage". In fact, because of the .net properties it would be more like:
@
Person p = datasource.Person.New();
// in qt/c++ we would need to use p.setName(...) so we could validate
// the new value and fire signals if needed
p.Name = "Andre";
p.Age = 35;
datasource.Person.Add(p);PersonDbAdptr adptr;
adptr.Update(datasource.Person);
@Also, my previous post was not very clear: Visual Studio DOES generate the code and that is one of the things I like about it. Of course, the generated classes inherit the base/common functionality from other classes and do not include every single function needed.[/quote]
OK, I misunderstood then.
I too am very interested to see what dguimard came up with.