Re: How to configure TraxProcessor in 2.2?

gelo1234 <[email protected]> Tue, 10 Dec 2019 00:10:41 +0100
Newsgroups gmane.text.xml.cocoon.user
Message-ID <CAPJaKUpAWownYyxWrWeLhNNZn3UVLyybM2r_4hNNOL3BwWVxmw@mail.gmail.com>
--000000000000ca3bea05994d8131
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Mark,

Why do you need a Custom XSLT Processor other than Saxon actually?? Saxon
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.

https://mrhaki.blogspot.com/2008/09/use-saxon-in-cocoon-22.html

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.ConfigurableTransformerFactor=
y'/>
> >
> > 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 the be=
an
> > 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: Error
> creating
> bean with name 'org.apache.excalibur.xml.xslt.XSLTProcessor/saxon' define=
d
> 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] to
> required
> type [java.lang.String] for property 'transformerFactory': no matching
> 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 run
> 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]>)
> 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, and th=
e
> > > advice I've found in several places around the Web doesn't seem to 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/saxo=
n"
> > >     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 fil=
e
> > > is even being looked for (and where *is* configuration looking)?  The
> > > Cocoon site directs me to Excalibur, which directs me to Avalon, whic=
h
> > > 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/saxon'
> > >           class=3D'org.apache.cocoon.components.xslt.TraxProcessor'
> > >           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 a=
n
> > > 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 components.
> > > It would be nice to know how to do this even if I wind up using the
> > > 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
>

--000000000000ca3bea05994d8131
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">Mar=
k,</div><div class=3D"gmail_default" style=3D"font-size:small"><br></div><d=
iv class=3D"gmail_default" style=3D"font-size:small">Why do you need a Cust=
om XSLT Processor other than Saxon actually?? Saxon should do the right thi=
ng. Why wrapping it inside any &quot;upper-level&quot; Transformer? It&#39;=
s getting kinda weird. You can always add a new Java class to standard Coco=
on Processors/Transformers. <br></div><div class=3D"gmail_default" style=3D=
"font-size:small"><br></div><div class=3D"gmail_default" style=3D"font-size=
:small"><a href=3D"https://mrhaki.blogspot.com/2008/09/use-saxon-in-cocoon-=
22.html">https://mrhaki.blogspot.com/2008/09/use-saxon-in-cocoon-22.html</a=
></div><div class=3D"gmail_default" style=3D"font-size:small"><br></div><di=
v class=3D"gmail_default" style=3D"font-size:small">Greetings,</div><div cl=
ass=3D"gmail_default" style=3D"font-size:small">Greg<br> </div><div class=
=3D"gmail_default" style=3D"font-size:small"><br></div></div><br><div class=
=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">pon., 9 gru 2019 o 2=
3:02=C2=A0Mark H. Wood &lt;<a href=3D"mailto:[email protected]">[email protected]=
du</a>&gt; napisa=C5=82(a):<br></div><blockquote class=3D"gmail_quote" styl=
e=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);paddin=
g-left:1ex">On Thu, Dec 05, 2019 at 04:13:08PM +0100, Javier Puerto wrote:<=
br>
&gt; I recommend you to use the Spring configuration. I never had this<br>
&gt; requirement before but by the error message and the configuration frag=
ment<br>
&gt; that you have sent the NPE is caused because you are not passing an<br=
>
&gt; instance of &quot;org.dspace.saxon.ConfigurableTransformerFactory&quot=
;, you are<br>
&gt; passing a String instead.<br>
&gt; <br>
&gt; &lt;property name=3D&#39;transformerFactory&#39;<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0value=3D&=
#39;org.dspace.saxon.ConfigurableTransformerFactory&#39;/&gt;<br>
&gt; <br>
&gt; IIRC you should change it to:<br>
&gt; &lt;property name=3D&#39;transformerFactory&#39;&gt;<br>
&gt;=C2=A0 =C2=A0&lt;bean class=3D&quot;org.dspace.saxon.ConfigurableTransf=
ormerFactory&quot;/&gt;<br>
&gt; &lt;/property&gt;<br>
&gt; <br>
&gt; The attribute &quot;value&quot; is for literal values. You can also de=
fine the bean<br>
&gt; with an ID and then use the attribute &quot;ref&quot; with the ID of t=
he bean.<br>
&gt; 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() takes<br>
a String argument.=C2=A0 That seems to be correct:=C2=A0 when I change it t=
o a<br>
reference, I get:<br>
<br>
09-Dec-2019 15:12:39.128 SEVERE [localhost-startStop-24] org.apache.catalin=
a.cor<br>
e.StandardContext.listenerStart Exception sending context initialized event=
 to l<br>
istener instance of class [org.springframework.web.context.ContextLoaderLis=
tener<br>
]<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 org.springframework.beans.factory.BeanCreationE=
xception: Error creating <br>
bean with name &#39;org.apache.excalibur.xml.xslt.XSLTProcessor/saxon&#39; =
defined in Se<br>
rvletContext resource [/WEB-INF/spring/applicationContext.xml]: Initializat=
ion o<br>
f bean failed; nested exception is org.springframework.beans.ConversionNotS=
uppor<br>
tedException: Failed to convert property value of type &#39;org.dspace.saxo=
n.Configu<br>
rableTransformerFactory&#39; to required type &#39;java.lang.String&#39; fo=
r property &#39;trans<br>
formerFactory&#39;; nested exception is java.lang.IllegalStateException: Ca=
nnot conv<br>
ert value of type [org.dspace.saxon.ConfigurableTransformerFactory] to requ=
ired <br>
type [java.lang.String] for property &#39;transformerFactory&#39;: no match=
ing 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 tries to run=
<br>
the XSLT transformer.<br>
<br>
It begins to look as though one can&#39;t really wire up TraxProcessor<br>
using Spring.=C2=A0 (By this I mean:=C2=A0 using Spring&#39;s normal &lt;be=
an&gt;<br>
&lt;property&gt; etc.)=C2=A0 I&#39;m guessing that it blows up because noth=
ing has<br>
called #parameterize(Parameters), because #parameterize() knows how<br>
the properties must be set up and makes sure they are all sensible,<br>
and thus something was left unset.<br>
<br>
I tried adding<br>
<br>
=C2=A0 log4j.logger.org.apache.excalibur =3D DEBUG<br>
=C2=A0 log4j.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 consulted for<br>
Cocoon component configuration, but it seems that none of the places<br>
I&#39;ve put my .xconf is one of them.<br>
<br>
&gt; El mi=C3=A9., 4 dic. 2019 a las 22:46, Mark H. Wood (&lt;<a href=3D"ma=
ilto:[email protected]" target=3D"_blank">[email protected]</a>&gt;) escribi=C3=
=B3:<br>
&gt; <br>
&gt; &gt; I&#39;m using Cocoon 2.2.=C2=A0 I need to pass a custom XSLT tran=
sformer<br>
&gt; &gt; factory (that wraps Saxon&#39;s to configure it) to TraxProcessor=
, and the<br>
&gt; &gt; advice I&#39;ve found in several places around the Web doesn&#39;=
t seem to be<br>
&gt; &gt; working:=C2=A0 my factory class never gets instantiated.<br>
&gt; &gt;<br>
&gt; &gt; I&#39;ve got a file META-INF/cocoon/avalon/cocoon-core-saxon-xslt=
.xconf:<br>
&gt; &gt;<br>
&gt; &gt; &lt;?xml version=3D&quot;1.0&quot; encoding=3D&quot;UTF-8&quot;?&=
gt;<br>
&gt; &gt; &lt;components&gt;<br>
&gt; &gt;=C2=A0 =C2=A0&lt;component role=3D&quot;org.apache.excalibur.xml.x=
slt.XSLTProcessor/saxon&quot;<br>
&gt; &gt;=C2=A0 =C2=A0 =C2=A0class=3D&quot;org.apache.cocoon.components.xsl=
t.TraxProcessor&quot;&gt;<br>
&gt; &gt;=C2=A0 =C2=A0 =C2=A0&lt;parameter name=3D&quot;use-store&quot; val=
ue=3D&quot;true&quot;/&gt;<br>
&gt; &gt;=C2=A0 =C2=A0 =C2=A0&lt;parameter name=3D&quot;transformer-factory=
&quot;<br>
&gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 value=3D&q=
uot;org.dspace.saxon.ConfigurableTransformerFactory&quot;/&gt;<br>
&gt; &gt;=C2=A0 =C2=A0&lt;/component&gt;<br>
&gt; &gt; &lt;/components&gt;<br>
&gt; &gt;<br>
&gt; &gt; I also tried copying it to WEB-INF/cocoon and it didnt&#39; seem =
to work<br>
&gt; &gt; there either.<br>
&gt; &gt;<br>
&gt; &gt; I do have &lt;configurator:settings/&gt; and &lt;avalon:bridge/&g=
t; in the Spring<br>
&gt; &gt; config.<br>
&gt; &gt;<br>
&gt; &gt; Is there some way to debug component configuration and see if the=
 file<br>
&gt; &gt; is even being looked for (and where *is* configuration looking)?=
=C2=A0 The<br>
&gt; &gt; Cocoon site directs me to Excalibur, which directs me to Avalon, =
which<br>
&gt; &gt; says that Avalon is wound up and directs me back to Excalibur....=
<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; I&#39;ve also tried to configure the thing using Spring:<br>
&gt; &gt;<br>
&gt; &gt;=C2=A0 =C2=A0 =C2=A0&lt;bean name=3D&#39;org.apache.excalibur.xml.=
xslt.XSLTProcessor/saxon&#39;<br>
&gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0class=3D&#39;org.apache.c=
ocoon.components.xslt.TraxProcessor&#39;<br>
&gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0init-method=3D&#39;initia=
lize&#39;<br>
&gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0destroy-method=3D&#39;dis=
pose&#39;&gt;<br>
&gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0&lt;!--property name=3D&#39;use-store&#=
39; value=3D&#39;true&#39;/--&gt;<br>
&gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0&lt;property name=3D&#39;transformerFac=
tory&#39;<br>
&gt; &gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0valu=
e=3D&#39;org.dspace.saxon.ConfigurableTransformerFactory&#39;/&gt;<br>
&gt; &gt;=C2=A0 =C2=A0 =C2=A0&lt;/bean&gt;<br>
&gt; &gt;<br>
&gt; &gt; but so far I&#39;m missing something:=C2=A0 TraxProcessor.sourceT=
oSAX throws an<br>
&gt; &gt; NPE.=C2=A0 I&#39;m probably not setting the parameters correctly =
-- there isn&#39;t<br>
&gt; &gt; a setter for use-store at all, for example.<br>
&gt; &gt;<br>
&gt; &gt; I&#39;ve found any number of pages that tell me Avalon configurat=
ion is<br>
&gt; &gt; being replaced by Spring, but nothing practical on how to convert=
<br>
&gt; &gt; Avalon configuration (such as the first sample above) to Spring, =
or<br>
&gt; &gt; even how to write fresh Spring configuration for Cocoon component=
s.<br>
&gt; &gt; It would be nice to know how to do this even if I wind up using t=
he<br>
&gt; &gt; Avalon approach with the present task.<br>
&gt; &gt;<br>
&gt; &gt; --<br>
&gt; &gt; Mark H. Wood<br>
&gt; &gt; Lead Technology Analyst<br>
&gt; &gt;<br>
&gt; &gt; University Library<br>
&gt; &gt; Indiana University - Purdue University Indianapolis<br>
&gt; &gt; 755 W. Michigan Street<br>
&gt; &gt; Indianapolis, IN 46202<br>
&gt; &gt; 317-274-0749<br>
&gt; &gt; <a href=3D"http://www.ulib.iupui.edu" rel=3D"noreferrer" target=
=3D"_blank">www.ulib.iupui.edu</a><br>
&gt; &gt;<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>

--000000000000ca3bea05994d8131--