Hi, It might be interesting to look at the examples in paragraph 3.7.1.4 of the Xquery rec: http://www.w3.org/TR/xquery/#id-whitespace
Note that these only concern direct element construction, not computed construction like you are using. Kind regards, Geert > Drs. G.P.H. Josten Consultant http://www.daidalos.nl/ Daidalos BV Source of Innovation Hoekeindsehof 1-4 2665 JZ Bleiswijk Tel.: +31 (0) 10 850 1200 Fax: +31 (0) 10 850 1199 http://www.daidalos.nl/ KvK 27164984 De informatie - verzonden in of met dit emailbericht - is afkomstig van Daidalos BV en is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onbedoeld hebt ontvangen, verzoeken wij u het te verwijderen. Aan dit bericht kunnen geen rechten worden ontleend. > From: [email protected] > [mailto:[email protected]] On Behalf Of > Tim Meagher > Sent: dinsdag 31 maart 2009 16:57 > To: 'General Mark Logic Developer Discussion' > Cc: 'Crewdson, Andrew'; 'Paul Rooney' > Subject: RE: [MarkLogic Dev General] Problem preserving > whitespace inanXML-to-XML xquery transform > > I tried it, but it doesn't help in my scenario for some odd reason. > > > > ________________________________ > > From: [email protected] > [mailto:[email protected]] On Behalf Of > Mark Helmstetter > Sent: Tuesday, March 31, 2009 10:53 AM > To: General Mark Logic Developer Discussion > Cc: Paul Rooney; Crewdson, Andrew > Subject: RE: [MarkLogic Dev General] Problem preserving > whitespace inanXML-to-XML xquery transform > > > > Assuming that you're using XQuery 1.0 add: > > declare boundary-space preserve; > > > > if you're using 0.9, add: > > declare xmlspace = preserve > > > > > > Cheers, > > Mark > > > > ________________________________ > > From: [email protected] > [mailto:[email protected]] On Behalf Of > Tim Meagher > Sent: Tuesday, March 31, 2009 2:26 PM > To: 'General Mark Logic Developer Discussion' > Cc: 'Crewdson, Andrew'; Paul Rooney > Subject: [MarkLogic Dev General] Problem preserving > whitespace in anXML-to-XML xquery transform > Importance: High > > > > Hi Folks, > > I have written an xquery transform whose purpose is to > convert mixed content that marked up in Schema A into the > same mixed content but marked up using Schema B. It's not > just a simple matter of renaming elements - so I have > implemented a recursive node-by-node approach using an > algorithm similar to the following: > > declare function cxtn:format-source-by-node($node as node) as node()* > > > > > > > > > > > { > > > > > > > > > > > ( > > > > > > > > > > > typeswitch ($node) > > > > > > > > > > > case text() > > > > > > > > > > > return ( > > > > > > > > > > > $node, > > > > > > > > > > > if (exists($node/following-sibling::node()[1])) then > > > > > > > > > > > > cxtn:format-source-by-node($node/following-sibling::node()[1]) > > > > > > > > > > > else text {""} > > > > > > > > > > > ) > > > > > > > > > > > case element (t) (: Title :) > > > > > > > > > > > return ( > > > > > > > > > > > element title {string($node)}, > > > > > > > > > > > if (exists($node/following-sibling::node()[1])) then > > > > > > > > > > > > cxtn:format-source-by-node($node/following-sibling::node()[1]) > > > > > > > > > > > else text {""} > > > > > > > > > > > ) > > > > > > > > > > > case element (v) (: Volume :) > > > > > > > > > > > return ( > > > > > > > > > > > element volume {string($node)}, > > > > > > > > > > > if (exists($node/following-sibling::node()[1])) then > > > > > > > > > > > > cxtn:format-source-by-node($node/following-sibling::node()[1]) > > > > > > > > > > > else text {""} > > > > > > > > > > > ) > > > > > > > > > > > case element () > > > > > > > > > > > (: Unexpected element - tag it as text and > process the next node in the list :) > > > > > > > > > > > return ( > > > > > > > > > > > text {string($node)}, > > > > > > > > > > > if (exists($node/following-sibling::node()[1])) then > > > > > > > > > > > > cxtn:format-source-by-node($node/following-sibling::node()[1]} > > > > > > > > > > > else text {""} > > > > > > > > > > > ) > > > > > > > > > > > (: No other node types need to be processed here, so > if encountered just return a text node :) > > > > > > > > > > > default return text {""} > > > > > > > > > > > ) > > > > > > > > > > > }; > > > > > > > > > > > > > > > > > > > > > > > What I'm left with is a node list that is attached to another > nodelist and eventually wrapped in a parent element, e.g., > > element node-list { > cxtn:format-source-by-node( $some-starting-node) } > > The results work as expected, except that when a text node is > encountered that contains only a space character, it is stripped away. > > This is not boundary space, it is space between elements, so > the input: > > <t>Title</t> <v>Volume</v> > > is converted to: > > <title>Title</title><volume>Volume</volume> > > where the space between the 2 elements has been removed. > > Can someone tell me how to preserve this space? > > Thank you! > > Tim > > _______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general
