oxy:allows-child-element() Function
The oxy:allows-child-element() function allows you to check whether or not an element that matches the arguments of the function is valid as a child of the element at the current cursor position, according to the associated schema. It is evaluated at the cursor position and has the following signature:
oxy:allows-child-element($childName, ($attributeName, $defaultAttributeValue,
$contains?)?)
childName
- The name of the element that you want to check if 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 prefix-qualified name of an element.
oxy:allows-child-element("prefix:para")
The prefix is resolved in the context of the element where the cursor is located. The function matches on the element with the
para
local name from the previously resolved namespace. If the prefix is not resolved to a namespace, the function returns a value offalse
. -
A specified namespace-URI-qualified name of an element.
oxy:allows-child-element("{namespaceURI}para")
The
namespaceURI
is the namespace of the element. The above example verifies if the<para>
element (of the specified namespace) is allowed in the current context. -
Any element.
oxy:allows-child-element("*")
The above function verifies if any element is allowed in the current context.Note: A common use case ofoxy:allows-child-element("*")
is in combination with theattributeName
parameter.
-
attributeName
- The attribute of an element that you want to check if 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 thetopic/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 cursor is located. If the prefix is not resolved to a namespace, the function returns a value of
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 to it.
contains
- An optional boolean. The default value is
true
. For thetrue
value, the default value of the attribute must contain thedefaultAttributeValue
parameter. If the value isfalse
, the two values must be the same.