Drawings SDK Developer Guide > Using Drawings Revision Control > Working with the XML Scheme for DRC > Working with Attributes for Class Versions
Working with Attributes for Class Versions

To work with class versions, the next attributes are used:

  • oda:addInVersion="value" — Used in <xs:element>, <oda:array>, <oda:condition> tags.
  • oda:deletedInVersion="value" — Used in <xs:element>, <oda:array>, <oda:condition> tags.
  • oda:default="value" — Used in <xs:element>, <oda:array>, <oda:condition> tags that have the "oda:addInVersion" attribute. For Ge objects, this attribute contains multiple values separated with commas. For example, a 3D object: oda:default="-2.01, 2.000000000006, 22.0". For example, a 2D object: oda:default="-2.01, 2.000000000006".

All classes (<xs:complexType> tag) must have an "oda:version="value" " attribute, where the value >= 1. When a new schema is released with some classes that are changed, they must increase their own "oda:version" attribute. Elements, conditions, and arrays that are added or deleted from this class must have the "oda:addInVersion/oda:deletedInVersion" attribute. For example:


OdResult LineExample::dwgInFields(OdDbDwgFiler* pFiler)
{
  m_NC = pFiler->rdInt32();
  if(version < 3)
    m_NG = pFiler->rdInt32();
  m_strPoint = pFiler->rdPoint2d();
  m_endPoint = pFiler->rdPoint2d();
}

<xs:complexType name=" LineExample " oda:version="4">
  <xs:sequence>
    <xs:element name="m_NC" type="xs:int "/>
    <xs:element name="m_NG" type="xs:int " oda:deletedInVersion="3"/>
    <xs:element name="m_strPoint" type="OdGePoint2d"/>
    <xs:element name="m_endPoint" type="OdGePoint2d"/>
  </xs:sequence>
</xs:complexType>

Below is a new version of the class.


OdResult LineExample::dwgInFields(OdDbDwgFiler* pFiler)
{
  m_NC = pFiler->rdInt32();
  if(version < 3)
    m_NG = pFiler->rdInt32();
  m_strPoint = pFiler->rdPoint2d();
  m_endPoint = pFiler->rdPoint2d();
  if(version > 4)
    m_color = pFiler->rdInt32();
}

<xs:complexType name=" LineExample " oda:version="5">
  <xs:sequence>
	<xs:element name="m_NC" type="xs:int "/>
	<xs:element name="m_NG" type="xs:int " oda:deletedInVersion="3"/>
	<xs:element name="m_strPoint" type="OdGePoint2d"/>
	<xs:element name="m_endPoint" type="OdGePoint2d"/>
	<xs:element name="m_color" type="xs:int " oda:addInVersion="5" oda:default="0"/>
  </xs:sequence>
</xs:complexType>

You can also use the combination of "oda:addInVersion" and "oda:deletedInVersion" attributes when a tag was first added and then deleted in later versions. For example:

<xs:element name="m_var8" type="xs:int" oda:addInVersion="4" oda:default="20" oda:deletedInVersion="6"/>

The difference between the oda:default attribute for an element, array, or condition is the following:

  • If a new condition or array (one that is added to a new version) could not find a value in the cache by key (name attribute), it is taken from oda:default.
  • For <xs:element> with the oda:default attribute, convert the object from the old version to the new version. For example, if you try open a .tig file that was saved in a previous version, this file will be converted to the actual version. For new elements, a default value is inserted.

See Also

Working with the XML Scheme for Revision Control

Copyright © 2002 – 2021. Open Design Alliance. All rights reserved.