[ 
http://jira.codehaus.org/browse/XFIRE-529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_89895
 ] 

Andrzej Doyle commented on XFIRE-529:
-------------------------------------

I've encountered this issue with 1.2.4 and the cause is the same as Andy D 
identified earlier.  I suspect that removing the trim() call from the 
getValue() method will probably break other components, as often the text 
content of an XML element contains 'alignment' whitespace that isn't part of 
the value itself.

However, I do recognise that it needs to be possible to get at the raw textual 
content - in the context where we call getValue() from StringType.readObject(), 
there is never any superfluous whitespace and so the text content of the node 
is exactly what we want to return.  In the absence of any deeper knowledge 
about how getValue() is used, one could simply have an alternative method 
(something like getRawContent()) that *doesn't* trim the data.  Since this 
isn't on the MessageReader interface it would be horribly hack-y to call from 
StringType though.

As such I second Andy's concept for a proposed solution - let the getValue() 
return the actual text value of the element, and then have the callers trim it 
themselves if necessary.  (Note that this is how the W3C DOM's Element class 
behaves - getTextContent() will include whitespace and the caller has the 
option to trim this if desired).

> leading spaces in Strings are removed i.e. not marshalled/unmarshalled 
> correctly 
> ---------------------------------------------------------------------------------
>
>                 Key: XFIRE-529
>                 URL: http://jira.codehaus.org/browse/XFIRE-529
>             Project: XFire
>          Issue Type: Bug
>          Components: Aegis Module
>    Affects Versions: 1.1.2
>         Environment: Sun j2sdk1.4.2_11 on Win32
>            Reporter: Lee G.
>         Assigned To: Dan Diephouse
>         Attachments: StringBug.java
>
>
> Leading spaces are being stripped from Strings during marshall/unmarshall.  A 
> simple JUnit test case is attached.
> <CODE>
> import java.net.MalformedURLException;
> import org.codehaus.xfire.aegis.AbstractXFireAegisTest;
> import org.codehaus.xfire.client.XFireProxyFactory;
> import org.codehaus.xfire.service.Service;
> import org.codehaus.xfire.service.invoker.BeanInvoker;
> public class StringBug  extends AbstractXFireAegisTest {
>       public void testString() throws MalformedURLException {
>               StringBug.ServiceIF svc = createLocalProxy();
>               final String textToSend = "     five leading spaces.";
>               String result = svc.echo(textToSend);
>               assertTrue("'" + result + "' are missing" ,result.length()== 
> textToSend.length());
>       }
>       private StringBug.ServiceIF createLocalProxy() throws 
> MalformedURLException {
>               final String svcURI = "xfire.local://echo";
>               final Service serviceM = 
> getServiceFactory().create(StringBug.ServiceIF.class, "echo", "", null);
>           serviceM.setInvoker(new BeanInvoker(new ServiceImpl()));
>           getServiceRegistry().register(serviceM);
>           XFireProxyFactory factory = new XFireProxyFactory(getXFire());;// 
> getXFireProxyFactory();
>               return (StringBug.ServiceIF) factory.create(serviceM, svcURI);
>       }
>       public interface ServiceIF
>       {
>               String echo(String s);
>       }
>       public class ServiceImpl implements StringBug.ServiceIF
>       {
>               public ServiceImpl() {}
>               
>               public String echo(String s )
>               {
>                       String in = "received text: '" + s + "'";
>                       System.out.println(in);
>                       return s;
>               }
>       }
> }
> </CODE>

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to