DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23778>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23778 Assertion failed in FormatterTreeWalker while traversing a xalan:nodeset() Summary: Assertion failed in FormatterTreeWalker while traversing a xalan:nodeset() Product: XalanC Version: 1.6 Platform: Other OS/Version: Other Status: NEW Severity: Normal Priority: Other Component: XalanC AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] Assertion failed: node != 0, file $XALANCROOT\src\xalanc\XMLSuppo rt\FormatterTreeWalker.cpp, line 192: bool FormatterTreeWalker::endNode(const XalanNode* node) { assert(node != 0); ... } Sample Code samples/ExternalFunction/ExternalFunction.cpp, only class FunctionAsctime must be overwritten with this code snippet: #include <xalanc/XMLSupport/FormatterToXML.hpp> #include <xalanc/XMLSupport/FormatterTreeWalker.hpp> #include <xalanc/PlatformSupport/XalanOutputStreamPrintWriter.hpp> #include <xalanc/PlatformSupport/XalanStdOutputStream.hpp> // This class defines a function that runs the C function // asctime() using the current system time. class FunctionAsctime : public Function { public: /** * Execute an XPath function object. The function must return a valid * object. Extension functions should override this version of execute (), * rather than one of the other calls designed for a specific number of * arguments. * * @param executionContext executing context * @param context current context node * @param args vector of pointers to XObject arguments * @param locator Locator for the XPath expression that contains the function call * @return pointer to the result XObject */ virtual XObjectPtr execute( XPathExecutionContext& executionContext, XalanNode* context, const XObjectArgVectorType& args, const LocatorType* locator) const { XALAN_USING_XALAN(FormatterToXML) XALAN_USING_XALAN(FormatterTreeWalker) XALAN_USING_XALAN(XalanStdOutputStream) XALAN_USING_XALAN(XalanOutputStreamPrintWriter) XALAN_USING_XALAN(XObject) XalanStdOutputStream theStream(std::cerr); XalanOutputStreamPrintWriter thePrintWriter(theStream); FormatterToXML theFormatter (thePrintWriter); FormatterTreeWalker theWalker(theFormatter); assert( args.size() == 1 ); assert( args[0].null() == false ); assert( args[0]->getType() == XObject::eObjectType::eTypeNodeSet ); assert( args[0]->nodeset().item(0) != NULL ); theFormatter.setShouldWriteXMLHeader(true); theFormatter.startDocument(); theWalker.traverseSubtree(args[0]->nodeset().item(0)); theFormatter.endDocument(); return executionContext.getXObjectFactory().createString(XalanDOMString ("asctime()")); } #if !defined(XALAN_NO_USING_DECLARATION) using Function::execute; #endif /** * Create a copy of the function object. * * @return pointer to the new object */ #if defined(XALAN_NO_COVARIANT_RETURN_TYPE) virtual Function* #else virtual FunctionAsctime* #endif clone() const { return new FunctionAsctime(*this); } protected: /** * Get the error message to report when * the function is called with the wrong * number of arguments. * * @return function error message */ const XalanDOMString getError() const { return StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("The asctime() function accepts one argument!")); } private: // Not implemented... FunctionAsctime& operator=(const FunctionAsctime&); bool operator==(const FunctionAsctime&) const; }; Sample Stylesheet (samples/ExternalFunction/foo.xsl, added an asctime param): <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:xalan="http://xml.apache.org/xalan" xmlns:external="http://ExternalFunction.xalan- c++.xml.apache.org" exclude-result-prefixes="external"> <xsl:template match="area"> <xsl:choose> <xsl:when test="function-available('external:square-root') and function-available('external:cube')"> <given> The area of each face of the cube is <xsl:value-of select="@value"/> <xsl:text> square units </xsl:text> <xsl:value-of select="@units"/>. </given> <result> Accordingly, the length of each side is <xsl:value-of select="external:square-root(@value)"/> <xsl:text> </xsl:text><xsl:value-of select="@units"/> and the volume of the cube is <xsl:value-of select="external:cube(external:square-root(@value))"/> <xsl:text> cubic </xsl:text> <xsl:value-of select="@units"/>. </result> </xsl:when> <xsl:otherwise> <result> The functions external:square-root() and external cube() are not available! </result> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="now"> <xsl:choose> <xsl:when test="function-available('external:asctime')"> <when> <xsl:variable name="samplenode"><root><traverse>me</traverse></root></xsl:variable> Date and time when we figured all this out: <xsl:value-of select="external:asctime(xalan:nodeset($samplenode))"/>. </when> </xsl:when> <xsl:otherwise> <result> The function external:asctime() is not available! </result> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet>
