Making Elements Read-Only
There are three scenarios when an XML editor may need to prevent users from modifying certain elements of XML:
- Prevent editing of a certain attribute
- Prevent an element from being removed from its parent
- Prevent editing of an element and all child nodes contained in it
All three scenarios could be enforced for a certain class of elements, (see lock attribute in model.xml) as well as for specific elements within the provided XML.
To enforce one of these rules on specific elements within XML, the developer uses the special _lock attribute. Its value will identify how the element should be handled. List of available values:
| _lock attribute value |
Description |
| attribute:<attribute_name> |
Prohibits editing of the specified attribute. For example:
<section product="UV Scanner"
_lock="attribute:product">
...
</section> |
| content |
Prohibits editing of an element along with attributes and child nodes. For example:
<section _lock="content">
...
</section> |
| inparent |
Prevents any action that could remove the element from its parent. For example:
<section _lock="inparent">
...
</section> |
| any combination of values above |
Combines the effect of multiple settings. Values should be coma or space separated. For example:
<section
_lock="inparent,attribute:product">
...
</section> |
Restriction: At the moment, the editor only enforces the read-only policy for WYSIWYG and Outline editing modes. Using the raw XML editing mode, users can overwrite read-only customizations. This issue will be addressed in future versions of the editor.
|