The xml:space Attribute

The xml:space Attribute

The xml:space attribute can indicate the significance (or lack thereof) of white space within a particular element. It has two legal values, default and preserve . The value default means that the application may treat white space in the element in whatever fashion is customary for that application. For instance, it might trim off or compress excess white space. The value preserve means that white space is significant, even if it normally isn't, and the application should not adjust the white space in any way.

For example, the xml:space attribute of the text element below indicates that white space is significant and should be preserved.

 <text xml:space="preserve">   I try to make XML lean   Without extra white space between   But when I forgo   All the spaces I know   My markup is not at all clean. </text> 

However, even without this attribute, the parser would still report all white space in the element content to the client application. It is the responsibility of the client application to inspect the value of the xml:space attribute and normalize the white space accordingly (or not).



Effective XML. 50 Specific Ways to Improve Your XML
Effective XML: 50 Specific Ways to Improve Your XML
ISBN: 0321150406
EAN: 2147483647
Year: 2002
Pages: 144

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net