You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by indian scorpio <co...@gmail.com> on 2008/04/18 09:06:26 UTC

New line & tab characters getting replaced by space

Hi

I am using XML DOM parser -
----------------------------------------------------------------------------------------
            org.apache.xerces.parsers.DOMParser parser = new
org.apache.xerces.parsers.DOMParser();
            String inputSpecName
            StringReader reader = new StringReader(inputSpecName);
            InputSource inputSource = new InputSource(reader);
             parser.parse(inputSource);
             //parser.
             org.w3c.dom.Document doc = parser.getDocument();
             org.w3c.dom.Node xNode = doc.getDocumentElement();
--------------------------------------------------------------------------------------------
where inputSpecName is a XML document as a String

Issue:

<Node Id="iioui" FunctionType="*iioui = &amp;srcFld1 ;*

*iioui=iioui+1 + ~contDeductible ;*

*iioui=iioui*5;*

*iioui=fibo(iioui);*

*iioui=mynewfunc(iioui)*

*iioui= iioui +1*" />
String in the attribute FunctionType consists of multiple-lines. Till
'inputSource' this is the case but once I parse and try to read myAttribute
from xNode - it loses this info & all new lines/ tabs etc are replaced by
simple space. Is there somthing creepy which I am doing...???

Tried to search Mailing List but couldn't find anything concrete (
http://marc.info/?l=xerces-j-user&m=112119927804184&w=2)

Re: New line & tab characters getting replaced by space

Posted by Stanimir Stamenkov <s7...@netscape.net>.
Sun, 20 Apr 2008 14:32:47 +0530, /indian scorpio/:
> On Fri, Apr 18, 2008 at 5:02 PM, <ke...@us.ibm.com> wrote:
> 
>> Whitespace will always be normalized in XML attribute values. If you 
>> don't want that happening, put the text in a child element instead.
>> 
>> http://www.w3.org/TR/REC-xml/#AVNormalize
> 
> A small doubt - is this the issue only with DOm Parser & not with SAX 
> parser. It seems to me that whike using SAX Parser line breaks etc are 
> maintained as such

Every XML processor is required to perform the attribute-value 
normalization.  Failing to do that makes it non-conforming to the 
XML specification.

You say "it seems to me" - have you verified there's difference with 
your DOM and SAX implementations?

-- 
Stanimir

---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: New line & tab characters getting replaced by space

Posted by indian scorpio <co...@gmail.com>.
A small doubt - is this the issue only with DOm Parser & not with SAX
parser. It seems to me that whike using SAX Parser line breaks etc are
maintained as such

On Fri, Apr 18, 2008 at 5:02 PM, <ke...@us.ibm.com> wrote:

>
> Whitespace will always be normalized in XML attribute values. If you don't
> want that happening, put the text in a child element instead.
>
> http://www.w3.org/TR/REC-xml/#AVNormalize
>
> ______________________________________
> "... Three things see no end: A loop with exit code done wrong,
> A semaphore untested, And the change that comes along. ..."
>  -- "Threes" Rev 1.1 - Duane Elms / Leslie Fish (
> http://www.ovff.org/pegasus/songs/threes-rev-11.html)

Re: New line & tab characters getting replaced by space

Posted by ke...@us.ibm.com.
Whitespace will always be normalized in XML attribute values. If you don't 
want that happening, put the text in a child element instead.

http://www.w3.org/TR/REC-xml/#AVNormalize

______________________________________
"... Three things see no end: A loop with exit code done wrong,
A semaphore untested, And the change that comes along. ..."
  -- "Threes" Rev 1.1 - Duane Elms / Leslie Fish (
http://www.ovff.org/pegasus/songs/threes-rev-11.html)