Re: Calling a function using a variable name
Glen Barnes <[email protected]> Sun, 6 Feb 2005 13:21:00 +1300
| Newsgroups | gmane.text.xml.o-xml |
|---|---|
| Message-ID | <[email protected]> |
That would work how I want and may get over the problem I have with
dynamically including files with XSLT (Which you cannot do). The only
problem? When I run it I get:
error: program not compiled yet
at: Program.setParameter(Node, Node): index.oml
It seems as though I cannot set a parameter before compiling. Is there
another thing I have to run before the setParameter function?
My program looks something like this:
<o:set module_to_run="Program($prog_name)"/>
<o:do
select="$module_to_run.setParameter($module/param/@name.string(),
String($module/param.string()))"/>
<o:eval select="$module_to_run.run()"/>
Another thing. Can I run the program and pass the output through and
xsl transform before returning that to the calling program?
Thanks,
Glen
On 6/02/2005, at 11:25, Martin Klang wrote:
>
> There's of course another possiblity which I didn't think of -
> you can use XSLT or o:XML to generate a program, or a Factory type.
>
> However in your case you want to load and invoke a set of modules
> based on an XML configuration file, right?
> With the new Program type in 1.1.0 it's very easy to run and include
> results from one program in another.
>
> Say the config file contains lines like these:
> <module name="blog" file="modules/blog.oml"/>
> <module name="foo" file="modules/foo.oml"/> ...etc
> Say then that each module is an o:XML program that takes a predefined
> set of parameters, and produces some output.
> You could then iterate over the config lines, load the corresponding
> module, set any parameters and run the program ->
>
> <o:set cfg="io:File('config.xml').parse()"/> <!-- load config file -->
> <o:for-each select="$cfg//module"> <!-- iterate over module elements
> -->
> <o:set module="Program(@file)"/> <!-- load program -->
> <o:do select="$module.setParameter('input', $input)"/> <!-- set a
> program parameter, called 'input' -->
> <o:eval select="$module.run()"/> <!-- compile and run the program,
> return the output -->
> </o:for-each>
>
> would that work for you?
>
> /m
>