Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 325988 - Translator framework: can't insert text into empty node
Summary: Translator framework: can't insert text into empty node
Status: RESOLVED FIXED
Alias: None
Product: WTP Common Tools
Classification: WebTools
Component: wst.common (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2.2 P   Edit
Assignee: Carl Anderson CLA
QA Contact: Carl Anderson CLA
URL:
Whiteboard:
Keywords:
Depends on: 190876
Blocks:
  Show dependency tree
 
Reported: 2010-09-22 12:58 EDT by Carl Anderson CLA
Modified: 2010-10-04 14:33 EDT (History)
2 users (show)

See Also:
ccc: review+


Attachments
Same patch (1.14 KB, patch)
2010-09-22 13:01 EDT, Carl Anderson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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