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
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Urs KeiserSubject: SAXON 8.6 xquery processor in Stylus Studio 2006 XML: Java methods as external functions
Author: Urs Keiser
Date: 16 Nov 2005 06:37 AM
I use Stylus Studio 2006 XML for creating and testing xqueries which will eventually be processed in an java application using Saxon XQuery Processor (SAXON 8.6).
Therefore I want to use the SAXON 8.6 xquery processor in Stylus Studio.
This works fine aslong as I do not use my own 'Java methods as external functions'.
When using 'Java methods as external functions' from library (i.e. java.lang.Math.sqrt(.)) it works.

When using my own java method:
- Stylus Studio with the Built-In xquery processor works fine.
- My Java application running the SAXON 8.6 processor works fine.
- Stylus Studio with the SAXON 8.6 processor produces an error.

In Stylus Studio 6 Release 3 Professional Edition:
'Java methods as external funtions' does not work for my own AND for library java classes (i.e. java.lang.Math.sqrt(.)).
Since I have no licence for Stylus Studio 6 Release 3 Enterprise Edition I could not test it there, but I can remember that it worked there when I first evaluated this process about in May 2005.
(It seems that this behavior has been corrected for library classes but not for self created java classes in the meantime)

Details:
--------

StylusStudio 2006 XML Professional Edition AND
StylusStudio 2006 XML Enterprise Edition
Java runtime version 1.4.2_10
Classpath set in StylusStudio menu: 'Tools' -> 'Options..' -> General -> Java Virtual Machine
Classpath = '${classpath};C:\StylusStudio\Java'
compiled test.java in 'C:\StylusStudio\Java\test\test.class'

Processor Input file = Input.xml:
---------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<TEST>
</TEST>

XQueryFile for Stylus Studio Built-In xquery processor:
-------------------------------------------------------

xquery version "1.0";
declare namespace math = "class:java.lang.Math";
declare namespace Test = "class:test.Test";
declare function Test:function($file as xs:string) as xs:string external;
declare function math:sqrt($arg1 as xs:double) as xs:double external;
let $Name := "NAME"
for $TEST in /TEST
return
<report>
<sqrt>{math:sqrt(2)}</sqrt>
<function>{Test:function($Name)}</function>
</report>

XQueryFile for SAXON 8.6 processor:
-----------------------------------

xquery version "1.0";
declare namespace math = "java:java.lang.Math";
declare namespace Test = "java:test.Test";
let $Name := "NAME"
for $TEST in /TEST
return
<report>
<sqrt>{math:sqrt(2)}</sqrt>
<function>{Test:function($Name)}</function>
</report>

My Java Class: test.java
------------------------

package test;
public class Test
{
public static String function(String name)
throws Exception
{
return name;
}
}

Error produced by Stylus Studio using SAXON 8.6 processor:
----------------------------------------------------------

Error: on line 9 ; XPST0017: Cannot find a matching 1-argument function named {java:test.Test}function();

Processor Output file with StylusStudio Built-In xquery processor:
-----------------------------------------------------------------

<report><sqrt>1.4142135623731</sqrt><function>NAME</function></report>



Is there anything wrong what I do, or is it a bug?

Urs Keiser
Switzerland


Postnext
(Deleted User) Subject: SAXON 8.6 xquery processor in Stylus Studio 2006 XML: Java methods as external functions
Author: (Deleted User)
Date: 16 Nov 2005 10:29 AM
Urs,
I am sorry, you are running into a known problem.
We are working on making those functions work in saxon.
In the meantime, as you have discovered, you can use
the built-in xquery processor, or the standalone Java with
the saxon processor.

- clyde

Postnext
Urs KeiserSubject: SAXON 8.6 xquery processor in Stylus Studio 2006 XML: Java methods as external functions
Author: Urs Keiser
Date: 17 Nov 2005 06:27 AM
Clyde,

Thank you for your answer.

I hope you will soon fix the problem.

We are currently developping and testing the xqueries with Stylus Studio. In production the xqueries are processed by the standalone Java application with the saxon processor. Therefore our intention is to use the same xquery processor for developping, testing and production, to minimize risks in our mission critical application.

Is it possible that you could inform me when this problem has been fixed?

king regards
Urs



Postnext
(Deleted User) Subject: SAXON 8.6 xquery processor in Stylus Studio 2006 XML: Java methods as external functions
Author: (Deleted User)
Date: 17 Nov 2005 07:46 AM
Urs, we will be sure to let you know.
- clyde

Postnext
Urs KeiserSubject: SAXON 8.6 xquery processor in Stylus Studio 2006 XML: Java methods as external functions
Author: Urs Keiser
Date: 25 Apr 2006 04:44 AM
Hello Stylus Studio Staff,

I wanted to ask you, if there has been any work done since November 2005 on this subject, i.e. if the problem is fixed in the newest release of 'Stylus StudioŽ 2006 Release 2 XML Professional Edition'.

Kind regards
Urs

Postnext
Minollo I.Subject: SAXON 8.6 xquery processor in Stylus Studio 2006 XML: Java methods as external functions
Author: Minollo I.
Date: 25 Apr 2006 08:47 AM
Yes, that problem should be fixed. You can download and try 2006 release 2 yourself (http://www.stylusstudio.com/download); it won't interfere with your existing installation/license.

Minollo

Postnext
Urs KeiserSubject: SAXON 8.6 xquery processor in Stylus Studio 2006 XML: Java methods as external functions
Author: Urs Keiser
Date: 25 Apr 2006 09:38 AM
Hi Minollo,

Thank you for your answer.

I wanted to try it out, so I downloaded as recommended the newest release.
However, since we only have at a 'Stylus Studio 6 XML Professional Edition' Licence at the moment, I wanted to get an evaluation key, but since I had downloaded an evaluation key when testing with 'Stylus Studio 2006 (Release 1) XML Professional Edition' I got an 'Stylus Studio Trial Expired' message.

We would like to test it, and if it works we want to upgrade to the newest release. Can you help by sending me an evaluation key to my email address ?

Thanks for your help

Urs

Postnext
Minollo I.Subject: SAXON 8.6 xquery processor in Stylus Studio 2006 XML: Java methods as external functions
Author: Minollo I.
Date: 25 Apr 2006 10:08 AM
Done.

Postnext
Urs KeiserSubject: SAXON 8.6 xquery processor in Stylus Studio 2006 XML: Java methods as external functions
Author: Urs Keiser
Date: 26 Apr 2006 05:30 AM
Hi Minollo,

Thank you very much for the key. I could test my application now.

Unfortunately I found out that the problem is not yet fixed (?):

I used the 'IntDate.xquery' example for the JavaExtension as included in the 'examples.prj' project:

The Stylus Studio classpath is set and I am using Java 1.5.0_06 JRE.

Stylus Studio with the built in xquery processor the following 'IntDate.xquery' file worked fine!
----- start of 'IntDate.xquery'
declare namespace ext = "java:IntDate";
declare function ext:getDate($year as xs:integer,
$month as xs:nonNegativeInteger,
$day as xs:nonNegativeInteger,
$format as xs:string)
as xs:string external;

for $date in /doc/date
return ext:getDate($date/@year,$date/@month,$date/@day,$date/@format)
---- end of 'IntDate.xquery'

Stylus Studio with the (included) SAXON 8.7 xquery processor the following 'IntDate.xquery' file aborted with the same error message as when tested in November 2005:
----- start of 'IntDate.xquery'
declare namespace ext = "java:IntDate";

for $date in /doc/date
return ext:getDate($date/@year,$date/@month,$date/@day,$date/@format)
---- end of 'IntDate.xquery'

Error: on line 4 of file:.../IntDate.xquery:; XPST0017: Cannot find a matching 4-argument function named {java:IntDate}getDate();

My Question:
Is there anything not correct in my xquery file or has this problem not yet been fixed?

Thanks for your help.

Urs

Postnext
Minollo I.Subject: SAXON 8.6 xquery processor in Stylus Studio 2006 XML: Java methods as external functions
Author: Minollo I.
Date: 26 Apr 2006 09:41 AM
Being getDate() defined as a non static function, you'll need to change the XQuery code for Saxon into:

return ext:getDate(ext:new(), $date/@year,$date/@month, $date/@day,$date/@format)

That will explicitly create a IntDate object and call the Java method against it. The Stylus Studio internal processor automatically creates a new Java object under the cover to call the function.

Minollo

Postnext
Urs KeiserSubject: SAXON 8.6 xquery processor in Stylus Studio 2006 XML: Java methods as external functions
Author: Urs Keiser
Date: 27 Apr 2006 06:26 AM
Hi Minollo,

Thanks for your answer.

I tried your suggestion in 'Stylus Studio 2006 Release 2 Professional Edition' and I got the following error:
--- START IntDate.xquery
declare namespace ext = "java:IntDate";

for $date in /doc/date
return ext:getDate( ext:new(), $date/@year, $date/@month, $date/@day, $date/@format )
--- END IntDate.xquery
Error: on line 4 of file:///c:/.../IntDate.xquery:; XPST0017: Cannot find a matching 0-argument function named {java:IntDate}new();

The Error was independent whether I declared the Java method as static or not and whether I implemented an empty Constructor 'IntDate()'.

Then I tried your suggestion also in 'Stylus Studio 2006 Release 2 Enterprise Edition' and it was producing correct preview results.
However after displaying data in preview (all data of the IntDate.xml file was correct returned in the preview frame),
the programm showed the following exceptions in the output window:
--- START Exceptions displayed in Output window
java.lang.NoSuchMethodException: com.stylusstudio.debugger.saxon.CSaxonXQueryDriver.instance()
at java.lang.Class.getMethod(Unknown Source)
at com.stylusstudio.debugger.saxon.JavaCall.<init>(JavaCall.java:17)
at com.stylusstudio.debugger.saxon.CallInterceptorForXQuery.invokeMethod(CallInterceptorForXQuery.java:15)
at net.sf.saxon.functions.ExtensionFunctionCall.call(ExtensionFunctionCall.java:220)
at net.sf.saxon.functions.ExtensionFunctionCall.iterate(ExtensionFunctionCall.java:112)
at net.sf.saxon.instruct.TraceWrapper.iterate(TraceWrapper.java:214)
at net.sf.saxon.instruct.TraceWrapper.iterate(TraceWrapper.java:214)
at net.sf.saxon.expr.ForExpression$MappingAction.map(ForExpression.java:603)
at net.sf.saxon.expr.MappingIterator.next(MappingIterator.java:61)
at net.sf.saxon.query.XQueryExpression$ErrorReportingIterator.next(XQueryExpression.java:518)
at com.stylusstudio.debugger.saxon.SerializeObject.serializeAnything(SerializeObject.java:78)
at com.stylusstudio.debugger.saxon.DebugRemote.sendResults(DebugRemote.java:93)
at com.stylusstudio.debugger.saxon.DebugTracer.sendResults(DebugTracer.java:94)
at com.stylusstudio.debugger.saxon.CSaxonXQueryDriver.run(CSaxonXQueryDriver.java:197)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at com.stylusstudio.debugger.saxon.JavaCall.beforeCall(JavaCall.java:54)
at com.stylusstudio.debugger.saxon.JavaCall.beforeCall(JavaCall.java:48)
at com.stylusstudio.debugger.saxon.CallInterceptorForXQuery.invokeMethod(CallInterceptorForXQuery.java:16)
at net.sf.saxon.functions.ExtensionFunctionCall.call(ExtensionFunctionCall.java:220)
at net.sf.saxon.functions.ExtensionFunctionCall.iterate(ExtensionFunctionCall.java:112)
at net.sf.saxon.instruct.TraceWrapper.iterate(TraceWrapper.java:214)
at net.sf.saxon.instruct.TraceWrapper.iterate(TraceWrapper.java:214)
at net.sf.saxon.expr.ForExpression$MappingAction.map(ForExpression.java:603)
at net.sf.saxon.expr.MappingIterator.next(MappingIterator.java:61)
at net.sf.saxon.query.XQueryExpression$ErrorReportingIterator.next(XQueryExpression.java:518)
at com.stylusstudio.debugger.saxon.SerializeObject.serializeAnything(SerializeObject.java:78)
at com.stylusstudio.debugger.saxon.DebugRemote.sendResults(DebugRemote.java:93)
at com.stylusstudio.debugger.saxon.DebugTracer.sendResults(DebugTracer.java:94)
at com.stylusstudio.debugger.saxon.CSaxonXQueryDriver.run(CSaxonXQueryDriver.java:197)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
...
--- END Exceptions displayed in Output window
(It looks as the NullPointerException is thrown for each value returned,
since the amount of thrown NullPointerExceptions (with identical stack)
is equal to the amount of values displayed in the preview.)

Do you see or know any other reason for the problem?

Tanks and greetings
Urs

Postnext
Minollo I.Subject: SAXON 8.6 xquery processor in Stylus Studio 2006 XML: Java methods as external functions
Author: Minollo I.
Date: 27 Apr 2006 09:26 AM
About Professional edition, the problem is that the classpath to "c:\Program Files\Stylus Studio 2006 Release 2 XML Professional Edition\examples\javaExtension" is not automatically added to the project; if you do that manually (right click on the project root, Set Classpath), preview will work as expected.

About the errors reported in the Output Window, those should be benign exceptions that can be ignored; they are being removed from future maintenance updates. You can disregard them for the time being.

Minollo

Postnext
Ivan PedruzziSubject: SAXON 8.6 xquery processor in Stylus Studio 2006 XML: Java methods as external functions
Author: Ivan Pedruzzi
Date: 27 Apr 2006 09:40 AM
Urs,

Even if an exception is thrown in the Output window you should still get the right result in the Preview Window, can you confirm that?


Thank You
Ivan Pedruzzi
Stylus Studio Team

Postnext
Urs KeiserSubject: SAXON 8.6 xquery processor in Stylus Studio 2006 XML: Java methods as external functions
Author: Urs Keiser
Date: 28 Apr 2006 05:20 AM
Hi Minollo and Ivan,

I can confirm that I get the right results in the Preview window.
The Output window is only opened at java compiling and stays open after that, therefore I saw the exceptions displayed in the output window.

I also can confirm, that when using static external java functions the special argument 'ext:new()' is not used, however non static external java functions need the 'ext:new()' argument with the Saxon processor.

Conclusion: Java methods as external functions works in Stylus Studio 2006 Release 2 prefessional and Enterprise Edition using the SAXON 8.7 xquery processor.

Many Thanks for your help
Urs

P.S. I will ask my boss to upgrade to Stylus Studio 2006 Release 2 XML Professional Edition today.

Posttop
Ivan PedruzziSubject: SAXON 8.6 xquery processor in Stylus Studio 2006 XML: Java methods as external functions
Author: Ivan Pedruzzi
Date: 28 Apr 2006 09:21 AM
Hi Urs,

The next update (591c) will fix the stack trace problem.
Thank You for your feedback

Ivan Pedruzzi
Stylus Studio Team

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 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.