[jdom-interest] Auto-normalizing attribute values

Elliotte Rusty Harold elharo at metalab.unc.edu
Sun May 12 09:39:28 PDT 2002


At 9:35 AM +0200 5/6/02, Laurent Bihanic wrote:
>Elliotte Rusty Harold wrote:
>>  Should the various setAttributeValue() methods in Element and 
>>Attribute check the attribute type and normalize the string 
>>according to the attribute type? i.e. normalize the white space if 
>>the attribute has any type other than CDATA or UNDECLARED.
>>
>That would also mean updating the attribute value when the attribute 
>type is changed. But if the type is then switched back to the 
>previous one, the original attribute value is lost.
>
>Why not just change the getAttributeValue methods to only normalize 
>the returned value according to the current type without changing 
>the inner storage?
>

That's an implementation detail. Either approach would work. I 
suppose it's mostly a question of whether you want to pay the cost on 
on the setting end or the reading end. I tend to prefer to put the 
cost on the setting end (and it would make storage marginally 
smaller) but I doubt it's significant enough to matter.

-- 

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
|          The XML Bible, 2nd Edition (Hungry Minds, 2001)           |
|             http://www.cafeconleche.org/books/bible2/              |
|   http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://www.cafeaulait.org/      |
|  Read Cafe con Leche for XML News: http://www.cafeconleche.org/    |
+----------------------------------+---------------------------------+



More information about the jdom-interest mailing list