Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 325988

Summary: Translator framework: can't insert text into empty node
Product: [WebTools] WTP Common Tools Reporter: Carl Anderson <ccc>
Component: wst.commonAssignee: Carl Anderson <ccc>
Status: RESOLVED FIXED QA Contact: Carl Anderson <ccc>
Severity: normal    
Priority: P3 CC: keith.chong.ca, valentinbaciu
Version: 2.0Flags: ccc: review+
Target Milestone: 3.2.2 P   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on: 190876    
Bug Blocks:    
Attachments:
Description Flags
Same patch none

Description Carl Anderson CLA 2010-09-22 12:58:31 EDT
This bug is for inclusion in WTP 3.2.2 patches

+++ This bug was initially created as a clone of Bug #190876 +++

We have a schema that allows for the following three options:

(no tag) - means that the setting is null
<tag/> - means that the setting has default value (I believe this should be the equivalent to <tag></tag>, but is the preferred method of specifying this default behavior)
<tag>value</tag> - means that the setting has the non-default value "value"

So we utilize a translator.  We can't use the type setting EMPTY_TAG, because that means that there should never be text content (or at least we get exceptions when there is content)  And the setting EMPTY_CONTENT_IS_SIGNIFICANT doesn't seem to have any effect.  The only setting we use is END_TAG_NO_INDENT.

Our problem occurs when trying to set the model value to "value" and the XML is in the form "<tag/>".  Nothing happens to the XML.  The problem is in EMF2DOMAdapterImpl#findOrCreateTextNode(Node, Translator, String).  We have overridden convertValueToString(Object, EOwner) in our code, so we do have a String value to insert into the XML, but this method simply determines that the XML element is an empty element, and doesn't create a text node for it.  It's a no-op.

I'm not sure exactly what the correct behavior is, but my guess is that if we are trying to set a non-null value into an empty tag, the adapter should check the translator to see if that's allowed, and should create a closing tag and a text node.

Otherwise, we just can't use translators to solve this problem.

(Additionally, we can't get the translators to create an empty tag by default over the form "<tag></tag>", but since the forms should be equivalent, that's not a huge problem)
Comment 1 Carl Anderson CLA 2010-09-22 13:01:08 EDT
Created attachment 179393 [details]
Same patch
Comment 2 Carl Anderson CLA 2010-10-04 14:33:40 EDT
Committed to R3_2_2_patches