DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=30229>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=30229

"StylesheetExecutionContext::getVariable(name)" crahes if variable "name" was not 
found.

[EMAIL PROTECTED] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From [EMAIL PROTECTED]  2004-07-22 19:01 -------
OK, I've figured out what's going on here.  There are some problems in your 
code, and then there are some documentation problems.

The first problem in your code is to change the first parameter of 
printVariable() to a const reference to a XalanQName:

    printVariable(const XalanQName &aXalanQName

Otherwise, your code is not legal C++, and would not compile for me.

The next problem is in the main() function, where you terminate the Xalan-C 
and Xerces-C libraries while Xalan-C objects are still in-scope.  The best way 
to do this is to introduce a new scope for the stack-based objects:

int main(int argc, char *argv[])
                 {
                 XMLPlatformUtils::Initialize();
                 XalanTransformer::initialize();

                 if(argc < 2)
                                 {
                                 cerr << "You must type the variable name !" 
<< endl;
                                 return 1;
                                 }

         {
                     XalanTransformer aXalanTransformer;
                     GetVariableTraceListener aGetVariableTraceListener(argv
[1]);

                     aXalanTransformer.addTraceListener
(&aGetVariableTraceListener);
                     aXalanTransformer.transform
("v:\\test\\philipips\\GetVariable.xml", "v:\\test\\philipips\\GetVariable.xsl"
, "v:\\test\\philipips\\GetVariable.out");
         }

        cerr << "end of program" << endl;

                 XalanTransformer::terminate();
                 XMLPlatformUtils::Terminate();
                 XalanTransformer::ICUCleanUp();

                 return(0);
                 }

The Xalan-C bug is one of documentation.  
StylesheetExecutionContext::getVariable() actually throws an exception when 
the variable is not found.  So, you will need to use a try/catch block if you 
want to catch situations where the variable is not defined but you want to 
continue execution.  We can consider changing this behavior with the 
enhancement request you created.  Otherwise, we can create a new API which 
will return a null XObjectPtr instance and is const.

I've updated the documentation for getVariable() to reflect the real behavior.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to