XML

The standard MTConnect format, defined and validated by the XSDs of each MTConnect version.
MTConnect.NET Docs Menu

XML is the canonical MTConnect wire format. Every MTConnect Standard version (v1.0 through v2.5 in this library; v2.7 in the standard at large) defines an XSD set that pins the on-the-wire envelope shape — MTConnectStreams_<ver>.xsd, MTConnectDevices_<ver>.xsd, MTConnectAssets_<ver>.xsd, and MTConnectError_<ver>.xsd. The library's XML codec produces output that validates against the matching-version XSD published at schemas.mtconnect.org.

The codec round-trips: it both reads agent output (e.g. an HTTP GET /current response) and writes envelopes for the agent to serve. Reads dispatch on the document's xmlns value to select the matching MTConnect version (see MTConnect.Namespaces for the URI → version table).

Document Format ID

The codec registers as XML in the formatter registry. Agent modules and adapters pass that string into IResponseDocumentFormatter / IEntityFormatter lookups to select XML output.

Codec Classes

ClassRole
MTConnect.Formatters.Xml.XmlResponseDocumentFormatterTop-level IResponseDocumentFormatter for the four envelope kinds (Streams, Devices, Assets, Error). Returns application/xml.
MTConnect.Formatters.Xml.XmlEntityFormatterPer-entity formatter (single Observation, single Asset, etc.) for callers that splice individual entities into a larger document.
MTConnect.Formatters.Xml.XmlPathFormatterXPath-style path resolver used by the path= query parameter on /current and /sample.
MTConnect.Streams.Xml.XmlStreamsResponseDocumentDTO that mirrors the <MTConnectStreams> envelope.
MTConnect.Devices.Xml.XmlDevicesResponseDocumentDTO that mirrors the <MTConnectDevices> envelope.
MTConnect.Assets.Xml.XmlAssetsResponseDocumentDTO that mirrors the <MTConnectAssets> envelope.
MTConnect.Errors.Xml.XmlErrorResponseDocumentDTO that mirrors the <MTConnectError> envelope.
MTConnect.XmlValidatorXSD validator that loads the embedded per-version schema set under MTConnect.Schemas and reports structural errors.

Sample Envelope

A minimal <MTConnectStreams> response captures the shape every Streams document follows — a <Header> with sequence + buffer metadata, a <Streams> container, one <DeviceStream> per device, one <ComponentStream> per addressed component, and a category container (<Events>, <Samples>, or <Condition>) holding the observations.

<?xml version="1.0" encoding="utf-8"?>
<MTConnectStreams
    xmlns="urn:mtconnect.org:MTConnectStreams:2.0"
    xmlns:m="urn:mtconnect.org:MTConnectStreams:2.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="urn:mtconnect.org:MTConnectStreams:2.0">
  <Header
      instanceId="1663078056"
      version="1.0.0.0"
      sender="ADSKPF3FBP2T"
      bufferSize="131072"
      firstSequence="1"
      lastSequence="222"
      nextSequence="223"
      deviceModelChangeTime="2022-09-13T14:07:36.2828516Z"
      creationTime="2022-09-13T14:07:47.2901070Z" />
  <Streams>
    <DeviceStream name="Machine" uuid="cc17e6f8-61c2-427b-a45f-11a2189ae3a4">
      <ComponentStream component="Controller" componentId="cont" name="controller">
        <Condition>
          <Fault dataItemId="comms_cond" type="COMMUNICATIONS"
                 sequence="221" timestamp="2022-09-13T14:07:36.444Z" />
          <Normal dataItemId="comms_cond" type="COMMUNICATIONS"
                  sequence="222" timestamp="2022-09-13T14:07:36.570Z" />
        </Condition>
      </ComponentStream>
    </DeviceStream>
  </Streams>
</MTConnectStreams>

The fixture is tests/MTConnect.NET-XML-Tests/Streams-Files/Current-Simple.xml. Devices, Assets, and Error envelopes share the same <Header> + payload pattern, with the per-envelope payload swapped (<Devices>, <Assets>, <Errors>).

Spec-Version Compatibility

The codec walks the xmlns attribute on the root element to pick the version. The XSDs are embedded into MTConnect.NET-XML.dll and exposed via MTConnect.Schemas; the MTConnect.XmlValidator class loads them on demand and runs structural validation against the matching version.

Spec versionXML namespaceStatus in this library
v1.0urn:mtconnect.org:MTConnectStreams:1.0 (and the matching Devices / Assets / Error)Read + write.
v1.1urn:mtconnect.org:MTConnectStreams:1.1Read + write.
v1.2urn:mtconnect.org:MTConnectStreams:1.2Read + write.
v1.3urn:mtconnect.org:MTConnectStreams:1.3Read + write.
v1.4urn:mtconnect.org:MTConnectStreams:1.4Read + write.
v1.5urn:mtconnect.org:MTConnectStreams:1.5Read + write.
v1.6urn:mtconnect.org:MTConnectStreams:1.6Read + write.
v1.7urn:mtconnect.org:MTConnectStreams:1.7Read + write.
v1.8urn:mtconnect.org:MTConnectStreams:1.8Read + write.
v2.0urn:mtconnect.org:MTConnectStreams:2.0Read + write.
v2.1urn:mtconnect.org:MTConnectStreams:2.1Read + write.
v2.2urn:mtconnect.org:MTConnectStreams:2.2Read + write.
v2.3urn:mtconnect.org:MTConnectStreams:2.3Read + write.
v2.4urn:mtconnect.org:MTConnectStreams:2.4Read + write.
v2.5urn:mtconnect.org:MTConnectStreams:2.5Read + write. The library's current MTConnectVersions.Max.

The per-envelope coverage rolls up to the same table — Streams, Devices, Assets, and Error all ship XSDs across the same version span. There is no v1.9 row because the MTConnect Standard skipped that number between v1.8 and v2.0; the XSD set has no 1.9 namespace and the library tracks the canonical gap. See the MTConnectVersions constants for the full enum.

For v2.6 and v2.7 namespaces, the codec falls through to the v2.5 reader path; the library's compliance posture for those versions is tracked in Compliance by Version. Authoritative XSDs for every version are at schemas.mtconnect.org and the normative SysML XMI is at mtconnect/mtconnect_sysml_model. Prose narration lives at docs.mtconnect.org in Part 2.0 (Streams), Part 3.0 (Devices), and Part 4.0 (Assets).

Request Flow

The /probe, /current, /sample, and /asset HTTP endpoints all follow the same envelope-build pipeline. The diagram below shows a /current request from a consumer through the agent's HTTP module, the codec, and back to the wire.

Consumer
Agent HTTP module
XmlResponseDocumentFormatter
XmlValidatorOptional
  1. Consumer HTTP moduleGET /current?path=//Controller
  2. HTTP moduleResolves the device and path to an IStreamsResponseOutputDocument
  3. HTTP module FormatterFormat(document, options)
  4. FormatterSerializes the Header and Streams subtree, and applies the xmlns of the negotiated MTConnect version
  5. When validation is enabled
  6. Formatter XmlValidatorValidateXml(stream, version)
  7. XmlValidator FormatterXmlValidationResponse
  8. Response
  9. Formatter HTTP moduleFormatWriteResult(stream, "application/xml")
  10. HTTP module Consumer200 OK with an application/xml body
The xmlns in the response tells the consumer which MTConnect version it's reading.

Reads run the same pipeline in reverse: the agent (or an XmlAdapter peer) reads the response stream, MTConnect.MTConnectVersion walks the document's xmlns to pick the version, and the matching DTO deserializes the payload.

Caveats and Known Divergences

  • Schema validation is opt-in. The codec emits XML unconditionally; it does not validate every write against the XSD. Call XmlValidator.ValidateXml explicitly when validation matters (e.g. before persisting an envelope or before relaying to a downstream consumer that gates on validation).
  • The v1.9 namespace does not exist. The MTConnect Standard numbered v1.8 → v2.0 directly. A document carrying urn:mtconnect.org:MTConnectStreams:1.9 is malformed by definition; the codec's namespace lookup returns the default empty Version for it, and downstream code paths treat the result as an unknown version.
  • XSD 1.1 features are not enforced. The published XSDs include XSD 1.1 assertions and conditional type assignments that .NET's XmlReader does not evaluate. Validation catches structural shape only; spec-prose rules (e.g. cross-element constraints not expressible in pure XSD 1.0) are enforced by the agent's typed object model, not by the validator. The compliance harness under tests/Compliance/ carries the XSD 1.1 + xlink runner that fills the gap.
  • Schema-pinned attribute order is not load-bearing. The MTConnect XSDs declare attributes in a documented order, but XML itself is order-insensitive for attributes. The codec emits attributes in the order the DTOs declare them; consumers that gate on a particular ordering are non-conformant to the XML specification, not to MTConnect.
  • The m: namespace prefix is conventional, not required. The library emits xmlns:m="urn:mtconnect.org:MTConnectStreams:<ver>" alongside the default xmlns declaration because the reference fixtures use that prefix. Consumers must accept any prefix (or none) bound to the same URI — the MTConnect Standard pins the namespace URI, not the prefix.

See Also