Ok, I got this aspect of it work now. I do run into a related problem though. I actually am using a "chain" of entity resolvers. So I ended up needing to have my chain implement EntityResolver2 also:
http://github.com/sebersole/jdocbook-core/blob/master/src/main/java/org/jboss/jdocbook/xslt/EntityResolverChain.java I am having trouble getting the delegation from EntityResolver2#resolveEntity to EntityResolver#resolveEntity correct given the need to manually account for the "expanded system id" much like y'all do in com.sun.org.apache.xerces.internal.impl.XMLEntityManager#expandSystemId Is there a "public API" version of this method around? Is it kosher to cal that method directly in my code? On Fri, 2010-08-20 at 13:50 -0500, Steve Ebersole wrote: > So given the DOCTYPE I described: > <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" > "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ > <!ENTITY % BOOK_ENTITIES SYSTEM > "Hibernate_Getting_Started_Guide.ent"> > %BOOK_ENTITIES; > ]> > > I see the following: > (1) resolveEntity( "%BOOK_ENTITIES", ... ); > (2) resolveEntity( "[dtd]", ... ); > > I tried adding my "extra" entities during call (1). Essentially, I load > the contents of the referenced file > (Hibernate_Getting_Started_Guide.ent), prepend my custom entities and > wrap that whole thing up in a InputStream. However that does not > "work"; it does not seem to pick up my entities. Found that a bit > counter-intuitive. > > If I delay this process until (2), I am not exactly sure what I am > supposed to return. As I understand it, I am being asked to resolve the > actual DTD file > (http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd)? > > > On Fri, 2010-08-20 at 08:41 -0400, Michael Glavassevich wrote: > > Steve Ebersole <steven.ebers...@gmail.com> wrote on 08/20/2010 > > 08:26:19 AM: > > > > > On Fri, 2010-08-20 at 08:19 -0400, Michael Glavassevich wrote: > > > > Perhaps EntityResolver2.getExternalSubset() is only part of the > > > > solution. Can you show concrete examples where this wouldn't work > > on > > > > its own? > > > > > > Based on what you said, I had assumed that something like this would > > not > > > work: > > > http://anonsvn.jboss.org/repos/hibernate/core/trunk/documentation/ > > > manual/src/main/docbook/en-US/HIBERNATE_- > > > _Relational_Persistence_for_Idiomatic_Java.xml > > > > > > Because we have: > > > <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" > > > "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ > > > <!ENTITY % BOOK_ENTITIES SYSTEM "HIBERNATE_- > > > _Relational_Persistence_for_Idiomatic_Java.ent"> > > > %BOOK_ENTITIES; > > > ]> > > > > > > So essentially we reference an external set of entities: > > > http://anonsvn.jboss.org/repos/hibernate/core/trunk/documentation/ > > > manual/src/main/docbook/en-US/HIBERNATE_- > > > _Relational_Persistence_for_Idiomatic_Java.ent > > > > So instead of getExternalSubset() you'll get a call to resolveEntity() > > and can do what I said below. > > > > > > 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 > > > > > > > > > > -- > > > 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 > > > > Michael Glavassevich > > XML Parser Development > > IBM Toronto Lab > > E-mail: mrgla...@ca.ibm.com > > E-mail: mrgla...@apache.org > > > -- 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