Re: How to configure TraxProcessor in 2.2?
gelo1234 <[email protected]> Tue, 10 Dec 2019 23:21:09 +0100
| Newsgroups | gmane.text.xml.cocoon.user |
|---|---|
| Message-ID | <CAPJaKUoS=s8rbugv6bXo+L6TzFRK-Tm8Frv1E6G-Uv=LZhWh_A@mail.gmail.com> |
--000000000000836997059960ee1a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Mark, I don't think this is the proper way to do this and if it's possible at all. Extension functions are only available in commercial releases of Saxon (PE and EE). I'm afraid they are not available in open-source Saxon-HE. We were trying to use Saxon-HE with Cocoon 3.0 and extension-functions without success. You either have to use OLDER release of Saxon or pay for the license. I know it's sad. I used to "such stupidites" since Oracle stopped releasing free JDK :( Hopefully we got OpenJDK. Greetings, Greg wt., 10 gru 2019 o 21:19 Mark H. Wood <[email protected]> napisa=C5=82(a): > On Tue, Dec 10, 2019 at 12:10:41AM +0100, gelo1234 wrote: > > Mark, > > > > Why do you need a Custom XSLT Processor other than Saxon actually?? Sax= on > > should do the right thing. Why wrapping it inside any "upper-level" > > Transformer? It's getting kinda weird. You can always add a new Java > class > > to standard Cocoon Processors/Transformers. > > Because, as I said, I need to configure Saxon, and Saxon-HE can only > be configured programmatically. So, if I want to register an > Integrated Extension Function, I have to gain access to the > TransformerFactory being created somewhere in the bowels of Cocoon, > get its Configuration, and call #registerExtensionFunction on that. > > To do this, I've created a class which extends TransformerFactoryImpl, > added a @PostConstruct method (which Spring should call after > instantiating the bean) to do the registration, and now I'm trying to > tell Cocoon to use my factory instead of the one that > javax.xml.transform.TransformerFactory will conjure up by default out > of the service provider framework when Saxon is present. > > > https://mrhaki.blogspot.com/2008/09/use-saxon-in-cocoon-22.html > > I've seen that. So far it hasn't helped. > > > Greetings, > > Greg > > > > > > pon., 9 gru 2019 o 23:02 Mark H. Wood <[email protected]> napisa=C5=82(a)= : > > > > > On Thu, Dec 05, 2019 at 04:13:08PM +0100, Javier Puerto wrote: > > > > I recommend you to use the Spring configuration. I never had this > > > > requirement before but by the error message and the configuration > > > fragment > > > > that you have sent the NPE is caused because you are not passing an > > > > instance of "org.dspace.saxon.ConfigurableTransformerFactory", you > are > > > > passing a String instead. > > > > > > > > <property name=3D'transformerFactory' > > > > > value=3D'org.dspace.saxon.ConfigurableTransformerFactory'/> > > > > > > > > IIRC you should change it to: > > > > <property name=3D'transformerFactory'> > > > > <bean class=3D"org.dspace.saxon.ConfigurableTransformerFactory"/> > > > > </property> > > > > > > > > The attribute "value" is for literal values. You can also define th= e > bean > > > > with an ID and then use the attribute "ref" with the ID of the bean= . > > > > I hope that helps. > > > > > > It would have made more sense for this to take a bean reference, but > > > the Javadoc for TraxProcessor says that setTransformerFactory() takes > > > a String argument. That seems to be correct: when I change it to a > > > reference, I get: > > > > > > 09-Dec-2019 15:12:39.128 SEVERE [localhost-startStop-24] > > > org.apache.catalina.cor > > > e.StandardContext.listenerStart Exception sending context initialized > > > event to l > > > istener instance of class > > > [org.springframework.web.context.ContextLoaderListener > > > ] > > > org.springframework.beans.factory.BeanCreationException: Erro= r > > > creating > > > bean with name 'org.apache.excalibur.xml.xslt.XSLTProcessor/saxon' > defined > > > in Se > > > rvletContext resource [/WEB-INF/spring/applicationContext.xml]: > > > Initialization o > > > f bean failed; nested exception is > > > org.springframework.beans.ConversionNotSuppor > > > tedException: Failed to convert property value of type > > > 'org.dspace.saxon.Configu > > > rableTransformerFactory' to required type 'java.lang.String' for > property > > > 'trans > > > formerFactory'; nested exception is java.lang.IllegalStateException: > > > Cannot conv > > > ert value of type [org.dspace.saxon.ConfigurableTransformerFactory] t= o > > > required > > > type [java.lang.String] for property 'transformerFactory': no matchin= g > > > editors o > > > r conversion strategy found > > > > > > When I change it back to the literal name of the class, the > > > webapp. starts normally. But it still errors out when it tries to ru= n > > > the XSLT transformer. > > > > > > It begins to look as though one can't really wire up TraxProcessor > > > using Spring. (By this I mean: using Spring's normal <bean> > > > <property> etc.) I'm guessing that it blows up because nothing has > > > called #parameterize(Parameters), because #parameterize() knows how > > > the properties must be set up and makes sure they are all sensible, > > > and thus something was left unset. > > > > > > I tried adding > > > > > > log4j.logger.org.apache.excalibur =3D DEBUG > > > log4j.logger.org.apache.avalon =3D DEBUG > > > > > > to our logging config. but it made no useful difference in the > > > output. I cannot see what paths are actually being consulted for > > > Cocoon component configuration, but it seems that none of the places > > > I've put my .xconf is one of them. > > > > > > > El mi=C3=A9., 4 dic. 2019 a las 22:46, Mark H. Wood (<[email protected]= du>) > > > escribi=C3=B3: > > > > > > > > > I'm using Cocoon 2.2. I need to pass a custom XSLT transformer > > > > > factory (that wraps Saxon's to configure it) to TraxProcessor, an= d > the > > > > > advice I've found in several places around the Web doesn't seem t= o > be > > > > > working: my factory class never gets instantiated. > > > > > > > > > > I've got a file > META-INF/cocoon/avalon/cocoon-core-saxon-xslt.xconf: > > > > > > > > > > <?xml version=3D"1.0" encoding=3D"UTF-8"?> > > > > > <components> > > > > > <component > role=3D"org.apache.excalibur.xml.xslt.XSLTProcessor/saxon" > > > > > class=3D"org.apache.cocoon.components.xslt.TraxProcessor"> > > > > > <parameter name=3D"use-store" value=3D"true"/> > > > > > <parameter name=3D"transformer-factory" > > > > > > > > value=3D"org.dspace.saxon.ConfigurableTransformerFactory"/> > > > > > </component> > > > > > </components> > > > > > > > > > > I also tried copying it to WEB-INF/cocoon and it didnt' seem to > work > > > > > there either. > > > > > > > > > > I do have <configurator:settings/> and <avalon:bridge/> in the > Spring > > > > > config. > > > > > > > > > > Is there some way to debug component configuration and see if the > file > > > > > is even being looked for (and where *is* configuration looking)? > The > > > > > Cocoon site directs me to Excalibur, which directs me to Avalon, > which > > > > > says that Avalon is wound up and directs me back to Excalibur.... > > > > > > > > > > > > > > > > > > > > I've also tried to configure the thing using Spring: > > > > > > > > > > <bean name=3D'org.apache.excalibur.xml.xslt.XSLTProcessor/sax= on' > > > > > class=3D'org.apache.cocoon.components.xslt.TraxProcesso= r' > > > > > init-method=3D'initialize' > > > > > destroy-method=3D'dispose'> > > > > > <!--property name=3D'use-store' value=3D'true'/--> > > > > > <property name=3D'transformerFactory' > > > > > > > > value=3D'org.dspace.saxon.ConfigurableTransformerFactory'/> > > > > > </bean> > > > > > > > > > > but so far I'm missing something: TraxProcessor.sourceToSAX > throws an > > > > > NPE. I'm probably not setting the parameters correctly -- there > isn't > > > > > a setter for use-store at all, for example. > > > > > > > > > > I've found any number of pages that tell me Avalon configuration = is > > > > > being replaced by Spring, but nothing practical on how to convert > > > > > Avalon configuration (such as the first sample above) to Spring, = or > > > > > even how to write fresh Spring configuration for Cocoon component= s. > > > > > It would be nice to know how to do this even if I wind up using t= he > > > > > Avalon approach with the present task. > > > > > > > > > > -- > > > > > Mark H. Wood > > > > > Lead Technology Analyst > > > > > > > > > > University Library > > > > > Indiana University - Purdue University Indianapolis > > > > > 755 W. Michigan Street > > > > > Indianapolis, IN 46202 > > > > > 317-274-0749 > > > > > www.ulib.iupui.edu > > > > > > > > > > > -- > > > Mark H. Wood > > > Lead Technology Analyst > > > > > > University Library > > > Indiana University - Purdue University Indianapolis > > > 755 W. Michigan Street > > > Indianapolis, IN 46202 > > > 317-274-0749 > > > www.ulib.iupui.edu > > > > > -- > Mark H. Wood > Lead Technology Analyst > > University Library > Indiana University - Purdue University Indianapolis > 755 W. Michigan Street > Indianapolis, IN 46202 > 317-274-0749 > www.ulib.iupui.edu > --000000000000836997059960ee1a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div class=3D"gmail_default" style=3D"font-size:small">Hi = Mark,</div><div class=3D"gmail_default" style=3D"font-size:small"><br></div= ><div class=3D"gmail_default" style=3D"font-size:small">I don't think t= his is the proper way to do this and if it's possible at all. Extension= functions are only available in commercial releases of Saxon (PE and EE). = <br></div><div class=3D"gmail_default" style=3D"font-size:small">I'm af= raid they are not available in open-source Saxon-HE. We were trying to use = Saxon-HE with Cocoon 3.0 and extension-functions without success.</div><div= class=3D"gmail_default" style=3D"font-size:small">You either have to use O= LDER release of Saxon or pay for the license. I know it's sad. I used t= o "such stupidites" since Oracle stopped releasing free JDK :( <b= r></div><div class=3D"gmail_default" style=3D"font-size:small">Hopefully we= got OpenJDK. <br></div><div class=3D"gmail_default" style=3D"font-size:sma= ll"><br></div><div class=3D"gmail_default" style=3D"font-size:small">Greeti= ngs,</div><div class=3D"gmail_default" style=3D"font-size:small">Greg<br></= div><div class=3D"gmail_default" style=3D"font-size:small"><br></div><div c= lass=3D"gmail_default" style=3D"font-size:small"><br></div></div><br><div c= lass=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">wt., 10 gru 2019= o 21:19=C2=A0Mark H. Wood <<a href=3D"mailto:[email protected]">mwood@iup= ui.edu</a>> napisa=C5=82(a):<br></div><blockquote class=3D"gmail_quote" = style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);pa= dding-left:1ex">On Tue, Dec 10, 2019 at 12:10:41AM +0100, gelo1234 wrote:<b= r> > Mark,<br> > <br> > Why do you need a Custom XSLT Processor other than Saxon actually?? Sa= xon<br> > should do the right thing. Why wrapping it inside any "upper-leve= l"<br> > Transformer? It's getting kinda weird. You can always add a new Ja= va class<br> > to standard Cocoon Processors/Transformers.<br> <br> Because, as I said, I need to configure Saxon, and Saxon-HE can only<br> be configured programmatically.=C2=A0 So, if I want to register an<br> Integrated Extension Function, I have to gain access to the<br> TransformerFactory being created somewhere in the bowels of Cocoon,<br> get its Configuration, and call #registerExtensionFunction on that.<br> <br> To do this, I've created a class which extends TransformerFactoryImpl,<= br> added a @PostConstruct method (which Spring should call after<br> instantiating the bean) to do the registration, and now I'm trying to<b= r> tell Cocoon to use my factory instead of the one that<br> javax.xml.transform.TransformerFactory will conjure up by default out<br> of the service provider framework when Saxon is present.<br> <br> > <a href=3D"https://mrhaki.blogspot.com/2008/09/use-saxon-in-cocoon-22.= html" rel=3D"noreferrer" target=3D"_blank">https://mrhaki.blogspot.com/2008= /09/use-saxon-in-cocoon-22.html</a><br> <br> I've seen that.=C2=A0 So far it hasn't helped.<br> <br> > Greetings,<br> > Greg<br> > <br> > <br> > pon., 9 gru 2019 o 23:02 Mark H. Wood <<a href=3D"mailto:mwood@iupu= i.edu" target=3D"_blank">[email protected]</a>> napisa=C5=82(a):<br> > <br> > > On Thu, Dec 05, 2019 at 04:13:08PM +0100, Javier Puerto wrote:<br= > > > > I recommend you to use the Spring configuration. I never had= this<br> > > > requirement before but by the error message and the configur= ation<br> > > fragment<br> > > > that you have sent the NPE is caused because you are not pas= sing an<br> > > > instance of "org.dspace.saxon.ConfigurableTransformerFa= ctory", you are<br> > > > passing a String instead.<br> > > ><br> > > > <property name=3D'transformerFactory'<br> > > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0value=3D'org.dspace.saxon.ConfigurableTransformerFactory'/><b= r> > > ><br> > > > IIRC you should change it to:<br> > > > <property name=3D'transformerFactory'><br> > > >=C2=A0 =C2=A0<bean class=3D"org.dspace.saxon.Configur= ableTransformerFactory"/><br> > > > </property><br> > > ><br> > > > The attribute "value" is for literal values. You c= an also define the bean<br> > > > with an ID and then use the attribute "ref" with t= he ID of the bean.<br> > > > I hope that helps.<br> > ><br> > > It would have made more sense for this to take a bean reference, = but<br> > > the Javadoc for TraxProcessor says that setTransformerFactory() t= akes<br> > > a String argument.=C2=A0 That seems to be correct:=C2=A0 when I c= hange it to a<br> > > reference, I get:<br> > ><br> > > 09-Dec-2019 15:12:39.128 SEVERE [localhost-startStop-24]<br> > > org.apache.catalina.cor<br> > > e.StandardContext.listenerStart Exception sending context initial= ized<br> > > event to l<br> > > istener instance of class<br> > > [org.springframework.web.context.ContextLoaderListener<br> > > ]<br> > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0org.springframework.beans.factor= y.BeanCreationException: Error<br> > > creating<br> > > bean with name 'org.apache.excalibur.xml.xslt.XSLTProcessor/s= axon' defined<br> > > in Se<br> > > rvletContext resource [/WEB-INF/spring/applicationContext.xml]:<b= r> > > Initialization o<br> > > f bean failed; nested exception is<br> > > org.springframework.beans.ConversionNotSuppor<br> > > tedException: Failed to convert property value of type<br> > > 'org.dspace.saxon.Configu<br> > > rableTransformerFactory' to required type 'java.lang.Stri= ng' for property<br> > > 'trans<br> > > formerFactory'; nested exception is java.lang.IllegalStateExc= eption:<br> > > Cannot conv<br> > > ert value of type [org.dspace.saxon.ConfigurableTransformerFactor= y] to<br> > > required<br> > > type [java.lang.String] for property 'transformerFactory'= : no matching<br> > > editors o<br> > > r conversion strategy found<br> > ><br> > > When I change it back to the literal name of the class, the<br> > > webapp. starts normally.=C2=A0 But it still errors out when it tr= ies to run<br> > > the XSLT transformer.<br> > ><br> > > It begins to look as though one can't really wire up TraxProc= essor<br> > > using Spring.=C2=A0 (By this I mean:=C2=A0 using Spring's nor= mal <bean><br> > > <property> etc.)=C2=A0 I'm guessing that it blows up be= cause nothing has<br> > > called #parameterize(Parameters), because #parameterize() knows h= ow<br> > > the properties must be set up and makes sure they are all sensibl= e,<br> > > and thus something was left unset.<br> > ><br> > > I tried adding<br> > ><br> > >=C2=A0 =C2=A0log4j.logger.org.apache.excalibur =3D DEBUG<br> > >=C2=A0 =C2=A0log4j.logger.org.apache.avalon =3D DEBUG<br> > ><br> > > to our logging config. but it made no useful difference in the<br= > > > output.=C2=A0 I cannot see what paths are actually being consulte= d for<br> > > Cocoon component configuration, but it seems that none of the pla= ces<br> > > I've put my .xconf is one of them.<br> > ><br> > > > El mi=C3=A9., 4 dic. 2019 a las 22:46, Mark H. Wood (<<a = href=3D"mailto:[email protected]" target=3D"_blank">[email protected]</a>>)<= br> > > escribi=C3=B3:<br> > > ><br> > > > > I'm using Cocoon 2.2.=C2=A0 I need to pass a custom= XSLT transformer<br> > > > > factory (that wraps Saxon's to configure it) to Tra= xProcessor, and the<br> > > > > advice I've found in several places around the Web = doesn't seem to be<br> > > > > working:=C2=A0 my factory class never gets instantiated= .<br> > > > ><br> > > > > I've got a file META-INF/cocoon/avalon/cocoon-core-= saxon-xslt.xconf:<br> > > > ><br> > > > > <?xml version=3D"1.0" encoding=3D"UTF= -8"?><br> > > > > <components><br> > > > >=C2=A0 =C2=A0<component role=3D"org.apache.excal= ibur.xml.xslt.XSLTProcessor/saxon"<br> > > > >=C2=A0 =C2=A0 =C2=A0class=3D"org.apache.cocoon.comp= onents.xslt.TraxProcessor"><br> > > > >=C2=A0 =C2=A0 =C2=A0<parameter name=3D"use-store= " value=3D"true"/><br> > > > >=C2=A0 =C2=A0 =C2=A0<parameter name=3D"transform= er-factory"<br> > > > ><br> > > value=3D"org.dspace.saxon.ConfigurableTransformerFactory&quo= t;/><br> > > > >=C2=A0 =C2=A0</component><br> > > > > </components><br> > > > ><br> > > > > I also tried copying it to WEB-INF/cocoon and it didnt&= #39; seem to work<br> > > > > there either.<br> > > > ><br> > > > > I do have <configurator:settings/> and <avalon= :bridge/> in the Spring<br> > > > > config.<br> > > > ><br> > > > > Is there some way to debug component configuration and = see if the file<br> > > > > is even being looked for (and where *is* configuration = looking)?=C2=A0 The<br> > > > > Cocoon site directs me to Excalibur, which directs me t= o Avalon, which<br> > > > > says that Avalon is wound up and directs me back to Exc= alibur....<br> > > > ><br> > > > ><br> > > > ><br> > > > > I've also tried to configure the thing using Spring= :<br> > > > ><br> > > > >=C2=A0 =C2=A0 =C2=A0<bean name=3D'org.apache.exca= libur.xml.xslt.XSLTProcessor/saxon'<br> > > > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0class=3D'or= g.apache.cocoon.components.xslt.TraxProcessor'<br> > > > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0init-method=3D&= #39;initialize'<br> > > > >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0destroy-method= =3D'dispose'><br> > > > >=C2=A0 =C2=A0 =C2=A0 =C2=A0<!--property name=3D'u= se-store' value=3D'true'/--><br> > > > >=C2=A0 =C2=A0 =C2=A0 =C2=A0<property name=3D'tran= sformerFactory'<br> > > > ><br> > >=C2=A0 value=3D'org.dspace.saxon.ConfigurableTransformerFactor= y'/><br> > > > >=C2=A0 =C2=A0 =C2=A0</bean><br> > > > ><br> > > > > but so far I'm missing something:=C2=A0 TraxProcess= or.sourceToSAX throws an<br> > > > > NPE.=C2=A0 I'm probably not setting the parameters = correctly -- there isn't<br> > > > > a setter for use-store at all, for example.<br> > > > ><br> > > > > I've found any number of pages that tell me Avalon = configuration is<br> > > > > being replaced by Spring, but nothing practical on how = to convert<br> > > > > Avalon configuration (such as the first sample above) t= o Spring, or<br> > > > > even how to write fresh Spring configuration for Cocoon= components.<br> > > > > It would be nice to know how to do this even if I wind = up using the<br> > > > > Avalon approach with the present task.<br> > > > ><br> > > > > --<br> > > > > Mark H. Wood<br> > > > > Lead Technology Analyst<br> > > > ><br> > > > > University Library<br> > > > > Indiana University - Purdue University Indianapolis<br> > > > > 755 W. Michigan Street<br> > > > > Indianapolis, IN 46202<br> > > > > 317-274-0749<br> > > > > <a href=3D"http://www.ulib.iupui.edu" rel=3D"noreferrer= " target=3D"_blank">www.ulib.iupui.edu</a><br> > > > ><br> > ><br> > > --<br> > > Mark H. Wood<br> > > Lead Technology Analyst<br> > ><br> > > University Library<br> > > Indiana University - Purdue University Indianapolis<br> > > 755 W. Michigan Street<br> > > Indianapolis, IN 46202<br> > > 317-274-0749<br> > > <a href=3D"http://www.ulib.iupui.edu" rel=3D"noreferrer" target= =3D"_blank">www.ulib.iupui.edu</a><br> > ><br> <br> -- <br> Mark H. Wood<br> Lead Technology Analyst<br> <br> University Library<br> Indiana University - Purdue University Indianapolis<br> 755 W. Michigan Street<br> Indianapolis, IN 46202<br> 317-274-0749<br> <a href=3D"http://www.ulib.iupui.edu" rel=3D"noreferrer" target=3D"_blank">= www.ulib.iupui.edu</a><br> </blockquote></div> --000000000000836997059960ee1a--