If the XQItem is a SaxonXQItem, then you can cast to SaxonXQItem, call getSaxonItem(), and then use Saxon's SingletonIterator class to create a SequenceIterator.

If it's an XQItem that isn't a SaxonXQItem, then Saxon can't do anything with it; you will have to convert it to something else yourself.

Michael Kay
Saxonica

On 24 May 2013, at 07:48, Kunal Chauhan wrote:

Hello,

I am using external functions in XQuery with Saxon HE 9.3.

An external function returns SequenceIterator. I wants to returns an XQItem and based  on that XQItem Query will process further.

In my earlier post Mike suggest me how to return Java object which  works perfectly for me.

But here I am not able to return XQItem. So, how to return XQItem as a SequenceIterator ?

Thanks and Regards,
Kunal Chauhan


On Tue, May 7, 2013 at 5:27 PM, Michael Kay <mike@saxonica.com> wrote:

First, you can wrap any Java Object as an ObjectValue

Item val = new ObjectValue(obj)

which makes it into a Saxon Item.

Then you can return a SingletonIterator which wraps this item: SingletonIterator.makeIterator(val)

Michael Kay
Saxonica

On 7 May 2013, at 12:41, Kunal Chauhan wrote:

Hi,

I implement the class, as per above mentioned link suggest.

public ExtensionFunctionCall makeCallExpression() {
        return new ExtensionFunctionCall() {
           
        public SequenceIterator call(SequenceIterator[] arguments, XPathContext context) throws XPathException {

               // here is my business logic
        }

  };

}

above function is in my class which calls an extention function.

I am getting Result as a Java class.
How can I convert this Java  class to SequenceIterator, If I get atomic value than function is able to return it but when I get java class as a result  I need to convert it .

How can I convert any java class to this return type compatible ?

-
Kunal


On Thu, May 2, 2013 at 7:05 PM, Kunal Chauhan <mail4ck@gmail.com> wrote:
Thanks Michael for your quick response.


- Kunal


On Thu, May 2, 2013 at 6:59 PM, Michael Kay <mike@saxonica.com> wrote:

These are called "extension functions" in XSLT and "external functions" in XQuery. The documentation on how to achieve this is here:


Michael Kay
Saxonica

On 2 May 2013, at 14:11, Kunal Chauhan wrote:

Hi,

I wants to bind function result to XQuery.
For Example there are some function call from the query, but I want to run those function in Java and whatever result comes as an
output, need to bind with Query as an output of that function.

I already gone through Function Extension, user-defiend function, From which you can call compiled querie's function from java.

Here I am mentioning an example which can help me to explain the scenario well.

Query :

    doSomething() eq node/@id

What I want is, this doSomething() I execute in java. this method is not available in query. I write it in java only. based on
method name it will execute it and whatever output comes, bind it to with query for further process.

is this possible?
can I bind value to the method, like we bind value to the external variable ?


Thanks and Regards,

--
Kunal Chauhan
[+918655517141]
------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------
Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
Get 100% visibility into your production application - at no cost.
Code-level diagnostics for performance bottlenecks with <2% overhead
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap1
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help



--
Kunal Chauhan
[+918655517141]
[+919904983614]



--
Kunal Chauhan
[+918655517141]
[+919904983614]
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their applications. This 200-page book is written by three acclaimed
leaders in the field. The early access version is available now.
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may_______________________________________________


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their applications. This 200-page book is written by three acclaimed
leaders in the field. The early access version is available now.
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help



--
Kunal Chauhan
[+918655517141]
[+919904983614]
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help