Digging into the code I see that the setWhiteSpace("preserve") call in the generated code does nothing as all the \r, \n, and \t characters are stripped some time before the StringValidator's validate method is called.
Looking at the code in UnmarshalHandler, it seems the only way whiteSpace will get preserved is if the instance document has xml:space=preserve as an attrubite for the element or one of the element's ancestors.
Is this really the desired behavior?
I see Keith's note on the normalize method in StringValidator:
* NOTE: THIS METHOD SHOULD NOT BE HERE..SHOULD BE MOVED
* TO A FieldHandler or to the Unmarshaller...but not
* here!!! (kvisco 20030125)I'm guessing this is all related.
-David
David Blevins wrote:
Hello Castor crew, hope all is well.
I am also having trouble with preserving whitespace, figured I'd respond to this thread for archive purposes (love news.gmane.org).
I am in the process of upgrading OpenEJB to Castor 0.9.5.3 from 0.9.2. I updated schemas and regenerated our config objects with no problems, but now all element data is without line separators. The generated code for getContent() looks good:
desc = new XMLFieldDescriptorImpl( String.class, "_content", "PCDATA", NodeType.Text); [snip] StringValidator typeValidator = new StringValidator(); typeValidator.setWhiteSpace("preserve"); fieldValidator.setValidator(typeValidator);
Any ideas?
-David Blevins
Bill Marcum wrote:
Turns out the 'preserve' stuff works on elements, but not on attributes. Not sure if that's a bug or not...
-----Original Message-----
From: Keith Visco [mailto:[EMAIL PROTECTED] Sent: Thursday, August 21, 2003 11:27 PM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] Having trouble with whiteSpace="preserve"
Hi Bill,
I believe whiteSpace="preserve" is supposed to do what you want, but if it's not working, then you probably want to open up a Bugzilla report (http://bugzilla.exolab.org).
Thanks,
--Keith
Bill Marcum wrote:
So Anyway, based on castor and xml schema documentation, I should be able to specify a simpleType with the whiteSpace="preserve" attribute,
and the effect should be that my carriage return/line feeds would be preserved. But it doesn't work. Does castor support this? Does the Xerces parser support this? Is there another method to acheive this?
-----Original Message----- From: Bill Marcum Sent: Tuesday, August 19, 2003 8:54 AM To: [EMAIL PROTECTED] Subject: [castor-dev] Having trouble with whiteSpace="preserve"
I'm trying to preserve crlfs in some string content. I've heard hints and rumours about the whiteSpace facet, but I'm having no luck getting it to work. I'm defining a new simpleType, specifying the whiteSpace="preserve" facet, and creating an attribute of that type. But the marshal/unmarshall behavior always seems to perform "collapse" behavior on my string.
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
