[xep-support] How can I use FOTransformer with xsl:include relative path.

From: frederic.ouellet@desjardins.com
Date: Thu Oct 21 2004 - 08:10:33 PDT

  • Next message: David Tolpin: "Re: [xep-support] How can I use FOTransformer with xsl:include relative path."

    With no reply, I will do it more simple...

    How can I use xsl:include relative path (with the URIResolver) with the FOTransformer?

    The only logical path I found to do it:

        FOTransformer transformer = new FOTransformer(new StreamSource(XSLfile.openStream()),formatter);
        transformer.setURIResolver(genPDFURIResolver);
        transformer.transform(new StreamSource(new StringReader(xmlStringData)), target);

    ERROR:

    The FOTransformer will validate my XSL file that has the xsl:include (he don'T find it, so he throw exception, see annex below). So, the setURIResolver cannot be
    effective and then, the PDF is not generated.

    I search a way to do:

       FOTransformer transformer = new FOTransformer(formatter);
       transformer.setURIResolver(genPDFURIResolver);
       transformer.setXSLFile(new StreamSource(XSLfile.openStream());
       transformer.transform(new StreamSource(new StringReader(xmlStringData)), target);

    I had gone to the light API documentation. The only method I found for adding XSL will be:

    setParameter
    public void setParameter(java.lang.String name,
                             java.lang.Object value)
          Adds a parameter for XSL transformation.
          Parameters:
                name - parameter name
                value - parameter value
          See Also:
                getParameter(String), clearParameters()

    But, I don't have a clue about those parameters... So, the userguide said I must see javax.xml.transform:

    setParameter
    public abstract void setParameter(String name,
                                      Object value)
          Add a parameter for the transformation.

          Pass a qualified name as a two-part string, the namespace URI enclosed in curly braces ({}), followed by the local name. If the name has a null URL, the String only
          contain the local name. An application can safely check for a non-null URI by testing to see if the first character of the name is a '{' character.

          For example, if a URI and local name were obtained from an element defined with <xyz:foo xmlns:xyz="http://xyz.foo.com/yada/baz.html"/>, then the qualified name
          would be "{http://xyz.foo.com/yada/baz.html}foo". Note that no prefix is used.
          Parameters:
                name - The name of the parameter, which may begin with a namespace URI in curly braces ({}).
                value - The value object. This can be any valid Java object. It is up to the processor to provide the proper object coersion or to simply pass the object on
                for use in an extension.

    Can I pass the XSL like this:

       transformer.setParameter(new StreamSource(MyPDFCreator.class.getResourceAsStream (XSLFile.getPath())),new StreamSource(XSLFile.openStream());

    So, please give me the proper algorithm to permit the relative path for include xsl with the FOTransformer... any algorithm will be appreciated.

    Best Regards,
    Frédéric Ouellet

                                                                                                                                                                              
                 frederic.ouellet@desjardins.com
                 Envoyé par : owner-xep-support@renderx.com
                                                                                                                                                                         Pour
                                                                                 xep-support@renderx.com
                 2004-10-20 13:26 cc
                                                                                 owner-xep-support@renderx.com, "frederic.ouellet@desjardins.com" <xep-support@renderx.com>
                                                                                                                                                                        Objet
                                   Veuillez répondre à Réf. : [xep-support] Re: Réf. : [xep-support] xsl:include -
                                 xep-support@renderx.com javax.xml.transform.TransformerException: Had IO Exception with stylesheet file:
                                                                                 ergoDesjardins.xsl
                                                                                                                                                                              
                                                                                                                                                                              
                                                                                                                                                                              
                                                                                                                                                                              
                                                                                                                                                                              
                                                                                                                                                                              

    Thanks Alexander,

    I actually try to create an EntityResolver to give the good path for the include file. I will develop it and test it. I hope it will give me a good solution.

    My file is in the EAR file on a weblogic server. I thought that the path of the include file was already relative but it don't seem to be true. I will give more
    information if I cannot handle this situation with EntityResolver.

    Your intervention was greatly appreciated.

    Best Regards,

    Frédéric Ouellet

                 Alexander Peshkov <peshkov@renderx.com>
                 Envoyé par : owner-xep-support@renderx.com
                                                                                                                                                                         Pour
                                                                                 "frederic.ouellet@desjardins.com" <xep-support@renderx.com>
                 2004-10-20 12:19 cc

                                                                                                                                                                        Objet
                                   Veuillez répondre à [xep-support] Re: Réf. : [xep-support] xsl:include -
                                 xep-support@renderx.com javax.xml.transform.TransformerException: Had IO Exception with stylesheet file:
                                                                                 ergoDesjardins.xsl

    Hello Frédéric,

    As you can see from the stack trace this exception produced by Xalan
    and thus has nothing to do with XEP itself or Saxon that is shipped with XEP.

    Still, if you explain your situation in more details someone can came
    up with a solution. The problem is clearly has something to do with
    incorrect paths (URLs) so the main information you should provide is
    full list of paths used for your application, basic stylesheet,
    referenced sub-stylesheets, etc. For example, does file
    /res/gabarit/pres/xsl/ergoDesjardins.xsl exists on your disk? I do not
    speak French (unfortunately) so I cant interpret exception text but
    I guess that it says about I/O error and file not found.
    More details on your environment/setup could also help.

    Best regards,
    Alexander Peshkov mailto:peshkov@renderx.com
    RenderX

    fodc> Restart my need...

    fodc> Does the support can help me?

    fodc> Here it is:

    fodc> Causé par: org.xml.sax.SAXException: Exception d?E/S avec le fichier de feuille de style : /res/gabarit/pres/xsl/ergoDesjardins.xsl
    fodc> à org.apache.xalan.processor.StylesheetHandler.error(StylesheetHandler.java:891)
    fodc> à org.apache.xalan.processor.StylesheetHandler.error(StylesheetHandler.java:919)
    fodc> à org.apache.xalan.processor.ProcessorInclude.parse(ProcessorInclude.java:316)
    fodc> à org.apache.xalan.processor.ProcessorInclude.startElement(ProcessorInclude.java:189)
    fodc> à org.apache.xalan.processor.StylesheetHandler.startElement(StylesheetHandler.java:656)
    fodc> à weblogic.apache.xerces.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:459)
    fodc> à weblogic.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:221)
    fodc> à weblogic.apache.xerces.impl.XMLNamespaceBinder.handleStartElement(XMLNamespaceBinder.java:874)
    fodc> à weblogic.apache.xerces.impl.XMLNamespaceBinder.emptyElement(XMLNamespaceBinder.java:591)
    fodc> à weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:747)
    fodc> à weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1477)
    fodc> à weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:329)
    fodc> à weblogic.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:525)
    fodc> à weblogic.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:581)
    fodc> à weblogic.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
    fodc> à weblogic.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1175)
    fodc> à weblogic.xml.jaxp.WebLogicXMLReader.parse(WebLogicXMLReader.java:135)
    fodc> à weblogic.xml.jaxp.RegistryXMLReader.parse(RegistryXMLReader.java:138)
    fodc> à org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:934)
    fodc> à org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:750)
    fodc> à weblogic.xml.jaxp.WebLogicTransformerFactory.newTransformer(WebLogicTransformerFactory.java:195)
    fodc> à weblogic.xml.jaxp.RegistryTransformerFactory.newTransformer(RegistryTransformerFactory.java:209)
    fodc> à com.renderx.xep.FOTransformer.createTransformer(Unknown Source)
    fodc> à com.renderx.xep.FOTransformer.<init>(Unknown Source)
    fodc> à fcdq.tiinap.infra.commun.generationpdf.GenerateurPDF.generePDF(GenerateurPDF.java:107)
    fodc> à fcdq.tiinap.infra.presdesj.gabarit.GestGabaritPDF.construirePDF(GestGabaritPDF.java:97)
    fodc> à fcdq.tiinap.infra.presdesj.servlet.GenerateurReponsePDF.produireReponseNormale(GenerateurReponsePDF.java:254)
    fodc> à fcdq.tiinap.infra.presdesj.servlet.ServletAiguilleur.construireReponse(ServletAiguilleur.java:230)
    fodc> à fcdq.tiinap.infra.presdesj.servlet.ServletAiguilleur.produireReponseErreur(ServletAiguilleur.java:2077)
    fodc> à fcdq.tiinap.infra.presdesj.servlet.ServletAiguilleur.produireReponse(ServletAiguilleur.java:1812)
    fodc> à fcdq.tiinap.infra.presdesj.servlet.ServletAiguilleur.traiterRequeteHttp(ServletAiguilleur.java:2182)
    fodc> à fcdq.tiinap.infra.presdesj.servlet.ServletAiguilleur.doGet(ServletAiguilleur.java:317)
    fodc> à javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    fodc> à javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    fodc> à weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:971)
    fodc> à weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402)
    fodc> à weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:28)
    fodc> à weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
    fodc> à fcdq.tiinap.infra.commun.servletfilter.ServletFilterBase.doFilter(ServletFilterBase.java:267)
    fodc> à weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
    fodc> à weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6356)
    fodc> à weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
    fodc> à weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
    fodc> à weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3635)
    fodc> à weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)
    fodc> à weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
    fodc> à weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)

    fodc> In the ear of the application, the classpath for ressources is res... so, I have tried a lot of path to include this in my xsl:

    fodc> <xsl:include href="ergoDesjardins.xsl"/>
    fodc> <xsl:template match="ERREUR_PDF">

    fodc> I have tried to pass the props BASE with my classpath for resources, but I have received a malformed url exception.

    fodc> This FoTransformer will be deploy on 4 cluster in staging and none-staging mode. So, I cannot put all the path like this: mydomain/webapp/andsoon.

    fodc> It is really annoying to pass 8 hours to include a file that don't want to be include... I hope XEP will give good support for this concern and I suggest to put
    this
    fodc> case in a well documented area. On the internet, google give 10 pages for this kind of error... and generally, the answer is to put the complete url. I cannot
    do
    fodc> this. I want to put a relative path.

    fodc> Please, take time to answer those concerns.

    fodc> Frédéric Ouellet

    fodc> frederic.ouellet@desjardins.com

    fodc> Envoyé par : owner-xep-support@renderx.com

    fodc>
    Pour
    fodc> xep-support@renderx.com

    fodc> 2004-10-19 15:11
    cc

    fodc>
    Objet
    fodc> Veuillez répondre à [xep-support] xsl:include - javax.xml.transform.TransformerException: Had IO Exception
    with
    fodc> xep-support@renderx.com stylesheet file: ergoDesjardins.xsl

    fodc> Hello everybody,

    fodc> I have some problems with the include of a xsl to do attribute-set. When I generated my PDF with XMLSpy (xml and xsl), everthing is good and smooth. When I do the
    same
    fodc> with my pdf generator services (in java), this exception is throw:

    fodc> javax.xml.transform.TransformerException: Had IO Exception with stylesheet file: ergoDesjardins.xsl

    fodc> I have change the location of the include file:

    fodc> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    fodc> <xsl:include href="./general/ergoDesjardins.xsl"/>
    fodc> <xsl:template match="ERREUR_PDF">

    fodc> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    fodc> <xsl:include href="general/ergoDesjardins.xsl"/>
    fodc> <xsl:template match="ERREUR_PDF">

    fodc> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    fodc> <xsl:include href="ergoDesjardins.xsl"/>
    fodc> <xsl:template match="ERREUR_PDF">

    fodc> There are all good in XmlSpy and all wrong with my FoTransformer.

    fodc> I have search the doc and google, but I didn't find evidence of the trouble.

    fodc> I hope you know what I have missed. Please, help me to find out!

    fodc> Best regards,

    fodc> Frédéric Ouellet

    fodc> -------------------
    fodc> (*) To unsubscribe, send a message with words 'unsubscribe xep-support'
    fodc> in the body of the message to majordomo@renderx.com from the address
    fodc> you are subscribed from.
    fodc> (*) By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/tos.html

    fodc> -------------------
    fodc> (*) To unsubscribe, send a message with words 'unsubscribe xep-support'
    fodc> in the body of the message to majordomo@renderx.com from the address
    fodc> you are subscribed from.
    fodc> (*) By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/tos.html

    -------------------
    (*) To unsubscribe, send a message with words 'unsubscribe xep-support'
    in the body of the message to majordomo@renderx.com from the address
    you are subscribed from.
    (*) By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/tos.html

    -------------------
    (*) To unsubscribe, send a message with words 'unsubscribe xep-support'
    in the body of the message to majordomo@renderx.com from the address
    you are subscribed from.
    (*) By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/tos.html

    -------------------
    (*) To unsubscribe, send a message with words 'unsubscribe xep-support'
    in the body of the message to majordomo@renderx.com from the address
    you are subscribed from.
    (*) By using the Service, you expressly agree to these Terms of Service http://www.renderx.com/tos.html



    This archive was generated by hypermail 2.1.5 : Thu Oct 21 2004 - 08:31:24 PDT