You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by David Mechner <fo...@mechner.com> on 2002/11/01 22:51:56 UTC

Setting svg dtd URI (continued)

Hi,

On advice received here, I'm trying to use CatalogResolver to make my
program access a local SVG dtd instead of a remote one at w3.org.

I've gotten as far as getting xalan to use the resolver, but it seems
that the problem (well, the behavior I want to change, anyway) is in
the next step; in FOP. But I can't see how to get FOP to use my
CatalogResolver.

My use of FOP is simple:

[...]
OutputStream pdfStream = new FileOutputStream(stagingDir + "/" + fname);
InputSource foDocInput = new DocumentInputSource((Document)foDoc.getNode());
fopDriver.setOutputStream(pdfStream);
fopDriver.setInputSource(foDocInput);
fopDriver.run();
[...]

How do I tell FOP to use my CatalogResolver?


Thanks,

-David


Re: Setting svg dtd URI (continued)

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Oleg Tkachenko wrote:
> David Mechner wrote:
> 
>> On advice received here, I'm trying to use CatalogResolver to make my
>> program access a local SVG dtd instead of a remote one at w3.org.
>>
>> I've gotten as far as getting xalan to use the resolver, but it seems
>> that the problem (well, the behavior I want to change, anyway) is in
>> the next step; in FOP. But I can't see how to get FOP to use my
>> CatalogResolver.
> 
> FOP works on tree level and has nothing to do with dtd handling, that's 
> completely duty of xml parser. I believe all you have to do is to set up 
> com.sun.resolver.tools.CatalogResolver as entity resolver using 
> setEntityResolver method of XMLReader class before parsing your fo/xsl/xml.
> 
The original poster had his FO already in a DOM tree, so I think
the problem is with SVG imported via fo:external-graphics.
The relevant code here appears to be in image/analyser/SSVGReader.java:
             SAXSVGDocumentFactory factory =
               new SAXSVGDocumentFactory(SVGImage.getParserName());
             SVGDocument doc = factory.createDocument(uri, imageStream);
The habit of passing class name around just sucks, but then, its
probably legacy from ancient times when there were not standard APIs.
The SAXSVGDocumentFactory is imported from Batik. I have no idea
whether there are hooks in Batik so that the parser can be configured
before the SVG is parsed. (FOP fortunately has the render(parser,inputSource),
where you can pass a configured parser).
There ought to be a possibility to tell FOP "use this parser factory
for creating all parsers you need" as part of the configuration.

Some Batik guru out there? I'm too lazy to check for myself right now, its
weekend and all that... :)

J.Pietschmann


Re: Setting svg dtd URI (continued)

Posted by Oleg Tkachenko <ol...@multiconn.com>.
David Mechner wrote:

> On advice received here, I'm trying to use CatalogResolver to make my
> program access a local SVG dtd instead of a remote one at w3.org.
> 
> I've gotten as far as getting xalan to use the resolver, but it seems
> that the problem (well, the behavior I want to change, anyway) is in
> the next step; in FOP. But I can't see how to get FOP to use my
> CatalogResolver.
FOP works on tree level and has nothing to do with dtd handling, that's 
completely duty of xml parser. I believe all you have to do is to set up 
com.sun.resolver.tools.CatalogResolver as entity resolver using 
setEntityResolver method of XMLReader class before parsing your fo/xsl/xml.

-- 
Oleg Tkachenko
eXperanto team
Multiconn Technologies, Israel