Skip to main content

Controlling the Element and Attribute Names for Array-Type Properties

Controlling the Element and Attribute Names for Array-Type Properties

Note:

This section does not apply to a collection property that specifies XMLPROJECTION as "ELEMENT". For such a property, each array item is treated as a separate property of the class. See Controlling the Projection for Collection Properties.

In an XML-enabled object, an array-type property is projected to an element with subelements, each of which is one item in that array, in the same basic way that a list property is projected; see the previous section.

Each subelement has an additional attribute that indicates the key associated with the item. You can control the name of this attribute.

Consider the following example property:

Property Tools As %ArrayOfDataTypes;

For example, suppose that (for some object instance) this property consists of an array as follows:

  • The value Hammer is stored with the key 845.

  • The value Monkey wrench is stored with the key 1009.

  • The value Screwdriver is stored with the key 3762.

By default, this property corresponds to the following XML fragment:

<Tools>
  <ToolsItem ToolsKey="845">Hammer</ToolsItem>
  <ToolsItem ToolsKey="1009">Monkey Wrench</ToolsItem>
  <ToolsItem ToolsKey="3762">Screwdriver</ToolsItem>
</Tools>

This shows the ToolsKey attribute, which corresponds to the key of an array. The name of this attribute is determined as follows:

Tag for List Item
XMLKEYNAME Parameter of Property XMLNAME Parameter of Property Name of Attribute That Contains the Key
Specified Ignored Value of XMLKEYNAME
Not specified Specified Value of XMLNAME with Key concatenated to the end
Not specified Property name with Key concatenated to the end

Notice that the XMLITEMNAME property parameter does not affect the attribute name; this parameter is discussed in the previous section.

For example, suppose you do not set XMLKEYNAME and you set XMLNAME equal to MyXMLName, as follows:

Property Tools As %ArrayOfDataTypes(XMLNAME = "MyXMLName");

Then the same property would correspond to the following XML fragment:

<MyXMLName>
  <MyXMLNameItem MyXMLNameKey="845">Hammer</MyXMLNameItem>
  <MyXMLNameItem MyXMLNameKey="1009">Monkey Wrench</MyXMLNameItem>
  <MyXMLNameItem MyXMLNameKey="3762">Screwdriver</MyXMLNameItem>
</MyXMLName>
FeedbackOpens in a new tab