The oxy:allows-child-element() Function

This extension function allows author actions to be available in a context only if the associated schema permits it.

The oxy:allows-child-element() is evaluated at the caret position and has the following signature: oxy:allows-child-element($childName, ($attributeName, $defaultAttributeValue, $contains?)?).

The following parameters are supported:
childName
the name of the element that you want to check whether it is valid in the current context. Its value is a string that supports the following forms:
  • the child element with the specified local name that belongs to the default namespace.
    oxy:allows-child-element("para")
    The above example verifies if the para element (of the default namespace) is allowed in the current context.
  • the child element with the local name specified by any namespace.
    oxy:allows-child-element("*:para")
    The above example verifies if the para element (of any namespace) is allowed in the current context.
  • a qualified name of an element.
    oxy:allows-child-element("prefix:para")
    The prefix is resolved in the context of the element where the caret is located. The function matches on the element with the para local name from the previous resolved namespace. In case the prefix is not resolved to a namespace, the function returns false.
  • any element.
    oxy:allows-child-element("*")
    The above function verifies if any element is allowed in the current context.
    Note: A common use case of oxy:allows-child-element("*") is in combination with the attributeName parameter.
attributeName
the attribute of an element that you want to check whether it is valid in the current context. Its value is a string that supports the following forms:
  • the attribute with the specified name from no namespace.
    oxy:allows-child-element("*", "class", " topic/topic ")
    The above example verifies if an element with the class attribute and the default value of this attribute (that contains the topic/topic string) is allowed in the current context.
  • the attribute with the local name specified by any namespace.
    oxy:allows-child-element("*", "*:localname", " topic/topic ")
  • a qualified name of an attribute.
    oxy:allows-child-element("*", "prefix:localname", " topic/topic ")
    The prefix is resolved in the context of the element where the caret is located. In case the prefix is not resolved to a namespace, the function returns false.
defaultAttributeValue
a string that represents the default value of the attribute. Depending on the value of the next parameter the default value of the attribute must either contain this value or be equal with it.
contains
an optional boolean. The default value is true. For the true value, the default value of the attribute must contain the defaultAttributeValue parameter. In case the value is false, the two values must be the same.