[jdom-interest] Auto-normalizing attribute values

Elliotte Rusty Harold elharo at metalab.unc.edu
Fri May 3 14:51:30 PDT 2002


A question for consideration:

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.

Currently it is possible for getAttributeValue() and related methods to 
return a string containing lots of extraneous white space where it 
wouldn't be expected in ID and IDREFs attributes and the like.

Note that unlike the getTextTrim() and getTextNormalize() methods for 
Element, the XML spec does specify normalization behavior for 
attributes. We follow this spec on input because th eparser normalizes 
for us. This would only be an issue when setting attribute values 
outside the context of a parser.

-- 
+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+ 
|           The XML Bible, 2nd Edition (IDG Books, 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