Supporting Resource Properties in Attribute XML Files

Currently there is no Property support in SMTK Attribute XML Reader. This topic presents a design on support Properties in the SBT XML Format. Note that this is only for reading XML. The XML writers are not being modified to support saving Properties.

Proposed Format

Add a Properties Element Block to the XML File that is at the same level as Categories, Analysis, Definitions, etc… The initial design will deal with the following Property types:

  • Integer
  • Double
  • String
  • Boolean

We can extend the support later for vectors and custom properties .

  <Properties>
    <Property Name="myInt" Type="int">10</Property>
    <Property Name="myPi" Type="double">3.141</Property>
    <Property Name="myString" Type="string">String Value</Property>
    <Property Name="myBool" Type="bool">true</Property>
  </Properties>

We can easily add this support for Attribute Instances if there is a need for it.

In the case for string properties, this:

    <Property Name="myString" Type="string"></Property>

Will produce an empty string property myString.

Effect of Using Included Files

Since an Attribute XML file can include other Attribute XML files, we do have to deal with the case of having to process multiple Properties Elements which could have overlapping Properties being defined.
Since the included files are processed first, their Properties Block will be processed before the Properties of the file that included them; therefore, the file’s Properties will override those set by the included files.

Boolean Values

You can use t, true, yes, and 1 for true and f, false, no, and 0 for false. Any surrounding white-space is ignored as well as case.

You can find the merge request here.

This implementation also supports adding Properties to Attributes using the same format above, except that the Properties node would be a child of an Att node. You can also look at data/attribute/attribute_collection/propertiesExample.rst and smtk/attribute/testing/cxx/unitXmlReaderProperties.cxx for a sample XML file and test.

Removing Properties

The implementation does not support removal of Properties but we could easily support this in the future by adding an XML attribute:

    <Property Name="myPi" Type="double" Remove="true"/>

@waj334 @chart3388 @johnt @dcthomp - FYI

+1

Additional notes from offline discussion:

  • If an invalid value is specified, a warning will be logged and the property will not be added to the resource.
  • Empty string values are valid.
  • Boolean values can be set to “true” or “false” with optional capitalization (i.e., “True” and “False” are also valid, as are “TRUE” and “FALSE”).