Results 1 to 3 of 3

Thread: two source references under mesh

  1. #1
    Member
    Join Date
    May 2005
    Location
    Carrollton, TX
    Posts
    40

    two source references under mesh

    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?
    David Wallace Croft
    www.CroftSoft.com

  2. #2
    Senior Member
    Join Date
    Aug 2005
    Location
    California
    Posts
    165
    Hello croft,
    Good question. We did that on purpose and no we can't put it back into one source. Heres the reasoning.
    1. 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.
    2. 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
    Code :
    <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
    Code :
    <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.
    1. 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.
    2. 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
    Code :
    <mesh>
      <source name="blah">...</source>
      <vertices ...> ... </vertices>
      <source name="blah2">...</source>
      <polygons ...> ... </polygons>
    </mesh>
    is functionally equivelent to
    Code :
    <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.

    -Andy

  3. #3
    Member
    Join Date
    May 2005
    Location
    Carrollton, TX
    Posts
    40

    two sources under mesh

    Andy:

    Quote Originally Posted by alorino
    2. 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)
    It's a shame you can't break that. It would be nice to have all of the source tags together at the top.

    Quote Originally Posted by alorino
    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.
    Yeah, I can't see how you can get around that.
    David Wallace Croft
    www.CroftSoft.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •