You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Loïc Trégan <lt...@hotmail.com> on 2000/12/29 11:21:03 UTC

set extension instance

Hello,


I need to set some property on an extension (like the home directory), which
are not found in the XML; can I force xalan 1.2 to use an extension that I
have correclty initialized ? Currenlty I use static variables, but it not
thread safe.

  Extension ext = new Extension();
  ext.setHomeDirectory("...");
  ext.failOnWarning( true );

   XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
   processor.registerExtension( ext );
    XSLTInputSource xslSheet =  new XSLTInputSource ( new
FileReader(xslfile));
    processor.setStylesheet(xslSheet);
    processor.process(xmlSource, null, xmlResult);

Is it a legitimate need ? Or maybe I can attach a user object to the
processor and the extension can retrieve it ?

thanks for your help.


loic

Re: set extension instance

Posted by Jim Melton <ja...@cylogix.com>.
I have the same question but for a different reason. I am using a
hacked up (by me) version of the RedirectWriter extension; I needed to
create multiple ouputs in Strings from a single input. I used a static
Vector to hold the Strings but am somewhat uncomfortable with this
design. Everything would be simpler if I could create a
HackedRedirectWriter object, pass it into the stylesheet, fill its
String array, and then use the Strings.

Thanks for any help,
Jim.

Loïc Trégan wrote:
> 
> Hello,
> 
> I need to set some property on an extension (like the home directory), which
> are not found in the XML; can I force xalan 1.2 to use an extension that I
> have correclty initialized ? Currenlty I use static variables, but it not
> thread safe.
> 
>   Extension ext = new Extension();
>   ext.setHomeDirectory("...");
>   ext.failOnWarning( true );
> 
>    XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
>    processor.registerExtension( ext );
>     XSLTInputSource xslSheet =  new XSLTInputSource ( new
> FileReader(xslfile));
>     processor.setStylesheet(xslSheet);
>     processor.process(xmlSource, null, xmlResult);
> 
> Is it a legitimate need ? Or maybe I can attach a user object to the
> processor and the extension can retrieve it ?
> 
> thanks for your help.
> 
> loic

-- 
James Melton
CyLogix, Inc. 
(609) 750-5190 
http://www.cylogix.com

Re: set extension instance

Posted by Gary L Peskin <ga...@firstech.com>.
Loïc Trégan wrote:
> 
> Hello,
> 
> I need to set some property on an extension (like the home directory), which
> are not found in the XML; can I force xalan 1.2 to use an extension that I
> have correclty initialized ? Currenlty I use static variables, but it not
> thread safe.
> 
>   Extension ext = new Extension();
>   ext.setHomeDirectory("...");
>   ext.failOnWarning( true );
> 
>    XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
>    processor.registerExtension( ext );
>     XSLTInputSource xslSheet =  new XSLTInputSource ( new
> FileReader(xslfile));
>     processor.setStylesheet(xslSheet);
>     processor.process(xmlSource, null, xmlResult);
> 
> Is it a legitimate need ? Or maybe I can attach a user object to the
> processor and the extension can retrieve it ?

You can pass the property such as home directory to your stylesheet as a
parameter.  In the stylesheet, pass the value of the parameter to the
extension function constructor.  If you are using extension elements,
the property can be passed as an attribute to an init method.

If you let us know whether you're using extension functions or elements,
I can provide an example.

Gary