On Sun, 18 Feb 2007 10:04:05 -0500, Arturo Perez wrote:

> In article <[EMAIL PROTECTED]>,
>  Andreas L Delmelle <[EMAIL PROTECTED]> wrote:
> 
>> On Feb 18, 2007, at 10:19, Jeremias Maerki wrote:
>> 
>> > <snip />
>> > Arturo, I don't know how you use the EntityResolver in your code, but
>> > I'd propose to switch to URIResolver entirely.
>> 
>> Seems like the best option indeed.
>> 
>> Just FYI:
>> As to an alternative, looking a bit closer into the API docs, an
>> EntityResolver is supposed to be set on an org.xml.sax.XMLReader
>> instance, through its setEntityResolver() method. The XMLReader here
>> being the reader that will be used by Xalan to parse the stylesheet.
>> 
>> 
>> Cheers,
>> 
>> Andreas
> 
> I haven't had a chance to try this.  But, in the interest of clarity, I
> have the EntityResolver working in my code for XSLT.  And I have the
> URIResolver working as well.  But PDF generation using FOP 0.92 doesn't
> seem to be using either.  Maybe all the XMLFilters in that process are
> interfering?
> 
> -arturo


I really need help on making this work with 0.92beta.  I could probably
upgrade to 0.93 if that works better.  Please note that I have this working
for a plain XSL that converts XML to HTML where FOP is not involved.

I put the URIResolver on the FOPFactory like this:
        fopFactory.setURIResolver(ArticleHelper.getURIResolver());

The transforming code for the PDF looks like:

        InputSource inputSource = 
                new InputSource(new ByteArrayInputStream(xmlBytes));
        
        Templates articleTemplates 
=TemplatesManager.getTemplates(transformName);
        TransformFilter foFilter = new TransformFilter(articleTemplates);
                                
        Transformer transformer = foFilter.getTransformer(); 
        Templates psmiTemplates = TemplatesManager.getTemplates("psmi");
        SAXTransformerFactory stf = 
(SAXTransformerFactory)TransformerFactory.newInstance(); 
        XMLFilter psmiFilter = stf.newXMLFilter(psmiTemplates);
        
         // Set up to read the input file
        XMLReader reader = source.getXMLReader();
        
        if (reader == null)
        {
                SAXParserFactory spf = SAXParserFactory.newInstance();
                spf.setNamespaceAware(true);
                SAXParser parser = spf.newSAXParser(); 
                reader = parser.getXMLReader();
        }
        // Add a filter to look for characters outside the standard font and 
send remapped 
        // events to the child filter.
        XMLFilter fontFilter = new FontRemappingFilter();
                
        foFilter.setParent(reader);
        psmiFilter.setParent(foFilter);
        fontFilter.setParent(psmiFilter);

        SAXSource pdfSource = new 
SAXSource(fontFilter,SAXSource.sourceToInputSource(source));
        Fop fop = FOPConfigurator.newFop(outStream); 
        SAXTransformerFactory stf = 
(SAXTransformerFactory)TransformerFactory.newInstance(); 
        Transformer transformer = stf.newTransformer();

        //Make sure the XSL transformation's result is piped through to FOP
        Result res = new SAXResult(fop.getDefaultHandler());
           
        transformer.transform(source, res);
        
My URIResolver just prints log statements when it is called.  The style
sheet has a document call like this:  document('urn:hayesinc:report:abc')

This is the log output.  The URIResolver is never called for the urn.  It
is called for all kinds of other things:

jndi:/localhost/....xsl; Line #77; Column #94; Can not load requested doc: 
unknown protocol: urn
....ArticleHelper- resolve: graphics/pdf_logo_healthcareTechBrief.jpg 
jndi:/localhost/fop/
....ArticleHelper- resolve: graphics/bottom_left_cornice.svg 
jndi:/localhost/fop/
....ArticleHelper- resolve: arialbd.xml jndi:/localhost/fonts/
....ArticleHelper- resolve: en.hyp jndi:hyphenation
....ArticleHelper- resolve: en.xml jndi:hyphenation
....ArticleHelper- resolve: arialbi.xml jndi:/localhost/fonts/
....ArticleHelper- resolve: ariali.xml jndi:/localhost/fonts/
2007-02-22 15:25:26,353 [articleId=3374] WARN  
org.apache.fop.area.AreaTreeModel- Page 1: Unresolved id reference 
"htpBeginning" found.
....ArticleHelper- resolve: ARIALI.ttf jndi:/localhost/fonts/
....ArticleHelper- resolve: ARIALBI.ttf jndi:/localhost/fonts/
....ArticleHelper- resolve: ARIALBD.ttf jndi:/localhost/fonts/
....ArticleHelper- resolve: ARIAL.ttf jndi:/localhost/fonts/
....ArticleHelper- resolve: arial.xml jndi:/localhost/fonts/
....ArticleHelper- resolve: ariali.xml jndi:/localhost/fonts/
....ArticleHelper- resolve: ARIALI.ttf jndi:/localhost/fonts/
....ArticleHelper- resolve: ARIAL.ttf jndi:/localhost/fonts/

The unresolved id is supposed to come from the xml loaded by the document() 
call.

Help please,
tia,
arturo



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to