Skip to content

Style: XSD file fixes and CI linter - #1674

Draft
pniedzielski wants to merge 3 commits into
bloomberg:mainfrom
pniedzielski:xsd-namespaces
Draft

Style: XSD file fixes and CI linter#1674
pniedzielski wants to merge 3 commits into
bloomberg:mainfrom
pniedzielski:xsd-namespaces

Conversation

@pniedzielski

Copy link
Copy Markdown
Collaborator

This PR includes a few XSD style fixes that I've found while doing work on an XSD->C++ codegen tool, as well as a CI check that could have found them. See commit messages for details on each.

This patch removes from mqbcmd.xsd the explicit `xmlns:xs` namespace,
which just duplicates the default namespace.  `xmlns:xs` was only used
to name simple XML Schema data types, like `xs:string`, not XML Schema
elements, like (`xs:`)`element`.

Along the way, we found some incorrect namespace usage in this file:
local types referenced as if they lived in the XML Schema namespace, and
built-in types referenced via `tns:`.  This never caused problems
because our code gen resolves type references by their local name,
ignoring the namespace, so the generated code was unaffected.  However,
under strict XSD validation, this fails.  In addition to making the XML
Schema namespace implicit, this patch also normalizes/corrects these
cases, listed below:

    1. In `LeaderMessageSequence`, `electorTerm` is given the type
      `tns:unsignedLong` (which is nonsense), rather than the real
      type: (`xs:`)`unsignedLong`.

    2. In `SubscriptionGroup`, `priorityGroup` is given the unprefixed
       type `PriorityGroup`, rather than the local type
       `tns:PriorityGroup`.

    3. In `PriorityGroup`, `highestSubscriptions` is given the
       unprefixed type `Subscription`, rather than the local type
       `tns:Subscription`.

    4. In `Subscription`, `subscriber` is given the unprefixed type
       `Subscriber`, rather than the local type `tns:Subscriber`.

    5. In `ClusterNodeInfo`, `status` is given the type
       `xs:NodeStatus` (which again, is nonsense), rather than the local
       type `tns:NodeStatus`.

    6. In `AppState`, `roundRobinRouter` is given the type
       `xs:RoundRobinRouter` (which is nonsense), rather than the local
       type `tns:RoundRobinRouter`.

Signed-off-by: Patrick M. Niedzielski <pniedzielski@bloomberg.net>
bmqstm.xsd is the only XSD file that qualifies every element with an
`xs:` namespace prefix, and that does not specify its target
namespace (or give it a prefix `tns:`).  This may have been because of
its history in the MWC package rather than being purely BMQ like the
others.  This patch brings it into line with the rest of the XSD files
by making the XML Schema namespace implicit, and making the target
namespace explicit.

Signed-off-by: Patrick M. Niedzielski <pniedzielski@bloomberg.net>
This patch adds a CI linter for our XML schemas, which would have caught
the style issues fixed by the two previous patches.  The linter does two
separate checks: first, it verifies that all the schemas are valid XML,
and then it verifies that they are all valid XML schemas.

Signed-off-by: Patrick M. Niedzielski <pniedzielski@bloomberg.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant