attribute is defaulted

operator

Return type:
Switch
Returns:
Returns true when the attribute is not specified and has its default value, and false otherise. Replacing is with isnt reverses the result.
Syntax
attribute attribute-name (of element-expression)? (is | isnt) defaulted
    


Purpose

The is defaulted attribute type test succeeds when:

  • the referenced element attribute has a default value, given in the attribute declaration, but no value is set in the start tag of the element in the document instance, or
  • the referenced data attribute has a default value, given in the declaration for the external entity's notation, but no value is set in the entity declaration.

Otherwise, the test fails. Using isnt instead of is reverses the results.

Unlike most other attribute references, no error is generated if the specified attribute does not exist, or was not given a value, since the test does not actually use the value.

If the element-expression references an element that does not exist, or the specified attribute is not declared, the is form of the test always fails, and the isnt form always succeeds.