Re: Problem using custom EntityResolver with fop 0.92 (RESOLVED)
Apparently, it's not the FOP transformer that needs the URIResolver. It's a TransformFilter somewhere in the chain. I stuck the URIResolver on that and now I have bugs I can deal with on my own :-) thanks all for the patience and understanding, arturo - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem using custom EntityResolver with fop 0.92
On Thu, 22 Feb 2007 23:22:11 +0100, Andreas L Delmelle wrote: > On Feb 22, 2007, at 23:12, Arturo Perez wrote: > >> On Thu, 22 Feb 2007 22:08:58 +0100, Andreas L Delmelle wrote: >> >>> Before we go any further: >>> Did you try Jeremias' suggestion and set the URIResolver on both the >>> FopFactory and the TransformerFactory? >> >> During one iteration I put the URIResolver on every XMLReader created by >> that >> codepath. Same problem. Is that different than what you/Jeremy >> suggested? > > To follow Jeremias' suggestion to the letter, try adding: > > stf.setURIResolver(ArticleHelper.getURIResolver()); > > right after you get the SAXTransformerFactory instance. > > HTH! > > Cheers, > > Andreas So, doing the below I still got the error: Can not load requested doc: unknown protocol: urn Fop fop = FOPConfigurator.newFop(outStream); SAXTransformerFactory stf = (SAXTransformerFactory)TransformerFactory.newInstance(); Transformer transformer = stf.newTransformer(); transformer.setURIResolver(ArticleHelper.getURIResolver()); //Make sure the XSL transformation's result is piped through to FOP Result res = new SAXResult(fop.getDefaultHandler()); grrr! arturo - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem using custom EntityResolver with fop 0.92
Arturo Perez wrote: During one iteration I put the URIResolver on every XMLReader created by that codepath. Same problem. Is that different than what you/Jeremy suggested? Probably, although putting an URIResolver on an XMLReader is, umm, difficult. Either you mean EntityResolver instead of URIResolver, which isn't (and can't) be used to resolve URIs in document() calls, or you mean other things like Transformer instead of XMLReader. Setting the custom URIResolver on the relevant Transformer objects would be the correct thing to do. J.Pietschmann - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem using custom EntityResolver with fop 0.92
On Feb 22, 2007, at 23:12, Arturo Perez wrote: On Thu, 22 Feb 2007 22:08:58 +0100, Andreas L Delmelle wrote: Before we go any further: Did you try Jeremias' suggestion and set the URIResolver on both the FopFactory and the TransformerFactory? During one iteration I put the URIResolver on every XMLReader created by that codepath. Same problem. Is that different than what you/Jeremy suggested? To follow Jeremias' suggestion to the letter, try adding: stf.setURIResolver(ArticleHelper.getURIResolver()); right after you get the SAXTransformerFactory instance. HTH! Cheers, Andreas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem using custom EntityResolver with fop 0.92
On Thu, 22 Feb 2007 22:08:58 +0100, Andreas L Delmelle wrote: > On Feb 22, 2007, at 21:55, Arturo Perez wrote: > > Arturo, > > Before we go any further: > Did you try Jeremias' suggestion and set the URIResolver on both the > FopFactory and the TransformerFactory? > > > Cheers, > > Andreas During one iteration I put the URIResolver on every XMLReader created by that codepath. Same problem. Is that different than what you/Jeremy suggested? -arturo - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem using custom EntityResolver with fop 0.92
On Feb 22, 2007, at 21:55, Arturo Perez wrote: 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: Transformer transformer = foFilter.getTransformer(); Templates psmiTemplates = TemplatesManager.getTemplates("psmi"); SAXTransformerFactory stf = (SAXTransformerFactory) TransformerFactory.newInstance(); XMLFilter psmiFilter = stf.newXMLFilter(psmiTemplates); Before we go any further: Did you try Jeremias' suggestion and set the URIResolver on both the FopFactory and the TransformerFactory? Cheers, Andreas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem using custom EntityResolver with fop 0.92
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: >> >> > >> > 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]
[Spam SpamAssassin=4.10,Body=R 4.10 ] Re: Problem using custom EntityResolver with fop 0.92
Andreas L Delmelle wrote: 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. An EntityResolver is for resolving URLs pointing to DTDs and external entities, at the XML parsing stage. The URLs used by the XSLT document() function are resolved by the URLResolver used by the Transformer object (BTW the URLS used by xsl:include and xsl:import are resolved by an URLResolver set on the TransformerFactory). J.Pietschmann - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem using custom EntityResolver with fop 0.92
In article <[EMAIL PROTECTED]>, Andreas L Delmelle <[EMAIL PROTECTED]> wrote: > On Feb 18, 2007, at 10:19, Jeremias Maerki wrote: > > > > > 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 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem using custom EntityResolver with fop 0.92
On Feb 18, 2007, at 10:19, Jeremias Maerki wrote: 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 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem using custom EntityResolver with fop 0.92
Right. It's important to realize that FOP cannot help during the XSLT stage at all. The document() function is purely XSLT. Setting an URIResolver on FOP's FopFactory only helps with resolving URIs for images, fonts etc. Arturo, I don't know how you use the EntityResolver in your code, but I'd propose to switch to URIResolver entirely. Please see the FopServlet as an example how a URIResolver can be set to be used by both the XSLT stage and the FO transformation: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/servlet/FopServlet.java?view=markup The key part there is this: this.uriResolver = new ServletContextURIResolver(getServletContext()); //This is for the XSLT stage (document() etc.) this.transFactory = TransformerFactory.newInstance(); this.transFactory.setURIResolver(this.uriResolver); //This is for the FO transformation (images, fonts etc.) this.fopFactory = FopFactory.newInstance(); this.fopFactory.setURIResolver(this.uriResolver); Good luck! On 18.02.2007 09:52:09 Andreas L Delmelle wrote: > On Feb 18, 2007, at 02:37, Arturo Perez wrote: > > > In article <[EMAIL PROTECTED]>, > > Jeremias Maerki <[EMAIL PROTECTED]> wrote: > > > >> http://xmlgraphics.apache.org/fop/0.93/embedding.html#fop-factory > > > > I had already been setting the URIResolver and that doesn't seem to > > work either. My document calls would look like > >document('urn:hayesinc:report:id') > > A call to document() is resolved during XSLT stage. Setting FOP's > URIResolver will do you little good here, unfortunately. > Xalan indeed allows an EntityResolver to be set from the command- > line, but I didn't immediately find a reference on their site as to > how this can be set if JAXP is used... > > Perhaps this is a question better suited for [EMAIL PROTECTED] > > Cheers, > > Andreas Jeremias Maerki - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem using custom EntityResolver with fop 0.92
On Feb 18, 2007, at 02:37, Arturo Perez wrote: In article <[EMAIL PROTECTED]>, Jeremias Maerki <[EMAIL PROTECTED]> wrote: http://xmlgraphics.apache.org/fop/0.93/embedding.html#fop-factory I had already been setting the URIResolver and that doesn't seem to work either. My document calls would look like document('urn:hayesinc:report:id') A call to document() is resolved during XSLT stage. Setting FOP's URIResolver will do you little good here, unfortunately. Xalan indeed allows an EntityResolver to be set from the command- line, but I didn't immediately find a reference on their site as to how this can be set if JAXP is used... Perhaps this is a question better suited for [EMAIL PROTECTED] Cheers, Andreas - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem using custom EntityResolver with fop 0.92
In article <[EMAIL PROTECTED]>, Jeremias Maerki <[EMAIL PROTECTED]> wrote: > http://xmlgraphics.apache.org/fop/0.93/embedding.html#fop-factory I had already been setting the URIResolver and that doesn't seem to work either. My document calls would look like document('urn:hayesinc:report:id') and no matter what I get urn: unknown protocol. I'll try again but I am sure I am missing something here. At the very least, I should be setting the UserAgent URIResolver? -arturo - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem using custom EntityResolver with fop 0.92
FOP doesn't support EntityResolver. But it supports javax.xml.transform.URIResolver. See http://xmlgraphics.apache.org/fop/0.93/embedding.html#fop-factory On 16.02.2007 22:33:12 Arturo Perez wrote: > Hi all, > > I'm trying to redo a bunch of XSL logic to use my own EntityResolver for > document() calls. I'm using Xalan SAX to do the XSL. > > My EntityResolver is being called by everything except FOP 0.92beta. I > cannot find where to force FOP to use my EntityResolver rather than > (I guess) the DefaultHandler. > > Any help in where to put the right call to setEntityResolver() would be > much appreciated, > > arturo Jeremias Maerki - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Problem using custom EntityResolver with fop 0.92
Hi all, I'm trying to redo a bunch of XSL logic to use my own EntityResolver for document() calls. I'm using Xalan SAX to do the XSL. My EntityResolver is being called by everything except FOP 0.92beta. I cannot find where to force FOP to use my EntityResolver rather than (I guess) the DefaultHandler. Any help in where to put the right call to setEntityResolver() would be much appreciated, arturo - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]