[jdom-interest] Resolving Entities...when no DTD is assigned
(notDOCTYPE declaration) in XML
vishpool at gmail.com
Thu Sep 1 11:39:02 PDT 2005
That's exactly what I thought too.
But, for some reason or another, I am having trouble implementing it.
I have tried the following couple of suggested answer, in other thread, with
1) SAXBuilder builder = new SAXBuilder();
...... = builder.build("test.xml", "test.dtd");
For some reason, the builder doesn't seem to validate the entities using the
2) SAXBuilder builder = new SAXBuilder();
...... = builder.build("test.xml");
Again, this has no effect on validating the entities -- which, if I see it
correclty, should just 'ignore' (NoOpEntityResolver) resolving entities.
If I understood your reply correctly, you are saying that I would need to
customize the parser (the builder) itself --so, you have the deep-down
control over when the exception occurs - the place for customizing/
If so, how should I go about it? Is there a good/close parser I should look
for when 'extending' such a parser?
Or, is there one such parser already implemented and available?
Any help will be appreciated!
On 9/1/05, Tatu Saloranta <cowtowncoder at yahoo.com> wrote:
> --- "Vish D." <vishpool at gmail.com> wrote:
> > So, in order for SAXBuilder to correctly parse/build
> > a XML file, the XML
> > file must contain DOCTYPE declaration?
> No, but to define parsed entities one has to have it.
> Entities can be declared in both internal and external
> subsets, but those both are part of DOCTYPE
> declaration (embedded / ref'd)
> Or alternatively, the parser needs to have special
> functionality to "inject" additional entities. This is
> something I'm planning to implement for the (stax) xml
> parser (Woodstox) I work on, and would think others
> may have done the same for other parsers.
> In my case, I'm adding this since although docs with
> undeclared entities are technically invalid XML, there
> are enough use cases (your xml document source is not
> under your control, and they just do not grasp the
> concept of declaring entities -- after all, "it works
> in HTML so why not in XML") that it's still a useful
> feature, especially for "XHTML" content. In fact, it's
> one of top requested new features, and reasonably easy
> to implement (just need a hook for method to call when
> an undeclared entity is encountered; default behaviour
> being throw-exception, but alternatively just creating
> an entity declaration on the fly).
> -+ Tatu +-
> > On 8/31/05, Michael Kay <mike at saxonica.com> wrote:
> > >
> > > I am having some trouble figuring out how to go
> > about resolving entities
> > > when an XML file doesn't have DOCTYPE declaration
> > (no DTD attached to it),
> > > but contains entities that are 'non-standarad'
> > (such as, '', etc...).
> > > I don't think such a file can correctly be
> > described as an XML file.
> > > Michael Kay
> > > http://www.saxonica.com/
> > >
> > > _______________________________________________
> > To control your jdom-interest membership:
> Start your day with Yahoo! - make it your home page
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the jdom-interest