Explicitly Defining an xProperty on an Item
Copy
The difference between xProperties and standard properties is that you have to define an xProperty for an item before you can perform an operation (for example get/set value) with it.
You can either define the xProperty explicitly or implicitly. To explicitly define an xProperty you have to add the @explicit and @set attributes to the Property node. If you do not specify the @set attribute or if it does not contain the value “explicit”, the “@explicit” attribute is ignored.
The following example shows how to add an item and define an xProperty programmatically. The default value is set for the “xp-cost” property because the “set” attribute does not contain a “value” string:
<Item type="Part" action="add">
<xp-cost set="explicit" explicit="1"/>
<cost>128</cost>
</Item>
The following example updates an item and defines the xProperty:
<Item type="Part" action="update" id="0FA8ED...">
<xp-cost set="explicit" explicit="1"/>
<cost>128</cost>
</Item>
This example updates the item, defines an xProperty and sets its value:
<Item type="Part" action="update" id="0FA8ED...">
<xp-cost set="value|explicit" explicit="1">100<xp-cost/>
<cost>128</cost>
</Item>
This example updates the item and sets the value for an already defined xProperty:
<Item type="Part" action="update" id="0FA8ED...">
<xp-cost set="value">100<xp-cost/>
<cost>128</cost>
</Item>
This is an example of making an explicitly defined xProperty undefined:
<Item type="Part" action="update" id="0FA8ED...">
<xp-cost set="explicit" explicit="0"/>
</Item>