Project

Profile

Help

Saxon/C API issues

Added by Sean B. Durkin about 9 years ago

I am using Saxon-HEC 0.3.1

I've been able to successfully do some things with Saxon-HEC, such as create an XsltProcessor processor instance, compile a stylesheet, and query the version string. But I can't create an XdmValue, nor run an XSLT transform ....


(1) If I attempt to locate the constructor in order to construct an XdmValue instance, Saxon-HEC hits an access violation, when I attempt to locate the constructor. The JNI API details for this call are ...

Class = 'net/sf/saxon/option/cpp/XdmValueForCpp' Method = '' Signature = '(Ljava/lang/String;Ljava/lang/String;)V' Invocation = CallObjectMethodV

It is as if the constructor has not been implemented. I have also tried other constructor signatures, with the same result:

(Ljava/lang/String;Ljava/lang/String;)V ()V (Z)V (I)V

Is this something that hasn't been implemented yet? Or have I misunderstood the API for constructing an XdmValue instance?


(2)

I've not been able to successfully invoke a transform. When I attempt to do so, an access violation is hit.

Class = 'net/sf/saxon/option/cpp/XsltProcessorForCpp' Method = 'xsltApplyStylesheet' Signature = '(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;' Invocation = CallObjectMethodV

Why is this AV'ing? I am confident that my parameter construction is correct (or at least identical to XsltProcessor.cpp).

Faithfully, Sean B. Durkin


Replies (4)

Please register to reply

RE: Saxon/C API issues - Added by O'Neil Delpratt about 9 years ago

Hi Sean,

How are you constructing the XdmValue? In C++ you can create an XdmValue via the SaxonProcessor using the parseString or parseFile methods.

Alternatively in the XdmValue class you can use the constructor or one of the makeXdmValue methods which covers most types. i.e.:

SaxonProcessor * processor = new SaxonProcessor();
processor->setcwd("/var/www/trax");

//Option 1 - create XdmValue via XdmValue constructor
XsltProcessor * xslt = processor->newTransformer();
test->setSourceFile("xml/foo.xml");
XdmValue * xdmvaluex = new XdmValue("string", "Hello to you");
xslt->setParameter("a-param", xdmvaluex);
const char * resultxx = xslt->xsltApplyStylesheet(NULL, "xsl/foo.xsl");


//Option 2 - create XdmValue via SaxonProcessor
XdmValue * node = processor->parseString("test");
xslt->setSourceValue(node);
xslt->setProperty("s","xml/foo.xml");
xslt->xsltSaveResultToFile(NULL,"xsl/foo.xsl","testOutput.xml");

It might be best for you to send your code either on this post or privately then I can try and spot what you might be doing wrong.

I hope this helps.

RE: Saxon/C API issues - Added by Sean B. Durkin about 9 years ago

Thanks O'Nell. I was simplifying my code for the purpose of posting it here to demonstrate the problem, and the process of simplifying my code uncovered my code defects. It is kind of like being stuck on a problem, and in the process of explaining your problem to someone else, the answer dawns on you.

Question

In the constructor for XdmValue (reference (1)) in the original post), there are two parameters: type and valueStr. In XdmValue.cpp, only one value for type is demonstrated: 'string'. What other types are valid?

Faithfully, Sean

RE: Saxon/C API issues - Added by Sean B. Durkin about 9 years ago

Also about properties The command-line version of Saxon has a large number of property-like command-line parameters. I have listed them below. Which of these are available as properties to pass to the xsltApplyStylesheet() method?

For example XsltProcessor.cpp, the 's' property, as passed to xsltApplyStylesheet(), is the same as the '-s:source' command-line property. But XsltProcessor.cpp doesn't give examples of any other possible properties.

+Command-line properties+

  • a
  • catalog
  • config
  • cr
  • dtd
  • expand
  • explain
  • ext
  • im
  • init
  • it
  • l
  • m
  • now
  • o
  • opt
  • or
  • outval
  • p
  • quit
  • r
  • repeat
  • sa
  • strip
  • t
  • T
  • threads
  • TJ
  • TP
  • traceout
  • tree
  • u
  • val
  • versionmsg
  • warnings
  • x
  • xi
  • xmlversion
  • xsd
  • xsiloc
  • xsl
  • xsltversion
  • y

RE: Saxon/C API issues - Added by Michael Kay about 9 years ago

Many of these command-line options map to Configuration/Processor feature settings, which are documented here:

http://www.saxonica.com/documentation/index.html#!configuration/config-features

and most of them (with the exception of those that are obviously Java-specific) are available in Saxon/C using SaxonProcessor.setProperty().

(The command line option, where applicable, is given below the feature name.)

For some of these options, to be honest, we would have to do some research to determine whether it has any effect on Saxon/C or not: it's this kind of exercise that makes getting to a production release such a long-drawn-out process.

    (1-4/4)

    Please register to reply