Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How to specify DTD to DTD.getDTD for DocumentParser?

Reply
Thread Tools

How to specify DTD to DTD.getDTD for DocumentParser?

 
 
Ronald Fischer
Guest
Posts: n/a
 
      03-08-2005
I would like to check a HTML file for errors such as mismatched start/end
tags or typos in the tags. Hence I need a validating HTML parser, which
gives me error messages when it encounters an error. I thought that
javax.swing.text.html.parser.DocumentParser could be a good choice.

I have now the problem that I don't know how to specify the DTD:

dp=new DocumentParser(DTD.getDTD(???WHAT SHOULD I WRITE HERE???));

I tried to call getDTD with the following arguments:

"http://www.w3.org/TR/html4/strict.dtd"
"-//W3C//DTD HTML 4.0 Transitional//EN"

In neither case was the parser able to recognize any tag. It called
the handleError callback on any tag encountered.

Unfortunately, the documentation for the class DTD is next to
non-existent. Could someone please help me with this?

Ronald
 
Reply With Quote
 
 
 
 
Thomas Weidenfeller
Guest
Posts: n/a
 
      03-08-2005
Ronald Fischer wrote:
> I would like to check a HTML file for errors such as mismatched start/end
> tags or typos in the tags. Hence I need a validating HTML parser, which
> gives me error messages when it encounters an error. I thought that
> javax.swing.text.html.parser.DocumentParser could be a good choice.


It is maybe the worst choice (see Q6.3.2 of the comp.lang.java.gui FAQ).
Instead consider jtidy or the original tidy.

/Thomas


--
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/...g/java/gui/faq
 
Reply With Quote
 
 
 
 
Ronald Fischer
Guest
Posts: n/a
 
      03-10-2005
Thomas Weidenfeller <(E-Mail Removed)> wrote in message news:<d0kcmr$6fi$(E-Mail Removed)>. ..
> Ronald Fischer wrote:
> > I would like to check a HTML file for errors such as mismatched start/end
> > tags or typos in the tags. Hence I need a validating HTML parser, which
> > gives me error messages when it encounters an error. I thought that
> > javax.swing.text.html.parser.DocumentParser could be a good choice.

>
> It is maybe the worst choice (see Q6.3.2 of the comp.lang.java.gui FAQ).
> Instead consider jtidy or the original tidy.


I tried out jtidy before, but found it completely useless for my purpose
(it complained about EVERY correct tag I tried). I then learned that
jtidy was implemented towards XHTML, not HTML, and for instance requires
that every tag must be in lower case etc. Also, I don't see how to have
jtidy distinguish between strict HTMl and transitional HTML.

Can't it be that there is no free HTML syntax checker available?????

Ronald
 
Reply With Quote
 
Thomas Weidenfeller
Guest
Posts: n/a
 
      03-10-2005
Ronald Fischer wrote:
> I then learned that
> jtidy was implemented towards XHTML, not HTML, and for instance requires
> that every tag must be in lower case etc.


Tidy.setXHTML(false);

> Also, I don't see how to have
> jtidy distinguish between strict HTMl and transitional HTML.


Tidy.setDocType("strict");

> Can't it be that there is no free HTML syntax checker available?????


Well ...

/Thomas

--
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/...g/java/gui/faq
 
Reply With Quote
 
Ronald Fischer
Guest
Posts: n/a
 
      03-17-2005
Thomas Weidenfeller <(E-Mail Removed)> wrote in message news:<d0p4n5$meb$(E-Mail Removed)>. ..
> Ronald Fischer wrote:
> > I then learned that
> > jtidy was implemented towards XHTML, not HTML, and for instance requires
> > that every tag must be in lower case etc.

>
> Tidy.setXHTML(false);
>
> > Also, I don't see how to have
> > jtidy distinguish between strict HTMl and transitional HTML.

>
> Tidy.setDocType("strict");


Thank you, this indeed works fine. Do you know wheather there is any
documentation available which explains how to use Jtidy? Sure, there
comes the class list with the package, but for example the HTML docs
for the class Tidy don't explain what the function setHTML does, and
they give only a coars description of what the argument to setDocType
must look like, but do also not explain how to use this function in
practice.

What I'm missing is kind of a "user manual" for this class....

Ronald
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
table hastle when I specify DocType (DTD) Philip HTML 11 05-13-2008 01:41 PM
Can you specify the path of a .dtd file using an environmentl variable? ezmiller XML 1 11-26-2005 11:10 AM
Can you specify the path of a .dtd file using an environmentl variable? ezmiller XML 0 11-26-2005 10:05 AM
DTD question - specify value of element unwiseone XML 1 08-10-2005 01:24 AM
must specify "encoding" attribute in DTD. Why? Kent Tong XML 4 02-23-2004 01:18 AM



Advertisments