Tony Mariella <[email protected]> writes:
> I have a ML Query that gives me results as xs:string
>
> I would like to use xs:normalizedString to strip out all the
> carriage returns and spaces
>
> from the result. I keep getting Invalid cast error.
>
> Any ideas ?
With respect to xs:normalizedString, it looks to me like rather than
removing any tabs or line feeds, it would simply be an error to attempt to
construct an xs:normaliedString that contains them.
As several replies have pointed out, the XPath "normalize-space"
function is probably what you want. XPath, like XML, treats spaces,
newlines, tabs, and line feeds all equivalently as spaces. The
normalize-space function replaces all whitespace characters (and
sequences of more than one whitespace character) with a single space.
If you want to remove all the spaces, the easiest way is probably to
use fn:replace, possibly after fn:normalize-space, just so you don't
have to specify all the whitespace characters separately in the
pattern.
One final very small point that *might* be relevant. XML parsers
typically replace carriage return characters with line feeds. It is
possible to get a lone carriage return into your document, but it
requires extra work. If you *really* meant carriage return, then you
might have to do it directly with replace.
Be seeing you,
norm
--
Norman Walsh
Principal Technologist
Mark Logic Corporation
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general