[Nitro] Whitespace - xhtml doctype - are you using REXML sax2 parser/listener to read doctype? I had found a bug in REXML

Jeff Barczewski jeff.barczewski at gmail.com
Mon Nov 6 11:48:02 EST 2006


On 11/4/06, Lars Olsson <lasso at lassoweb.se> wrote:
>
> Hello,
>
> I found the bug. In /nitro/compiler/elements.rb the doctype method is
> missing. It should be added. The one from /nitro/compiler/morphing.rb
> works just fine:
>
> (from nitro/compiler/morphing.rb, Listener class)
>
>      def doctype(name, pub_sys, long_name, uri)
>        @buffer << "<!DOCTYPE #{name} #{pub_sys} #{long_name} #{uri}>"
>      end
>
> (you might just want to add a newline at the end. DOCTYPEs generally
> stand on its own line.)
>
> Btw, The fix above works with the default transformation pipeline. There
> *might* be some other compiler classes (not in the default pipeline)
> that need that method added too.
>
> Sincerely
>
> /lasso
>
>
> ________________________________________
> Lars Olsson
> lasso at lassoweb.se
> http://www.lassoweb.se/
>
>
>
> George Moschovitis skrev:
> >> No problem there. REXML already supports DOCTYPEs. The problem is that
> >> Nitro strips the DOCTYPE *after* REXML has processed the template.
> Since
> >> some XML tools require this type of information in order to function
> >> they are unable to parse pages rendered by Nitro. This is *very* bad in
> >> my opinion (luckily there are workarounds).
> >
>


George and Lars,

Are you using the REXML sax2 parser/listener to read doctypes?

If so, then I would be suprised if the above code (using REXML 3.1.5 or
less) would work. I also use REXML and was trying to read the doctype using
the sax2 parser/listener and after much debugging I found that there were a
few bugs in REXML code that prevented it from ever calling the doctype
method. Further investigation showed that there were no test cases around
this either. I had tested on 3.1.3 (that came with Ruby 1.8.4) and the
latest version 3.1.5 but defect exists in both places.

So I put together a test case for REXML and submitted a patch (fix) along
with my bug report about a week ago, but no one from REXML has responded or
applied it.
http://www.germane-software.com/projects/rexml/ticket/92

So I was just curious how this could work for you with an unpatched REXML,
unless maybe you weren't using the sax2 parser/listener.

Also the documentation around the sax2 listener for doctype is a little
vague regarding the long_name and uri. I believe the intention of the API is
that the long_name and uri would be provided without the surrounding quotes.
So this is the way my patch is written (to provide the contents from inside
of the quotes) when doctype listener method is called. If this is correct
then your above Nitro fix should turn around and quote those two variables
when outputting.

Anyway, I just wanted to ask whether you were indeed using sax2
parser/listener and if so share my experience and patch if it would be
useful. If you don't have the same issue then could you tell me what
parser/listener you are using, etc.

Blessings,

Jeff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/nitro-general/attachments/20061106/89bbebb2/attachment.html 


More information about the Nitro-general mailing list