You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Alan Pocklington <aj...@pocko.freeserve.co.uk> on 2004/04/11 11:25:32 UTC

[Digester] Preserve line breaks.

Hi,

Is there any way to preserve the line breaks entered into an XML doc when 
parsing with Digester?

I.e. I have this xml snippet:

    	<field name="field1" value="Line 1,
    	line 2,
    	line 3/>

But when I parse the xml file with the following appropriate rule:

    	digester.addSetProperties("application/page/fieldset/field", "value",     
	"value");

The set property becomes: "Line 1, line 2, line 3".  All my nice formatting 
has been lost.

Any solutions/ideas greatly appreciated.

Thanks in advance,

Alan.



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [Digester] Preserve line breaks.

Posted by Alan Pocklington <aj...@pocko.freeserve.co.uk>.
Hi Robert,

Many thanks for your quick reply.  I have changed things around to use 
element body text as you suggested.  It should have been like that to 
start with really.  

It's working well now.

Thanks again.

Alan.



robert burrell donkin <ro...@blueyonder.co.uk> wrote in 
news:5682A296-8BA6-11D8-A1FD-003065DC754C@blueyonder.co.uk:

> hi alan
> 
> hi alan
> 
> my reading of the xml specification leads me to think that the expected 
> behaviour for the parser is to normalize the attribute value before 
> passing it to digester. the rules for this normalization depend (to 
> some extent) on the DTD (if your document has one) but i would expect 
> newlines to be replaced by simple spaces. for more information see 
> http://www.w3.org/XML/ and http://www.xml.com/axml/testaxml.htm.
> 
> you may be able to persuade the parser to retain the whitespace by 
> using entities (or some other xml magic involving DTDs) but you may be 
> better advised to consider using element body text.
> 
> - robert
> 
> On 11 Apr 2004, at 10:25, Alan Pocklington wrote:
> 
>> Hi,
>>
>> Is there any way to preserve the line breaks entered into an XML doc 
>> when
>> parsing with Digester?
>>
>> I.e. I have this xml snippet:
>>
>>          <field name="field1" value="Line 1,
>>          line 2,
>>          line 3/>
>>
>> But when I parse the xml file with the following appropriate rule:
>>
>>          digester.addSetProperties("application/page/fieldset/field", 
>> "value",
>>      "value");
>>
>> The set property becomes: "Line 1, line 2, line 3".  All my nice 
>> formatting
>> has been lost.
>>
>> Any solutions/ideas greatly appreciated.
>>
>> Thanks in advance,
>>
>> Alan.
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [Digester] Preserve line breaks.

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
hi alan

hi alan

my reading of the xml specification leads me to think that the expected 
behaviour for the parser is to normalize the attribute value before 
passing it to digester. the rules for this normalization depend (to 
some extent) on the DTD (if your document has one) but i would expect 
newlines to be replaced by simple spaces. for more information see 
http://www.w3.org/XML/ and http://www.xml.com/axml/testaxml.htm.

you may be able to persuade the parser to retain the whitespace by 
using entities (or some other xml magic involving DTDs) but you may be 
better advised to consider using element body text.

- robert

On 11 Apr 2004, at 10:25, Alan Pocklington wrote:

> Hi,
>
> Is there any way to preserve the line breaks entered into an XML doc 
> when
> parsing with Digester?
>
> I.e. I have this xml snippet:
>
>     	<field name="field1" value="Line 1,
>     	line 2,
>     	line 3/>
>
> But when I parse the xml file with the following appropriate rule:
>
>     	digester.addSetProperties("application/page/fieldset/field", 
> "value",
> 	"value");
>
> The set property becomes: "Line 1, line 2, line 3".  All my nice 
> formatting
> has been lost.
>
> Any solutions/ideas greatly appreciated.
>
> Thanks in advance,
>
> Alan.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org