[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Re: Interesting QDomDocument::setContent variant
From:       Nicolas Goutte <nicolasg () snafu ! de>
Date:       2004-02-16 12:49:06
Message-ID: 200402161349.07530.nicolasg () snafu ! de
[Download RAW message or body]

On Monday 16 February 2004 12:33, David Faure wrote:
> On Monday 16 February 2004 12:28, Nicolas Goutte wrote:
> > On Monday 16 February 2004 11:39, David Faure wrote:
> > > On Monday 16 February 2004 11:33, Nicolas Goutte wrote:
> > > > On Monday 16 February 2004 11:17, David Faure wrote:
> > > > > The OASIS format has a special tag for whitespace to ensure
> > > > > whitespace is preserved. This is more reliable than using real
> > > > > whitespace and depending on the XML parser to respect it.
> > > >
> > > > Something like:
> > > > <text:span> </text:span>
> > > > too?
> > >
> > > No, <text:s text:c="4"> for 4 spaces.
> >
> > Yes, but you do not write:
> > <text:span><text:s text:c="1"/></text:span>
> > but
> > <text:span> </text:span>
>
> Yes, because one space is always preserved, the problem is that 2 or more
> spaces can be collapsed as a single one, no?

No, the problem is the feature:
http://trolltech.com/xml/features/report-whitespace-only-CharData
of Qt's SAX parser.

(See QXmlSimpleReader in Qt's doc.)

With it on (which QDomDocument does by default), if white space is the only 
content of an element, it is not reported (i.e. ignored.)

>
> Or do you see problems with XML parsers (which ones?) not seeing the single
> space in <text:span> </text:span>?

Try it with a normal QDomDocument::setContent 

QDomDocument doc;
doc.setContent( QCString( "<test> </test>" ) );
qDebug("%s\n", doc.toCString().data() );

And you get:
<test/>

(I know very well the problem. I have it since the start of KWord's AbiWord 
import filter. Without making it on purpose, the test file, which I had made, 
had exactly such a construction and of course gave problems with 
QDomDocument::setContent. That is why the AbiWord import filter is made with 
SAX (i.e. the QXML classes.))

Have a nice day!

_______________________________________________
koffice-devel mailing list
koffice-devel@mail.kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic