Control XML Serialization in the Oxygen XML Author Component
Use Case
You want to force the Oxygen XML Author Component to save the XML with zero indent size and not to break the line inside block elements.
Solution
Usually, in a standalone version of Oxygen XML Author, the and preferences pages allow you to control the way the XML is saved on the disk after you edit it in the Author mode.
Also, the APIAccessibleOptionTags interface contains a list of all accessible keys that can be read or set from the options.
In the Oxygen XML Author application, you can either bundle a default set of options or use the
PluginWorkspace.setGlobalObjectProperty(String, Object)
API://For not breaking the line
//Long line
pluginWorkspace.setObjectProperty
(APIAccessibleOptionTags.EDITOR_LINE_WIDTH, new Integer(100000));
//Do not break before inline elements
pluginWorkspace.setObjectProperty
(APIAccessibleOptionTags.EDITOR_FORMAT_INDENT_INLINE_ELEMENTS, false);
//For forcing zero indent
//Force indent settings to be controlled by us
pluginWorkspace.setObjectProperty
(APIAccessibleOptionTags.EDITOR_DETECT_INDENT_ON_OPEN, false);
//Zero indent size
pluginWorkspace.setObjectProperty
(APIAccessibleOptionTags.EDITOR_INDENT_SIZE, 0);
In the Oxygen XML Author Component, you can either bundle a fixed set of options, or use
the Java API to set properties that overwrite the default
options.
//For not breaking the line
//Long line
AuthorComponentFactory.getInstance().setObjectProperty
(APIAccessibleOptionTags.EDITOR_LINE_WIDTH, new Integer(100000));
//Do not break before inline elements
AuthorComponentFactory.getInstance().setObjectProperty
(APIAccessibleOptionTags.EDITOR_FORMAT_INDENT_INLINE_ELEMENTS, false);
//For forcing zero indent
//Force indent settings to be controlled by us
AuthorComponentFactory.getInstance().setObjectProperty
(APIAccessibleOptionTags.EDITOR_DETECT_INDENT_ON_OPEN, false);
//Zero indent size
AuthorComponentFactory.getInstance().setObjectProperty
(APIAccessibleOptionTags.EDITOR_INDENT_SIZE, 0);