## F.15 Example

An example of the UANodeSet can be found below.

This example defines the Nodes for an InformationModel with the URI of “http://sample.com/Instances”. This example references Nodes defined in the base OPC UA InformationModel and an InformationModel with the URI “http://sample.com/Types”.

The XML namespaces declared at the top include the URIs for the Namespaces referenced in the document because the document includes Complex Data. Documents without Complex Data would not have these declarations.


<UANodeSet
xmlns:s1="http://sample.com/Instances"
xmlns:s0="http://sample.com/Types"
xmlns:uax="http://opcfoundation.org/UA/2008/02/Types.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://opcfoundation.org/UA/2011/03/UANodeSet.xsd">



The NamespaceUris table includes all Namespaces referenced in the document except for the base OPC UA InformationModel. A NamespaceIndex of 1 refers to the URI “http://sample.com/Instances”.


<NamespaceUris>
<Uri>http://sample.com/Instances</Uri>
<Uri>http://sample.com/Types</Uri>
</NamespaceUris>



The Aliases table is provided to enhance readability. There are no rules for what is included. A useful guideline would include standard ReferenceTypes and DataTypes if they are referenced in the document. An Alias may be used for any NodeId value in the document except for NodeIds that appear in Values of Variables or VariableTypes.


<Aliases>
<Alias Alias="HasComponent">i=47</Alias>
<Alias Alias="HasProperty">i=46</Alias>
<Alias Alias="HasSubtype">i=45</Alias>
<Alias Alias="HasTypeDefinition">i=40</Alias>
</Aliases>



The BicycleType is a DataType Node that inherits from a DataType defined in another InformationModel (ns=2;i=314). It is assumed that any application importing this file will already know about the referenced InformationModel. A Server could map the references onto another OPC UA Server by adding a ServerIndex to TargetNode NodeIds. The structure of the DataType is defined by the Definition element. This information can be used by code generators to automatically create serializers for the DataType.


<DisplayName>BicycleType</DisplayName>
<References>
<Reference ReferenceType="HasSubtype" IsForward="false">ns=2;i=314</Reference>
</References>
<Definition Name="BicycleType">
<Field Name="NoOfGears" DataType="UInt32" />
<Field Name="ManufacturerName" DataType="String" />
</Definition>



This Node is an instance of an Object TypeDefinition Node defined in another InformationModel (ns=2;i=341). It has a single Property which is declared later in the document.

<UAObject NodeId="ns=1;i=375" BrowseName="1:DriverOfTheMonth" ParentNodeId="ns=1;i=281">
<DisplayName>DriverOfTheMonth</DisplayName>
<References>
<Reference ReferenceType="HasProperty">ns=1;i=376</Reference>
<Reference ReferenceType="HasTypeDefinition">ns=2;i=341</Reference>
<Reference ReferenceType="HasComponent" IsForward="false">ns=1;i=281</Reference>
</References>
</UAObject>



This Node is an instance of a Variable TypeDefinition Node defined in base OPC UA InformationModel (i=68). The DataType is the base type for the BicycleType DataType. The AccessLevels declare the Variable as Readable and Writeable. The ParentNodeId indicates that this Node is tightly coupled with the Parent (DriverOfTheMonth) and will be deleted if the Parent is deleted.

<UAVariable NodeId="ns=1;i=376" BrowseName="2:PrimaryVehicle"
ParentNodeId="ns=1;i=375" DataType="ns=2;i=314" AccessLevel="3">
<DisplayName>PrimaryVehicle</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
<Reference ReferenceType="HasProperty" IsForward="false">ns=1;i=375</Reference>
</References>


This Value is an instance of a BicycleType DataType. It is wrapped in an ExtensionObject which declares that the value is serialized using the Default XML DataTypeEncoding for the DataType. The Value could be serialized using the Default Binary DataTypeEncoding but that would result in a document that cannot be edited by hand. No matter which DataTypeEncoding is used, the NamespaceIndex used in the ManufactureName field refers to the NamespaceUris table in this document. The application is responsible for changing whatever value it needs to be when the document is loaded by an application.


<Value>
<ExtensionObject xmlns="http://opcfoundation.org/UA/2008/02/Types.xsd">
<TypeId>
<Identifier>ns=1;i=366</Identifier>
</TypeId>
<Body>
<s1:BicycleType>
<s0:Make>Trek</s0:Make>
<s0:Model>Compact</s0:Model>
<s1:NoOfGears>10</s1:NoOfGears>
<s1:ManufactureName>
<uax:NamespaceIndex>1</uax:NamespaceIndex>
<uax:Name>Hello</uax:Name>
</s1:ManufactureName>
</s1:BicycleType>
</Body>
</ExtensionObject>
</Value>
</UAVariable>



These are the DataTypeEncoding Nodes for the BicycleType DataType.

<UAObject NodeId="ns=1;i=366" BrowseName="Default XML">
<DisplayName>Default XML</DisplayName>
<References>
<Reference ReferenceType="HasEncoding" IsForward="false">ns=1;i=365</Reference>
<Reference ReferenceType="HasTypeDefinition">i=76</Reference>
</References>
</UAObject>
<UAObject NodeId="ns=1;i=370" BrowseName="Default Binary">
<DisplayName>Default Binary</DisplayName>
<References>
<Reference ReferenceType="HasEncoding" IsForward="false">ns=1;i=365</Reference>
<Reference ReferenceType="HasTypeDefinition">i=76</Reference>
</References>
</UAObject>