Arbortext Command Language > Callbacks > doc_add_callback > attribute_default_value Callback Type
  
attribute_default_value Callback Type
Function prototype:
function funcname (doc, oid, attrArr[,flag])
attribute_default_value is called whenever default attribute values for an element are needed. The callback allows default attribute values to be provided when the default value is not specified in the DTD or schema or when a default value should be inherited from other elements. This callback is only used for Column View display, not during DITA document publishing.
This function returns either a count of the number of items added to attrArr, 0 if no items were added to attrArr, or -1 if there was an error.
Arguments:
doc — The identifier of the document containing the element for which you want to provide default values.
oid — The object identifier (OID) of the element for which you want to provide default values.
attrArr — An input/output associative array with the array key being the attribute names and the array values being the default values for the corresponding attribute.
As a special case, when the callback is called to obtain default values to display for Column view, the first attribute name in attrArr will be the string *ElementName*. If its value is changed, then that value will replace the element name in the Column view Outline column.
Note that attributes can have a legitimate value of the empty string, for example if the attribute is a CDATA attribute. To distinguish between an attribute that is not defaulted and an empty string value, the value of *ATI_EMPTY_STRING* should be returned for any attribute that has a legitimate value of the empty string. Any calling program must be prepared to accept and handle this special value.
If multiple callbacks are registered, attrArr will accumulate the default values from each of the routines. Callback routines can overwrite values provided by previously called routines, but they should do so deliberately and with care. In general, separate callbacks will deal with different sets of attributes. For example, one callback might be registered to deal with the standard DITA elements and attributes, while another might be registered to deal with a set of namespaced elements or attributes. You can leave the default value for an attribute empty (null) when there is no default value for the attribute or when the particular routine does not know the default value for the attribute. The callback routine might be called with the names of attributes in attrArr that do not exist for the element represented by oid or for namespaced attributes, so the callback must be prepared to deal with this by returning a default value, a null string, or returning no value.
flag — An optional set of option bit flags which default to zero. Allowed values are:
0x0000 — Process normally, adding default values that are inherited from ancestors and application and processor default values.
0x0001 — Process as with flag 0x0000, except for DITA map documents. For DITA map documents, add default values that are inherited from ancestors and application and processor supplied default values for only the scope and format attributes.
0x0002 — Process as with flag 0x0000, except for DITA map documents. For DITA map documents, do not add default values that are inherited from ancestors or any application or processor supplied default values for any attributes. (0x0002 overrides 0x0001.)
Other bits are unused and should be zero.