Ticket #575 (closed task: fixed)

Opened 15 years ago

Last modified 15 years ago

[M][DS]Preserve order of elements in Moles parser.

Reported by: domlowe Owned by: domlowe
Priority: required Milestone: PreBeta
Component: MOLES Version:
Keywords: Cc:


Preserve order of child elements in Moles parser.

Change History

comment:1 Changed 15 years ago by domlowe

  • Status changed from new to assigned

comment:2 Changed 15 years ago by lawrence


comment:3 Changed 15 years ago by ko23

It's XML so you should always preserve order; order is significant.

comment:4 Changed 15 years ago by domlowe

Actually I completely agree with Bryan, why? The order of child elements shouldn't be significant (other than making it easier to read). And XML schema does allow for unordered elements. See:  http://www.w3schools.com/schema/schema_complex_indicators.asp

As it happens though, the MOLES schema uses xs:sequence, which specifies that order should be preserved. But I don't really see why this is necessary either.

comment:5 Changed 15 years ago by ko23

I think the only place that MOLES demands sequencing to preserve semantics is in the points of the dgPolygon2DType; even the ordering of authors in citations can be done via the authorOrdinal element. If you've noticed some others, please let me know.

Note as well that the "all" indicator only allows one instance of that element within the group, which would have turned out to be a limitation in some cases, and a major complication in others (nesting unnecessarily).

So the bottom line is that the ordering of most things is that it:

  1. simplifies the schema;
  2. makes it easier for some people to understand the schema;
  3. makes it easier for people to check the output XML;
  4. satisfies my "picture-straightening" tendency.

...and probably a couple of other things.

Once you've got it in Python, then it becomes an issue for the application, so my point is that of "correctness" rather than pragmatism, so, given what I said above, I suspect that you don't have to order the elements properly once you get it into Python.

Please note that I am really interested in any issues that exist, so I'll schedule a brief meeting to discuss them.

comment:6 Changed 15 years ago by domlowe

$ grep -c "<xs:sequence>" ndgmetadata1.3.xsd 81 :-)

It is a good point though that 'all' only allows one instance of each element... how odd.

comment:7 Changed 15 years ago by ko23

More than odd, it's fatal!

I'm still interested as to why the ordering should be a problem, especially since I believed that it's clear that, in this case, it's more an extensibility/validation artefact than an application one. It would have needed more input from the application end for me to put sequencing in for that sort of reason. Anyway, see you shortly.

(and I'm giving up trying to use Wiki lists ;|

comment:8 Changed 15 years ago by domlowe

  • Status changed from assigned to closed
  • Resolution set to fixed

Discussion aside I've implemented this now as Sue wanted it working it so she could create some 'ordered' moles for metadata training day.

The moles parser now examines the moles schema for sequences within complexTypes and uses this information to help order the elements when it's writing out Moles documents.

Note: See TracTickets for help on using tickets.