You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by Colin Paul Adams <co...@colina.demon.co.uk> on 2003/03/26 22:26:19 UTC

Portability of XalanTransformer::CompiledStylesheet?

I notice that XalanTransformer::ParsedSource is owned by the
transformer, and can't be used by another.

Would I be right to assume that this restriction does NOT applied to
CompiledStylesheet, so they could be cached, for instance?
-- 
Colin Paul Adams
Preston Lancashire

RE: Portability of XalanTransformer::CompiledStylesheet?

Posted by David N Bertoni/Cambridge/IBM <da...@us.ibm.com>.



Hi Mark,

Xalan's default implementation of the source tree _is_ thread-safe.  The
default implementation of compiled stylesheets is also thread-safe.

There is no way to modify the default implementation of the source tree, so
all use is read-only.

Dave



                                                                                                                         
                      "Mark Weaver"                                                                                      
                      <mark@npsl.co.uk         To:      <xa...@xml.apache.org>                                   
                      >                        cc:      (bcc: David N Bertoni/Cambridge/IBM)                             
                                               Subject: RE: Portability of XalanTransformer::CompiledStylesheet?         
                      03/26/2003 01:48                                                                                   
                      PM                                                                                                 
                                                                                                                         



The transformer caches both sources and compiled stylesheets.  You could
get
around this by having a global instance of the transformer and using both
compiled stylesheets and sources from that (application permitting of
course), or you could extract code from XalanTransformer, or copy/hack up
the thing to create a custom version.

I do the latter (the functions aren't virtual/members are private so it's
not possible to derive and override), and cache both sources and
stylesheets
outside of the transformer object.

I'm not aware of anything that says that parsed sources are thread safe;
however I'm reasonably certain that if they are used in a read only fashion
there shouldn't be a problem.  (Someone please tell me if this isn't the
case!)

Mark

> -----Original Message-----
> From: Colin Paul Adams [mailto:colin@colina.demon.co.uk]
> Sent: 26 March 2003 21:26
> To: xalan-c-users@xml.apache.org
> Subject: Portability of XalanTransformer::CompiledStylesheet?
>
>
> I notice that XalanTransformer::ParsedSource is owned by the
> transformer, and can't be used by another.
>
> Would I be right to assume that this restriction does NOT applied to
> CompiledStylesheet, so they could be cached, for instance?
> --
> Colin Paul Adams
> Preston Lancashire
>
>




RE: Portability of XalanTransformer::CompiledStylesheet?

Posted by Mark Weaver <ma...@npsl.co.uk>.
The transformer caches both sources and compiled stylesheets.  You could get
around this by having a global instance of the transformer and using both
compiled stylesheets and sources from that (application permitting of
course), or you could extract code from XalanTransformer, or copy/hack up
the thing to create a custom version.

I do the latter (the functions aren't virtual/members are private so it's
not possible to derive and override), and cache both sources and stylesheets
outside of the transformer object.

I'm not aware of anything that says that parsed sources are thread safe;
however I'm reasonably certain that if they are used in a read only fashion
there shouldn't be a problem.  (Someone please tell me if this isn't the
case!)

Mark

> -----Original Message-----
> From: Colin Paul Adams [mailto:colin@colina.demon.co.uk]
> Sent: 26 March 2003 21:26
> To: xalan-c-users@xml.apache.org
> Subject: Portability of XalanTransformer::CompiledStylesheet?
>
>
> I notice that XalanTransformer::ParsedSource is owned by the
> transformer, and can't be used by another.
>
> Would I be right to assume that this restriction does NOT applied to
> CompiledStylesheet, so they could be cached, for instance?
> --
> Colin Paul Adams
> Preston Lancashire
>
>


Re: Portability of XalanTransformer::CompiledStylesheet?

Posted by David N Bertoni/Cambridge/IBM <da...@us.ibm.com>.



Hi Colin,

Actually, they both can be freely shared -- the ownership issue has to do
with the lifetime of the object.  For example, it's possible to use a
XalanTransformer instance as a factory for XalanParsedSource and
XalanCompiledStylesheet instances and use them in transformations with
other XalanTransformer instances.

See the ThreadTest test program for an example of a XalanTransformer
instance used solely as a factory.

Of course, you can always create instances of the implementation classes of
XalanParsedSource and/or XalanCompiledStylesheet without using a
XalanTransformer as a factory.  That might make more sense if you want a
cache of source trees and/or compiled stylesheets.

Dave



                                                                                                                         
                      Colin Paul Adams                                                                                   
                      <colin@colina.de         To:      xalan-c-users@xml.apache.org                                     
                      mon.co.uk>               cc:      (bcc: David N Bertoni/Cambridge/IBM)                             
                                               Subject: Portability of XalanTransformer::CompiledStylesheet?             
                      03/26/2003 01:26                                                                                   
                      PM                                                                                                 
                                                                                                                         



I notice that XalanTransformer::ParsedSource is owned by the
transformer, and can't be used by another.

Would I be right to assume that this restriction does NOT applied to
CompiledStylesheet, so they could be cached, for instance?
--
Colin Paul Adams
Preston Lancashire