Validation of aircraft XML definition file #1038
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contributes to addressing the issue #155. It updates the XML validation document
JSBSim.xsd
to (nearly ?) match the current state of aircraft definition files format. Some code has been moved fromJSBSimScript.xsd
andJSBSimSystems.xsd
toJSBSimCommon.xsd
to reduce redundancy.Disclaimer
That's a very long introductory comment for a PR and it will most likely be affected by the bike-shed effect a.k.a. law of triviality. I have mostly created it to initiate the discussion. There are a number of choices I made that certainly need to be reviewed and in all likeliness, I'll have to break this PR down into several PR's to make it easier to review.
Consider this PR as a basis for discussion. It is not meant to be merged as is. I have chosen the form of a PR because the changed files show what the result would look like.
Limitations
One of the main limitation to the XSD format is that it does not allow configurations where you could have as many sections as you want in whichever order that suits you. Actually one have to pick one option between the following ones:
<xs:sequence>
: allows as many instances of each section as the user deems so but the order is imposed.<xs:all>
: allows at most one instance of each section without restriction on the order in which they are listed.Limitations of
<xs:sequence>
For example, using
<xs:sequence>
if the following file validates:then the same file with a different order of sections is rejected:
Limitations of
<xs:all>
Using
<xs:all>
validates the following files:but rejects this file as there are 2 instances of
<output/>
:Mitigation for JSBSim
In JSBSim there are a number of models that allows multiple
<output>
elements or so. For such models the only available option is<xs:sequence>
. The consequence is that for XML validation to succeed, an aircraft definition file must meet the following order:Notes
Results/Achievements
There are good reasons to validate XML files:
Modifications
Example
There was a great deal of variation (and creativity !) in the way in which
<fileheader>
was filled. The proposed schema isNote XSD do not allow spaces around dates so you will find a number of changes such as:
There are a lot of changes of that kind, I will not review them in details here but I'd be happy to discuss them below.
Errors found
Extra
name="POINTMASS"
There is a lot of occurrences of
<location name="POINTMASS"/>
in<pointmass/>
items. The attributename
in<location>
is not used by JSBSim so I removed it.Extra
<product>
around<table>
There is a lot of occurrences of the following sequence of tags:
Here the
<product>
item is useless as there is only one item provided (and<product>
needs at least 2 to compute a result). In such a case, JSBSim issues a warning and ignores<product>
but it is better if the extra<product>
would be removed which I did.Ignored
<aerosurface_scale>
In the aircraft
B747
there is an<aerosurface_scale>
that is included in a<kinematic>
element. In such a case, JSBSim silently ignores<aerosurface_scale>
. This was most likely a copy-paste error that can easily be detected by XSD schemasjsbsim/aircraft/B747/B747.xml
Lines 358 to 371 in 92daf89
Potato or Potato ? i.e.
<description>
or<documentation>
?There are a whole lot of occurrences of the
<documentation>
tag which is illegal per the legacyJSBSim.xsd
. As their name implies, these tags are for documentation and are plainly ignored by JSBSim. In this PR, I've followed the legacy and replaced all occurrences of<documentation>
by<description>
. Retrospectively I'd allow both so that there are less file modifications.I have also replaced all occurrences of
<description>
under the<tank>
element by XML comments<!-- -->
(see the aircraftB17
). There again, we could allow the occurrence of a<description>
tag for<tanks>
and that would reduce the size of the PR.