In version 1.3.1 of the COLLADA Schema, there are two separate references to element “source” in “mesh”. This confuses my automatic XML schema-to-class source code compiler which wants to create a method like “getSource()”. I added some customization so that it now uses “getSource1()” and “getSource2()” but it seems like a hack. How about combining the two separate references to element “source” in “mesh” back into one?
Good question. We did that on purpose and no we can’t put it back into one source. Heres the reasoning.
- To tighten up the schema validation and to make the COLLADA-DOM more closely reflect the schema we removed xs:choice maxOccurs=“unbounded” groups and replaced them with strict ordering xs:sequence groups where applicable.
- So we didn’t invalidate a lot of existing COLLADA documents we needed to allow mesh to have sources before and after the vertices element. I believe the majority of the documents from the COLLADAMAYA exporter do that. (don’t hold me to that though)
Since you do your own code generation I’m going to assume you understand schema and go into an example now. If I’m wrong you can just skip this part.
Schema looking like this
<xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element ref="source" maxOccurs="unbounded"/> <xs:element ref="vertices" maxOccurs="1"/> <xs:element ref="polygons" maxOccurs="unbounded"/> </xs:choice>
will allow documents like this
<mesh> <source name="blah">...</source> <vertices ...> ... </vertices> <polygons ...> ... </polygons> <source name="blah2">...</source> <vertices ...> ... </vertices> </mesh>
Notice how there are two vertices element even though the max occurs = 1
that is the horror of unbounded choice groups which is why we NEEDED to change it.
This is how our codegenerator deals with it, and if yours handles schema simularly you might be able to do the same.
- since source can occur more than once in the mesh (even before 1.3.1) we had an array of sources in our generated code.
- if the generator came accros an element that was already there it would a) turn the existing element into an array if it wasnt one, or b) do nothing since there was already an array of those element to hold the new one.
That logic is perfectly valid because a document read in as
<mesh> <source name="blah">...</source> <vertices ...> ... </vertices> <source name="blah2">...</source> <polygons ...> ... </polygons> </mesh>
is functionally equivelent to
<mesh> <source name="blah">...</source> <source name="blah2">...</source> <vertices ...> ... </vertices> <polygons ...> ... </polygons> </mesh>
and both versions are valid COLLADA documents.
I hope this helps, if you have any more questions about it feel free to keep posting. And thanks for supporting COLLADA.
It’s a shame you can’t break that. It would be nice to have all of the source tags together at the top.
Yeah, I can’t see how you can get around that.