Re: How to configure TraxProcessor in 2.2?

gelo1234 <[email protected]> Fri, 6 Dec 2019 09:04:42 +0100
Newsgroups gmane.text.xml.cocoon.user
Message-ID <CAPJaKUr3ECyxnLBTjOWCGvDnDFvVGhpaor-TnZY0Gr65fCRnsg@mail.gmail.com>
--00000000000033173e05990480fa
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi Mark,

Also make sure, you have that class:
org.dspace.saxon.ConfigurableTransformerFactory available on the CLASSPATH
(-> WEB-INF/lib/*.jar)
And a proper version/config for Saxon HE. Here is the guide:
https://stackoverflow.com/questions/22483436/using-saxon9-for-xslt-with-apa=
che-cocoon-2-2

Greetings,
Greg


czw., 5 gru 2019 o 16:13 Javier Puerto <[email protected]> napisa=C5=82(a):

> Hi Mark,
>
> I recommend you to use the Spring configuration. I never had this
> requirement before but by the error message and the configuration fragmen=
t
> 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 the bean
> with an ID and then use the attribute "ref" with the ID of the bean.
> I hope that helps.
>
> Salu2.
>
> 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 the
>> 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/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/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 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 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
>>
>

--00000000000033173e05990480fa
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">Also make sure, you=
 have that class: org.dspace.saxon.ConfigurableTransformerFactory available=
 on the CLASSPATH (-&gt; WEB-INF/lib/*.jar)</div><div class=3D"gmail_defaul=
t" style=3D"font-size:small">And a proper version/config for Saxon HE. Here=
 is the guide:</div><div class=3D"gmail_default" style=3D"font-size:small">=
<a href=3D"https://stackoverflow.com/questions/22483436/using-saxon9-for-xs=
lt-with-apache-cocoon-2-2">https://stackoverflow.com/questions/22483436/usi=
ng-saxon9-for-xslt-with-apache-cocoon-2-2</a></div><div class=3D"gmail_defa=
ult" style=3D"font-size:small"><br></div><div class=3D"gmail_default" style=
=3D"font-size:small">Greetings,</div><div class=3D"gmail_default" style=3D"=
font-size:small">Greg<br></div><div class=3D"gmail_default" style=3D"font-s=
ize:small"><br></div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" =
class=3D"gmail_attr">czw., 5 gru 2019 o 16:13=C2=A0Javier Puerto &lt;<a hre=
f=3D"mailto:[email protected]">[email protected]</a>&gt; napisa=C5=82(a):<b=
r></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex=
;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr">=
<div>Hi Mark,</div><div><br></div><div>I recommend you to use the Spring co=
nfiguration. I never had this requirement before but by the error message a=
nd the configuration fragment that you have sent the NPE is caused because =
you are not passing an instance of &quot;org.dspace.saxon.ConfigurableTrans=
formerFactory&quot;, you are passing a String instead.</div><div><br></div>=
<div>&lt;property name=3D&#39;transformerFactory&#39;<br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 value=3D&#39;org.dspace.saxon.Config=
urableTransformerFactory&#39;/&gt;<br></div><div><br></div><div>IIRC you sh=
ould change it to:</div><div>&lt;property name=3D&#39;transformerFactory&#3=
9;&gt;<br></div><div>=C2=A0 &lt;bean class=3D&quot;org.dspace.saxon.Configu=
rableTransformerFactory&quot;/&gt;</div><div>&lt;/property&gt;</div><div><b=
r></div><div>The attribute &quot;value&quot; is for literal values. You can=
 also define the bean with an ID and then use the attribute &quot;ref&quot;=
 with the ID of the bean.</div><div>I hope that helps.</div><div><br></div>=
<div>Salu2.</div><div><br></div><div class=3D"gmail_quote"><div dir=3D"ltr"=
 class=3D"gmail_attr">El mi=C3=A9., 4 dic. 2019 a las 22:46, Mark H. Wood (=
&lt;<a href=3D"mailto:[email protected]" target=3D"_blank">[email protected]</a=
>&gt;) escribi=C3=B3:<br></div><blockquote class=3D"gmail_quote" style=3D"m=
argin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left=
:1ex">I&#39;m using Cocoon 2.2.=C2=A0 I need to pass a custom XSLT transfor=
mer<br>
factory (that wraps Saxon&#39;s to configure it) to TraxProcessor, and the<=
br>
advice I&#39;ve found in several places around the Web doesn&#39;t seem to =
be<br>
working:=C2=A0 my factory class never gets instantiated.<br>
<br>
I&#39;ve got a file META-INF/cocoon/avalon/cocoon-core-saxon-xslt.xconf:<br=
>
<br>
&lt;?xml version=3D&quot;1.0&quot; encoding=3D&quot;UTF-8&quot;?&gt;<br>
&lt;components&gt;<br>
=C2=A0 &lt;component role=3D&quot;org.apache.excalibur.xml.xslt.XSLTProcess=
or/saxon&quot;<br>
=C2=A0 =C2=A0 class=3D&quot;org.apache.cocoon.components.xslt.TraxProcessor=
&quot;&gt;<br>
=C2=A0 =C2=A0 &lt;parameter name=3D&quot;use-store&quot; value=3D&quot;true=
&quot;/&gt;<br>
=C2=A0 =C2=A0 &lt;parameter name=3D&quot;transformer-factory&quot;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0value=3D&quot;org.ds=
pace.saxon.ConfigurableTransformerFactory&quot;/&gt;<br>
=C2=A0 &lt;/component&gt;<br>
&lt;/components&gt;<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 &lt;configurator:settings/&gt; and &lt;avalon:bridge/&gt; 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 to Avalon, which<br>
says that Avalon is wound up and directs me back to Excalibur....<br>
<br>
<br>
<br>
I&#39;ve also tried to configure the thing using Spring:<br>
<br>
=C2=A0 =C2=A0 &lt;bean name=3D&#39;org.apache.excalibur.xml.xslt.XSLTProces=
sor/saxon&#39;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 class=3D&#39;org.apache.cocoon.component=
s.xslt.TraxProcessor&#39;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 init-method=3D&#39;initialize&#39;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 destroy-method=3D&#39;dispose&#39;&gt;<b=
r>
=C2=A0 =C2=A0 =C2=A0 &lt;!--property name=3D&#39;use-store&#39; value=3D&#3=
9;true&#39;/--&gt;<br>
=C2=A0 =C2=A0 =C2=A0 &lt;property name=3D&#39;transformerFactory&#39;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 value=3D&#39;org.ds=
pace.saxon.ConfigurableTransformerFactory&#39;/&gt;<br>
=C2=A0 =C2=A0 &lt;/bean&gt;<br>
<br>
but so far I&#39;m missing something:=C2=A0 TraxProcessor.sourceToSAX throw=
s an<br>
NPE.=C2=A0 I&#39;m probably not setting the parameters correctly -- there i=
sn&#39;t<br>
a setter for use-store at all, for example.<br>
<br>
I&#39;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) to 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>
</blockquote></div></div>
</blockquote></div>

--00000000000033173e05990480fa--