where did my white space go?

View: New views
3 Messages — Rating Filter:   Alert me  

where did my white space go?

by Birnbaum, David J :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

Re: where did my white space go?

by Wolfgang Meier-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> 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.

Please edit conf.xml and change the parameter
preserve-whitespace-mixed-content="no" to "yes".

Actually, this should be set to "yes" by default (which I again forgot
to do in the 1.2.1 release). Also, xml:space="preserve" should
normally overwrite all other settings. This looks like a bug.

Wolfgang

-------------------------------------------------------------------------
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

Re: where did my white space go?

by Birnbaum, David J :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear Wolfgang (cc eXist-open),

Thank you for the quick response. That fixed the problem.

Sincerely,

David

> -----Original Message-----
> From: Wolfgang Meier [mailto:wolfgang@...]
> Sent: Thursday, May 15, 2008 11:42 AM
> To: Birnbaum, David J
> Cc: exist-open@...
> Subject: Re: [Exist-open] where did my white space go?
>
> > 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.
>
> Please edit conf.xml and change the parameter
> preserve-whitespace-mixed-content="no" to "yes".
>
> Actually, this should be set to "yes" by default (which I again forgot
> to do in the 1.2.1 release). Also, xml:space="preserve" should
> normally overwrite all other settings. This looks like a bug.
>
> Wolfgang
-------------------------------------------------------------------------
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