[xquery-talk] preserving space in attribute content

David Carlisle davidc at nag.co.uk
Wed Jun 7 01:05:16 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?

The white space isn't normali[zs]ed in the sense of normalize-space, 

<elem someAttr="     somecontent"/>

is a valid XQuery expression that produces

<elem someAttr="     somecontent"/>

with all spaces intact.

The only normalisation that happens is the same as XML,newlines get
turned to spaces. You can stop this by using a numeric character
reference. 

> What's the &_ ... underscore in your entitized version btw?

Mike stuck a spurious _ in his example to make sure that
you saw the & syntax, some brokem mailers try to be smart and assume
that things that look like html should be displayed as html which would
mean that the character ref was displayed as a newline, which would
spoil the point of the comment. (This is a perennial problem over on
xsl-list.)

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________


More information about the talk mailing list