Difference between revisions of "Extending the Schema"

From MTConnect® User's Portal
Jump to: navigation, search
(First cut)
 
m
Line 7: Line 7:
 
== Adding a new Data Item Type ==  
 
== Adding a new Data Item Type ==  
  
The header  
+
The header must look something like the following:
  
<code>
+
<source lang="XML" line>
 
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns='urn:example.com:ExampleStreams:1.2'  
 
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns='urn:example.com:ExampleStreams:1.2'  
xmlns:e='urn:example.com:ExampleStreams:1.2' targetNamespace='urn:example.com:ExampleStreams:1.2' elementFormDefault='qualified' attributeFormDefault='unqualified' xmlns:mt='urn:mtconnect.org:MTConnectStreams:1.2'>
+
  xmlns:e='urn:example.com:ExampleStreams:1.2'
 +
  targetNamespace='urn:example.com:ExampleStreams:1.2' elementFormDefault='qualified'  
 +
  attributeFormDefault='unqualified' xmlns:m='urn:mtconnect.org:MTConnectStreams:1.2'>
 
   <xs:import namespace='urn:mtconnect.org:MTConnectStreams:1.2' schemaLocation='../MTConnectStreams_1.2.xsd'/>
 
   <xs:import namespace='urn:mtconnect.org:MTConnectStreams:1.2' schemaLocation='../MTConnectStreams_1.2.xsd'/>
</code>
+
</source>
 +
 
 +
The header needs to be modified slightly to include the new namespace <code>e</code> and MTConnect must remain the default namespace. The statements on lines 3 and 4 show how this is done. The MTConnect namespace <code>m</code> should always be assigned to MTConnect, this will make sure the agent operates correctly when generating XML.

Revision as of 04:20, 27 February 2014

MTConnect was designed with various extension points that are created as substitution groups. These extension points allow for new elements to be created that have certain properties that must be inherited from the parent to provide consistency for an application. There are three places where the MTConnect schema can be extended using an additional namespace: 1. New components can be added, 2. new data item types can be added, and 3. new asset types or measurements can be added. Each requires extending one of the three main XSD schema file. The XSD can be extended using a separate namespace in a separate XSD file and importing the base MTConnect XSD or you can use the schema generator to create the file for you.

Adding a new Component

Adding a new Data Item Type

The header must look something like the following:

  1. <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns='urn:example.com:ExampleStreams:1.2' 
  2.    xmlns:e='urn:example.com:ExampleStreams:1.2'
  3.   targetNamespace='urn:example.com:ExampleStreams:1.2' elementFormDefault='qualified' 
  4.   attributeFormDefault='unqualified' xmlns:m='urn:mtconnect.org:MTConnectStreams:1.2'>
  5.   <xs:import namespace='urn:mtconnect.org:MTConnectStreams:1.2' schemaLocation='../MTConnectStreams_1.2.xsd'/>

The header needs to be modified slightly to include the new namespace e and MTConnect must remain the default namespace. The statements on lines 3 and 4 show how this is done. The MTConnect namespace m should always be assigned to MTConnect, this will make sure the agent operates correctly when generating XML.