Re: [xslt] Structured parameters how to



On Sun, Mar 24, 2002 at 01:20:42PM +0100, Eric van der Vlist wrote:
> Hi Daniel,
> 
> Daniel Veillard wrote:
> 
> > the values are evaluated as XPath expressions in the context of the root
> > of the target document, exactly like the global variables or parameter
> > values. 
> 
> Yes, that's what I have noticed (I have been quite surprised at the 
> begining but I reckon it has some advantages!).

  I didn't gave it much thought, when I wrote the code I simply
handled user defined params like internal ones with a select= value.
I really didn't expected anybody would like to handle this differently,
I'm lazy I usually never look at other projects code.

> > So the values can be nodesets, but the current API doesn't allow
> > to directly pass a subtree. If you use "document()" in the expression it
> > should be possible to load a node-set dynamically when the parameter is
> > evaluated.
> 
> Don't you need to save it on file first? I would prefer to work in memory.

  Hum, by playing with the URI used for it it could be possible:
    - to hack libxml2 I/O to parse it from a memory string
   or
    - by using some less common libxslt APIs like 
         xsltNewTransformContext()
      and
         xsltNewDocument()
      one could build a transformation context, then register the
      existing in-memory document tree (make sure doc->URI is the same
      as what is used in the document() call).
      Then xsltApplyStylesheetUser() with that existing context.

> >   I hope this will be sufficient, otherwise it might be possible to
> > add that functionality, but it would require an API extension I'm afraid.
> 
> For the application I am working on, yes it will be (I have ended up 
> passing the structured content as a string and "parsing" it in a named 
> template... not the most beautiful solution, but that works). However, 

  Okay, I see.

> passing substrees is very powerfull and this might be a useful extension 
> to consider for a future version.

  Yes, I would need to add the concept of tree parameter, and creat new
APIs to pass those to the transformation engine.

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard@redhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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