| Summary: | Empty model element should be deleted from source | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | Ling Hao <ling.hao> |
| Component: | Sapphire | Assignee: | Konstantin Komissarchik <konstantin> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | konstantin, shenxue.zhou |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
|
Description
Ling Hao
There may be cases where this is desired (such as implied element properties), but we will not in general remove empty parent elements when content is deleted. Before we can remove an element, we need to know that its presence doesn't carry semantic information.
In the sited cases, the bindings are defined as follows:
@XmlElementBinding( path = "homogeneous", mappings = @XmlElementBinding.Mapping( element = "child", type = IChildElement.class ) )
@XmlElementBinding
(
path = "heterogeneous",
mappings =
{
@XmlElementBinding.Mapping( element = "child", type = IChildElement.class ),
@XmlElementBinding.Mapping( element = "child-with-integer", type = IChildElementWithInteger.class ),
@XmlElementBinding.Mapping( element = "child-with-enum", type = IChildElementWithEnum.class )
}
)
In these cases, we do know that element specified in the path attribute ("homogeneous" and "heterogeneous") are just structural and do not carry semantic information. They are created as necessary and the can be deleted if empty.
Targeting to 0.3 for now in order to review cases.
This was already implemented for value and list property bindings, but element property bindings (implied and explicit) weren't acting in the same manner. Fixed that. Please verify. Verified with sapphire-gallery.xml and the coherence use case. The fix causes a regression when the model element only contains xml attributes. For example, the following generated xml: <?xml version="1.0" encoding="UTF-8"?> <adfc-config xmlns="http://xmlns.oracle.com/adf/controller" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/adf/controller http://xmlns.oracle.com/adf/controller/1.0"> <task-flow-definition id="task-flow-definition"> </adfc-config> becomes: <?xml version="1.0" encoding="UTF-8"?> <adfc-config xmlns="http://xmlns.oracle.com/adf/controller" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/adf/controller http://xmlns.oracle.com/adf/controller/1.0"> </adfc-config> Using the same code snippet: XmlResourceStore xmlStore = new XmlResourceStore( new WorkspaceFileResourceStore(taskFlowFile)); IADFController controller = IADFController.TYPE.instantiate(new RootXmlResource(xmlStore)); controller.getTaskFlow().setTaskFlowId(id); xmlStore.save(); Fixed the issue with attributes. TestXmlBinding0008 now covers this scenario, including the attributes corner case. Please re-verify the original scenarios too. I've verified with my use case. Verified with sapphire-gallery.xml and the coherence use case again. |