tags:

views:

473

answers:

5

The subject sums my question up. Is there a standard? I tried researching W3C consortium and couldnt find anything on the character limit, just some notes on speacial characters needs to be escaped

+5  A: 

I don't believe there is a character limit per the XML specification, but the Best Practice is to keep attribute values short.

If an attribute value grows long...chances are that it should be an element of its own rather than an attribute on another element.

Justin Niessner
Correct, the XML recommendation doesn't limit the lengths of anything.
Richard
A: 

I don't think there are standard limitations, but any particular implementation may be limited in its capabilities, so I'd try to keep the size sane.

Michael Krelin - hacker
+3  A: 

If you care about this then you're doing something wrong.

Thomi
A more constructive answer would be much more helpful to the OP.
Danny
+1  A: 

There is no maximum character length for an attribute.

The spot where you could run into issues is the point where you are reading the xml file using another language.

The language you use to manipulate the xml file will determine your limitations.

For instance, if you plan on reading the information into a String, you should limit yourself to the maximum number of characters that can be held in a string in the language you are using.

Additionally, as others have said, you are probably not following standard name conventions if this is a problem. I would suggest that, if you have a large amount of text to store, it should be the value of an element, not an attribute.

JK
A: 

An attribute is composed or a name and a value. The value can be of any length including zero and can contain any valid XML characters, depending on the encoding. The name may or may not be qualified with a namespace; if so if will have a prefix of at least one character. The shortest attributes are therefore:

a=''
b:a=''

The attribute value will be normalised by conforming XML parsers so that whitespaces such as newlines will be normalised to single spaces.

peter.murray.rust