I'm currently working on a CityGML (de)serializer - I need C# classes for certain corresponding objects - and I'm having some trouble with
the root class I need for the System.Xml.Serialization.XmlSerializer instance. I don't know how familiar everyone here is with CityGML,
but here's a description of the situation. I've also described how I created my classes, if you wish to skip this you can start reading
from the <><><> mark:
CityGML is composed of several .xsd files, each being a module describing a certain type of elements (appearance.xsd, transports.xsd,
building.xsd, vegetation.xsd etc.), also having a root file, CityGML.xsd. As you might expect, each of the modules requires elements from
this root file. Then there's also the fact that CityGML actually inherits a lot from GML, so imports from GML .xsd files are also necessary.
So far, in terms of C# class generation, I've tried two approaches, both using the classic xsd.exe:
- the creation of a single .cs file which will include all the CityGML classes I need - a single command line:
For each of the commands, the last .xsd is the desired module, while the others are necessary imports.
Unfortunately, though xsd.exe deals with imports from other .xsd files and it creates classes of the required file as well as from the imported
files, it does this quite "directly", stacking all of these classes in one .cs file. Apparently there's no way to separate the desired classes
from the imported classes in different .cs files.
Consequently, my first question would be ARE THERE ANY (DE)SERIALIZATION TOOLS, SIMILAR TO XSD.EXE, WHICH DEAL WITH IMPORTED .XSD FILES
AND CREATE A CERTAIN .CS FILE HIERARCHY ? This would avoid repetition of, for example, the classes of feature.xsd in all of the above module
.cs files.
<><><>
Moving on, the issue which actually causes me trouble is related to the XmlSerializer instance, which cannot be created because the base CityGML
object type, CityModelType, which is also the root class in the entire hierarchy, is not entirely valid:
System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(typeof(CityModelType));
This assignment first yielded an error concerning the use of XmlTextAttribute to define a string[], which rendered the "reflection" of CityModelType
impossible. I replaced XmlTextAttribute with XmlAttributeAttribute and the current messages, whose origin I haven't been able to trace,
are these (yes, I am working in French):
System.InvalidOperationException: Impossible de générer une classe temporaire (result=1).
error CS0030: Impossible de convertir le type 'CityGML.LineStringSegmentType[]' en 'CityGML.LineStringSegmentType'
error CS0030: Impossible de convertir le type 'CityGML.LineStringSegmentType[]' en 'CityGML.LineStringSegmentType'
error CS0030: Impossible de convertir le type 'CityGML.LineStringSegmentType[]' en 'CityGML.LineStringSegmentType'
error CS0029: Impossible de convertir implicitement le type 'CityGML.LineStringSegmentType' en 'CityGML.LineStringSegmentType[]'
error CS0029: Impossible de convertir implicitement le type 'CityGML.LineStringSegmentType' en 'CityGML.LineStringSegmentType[]'
error CS0029: Impossible de convertir implicitement le type 'CityGML.LineStringSegmentType' en 'CityGML.LineStringSegmentType[]'
First of all, the only occurences of LineStringSegmentType are related to curves, which I am not using in my .gml file. They are defined like this:
public partial class LineStringSegmentType : AbstractCurveSegmentType {
Bookmarks