[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

Problems inserting an attribute that contains new lines

Newman, John W John.newman at viaoncology.com
Mon Dec 14 16:35:31 PST 2009


  Problems inserting an attribute that contains new
	lines
Hello,

We are using mxquery 0.6.  A few months ago, I noticed a problem where our xquery updates were losing newlines.   One of my coworkers did some testing, closed it as "not a bug, cannot reproduce", but now today I've found that the problem is still happening when inserting attributes but not replacing them (which is probably what he tested).

Sample query:

declare variable $source external;
declare variable $newNote := "A note
with
some new

lines in it.";

copy $target := $source modify (
   let $targetElement := $target//<el>;
   let $notes := $targetElement/@Notes
   return (
             if ($notes) then (
                   replace value of node $notes with $newNote    (: this works fine, new lines are preserved :)
             ) else (
                   insert nodes attribute Notes '{' $newNote '}' into $targetElement  (: this loses new lines, they are replaced with a space :)
            )
   )
)
return $target

input:    <root><el /></root>
output:  <root><el Notes="A note with some new  lines in it." /></root> (incorrect, escaped new lines have been replaced with regular spaces)

input:    <root><el Notes="x" /></root>
output: <root><el Notes="A note&#X0A;with&#X0A;some new&#X0A;&#X0A;lines in it." /></root>    (correct, replace is OK)

I've been digging through the xquery update spec for a bit but I am not finding my answer - is there an extra symbol or setting we need to preserve the new lines for an insert?  Is the processor doing 'too much' normalization?  I'd be happier if it wasn't modifying data on its own. =)

Thanks in advance for any advice
-John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://x-query.com/pipermail/talk/attachments/20091214/a403d269/attachment.htm


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.