You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by Ryan Sawatzky <rs...@openfox.com> on 2003/03/28 19:25:29 UTC

External Functions

Hey everyone,

I am installing my own external function and I had a question on how the 
error reporting works.  I looked at the ExternalFunction sample app that 
came with Xalan, and I noticed that when the execute() function fails, 
it seems to return a dummy XObjectPtr.  Also the getError() function 
always returns a string talking about how many arguments to pass in.

I want to perform some type checking in my function, so that if the 
function doesn't get the type of arguments it wants, I can print out a 
specific error.  My question is how do I return a value from the 
execute() function that tells the XalanTransformer that execute() failed 
and to then call my getError() function?  I didn't see anything in the 
API about this.  Thanks for any help.

--Ryan


Re: External Functions

Posted by David N Bertoni/Cambridge/IBM <da...@us.ibm.com>.



Hi Ryan,

Function::getError() function is only called from the base class when the
number of arguments passed is not supported, because your extension
function didn't override the version of execute() with that number of
arguments.

If you want to do type checking and report errors, just call one of the
error() overloads of XPathExecutionContext.  There are lots of example of
how that's done in the code.

Dave



                                                                                                                         
                      Ryan Sawatzky                                                                                      
                      <rsawatzky@openf         To:      xalan-c-users@xml.apache.org                                     
                      ox.com>                  cc:      (bcc: David N Bertoni/Cambridge/IBM)                             
                                               Subject: External Functions                                               
                      03/28/2003 10:25                                                                                   
                      AM                                                                                                 
                                                                                                                         



Hey everyone,

I am installing my own external function and I had a question on how the
error reporting works.  I looked at the ExternalFunction sample app that
came with Xalan, and I noticed that when the execute() function fails,
it seems to return a dummy XObjectPtr.  Also the getError() function
always returns a string talking about how many arguments to pass in.

I want to perform some type checking in my function, so that if the
function doesn't get the type of arguments it wants, I can print out a
specific error.  My question is how do I return a value from the
execute() function that tells the XalanTransformer that execute() failed
and to then call my getError() function?  I didn't see anything in the
API about this.  Thanks for any help.

--Ryan