You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Mark Lundquist <lu...@gmail.com> on 2008/08/28 19:22:31 UTC

Help... how can I setFeature() on JaxpParser

Hi,

I very much need to set the feature "http://apache.org/xml/features/nonvalidating/load-external-dtd 
"  (see http://xerces.apache.org/xerces-j/features.html#load-external-dtd) 
  on the Xerces parser wrapped by a JaxpParser instance (returned by  
manager lookup of SAXParser.role).

I don't see a way to do it... it looks like JaxpParser doesn't expose  
an interface for it.  JaxpParser buries the factory instances and the  
parser instances pretty thoroughly and doesn't provide any handles to  
set features, even in the component configuration.

This is for a project that's stuck on Cocoon 2.1.8, BTW.  I guess I  
can always just create my own parser instance if it comes down to  
that.  Before I bother, does anybody know of a way to avoid the  
bother?  Maybe I'm missing something...

cheers,
—ml—


Re: Help... how can I setFeature() on JaxpParser

Posted by Mark Lundquist <lu...@gmail.com>.
On Aug 28, 2008, at 3:18 PM, Thorsten Scherler wrote:

> not sure whether you are aware of
> http://svn.apache.org/viewvc/forrest/branches/update_cocoon_2.1.12-dev/main/webapp/WEB-INF/cocoon.xconf?diff_format=h&view=markup
> <entity-resolver logger="core.resolver">
>    <parameter name="catalog" value="resources/schema/catalog.xcat"/>
>    <parameter name="verbosity" value="$ 
> {org.apache.xml.resolver.verbosity}"/>
>  </entity-resolver>
>
> maybe that helps.

Thx for the reply, Thorsten!  Yes, I'm aware of Cocoon's catalog  
entity resolver.  I've got this transformer written a long time ago by  
somebody else, that uses Xerces but was not supplying any entity  
resolver, so I changed it to use Cocoon's catalog-based resolver, and  
it worked a lot better but was still making some network connections  
in spite of this (and for some reason, I'm getting a lot of  
"connection refused" from w3.org, all starting a couple of weeks ago,  
which is weird and is what started me down this whole path of looking  
at this transformer).

Finally I figured out that if I stick the whole DTD into a catalog,  
Xerces no longer makes these network connections.  Maybe that is what  
you were getting at above.  Anyway, I figured it out through kind of a  
roundabout way.  My original question was about setting the "load- 
external-dtd" feature, because a guy on the Xerces list told me that  
would magically fix this problem.  I went ahead and did that, but it  
was bum advice... it does not fix the problem, and indeed looking at  
the Xerces source code I see that it has nothing to do with it.  Then  
I ran across this post:

	http://tersesystems.com/post/6000058.jhtml

which confirmed what I a was seeing from experience and also looking  
at the Xerces source.  He goes one to describe the "crushingly  
obvious" solution of writing a wrapper class for the EntityResolver.   
But if you consider what his wrapper class is actually doing, it's  
acttually a kind of degenerate, hard-coded catalog!  So if you have a  
catalog entity resolver already, the even more "crushingly obvious"  
solution is to enter the DTD in a catalog.  Poofo, problem solved! :-)

cheers & thx again,
—ml—


Re: Help... how can I setFeature() on JaxpParser

Posted by Thorsten Scherler <th...@apache.org>.
On Thu, 2008-08-28 at 14:54 -0700, Mark Lundquist wrote:
> Never mind.
> 
> I went ahead as described, creating an XMLReader and setting the  
> EntityResolver by hand, then setting the feature.  It turns out I was  
> given some bad advice that setting the "load-external-dtd" feature to  
> false would solve my problem (Xerces trying to connect to w3c.org in  
> spite of catalog-based EntityResolver), but it doesn't fix it anyway,  
> so... back to the drawing board.

not sure whether you are aware of 
http://svn.apache.org/viewvc/forrest/branches/update_cocoon_2.1.12-dev/main/webapp/WEB-INF/cocoon.xconf?diff_format=h&view=markup
<entity-resolver logger="core.resolver">
    <parameter name="catalog" value="resources/schema/catalog.xcat"/>
    <parameter name="verbosity" value="${org.apache.xml.resolver.verbosity}"/>
  </entity-resolver>

maybe that helps.

salu2

> —ml—
> 
> 
> On Aug 28, 2008, at 10:22 AM, Mark Lundquist wrote:
> 
> >
> > Hi,
> >
> > I very much need to set the feature "http://apache.org/xml/features/nonvalidating/load-external-dtd 
> > "  (see http://xerces.apache.org/xerces-j/features.html#load-external-dtd) 
> >  on the Xerces parser wrapped by a JaxpParser instance (returned by  
> > manager lookup of SAXParser.role).
> >
> > I don't see a way to do it... it looks like JaxpParser doesn't  
> > expose an interface for it.  JaxpParser buries the factory instances  
> > and the parser instances pretty thoroughly and doesn't provide any  
> > handles to set features, even in the component configuration.
> >
> > This is for a project that's stuck on Cocoon 2.1.8, BTW.  I guess I  
> > can always just create my own parser instance if it comes down to  
> > that.  Before I bother, does anybody know of a way to avoid the  
> > bother?  Maybe I'm missing something...
> >
> > cheers,
> > —ml—
> >
> >
> 
-- 
Thorsten Scherler                                 thorsten.at.apache.org
Open Source Java                      consulting, training and solutions


Re: Help... how can I setFeature() on JaxpParser

Posted by Mark Lundquist <lu...@gmail.com>.
Never mind.

I went ahead as described, creating an XMLReader and setting the  
EntityResolver by hand, then setting the feature.  It turns out I was  
given some bad advice that setting the "load-external-dtd" feature to  
false would solve my problem (Xerces trying to connect to w3c.org in  
spite of catalog-based EntityResolver), but it doesn't fix it anyway,  
so... back to the drawing board.

—ml—


On Aug 28, 2008, at 10:22 AM, Mark Lundquist wrote:

>
> Hi,
>
> I very much need to set the feature "http://apache.org/xml/features/nonvalidating/load-external-dtd 
> "  (see http://xerces.apache.org/xerces-j/features.html#load-external-dtd) 
>  on the Xerces parser wrapped by a JaxpParser instance (returned by  
> manager lookup of SAXParser.role).
>
> I don't see a way to do it... it looks like JaxpParser doesn't  
> expose an interface for it.  JaxpParser buries the factory instances  
> and the parser instances pretty thoroughly and doesn't provide any  
> handles to set features, even in the component configuration.
>
> This is for a project that's stuck on Cocoon 2.1.8, BTW.  I guess I  
> can always just create my own parser instance if it comes down to  
> that.  Before I bother, does anybody know of a way to avoid the  
> bother?  Maybe I'm missing something...
>
> cheers,
> —ml—
>
>