Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] TagSoup, malformed comments and XOM

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Wolfgang Hoschek <wolfgang.hoschek AT mac.com>
  • To: Bart Schuller <schuller+xom-interest AT lunatech.com>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] TagSoup, malformed comments and XOM
  • Date: Tue, 27 Jun 2006 15:31:23 -0700

Looks like the TagSoup command line application (java -jar tagsoup.jar test.html) isn't using a lexical handler (org.xml.sax.ext.LexicalHandler) by default (--lexical option), leading to supression of comments. XOM tells the SAX parser (Tagsoup in this case) to use a lexical handler, and there's no direct way to turn comments off, except through an appropriate NodeFactory, as you've already found out.

It would be nice if tagsoup could internally try to fix up the comments, if possible.

While we're at it, it would also be nice for tagsoup not to report malformed public IDs, as in the following case:


[hoschek /Users/hoschek/unix/devel/nux] head doc/index.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http:// www.w3.org
/TR/html4/loose.dtd">
<!--Do not edit this autogenerated HTML file; edit src/xdocs files instead. -->
... and so on


[hoschek /Users/hoschek/unix/devel/nux] fire-xquery --validate=html -- query='{.}' doc/index.html --debug
Oopsla: nu.xom.ParsingException: The character 0x22 is not allowed in public IDs
at nu.xom.Builder.build(Builder.java:1179)
at nu.xom.Builder.build(Builder.java:627)
at nux.xom.pool.DocumentFactory.createDocument (DocumentFactory.java:119)
at nux.xom.tests.XQueryCommand$4.createDocument (XQueryCommand.java:695)
at nux.xom.pool.DocumentFactory.createDocument (DocumentFactory.java:88)
at nux.xom.pool.DocumentPool.getDocument(DocumentPool.java:161)
at nux.xom.tests.XQueryCommand.run(XQueryCommand.java:565)
at nux.xom.tests.CmdLineProgram.doMain(CmdLineProgram.java:62)
at nux.xom.tests.XQueryCommand.main(XQueryCommand.java:132)
Caused by: nu.xom.IllegalDataException: The character 0x22 is not allowed in public IDs
at nu.xom.DocType._setPublicID(DocType.java:309)
at nu.xom.DocType.<init>(DocType.java:92)
at nu.xom.NodeFactory.makeDocType(NodeFactory.java:318)
at nu.xom.XOMHandler.startDTD(XOMHandler.java:523)
at org.ccil.cowan.tagsoup.Parser.decl(Parser.java:665)
at org.ccil.cowan.tagsoup.HTMLScanner.scan(HTMLScanner.java: 492)
at org.ccil.cowan.tagsoup.Parser.parse(Parser.java:386)
at nu.xom.Builder.build(Builder.java:1160)
... 8 more
[hoschek /Users/hoschek/unix/devel/nux]


On Jun 27, 2006, at 1:53 PM, Bart Schuller wrote:

Hi,

I have some nasty HTML to parse so I immediately tried out Tagsoup,
which produced a workable XML file. But when I tried building a XOM tree
in one step using the example from the nux page, I got an exception:

Exception in thread "main" nu.xom.ParsingException: Comment data
contains a double hyphen (--).

It turned out that the HTML had something like <!----- Here it is -->.

TagSoup deletes all comments when run from the commandline, so it
doesn't get noticed then.

It was easy enough build myself a NoCommentNodeFactory, but as it is,
the combination from the nux page does not "Just Keep On Truckin'".

Who's at fault here?
a) TagSoup, for reporting something an XML parser would never be able
to report, or
b) XOM, for not being robust/sleazy enough to change "--" to "- -" in
comments to be built or
c) the example "new Builder(new org.ccil.cowan.tagsoup.Parser())" for
being too simple?

I'm leaning towards a and maybe c.

Opinions?

--
Bart.
_______________________________________________
XOM-interest mailing list
XOM-interest AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/xom-interest





Archive powered by MHonArc 2.6.24.

Top of Page