logo       

Re: xhtml compatibility guideline: msg#00049

java.enhydra.xmlc

Subject: Re: xhtml compatibility guideline

Petr Stehlik <pstehlik@xxxxxxxxxx> writes:
> thanks to your help I finally got the damn xhtml source files compiled
> and then generated by Enhydra. Good news is that everything seems to be
> OK - no lost </h2> tags or anything like that. BTW, I was rather
> surprised that the formatting of the original xhtml is preserved - i.e.
> it didn't strip all the whitespaces and end-of-line characters like it
> usually dooes for plain html. Why?

A completely different parser is used for xhtml (xerces). This has to do with
what whitespace in text is passed through by the parser. Sorry I don't
remember the details off the top of my head, but I think this may have
to do with xmlc handling ignorable whitespace correctly.

> One important question: XHTML Compatibility Guidelines (compatibility of
> XHTML with HTML browsers) says that the single tags without a closing
> tag (<br />) should keep a space between the tag and the "/>"). The
> XHTML files

The suggestion to output <br /> is a suggestion because a few common browers
that don't understand xhtml are able to render this invalid html in some
reasonable manner. This is only going to work with bug-compatible browsers.

>I have here follows this rule but the generated stream
> doesn't contain it.
>
> So source : <br />
> but result: <br/>

>
> It's weird considering that all other white spaces were preserved. I
> would say that it should be the other way round - it should be one
> LOOONG line (as enhydra likes to produce) but this particular important
> white space should be preserved for the compatibility with HTML
> browsers.

XMLC doesn't record the original format of tags. The information contained in
the tags is represented by the DOM object structure. When the DOM is
formatted into a document, tags are created from the object structure
according to the HTML or XML rules.

While it would be possible to change the formatter to add the white space in
tag, XMLC offers a much better option. A HTML or XHTML document is able to
represent the same data, it just a different formatting. A DOM is an object
representation of the same data (but not the format). The XMLC formatter
supports formatting a document that was originally HTML as XHTML, or
one that started out as XHTML as HTML. By default, it uses the original
format. There are options to the formatter to implement this, however
my machine with xmlc on it is down right now, so I can't tell you
the details (it is documented in the java doc)...

Mark


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise