Steve, Steve Ebersole <steven.ebers...@gmail.com> wrote on 08/18/2010 01:24:36 PM:
> On Tue, 2010-08-17 at 18:04 -0500, Steve Ebersole wrote: > > On Tue, 2010-08-17 at 17:15 -0400, Michael Glavassevich wrote: > > > > Oh, I need this to happen even if there is already a DTD. It will > > > in > > > > all likelihood have a DTD declared. I just need to inject some > > > entities > > > > into it. > > > > > > Unless you've written your own XML parser how can you reliably do > > > that? > > > > I am not an XML expert, so I have no idea how I can expect it to be > > reliable. I work a lot on trial-and-error. That said, this works, or > > at least works in all cases I and users have encountered so far (this > > parse="text" situation notwithstanding): > > > > http://github.com/sebersole/jdocbook-core/blob/master/src/main/ > java/org/jboss/jdocbook/util/FileUtils.java#L93 > > So if I understand correctly, the EntityResolver2.getExternalSubset > approach is not going to work here. Perhaps EntityResolver2.getExternalSubset() is only part of the solution. Can you show concrete examples where this wouldn't work on its own? Note that if a document already has an external subset your instance of EntityResolver2 will get a call to resolveEntity() and you can tell by the entity name "[dtd]" that the parser is asking you to resolve it. That's also an opportunity to inject whatever entity declarations you want to add and could include the DTD you were asked to resolve through a parameter entity. > Which takes me back to the question of a custom XIncludeHandler and (a) > whether that is a valid option and (b) how to properly make sure my > custom XIncludeHandler gets used in the pipeline. There's no supported way of doing that. You would have to reach into the implementation and if you managed to get something working your application could be broken with a future release of Xerces. We make no guarantees on the stability of internal components and warn users in the Javadoc that they're on shaky ground if they choose that path. > -- > Steve Ebersole <st...@hibernate.org> > http://hibernate.org > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: j-users-unsubscr...@xerces.apache.org > For additional commands, e-mail: j-users-h...@xerces.apache.org Thanks. Michael Glavassevich XML Parser Development IBM Toronto Lab E-mail: mrgla...@ca.ibm.com E-mail: mrgla...@apache.org