void TestStringResults( XPathFactory& theXPathFactory, XPathProcessor& theXPathProcessor, XPathEnvSupport& theXPathEnvSupport, DOMSupport& theDOMSupport, PrintWriter& thePrintWriter, XPathExecutionContext& theExecutionContext) { assert(sizeof(theStringTestInput) == sizeof(theStringTestExpectedOutput)); MemoryManagerType& theMemoryManager = theExecutionContext.getMemoryManager(); for(int i = 0; theStringTestInput[i] != 0; i++) { try { XPath* const theXPath = theXPathFactory.create(); XPathConstructionContextDefault theXPathConstructionContext(theMemoryManager); const XPathGuard theGuard( theXPathFactory, theXPath); XalanDOMString theInputString(theMemoryManager); XalanDOMString theResult(theMemoryManager); const ElementPrefixResolverProxy thePrefixResolver( 0, theXPathEnvSupport, theDOMSupport); const NodeRefList theDummyNodeList(theMemoryManager); TestStringResult( theXPathProcessor, *theXPath, theXPathConstructionContext, TranscodeFromLocalCodePage(theStringTestInput[i], theInputString), thePrintWriter, TranscodeFromLocalCodePage(theStringTestExpectedOutput[i], theResult), 0, thePrefixResolver, theDummyNodeList, theExecutionContext); } catch(...) { thePrintWriter.print("Exception caught evaluating XPath \""); thePrintWriter.print(theStringTestInput[i]); thePrintWriter.println(); } } }
void Blockquote::printTex( PrintWriter& p ) const { switch ( this->type ) { case START: p.printf( "\\begin{quote}\n" ); break; case END: p.printf( "\\end{quote}\n" ); } }
void Blockquote::print( PrintWriter& p ) const { switch ( this->type ) { case START: p.printf( "<blockquote>\n" ); break; case END: p.printf( "</blockquote>\n" ); } }
bool TestNumericResult( XPathProcessor& theXPathProcessor, XPath& theXPath, XPathConstructionContext& theXPathConstructionContext, const XalanDOMString& theXPathString, PrintWriter& thePrintWriter, double 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); thePrintWriter.print("Execution of XPath "); thePrintWriter.print(theXPathString); if (theResult->num() == theExpectedResult) { thePrintWriter.println(" succeeded."); thePrintWriter.print("The result was "); thePrintWriter.println(theResult->num()); } else { fError = true; thePrintWriter.println(" failed!"); thePrintWriter.print("The expected result was "); thePrintWriter.println(theExpectedResult); thePrintWriter.print("The actual result was "); thePrintWriter.println(theResult->num()); } return fError; }
void Paragraph::printTex( PrintWriter& p ) const { p.printf( "\n" ); IPIterator<Line>* it = this->lines->positions(); while ( it->hasNext() ) { IPosition<Line>* pos = it->next(); { pos->getElement().printTex( p ); } delete pos; } delete it; p.printf( "\n" ); }
void ProblemListenerDefault::problem( PrintWriter& pw, eProblemSource where, eClassification classification, const XalanNode* sourceNode, const ElemTemplateElement* styleNode, const XalanDOMString& msg, const XalanDOMChar* uri, int lineNo, int charOffset) { if (eXMLPARSER == where) { pw.print(xmlHeader); } else if (eXPATH == where) { pw.print(xpathHeader); } else { pw.print(xslHeader); } if (eERROR == classification) { pw.print(XalanMessageLoader::getMessage(XalanMessages::Error_1Param, msg)); } else if (eWARNING == classification) { pw.print(XalanMessageLoader::getMessage(XalanMessages::Warning_1Param, msg)); } else { pw.print(XalanMessageLoader::getMessage(XalanMessages::Message_1Param, msg)); } if (0 != styleNode) { pw.print(XalanMessageLoader::getMessage(XalanMessages::StyleTreeNode_1Param, styleNode->getElementName())); } if (0 != sourceNode) { pw.print(XalanMessageLoader::getMessage(XalanMessages::SourceTreeNode_1Param, sourceNode->getNodeName())); } pw.print(locationOpen); if (0 != uri) { pw.print(uriHeader); pw.print(uri); } const XalanDOMString lineNoString = LongToDOMString(lineNo); const XalanDOMString charOffsetString = LongToDOMString(charOffset); pw.print(XalanMessageLoader::getMessage(XalanMessages::LineNumberColumnNumber_2Params, lineNoString , charOffsetString)); pw.print(locationClose); pw.println(); }
bool TestPredicateResult( XPathProcessor& theXPathProcessor, XPathEnvSupport& theXPathEnvSupport, DOMSupport& theDOMSupport, XMLParserLiaison& theLiaison, XPathFactory& theXPathFactory, const XalanDOMString& theXMLFileURL, const XalanDOMString& theXSLFileURL, PrintWriter& thePrintWriter, XPathExecutionContext& theExecutionContext) { bool fError = false; XalanDocument* const theXMLDocument = ParseXML(theLiaison, theXMLFileURL); MemoryManagerType& theMemoryManager = theExecutionContext.getMemoryManager(); if (theXMLDocument != 0) { XalanDOMString theContextNodeMatchPattern(theMemoryManager); XalanDOMString theXPathString(theMemoryManager); if (GetXSLInput(theLiaison, theXSLFileURL, theContextNodeMatchPattern, theXPathString, theMemoryManager) == true) { XalanNode* const theContextNode = FindContextNode(theXPathProcessor, theXPathEnvSupport, theDOMSupport, theXPathFactory, theXMLDocument, theContextNodeMatchPattern, thePrintWriter, theExecutionContext); if (theContextNode != 0) { XalanElement* const theNamespaceContext = 0; ElementPrefixResolverProxy thePrefixResolver(theNamespaceContext, theXPathEnvSupport, theDOMSupport); NodeRefList theContextNodeList(theMemoryManager); XPath* const theXPath1 = theXPathFactory.create(); XPathConstructionContextDefault theXPathConstructionContext(theMemoryManager); XPathGuard theGuard1(theXPathFactory, theXPath1); XalanDOMString theResult(theMemoryManager); theXPathProcessor.initXPath(*theXPath1, theXPathConstructionContext, TranscodeFromLocalCodePage("following-sibling::*", theResult), thePrefixResolver); XPath* const theXPath2 = theXPathFactory.create(); XPathGuard theGuard2(theXPathFactory, theXPath2); theXPathProcessor.initXPath(*theXPath2, theXPathConstructionContext, TranscodeFromLocalCodePage("descendant::*", theResult), thePrefixResolver); bool fDump = false; if (fDump == true) { thePrintWriter.println(); thePrintWriter.println(); theXPath1->getExpression().dumpOpCodeMap(thePrintWriter); thePrintWriter.println(); theXPath1->getExpression().dumpTokenQueue(thePrintWriter); thePrintWriter.println(); thePrintWriter.println(); theXPath2->getExpression().dumpOpCodeMap(thePrintWriter); thePrintWriter.println(); theXPath2->getExpression().dumpTokenQueue(thePrintWriter); thePrintWriter.println(); thePrintWriter.println(); } XalanNode* theContextNode = theXMLDocument->getFirstChild()->getFirstChild(); for( ; theContextNode != 0; theContextNode = theContextNode->getNextSibling()) { if (theContextNode->getNodeType() != XalanNode::ELEMENT_NODE) { continue; } const XObjectPtr theResult1 = theXPath1->execute(theExecutionContext); try { assert(theResult1.null() == false); const NodeRefListBase& theResultList = theResult1->nodeset(); const unsigned int theLength = theResultList.getLength(); thePrintWriter.print("theResult1->str() == \""); thePrintWriter.print(theResult1->str()); thePrintWriter.print("\""); thePrintWriter.println(); if (theLength > 0) { for (unsigned int i = 0; i < theLength; i++) { thePrintWriter.print(theResultList.item(i)->getNodeName()); thePrintWriter.println(); } } } catch(...) { thePrintWriter.print("Execution of XPath "); thePrintWriter.print(theXPathString); thePrintWriter.println(" failed!"); } const XObjectPtr theResult2 = theXPath2->execute(theExecutionContext); try { assert(theResult2.null() == false); const NodeRefListBase& theResultList = theResult2->nodeset(); const int theLength = theResultList.getLength(); thePrintWriter.print("theResult2->str() == \""); thePrintWriter.print(theResult2->str()); thePrintWriter.print("\""); thePrintWriter.println(); if (theLength > 0) { for (int i = 0; i < theLength; i++) { thePrintWriter.print(theResultList.item(i)->getNodeName()); thePrintWriter.println(); } } } catch(...) { thePrintWriter.print("Execution of XPath "); thePrintWriter.print(theXPathString); thePrintWriter.println(" failed!"); } if (theResult1->equals(*theResult2, theExecutionContext) == true) { thePrintWriter.print("theResult1 is equal to theResult2"); thePrintWriter.println(); thePrintWriter.print("theContextNode->getNodeName() == \""); thePrintWriter.print(theContextNode->getNodeName()); thePrintWriter.print("\" theContextNode->getNodeValue() == \""); thePrintWriter.print(theContextNode->getNodeValue()); thePrintWriter.println("\""); } } } } } return fError; }
bool TestAxisResult( XPathProcessor& theXPathProcessor, XPathEnvSupport& theXPathEnvSupport, DOMSupport& theDOMSupport, XMLParserLiaison& theLiaison, XPathFactory& theXPathFactory, const XalanDOMString& theXMLFileURL, const XalanDOMString& theXSLFileURL, PrintWriter& thePrintWriter, XPathExecutionContext& theExecutionContext) { bool fError = false; XalanDocument* const theXMLDocument = ParseXML(theLiaison, theXMLFileURL); MemoryManagerType& theMemoryManager = theExecutionContext.getMemoryManager(); if (theXMLDocument != 0) { XalanDOMString theContextNodeMatchPattern(theMemoryManager); XalanDOMString theXPathString(theMemoryManager); if (GetXSLInput(theLiaison, theXSLFileURL, theContextNodeMatchPattern, theXPathString, theMemoryManager) == true) { XalanNode* const theContextNode = FindContextNode(theXPathProcessor, theXPathEnvSupport, theDOMSupport, theXPathFactory, theXMLDocument, theContextNodeMatchPattern, thePrintWriter, theExecutionContext); if (theContextNode != 0) { XalanElement* const theNamespaceContext = 0; ElementPrefixResolverProxy thePrefixResolver(theNamespaceContext, theXPathEnvSupport, theDOMSupport); NodeRefList theContextNodeList(theMemoryManager); XPath* const theXPath = theXPathFactory.create(); XPathConstructionContextDefault theXPathConstructionContext(theMemoryManager); XPathGuard theGuard(theXPathFactory, theXPath); theXPathProcessor.initXPath(*theXPath, theXPathConstructionContext, theXPathString, thePrefixResolver); bool fDump = false; if (fDump == true) { thePrintWriter.println(); thePrintWriter.println(); theXPath->getExpression().dumpOpCodeMap(thePrintWriter); thePrintWriter.println(); theXPath->getExpression().dumpTokenQueue(thePrintWriter); thePrintWriter.println(); thePrintWriter.println(); } const XObjectPtr theResult = theXPath->execute(theContextNode, thePrefixResolver, theContextNodeList, theExecutionContext); try { assert(theResult.null() == false); const NodeRefListBase& theResultList = theResult->nodeset(); const unsigned int theLength = theResultList.getLength(); if (theLength == 0) { thePrintWriter.println("<out/>"); } else { thePrintWriter.print("<out>"); for (unsigned int i = 0; i < theLength; i++) { thePrintWriter.print(theResultList.item(i)->getNodeName()); thePrintWriter.print(" "); } thePrintWriter.println("</out>"); } } catch(...) { thePrintWriter.print("Execution of XPath "); thePrintWriter.print(theXPathString); thePrintWriter.println(" failed!"); } } } } theLiaison.reset(); return fError; }
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(); } } } }