XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Maya BSubject: Receiving a function as a parameter, and operate it.
Author: Maya B
Date: 18 Jul 2006 11:33 AM
Originally Posted: 18 Jul 2006 11:31 AM
In xquery in the running time,
I am dynamicly building a function (as a string).

I need a function :
that receives the function (that I built as a string) and a parameter
(as the variables) - and operate the function on the paramater.
such as :

declare function operate ($func($p as element) as function, $p as element)
{
@($func($p))
};

Is it possible to preform this in xquery,
and If not, how can I preform this (using other languages),
when the function is dynamicly built in xquery (as a string)?

Thanks,
Maya

Postnext
Ivan PedruzziSubject: Receiving a function as a parameter, and operate it.
Author: Ivan Pedruzzi
Date: 18 Jul 2006 12:01 PM
Hi Maya,

Most of the XQuery implementations do not support to evaluate code at
run-time.

Doing it with multiple queries should be simple.

The query processor you are planing to use dictates which API you will need to learn.
Almost all XQuery implementations allow to read a xquery expression from string, stream or file.

Hope this helps
Ivan Pedruzzi
Stylus Studio Team

Postnext
Maya BSubject: Receiving a function as a parameter, and operate it.
Author: Maya B
Date: 18 Jul 2006 12:17 PM

From your answer I still didn't get how do I implement this on xquery (using stylus studio engine or any other engine that you might suggest),
[ and using run time evaluating code ]

If you could give me a specific example that would be really good.

Postnext
Ivan PedruzziSubject: Receiving a function as a parameter, and operate it.
Author: Ivan Pedruzzi
Date: 18 Jul 2006 12:21 PM
Hi Maya,

Could you please provide a concrete use case with input and desired output and why you have the need to generate the query on the fly?

Thank You
Ivan Pedruzzi
Stylus Studio Team

Postnext
Maya BSubject: Receiving a function as a parameter, and operate it.
Author: Maya B
Date: 18 Jul 2006 12:41 PM
Originally Posted: 18 Jul 2006 12:38 PM
The problem is as follow,

Input :
1. XML document describing a query (on graph stracture).
2. XML document describing a Graph
[the graph might be on more then one document but this I discover or run time]

I need to translate the query written in XML to an
Xquery function and operate it on the first graph.

Also since there might be more then one destination graph,
(and this I discover during run time after going over the first document)
I might need to divide the query I build for some of it querying
different graphs (on different documents).
- Therefore, for each graph I will need to generate a query that fits
it, and I need to operate those dynamicly -run time- builded queries,
on the different graphs.

How do I preform this?
(assuming: 1. I know how to build the queries as string
2. The destination files (except from the first) - I discover during run time )

Postnext
Ivan PedruzziSubject: Receiving a function as a parameter, and operate it.
Author: Ivan Pedruzzi
Date: 18 Jul 2006 11:39 PM
Maya,

Here a simple but hopefully complete example of what I understood from you description.

Assume you have a XML document representing some sort of expression that you would like to represent as a xquery (expression-graph.xml).

The expression stored in expression-graph.xml means the following
- declare a variable named p
- evaluate the variable

Using the xquery "expression-graph-to-xquery.xquery" I translate the expression-graph.xml into expression-graph.xquery

Now i can process incoming graphs with my programmatically generated expression-graph.xquery

For semplicity I used XQueryX to create the XML expression.

If you like to see how to execute a xquery programmatically open
"expression-graph-to-xquery.xquery" then click XQuery -> Generate Java Code...


Hope this helps
Ivan Pedruzzi
Stylus Studio Team


DocumentGraphToXQuery.zip

Posttop
Maya BSubject: Receiving a function as a parameter, and operate it.
Author: Maya B
Date: 19 Jul 2006 09:19 AM
wow!
cool thanks,
I hope this will help me, anyhow - it solved me couple more wonders I've had.... :)

 
Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.