> I also keep my own (mutex protected) map of stylesheet path->compiled
> > stylesheets; the stylesheet is effectively compiled & stored on
> the first
> > usage.  Thread safety of STL containers is a bit of a pain, for maximum
> > efficiency you need a multiple readers/single writer locking
> mechanism (I
> > have a generic one of these).  Presumably the transform() mechanism is
> > thread safe?
>
> No, XalanTransformer instance are _not_ shareable amongst threads.
> However, compiled stylesheets and parsed source documents are thread-safe.
> You can either have a cache of XalanTransformer instances, which you
> control through a mutex, or you can just create a new one on the stack for
> every thread.

I create the instance each time I want to do a transform at the moment, but
am caching stylesheets.  From what you are saying the class is heavyweight
enough that its worth trying not to do this.  I will probably use TLS and
fault the XalanTransfomer objects in as this way I can avoid mutex
contention.

> > Also, do you know of any STL class that encapsulates a non-copying
> istream?
> > That is, I have the data in a read-only string buffer, creating an
> > istringstream will copy that data to an encapsulated STL string
> (typically),
> > which means that I get two copies of the buffer.  I'd like to avoid this
> if
> > possible.
>
> If you look at the StreamTransform sample, you'll see we use istrstream,
> which does not copy data.
Aha, thanks!

>
> > Finally, do you know of anyway of setting the entity resolver used when
> > parsing stylesheets?  My stylesheets tend to reference one another via
> HTTP
> > requests, my problem is that I would like to pass some HTTP
> headers along
> > with the request, but I couldn't see an easy way to do this.
>
> I'm not sure there's a way to do this with the XalanTransformer classes.
> Perhaps we should consider this as a new feature.
>
> Dave
It is quite likely that I will need to make some modifications to do this in
the near future.  Would you have any advice as to what the best way to
set/pass the resolver along the chain would be?

Thanks,

Mark

Reply via email to