[xquery-talk] preserving space in attribute content

Michael Kay mhk at mhk.me.uk
Tue Jun 6 23:23:22 PDT 2006


> 
> I need to preserve whitespace in an attribute, as in
> 
> <elem someAttr="     somecontent"/>
> 
> The space in other words is signficant and I don't want it 
> normalized away on processing. Is this doable?

Do it as you would in XML - entitize the spaces using &_#x20;.

You could also write

<elem someAttr="{'     somecontent'}"/>

However, it's not a good design to use attributes for content where
whitespace is significant: even if you get the whitespace into the result
document, it's liable to be normalized next time it sees the inside of an
XML parser.

Michael Kay
http://www.saxonica.com/




More information about the talk mailing list