Re: [xslt] adding my own data to transformer context ?



On Wed, Jul 18, 2001 at 12:02:21AM -0500, Tom Moog wrote:
> 
> Is there a clean way to add information to the
> transform context object ?  Here is my motivation:

  No

> I need to pass an argument to document() as a C 
> string rather than an actual file since it's not
> in a real file.  At first I thought I could 
> register some kind of URL handler so that when
> it sees "string:/foo"

  You can register URI handlers see xmlIO.h

> it would find a string
> defined in a (additional) hash table in the 
> transform context name "foo"  and process it.
> But then I realized this wouldn't work because
> the URL handler would only see "foo" and doesn't
> have access to the transform context where the
> association between "foo" and the actual string
> is stored (because the transform context pointer
> isn't passed to the URL handler).

  The URI handler will see "string:/foo"
I suggest you use a global variable

> I found a function named xmlSaxParseMemory (or
> something similar) which looks like what I need.
> However, the real issue is how to add my own 
> information to the transform context.

  It is not what you need SAX is at the parsing level
and cannot be reused with XSLT

> First problem: I notice that some structures have
> a private pointer which I could use to store a
> pointer to my own stuff, but xsltTransformContext
> does not.

  Right

> Second problem: xsltApplyStyleSheetInternal 
> constructs the transform context and then does
> everything else without letting the caller do
> anything to the transform context.  it would
> be useful if the caller could pass in an 
> already constructed transform context which
> would be used instead of building a new one.
> Then a caller could (a) build a transform context,
> (b) add some things to it using the private pointer
> and then (c) call xsltApplyStyleSheetInternal to
> do the hard work.

  That should be possible

> Third problem: If there is a way for the caller
> to pass in an already constructed transform 
> context then there should be a way for the caller
> to do the destruction also perhaps by storing the
> address of a callback routine in the transform 
> context when it is constructed.

  No the caller will have to free the transformation
context (since he allocated it) and hence can perfectly
free the extra informations at the same time. I don't
see the point of adding a callback mechanism.

  In general inventing new kind of URI for special
purposes sounds fishy to me (it won't be portable or
interoperable, so why bother with XSLT at all ???).

  I will add some _private fields to the stylesheet and
transformation contexts.

Daniel

-- 
Daniel Veillard      | Red Hat Network http://redhat.com/products/network/
veillard@redhat.com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
Sep 17-18 2001 Brussels Red Hat TechWorld http://www.redhat-techworld.com




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]