[prev in list] [next in list] [prev in thread] [next in thread]
List: xerces-j-dev
Subject: Re: custom XIncludeHandler
From: Michael Glavassevich <mrglavas () ca ! ibm ! com>
Date: 2010-08-26 2:56:52
Message-ID: OFCF31BC09.AFBE1870-ON8525778B.000F8DEB-8525778B.0010325A () ca ! ibm ! com
[Download RAW message or body]
Steve,
The EntityResolver2 flavour of resolveEntity() passes you the base URI.
"Expanding" the system ID is just resolving it against the base URI. As for
a public API, you can use java.net.URI to do this.
Thanks.
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
Steve Ebersole <steven.ebersole@gmail.com> wrote on 08/25/2010 12:38:22 PM:
> 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.ebersole@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 <steve@hibernate.org>
> > > > > > http://hibernate.org
> > > > > >
> > > > > >
> > > > > >
> > > > >
> > > ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > > > > > For additional commands, e-mail: j-users-help@xerces.apache.org
> > > > >
> > > > > Thanks.
> > > > >
> > > > > Michael Glavassevich
> > > > > XML Parser Development
> > > > > IBM Toronto Lab
> > > > > E-mail: mrglavas@ca.ibm.com
> > > > > E-mail: mrglavas@apache.org
> > > > >
> > > >
> > > > --
> > > > Steve Ebersole <steve@hibernate.org>
> > > > http://hibernate.org
> > > >
> > > >
> > > >
> > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> > > > For additional commands, e-mail: j-users-help@xerces.apache.org
> > >
> > > Michael Glavassevich
> > > XML Parser Development
> > > IBM Toronto Lab
> > > E-mail: mrglavas@ca.ibm.com
> > > E-mail: mrglavas@apache.org
> > >
> >
>
> --
> Steve Ebersole <steve@hibernate.org>
> http://hibernate.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
[Attachment #3 (text/html)]
<html><body>
<p><tt>Steve,</tt><br>
<br>
<tt>The EntityResolver2 flavour of resolveEntity() passes you the base URI. \
"Expanding" the system ID is just resolving it against the base URI. As for \
a public API, you can use java.net.URI to do this.</tt><br> <br>
<tt>Thanks.</tt><br>
<br>
<tt>Michael Glavassevich<br>
XML Parser Development<br>
IBM Toronto Lab<br>
E-mail: mrglavas@ca.ibm.com</tt><br>
<tt>E-mail: mrglavas@apache.org</tt><br>
<br>
<tt>Steve Ebersole <steven.ebersole@gmail.com> wrote on 08/25/2010 12:38:22 \
PM:<br> <br>
> Ok, I got this aspect of it work now. I do run into a related problem<br>
> though. I actually am using a "chain" of entity resolvers. \
So I ended<br> > up needing to have my chain implement EntityResolver2 \
also:<br> > <br>
> <a href="http://github.com/sebersole/jdocbook-core/blob/master/src/main/java/">http://github.com/sebersole/jdocbook-core/blob/master/src/main/java/</a><br>
> org/jboss/jdocbook/xslt/EntityResolverChain.java<br>
> <br>
> I am having trouble getting the delegation from<br>
> EntityResolver2#resolveEntity to EntityResolver#resolveEntity correct<br>
> given the need to manually account for the "expanded system id" \
much<br> > like y'all do in<br>
> com.sun.org.apache.xerces.internal.impl.XMLEntityManager#expandSystemId<br>
> <br>
> Is there a "public API" version of this method around? Is it \
kosher to<br> > cal that method directly in my code?<br>
> <br>
> <br>
> On Fri, 2010-08-20 at 13:50 -0500, Steve Ebersole wrote:<br>
> > So given the DOCTYPE I described:<br>
> > <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"<br>
> > "<a href="http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd</a>" \
[<br> > > <!ENTITY % BOOK_ENTITIES SYSTEM<br>
> > "Hibernate_Getting_Started_Guide.ent"><br>
> > %BOOK_ENTITIES;<br>
> > ]><br>
> > <br>
> > I see the following:<br>
> > (1) resolveEntity( "%BOOK_ENTITIES", ... );<br>
> > (2) resolveEntity( "[dtd]", ... );<br>
> > <br>
> > I tried adding my "extra" entities during call (1). \
Essentially, I load<br> > > the contents of the referenced file<br>
> > (Hibernate_Getting_Started_Guide.ent), prepend my custom entities and<br>
> > wrap that whole thing up in a InputStream. However that does not<br>
> > "work"; it does not seem to pick up my entities. Found that \
a bit<br> > > counter-intuitive.<br>
> > <br>
> > If I delay this process until (2), I am not exactly sure what I am<br>
> > supposed to return. As I understand it, I am being asked to resolve \
the<br> > > actual DTD file<br>
> > (<a href="http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd</a>)?<br>
> > <br>
> > <br>
> > On Fri, 2010-08-20 at 08:41 -0400, Michael Glavassevich wrote:<br>
> > > Steve Ebersole <steven.ebersole@gmail.com> wrote on \
08/20/2010<br> > > > 08:26:19 AM:<br>
> > > <br>
> > > > On Fri, 2010-08-20 at 08:19 -0400, Michael Glavassevich \
wrote:<br> > > > > > Perhaps EntityResolver2.getExternalSubset() is \
only part of the<br> > > > > > solution. Can you show concrete \
examples where this wouldn't work<br> > > > on<br>
> > > > > its own?<br>
> > > > <br>
> > > > Based on what you said, I had assumed that something like this \
would<br> > > > not<br>
> > > > work:<br>
> > > > <a \
href="http://anonsvn.jboss.org/repos/hibernate/core/trunk/documentation/">http://anonsvn.jboss.org/repos/hibernate/core/trunk/documentation/</a><br>
> > > > manual/src/main/docbook/en-US/HIBERNATE_-<br>
> > > > _Relational_Persistence_for_Idiomatic_Java.xml<br>
> > > > <br>
> > > > Because we have:<br>
> > > > <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML \
V4.5//EN"<br> > > > > "<a \
href="http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd</a>" \
[ <br> > > > > <!ENTITY % BOOK_ENTITIES SYSTEM "HIBERNATE_-<br>
> > > > _Relational_Persistence_for_Idiomatic_Java.ent"><br>
> > > > %BOOK_ENTITIES;<br>
> > > > ]><br>
> > > > <br>
> > > > So essentially we reference an external set of entities:<br>
> > > > <a \
href="http://anonsvn.jboss.org/repos/hibernate/core/trunk/documentation/">http://anonsvn.jboss.org/repos/hibernate/core/trunk/documentation/</a><br>
> > > > manual/src/main/docbook/en-US/HIBERNATE_-<br>
> > > > _Relational_Persistence_for_Idiomatic_Java.ent<br>
> > > <br>
> > > So instead of getExternalSubset() you'll get a call to \
resolveEntity()<br> > > > and can do what I said below.<br>
> > > <br>
> > > > > Note that if a document already has an external subset \
your<br> > > > instance<br>
> > > > > of EntityResolver2 will get a call to resolveEntity() and \
you can<br> > > > tell<br>
> > > > > by the entity name "[dtd]" that the parser is \
asking you to<br> > > > resolve<br>
> > > > > it. That's also an opportunity to inject whatever entity<br>
> > > declarations<br>
> > > > > you want to add and could include the DTD you were asked \
to<br> > > > resolve<br>
> > > > > through a parameter entity.<br>
> > > > > <br>
> > > > > > Which takes me back to the question of a custom \
XIncludeHandler<br> > > > and<br>
> > > > > (a)<br>
> > > > > > whether that is a valid option and (b) how to properly \
make sure<br> > > > my<br>
> > > > > > custom XIncludeHandler gets used in the pipeline.<br>
> > > > > <br>
> > > > > There's no supported way of doing that. You would have to \
reach<br> > > > into<br>
> > > > > the implementation and if you managed to get something \
working<br> > > > your<br>
> > > > > application could be broken with a future release of Xerces. \
We<br> > > > make<br>
> > > > > no guarantees on the stability of internal components and \
warn<br> > > > users<br>
> > > > > in the Javadoc that they're on shaky ground if they choose \
that<br> > > > path.<br>
> > > > > <br>
> > > > > > -- <br>
> > > > > > Steve Ebersole <steve@hibernate.org><br>
> > > > > > <a \
href="http://hibernate.org">http://hibernate.org</a><br> > > > > > \
> <br> > > > > > > <br>
> > > > > ><br>
> > > > ><br>
> > > ---------------------------------------------------------------------<br>
> > > > > > To unsubscribe, e-mail: \
j-users-unsubscribe@xerces.apache.org<br> > > > > > > For \
additional commands, e-mail: j-users-help@xerces.apache.org<br> > > > > \
> <br> > > > > > Thanks.<br>
> > > > > <br>
> > > > > Michael Glavassevich<br>
> > > > > XML Parser Development<br>
> > > > > IBM Toronto Lab<br>
> > > > > E-mail: mrglavas@ca.ibm.com<br>
> > > > > E-mail: mrglavas@apache.org<br>
> > > > > <br>
> > > > <br>
> > > > -- <br>
> > > > Steve Ebersole <steve@hibernate.org><br>
> > > > <a href="http://hibernate.org">http://hibernate.org</a><br>
> > > > <br>
> > > > <br>
> > > ><br>
> > > ---------------------------------------------------------------------<br>
> > > > To unsubscribe, e-mail: \
j-users-unsubscribe@xerces.apache.org<br> > > > > For additional \
commands, e-mail: j-users-help@xerces.apache.org<br> > > > <br>
> > > Michael Glavassevich<br>
> > > XML Parser Development<br>
> > > IBM Toronto Lab<br>
> > > E-mail: mrglavas@ca.ibm.com<br>
> > > E-mail: mrglavas@apache.org<br>
> > > <br>
> > <br>
> <br>
> -- <br>
> Steve Ebersole <steve@hibernate.org><br>
> <a href="http://hibernate.org">http://hibernate.org</a><br>
> <br>
> <br>
> ---------------------------------------------------------------------<br>
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org<br>
> For additional commands, e-mail: \
j-users-help@xerces.apache.org</tt></body></html>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic