[jdom-interest] Ignoring DTD with no base URI
listen at quimby.de
Sun Oct 24 07:25:09 PDT 2004
> Do you mean that I should manually replace this xml portion (relative
> URI substring, let's say with String.replace() method) with some fake
> absolute URL, before passing it to parser ?
> And, is this exception raising something as a bug in JDOM parser, or
> case with XML being improperly defined, or something third ?
No - i meant to supply a systemId for the document itself.
The problem is, that the parser wants to resolve the relative systemId
of the DTD against the context of the document. If you supply your
document as an InputStream the parser has no idea how to resolve that
URI - that's what he's complaining about.
To specify a document systemID, parse your document with:
SAXBuilder.build( InputStream is, String systemId )
I you can't think of a meaningful absolute URI for your document, think
up a fake one, because if you registered your own EntityResolver, it
will not be used by the parser.
Don't ask me why the parser insists on having a systemId even if you
have supplied an EntityResolver, because i don't know. There's probably
some exotic situations where it still might be needed.
>> supply an absolute System ID for the document you're parsing (can even
>> be a fake one). This should solve your problem.
>>> Hi everybody.
>>> I'm using JDOM1.0, and I read FAQ about ignoring DTD by registering
>>> NoOpEntityResolver, but problem that XMLs that I'm working with have
>>> <!DOCTYPE BXML SYSTEM "dtd/something.1.0.dtd">
>>> and my XML parser raises exception even before calling my no-op
>>> resolver :
>>> Error on line 2: Relative URI "dtd/something.1.0.dtd"; can not be
>>> without a base URI.
>>> XML are loaded from network stream, sent by third-party application,
>>> thus I
>>> cannot effect it. I just need some way of completely ignoring this
>>> DTD. Is
>>> this possible, or XML with DTD reference defined as above is not
>>> (without complete URL scheme), thus no parser will allow it ?
More information about the jdom-interest