That's exactly what I thought too.<br>
<br>
But, for some reason or another, I am having trouble implementing it.<br>
<br>
I have tried the following couple of suggested answer, in other thread, with no luck:<br>
<br>
1) SAXBuilder builder = new SAXBuilder();<br>
...... = builder.build("test.xml", "test.dtd");<br>
For some reason, the builder doesn't seem to validate the entities using the given dtd.<br>
<br>
2) SAXBuilder builder = new SAXBuilder();<br>
builder.setEntityResolver(new NoOpEntityResolver());<br>
...... = builder.build("test.xml");<br>
Again, this has no effect on validating the entities
-- which, if I see it correclty, should just 'ignore'
(NoOpEntityResolver) resolving entities.<br>
<br>
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/ "injecting" entities?<br>
<br>
If so, how should I go about it? Is there a good/close parser I should look for when 'extending' such a parser? <br>
<br>
Or, is there one such parser already implemented and available?<br>
<br>
Any help will be appreciated!<br>
<br>
<br><br><div><span class="gmail_quote">On 9/1/05, <b class="gmail_sendername">Tatu Saloranta</b> <<a href="mailto:cowtowncoder@yahoo.com">cowtowncoder@yahoo.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
--- "Vish D." <<a href="mailto:vishpool@gmail.com">vishpool@gmail.com</a>> wrote:<br><br>> So, in order for SAXBuilder to correctly parse/build<br>> a XML file, the XML<br>> file must contain DOCTYPE declaration?
<br><br>No, but to define parsed entities one has to have it.<br>Entities can be declared in both internal and external<br>subsets, but those both are part of DOCTYPE<br>declaration (embedded / ref'd)<br><br>Or alternatively, the parser needs to have special
<br>functionality to "inject" additional entities. This is<br>something I'm planning to implement for the (stax) xml<br>parser (Woodstox) I work on, and would think others<br>may have done the same for other parsers.
<br><br>In my case, I'm adding this since although docs with<br>undeclared entities are technically invalid XML, there<br>are enough use cases (your xml document source is not<br>under your control, and they just do not grasp the
<br>concept of declaring entities -- after all, "it works<br>in HTML so why not in XML") that it's still a useful<br>feature, especially for "XHTML" content. In fact, it's<br>one of top requested new features, and reasonably easy
<br>to implement (just need a hook for method to call when<br>an undeclared entity is encountered; default behaviour<br>being throw-exception, but alternatively just creating<br>an entity declaration on the fly).<br><br>-+ Tatu +-
<br><br>><br>><br>> On 8/31/05, Michael Kay <<a href="mailto:mike@saxonica.com">mike@saxonica.com</a>> wrote:<br>> ><br>> > I am having some trouble figuring out how to go<br>> about resolving entities
<br>> > when an XML file doesn't have DOCTYPE declaration<br>> (no DTD attached to it),<br>> > but contains entities that are 'non-standarad'<br>> (such as, '', etc...).<br>> > I don't think such a file can correctly be
<br>> described as an XML file.<br>> > Michael Kay<br>> > <a href="http://www.saxonica.com/">http://www.saxonica.com/</a><br>> ><br>> > _______________________________________________<br>> To control your jdom-interest membership:
<br>><br><a href="http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com">http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com</a><br><br><br><br><br>____________________________________________________
<br>Start your day with Yahoo! - make it your home page<br><a href="http://www.yahoo.com/r/hs">http://www.yahoo.com/r/hs</a><br><br></blockquote></div><br>