Dear eXistentialists,
I've run into a problem with disappearing white space and I'd be grateful for advice.
My test source document (test.xml) looks like:
----[begin source document]----
<?xml version="1.0" encoding="UTF-8"?>
<glossary xml:space="preserve">
<entry><ocs>one</ocs> <ocs>two</ocs> <ocs>three</ocs> <ocs>four</ocs> <ocs>five</ocs> <ocs>six</ocs> I, me</entry>
</glossary>
----[end source document]----
Note that the <entry> element contains mixed content and there are white-space text nodes between the <ocs> elements in the source document (as well as one final text node that also contains non-white-space characters).
My test xquery looks like the following:
----[begin xquery]----
xquery version "1.0";
let $hits := for $i in document("/db/ocs/test.xml")//entry[.//ocs[matches(.,'one')]] return $i
return
<html>
<head>
<title>title goes here</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
</head>
<body>
<dl>
{for $i in $hits return
(<dt>{$i/ocs[1]}</dt>,
<dd>{$i/node()}</dd>)}
</dl>
</body>
</html>
----[end xquery]----
My intention in the <dd> output was to copy both the <ocs> nodes and the text() nodes (including white-space text() nodes) between and around them. (In a subsequent xslt transformation I'll rewrite the <ocs> elements as something valid in html, but for the moment I've left them in.)
The output from eXist is:
----[begin output]----
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html><head><title>OCS glossary search report</title><meta http-equiv="Content-Type" content="text/html;charset=utf-8"/></head><body><dl><dt><ocs>one</ocs></dt><dd><ocs>one</ocs><ocs>two</ocs><ocs>three</ocs><ocs>four</ocs><ocs>five</ocs><ocs>six</ocs> I, me</dd></dl></body></html>
----[end output]----
Note that although the last text node (which reads " I, me") is reproduced correctly, the original white-space text nodes between the <ocs> elements are gone.
Can anyone advise me on how I can get them to come through the query?
Thanks,
David
djbpitt+xml@...
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________
Exist-open mailing list
Exist-open@...
https://lists.sourceforge.net/lists/listinfo/exist-open