Author Topic: Ordering elements in XSD  (Read 3545 times)

atingley

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Ordering elements in XSD
« on: February 03, 2005, 02:06:48 pm »
How do I specify the order of elements in a generated XML Schema?

I have 3 classes, A, B, C.  A has an association to B and C.  In the generated schema, I want  the <complexType> declaration for A to define a <sequence> with <element> references first to B, then to C.

The docs say something about a "position" tag on the <<XSDelement>> Profile element, as applied to the UML Attribute or AssociationEnd.  However, if I drop the XSDelement Profile element onto B or C, I don't see the "position" tag; if I add the tag manually, it doesn't seem to take effect.

The only way I can guarantee the ordering of the elements within the sequence is to remove the associations from B to A and C to A (Links tab, Delete relation button), then re-draw the associations in the order I want to see the elements; in this case, first from A to B, then from A to C.  This can get cumbersome, however.

Any pointers would be appreciated.

benc

  • EA Administrator
  • EA User
  • *****
  • Posts: 200
  • Karma: +0/-0
    • View Profile
Re: Ordering elements in XSD
« Reply #1 on: February 09, 2005, 04:13:36 pm »
Hi atingley,

Try putting the position as a tagged value on the 'other' end of the association. (Probably your association Source end). It's counter-intuitive, but the schema generator expects the tags for the association to be on the source end.

(Actually, it relates to a bug that we'll need to fix in a backward compatible way for existing schema models - ie. make the generator look first for the tags on the target end, then check the source end if not present.)

You should be able to set any other tags that apply to class attributes to association ends in the same way. For example form=unqualified, anonymousRole=true etc.

I hope this make some sense.

Regards,
Ben