bool TestBooleanResult( XPathProcessor& theXPathProcessor, XPath& theXPath, XPathConstructionContext& theXPathConstructionContext, const XalanDOMString& theXPathString, PrintWriter& thePrintWriter, bool theExpectedResult, XalanNode* theContextNode, const PrefixResolver& thePrefixResolver, const NodeRefListBase& theContextNodeList, XPathExecutionContext& theExecutionContext) { bool fError = false; const XObjectPtr theResult = ExecuteXPath( theXPathProcessor, theXPathConstructionContext, theXPath, theXPathString, theContextNode, thePrefixResolver, theContextNodeList, theExecutionContext); bool fDump = false; if (fDump == true) { thePrintWriter.println(); thePrintWriter.println(); theXPath.getExpression().dumpOpCodeMap(thePrintWriter); thePrintWriter.println(); theXPath.getExpression().dumpTokenQueue(thePrintWriter); thePrintWriter.println(); thePrintWriter.println(); } thePrintWriter.print("Execution of XPath "); thePrintWriter.print(theXPathString); if (theResult->boolean() == theExpectedResult) { thePrintWriter.println(" succeeded."); thePrintWriter.print("The result was "); thePrintWriter.print(theResult->boolean()); thePrintWriter.println("."); } else { fError = true; thePrintWriter.println(" failed!"); thePrintWriter.print("The expected result was \""); thePrintWriter.print(theExpectedResult); thePrintWriter.println("\"."); thePrintWriter.print("The actual result was \""); thePrintWriter.print(theResult->boolean()); thePrintWriter.println("\"."); } return fError; }
void TestAxes( XPathFactory& theXPathFactory, XPathProcessor& theXPathProcessor, XPathEnvSupport& theXPathEnvSupport, DOMSupport& theDOMSupport, XMLParserLiaison& theLiaison, const XalanDOMString& theDirectory, PrintWriter& thePrintWriter, XPathExecutionContext& theExecutionContext) { MemoryManagerType& theMemoryManager = XalanMemMgrs::getDefaultXercesMemMgr(); const XalanDOMString theProtocol("file://", theMemoryManager); XalanDOMString theBaseURL (theProtocol , theMemoryManager); theBaseURL += theDirectory; XalanDOMString thetmp(theDirectory, theMemoryManager); #if defined(WIN32) thetmp.append("\\*"); #else thetmp.append("/*"); #endif const XalanDOMString theSearchSpecification(thetmp, theMemoryManager); const XalanDOMString theXMLSuffix(".xml", theMemoryManager); typedef XalanVector<XalanDOMString> FileNameVectorType; DirectoryEnumeratorFunctor<FileNameVectorType, XalanDOMString> theEnumerator(theMemoryManager); FileNameVectorType theFiles(theMemoryManager); theEnumerator(theSearchSpecification, theFiles); thePrintWriter.println(); for(FileNameVectorType::size_type i = 0; i < theFiles.size(); i++) { if (endsWith(theFiles[i], theXMLSuffix) == true) { try { // Create a fully qualified URL specification... XalanDOMString theXMLFileName (theBaseURL, theMemoryManager); theXMLFileName += theFiles[i]; // Get the name of the corresponding XSL file... XalanDOMString theXSLFileName (theMemoryManager); GetXSLFileName(theXMLFileName, theXSLFileName); XPathGuard theXPath(theXPathFactory, theXPathFactory.create()); TestAxisResult(theXPathProcessor, theXPathEnvSupport, theDOMSupport, theLiaison, theXPathFactory, theXMLFileName, theXSLFileName, thePrintWriter, theExecutionContext); } catch(...) { thePrintWriter.print("Exception caught evaluating XPath!"); thePrintWriter.println(); } } } }