const XObjectPtr ElemVariable::getValue( StylesheetExecutionContext& executionContext, XalanNode* sourceNode) const { if(m_selectPattern == 0) { if (getFirstChildElem() == 0) { return executionContext.getXObjectFactory().createStringReference(s_emptyString); } else { return executionContext.createXResultTreeFrag(*this, sourceNode); } } else { XObjectPtr theValue; XalanNode* const theCurrentNode = executionContext.getCurrentNode(); if (theCurrentNode == sourceNode) { theValue = m_selectPattern->execute(*this, executionContext); } else { const XPathExecutionContext::CurrentNodePushAndPop theCurrentNodePushAndPop(executionContext, sourceNode); theValue = m_selectPattern->execute(*this, executionContext); } if(0 != executionContext.getTraceListeners()) { executionContext.fireSelectEvent( SelectionEvent( executionContext, sourceNode, *this, StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("select")), *m_selectPattern, theValue)); } return theValue; } }
XalanDocument* XercesParserLiaison::parseXMLStream( const InputSourceType& reader, const XalanDOMString& /* identifier */) { XalanAutoPtr<DOMParserType> theParser(CreateDOMParser()); if (m_errorHandler == 0) { theParser->setErrorHandler(this); } else { theParser->setErrorHandler(m_errorHandler); } theParser->parse(reader); #if XERCES_VERSION_MAJOR >= 2 DOMDocument_Type* const theXercesDocument = theParser->getDocument(); theXercesDocument->normalize(); #else DOM_Document_Type theXercesDocument = theParser->getDocument(); theXercesDocument.normalize(); #endif #if XERCES_VERSION_MAJOR >= 2 XercesDocumentWrapper* theNewDocument = 0; if (theXercesDocument != 0) { theNewDocument = doCreateDocument(theXercesDocument, m_threadSafe, m_buildWrapper, m_buildMaps, true); theParser->adoptDocument(); #else XercesDocumentBridge* theNewDocument = 0; if (theXercesDocument.isNull() == false) { theNewDocument = doCreateDocument(theXercesDocument, m_threadSafe, m_buildBridge, true); #endif } return theNewDocument; } void XercesParserLiaison::destroyDocument(XalanDocument* theDocument) { const DocumentMapType::iterator i = m_documentMap.find(theDocument); if (i != m_documentMap.end()) { const XalanAutoPtr<XalanDocument> theGuard(theDocument); m_documentMap.erase(i); } } int XercesParserLiaison::getIndent() const { return m_indent; } void XercesParserLiaison::setIndent(int i) { m_indent = i; } bool XercesParserLiaison::getUseValidation() const { return m_useValidation; } void XercesParserLiaison::setUseValidation(bool b) { m_useValidation = b; } const XalanDOMString XercesParserLiaison::getParserDescription() const { return StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("Xerces")); } DOMDocument_Type* XercesParserLiaison::createDOMFactory() { DOMDocument_Type* const theXercesDocument = DOMImplementationType::getImplementation()->createDocument(); createDocument(theXercesDocument, false, false); return theXercesDocument; } void XercesParserLiaison::destroyDocument(DOMDocument_Type* theDocument) { // Delete any live documents... for(DocumentMapType::iterator i = m_documentMap.begin(); i != m_documentMap.end(); ++i) { if ((*i).second.isDeprecated() == false && (*i).second.m_wrapper->getXercesDocument() == theDocument) { destroyDocument((XalanDocument*)(*i).first); } } } bool XercesParserLiaison::getIncludeIgnorableWhitespace() const { return m_includeIgnorableWhitespace; } void XercesParserLiaison::setIncludeIgnorableWhitespace(bool include) { m_includeIgnorableWhitespace = include; } ErrorHandlerType* XercesParserLiaison::getErrorHandler() const { return m_errorHandler; } void XercesParserLiaison::setErrorHandler(ErrorHandlerType* handler) { m_errorHandler = handler; } bool XercesParserLiaison::getDoNamespaces() const { return m_doNamespaces; } void XercesParserLiaison::setDoNamespaces(bool newState) { m_doNamespaces = newState; } bool XercesParserLiaison::getExitOnFirstFatalError() const { return m_exitOnFirstFatalError; } void XercesParserLiaison::setExitOnFirstFatalError(bool newState) { m_exitOnFirstFatalError = newState; } EntityResolverType* XercesParserLiaison::getEntityResolver() const { return m_entityResolver; } void XercesParserLiaison::setEntityResolver(EntityResolverType* resolver) { m_entityResolver = resolver; } const XalanDOMChar* XercesParserLiaison::getExternalSchemaLocation() const { return m_externalSchemaLocation.length() == 0 ? 0 : m_externalSchemaLocation.c_str(); } void XercesParserLiaison::setExternalSchemaLocation(const XalanDOMChar* location) { if (location == 0) { m_externalSchemaLocation.clear(); } else { m_externalSchemaLocation = location; } } const XalanDOMChar* XercesParserLiaison::getExternalNoNamespaceSchemaLocation() const { return m_externalNoNamespaceSchemaLocation.length() == 0 ? 0 : m_externalNoNamespaceSchemaLocation.c_str(); } void XercesParserLiaison::setExternalNoNamespaceSchemaLocation(const XalanDOMChar* location) { if (location == 0) { m_externalNoNamespaceSchemaLocation.clear(); } else { m_externalNoNamespaceSchemaLocation= location; } } #if defined(XALAN_BUILD_DEPRECATED_DOM_BRIDGE) XalanDocument* XercesParserLiaison::createDocument( const DOM_Document_Type& theXercesDocument, bool threadSafe, bool buildBridge) { return doCreateDocument(theXercesDocument, threadSafe, buildBridge); } #endif XalanDocument* XercesParserLiaison::createDocument( const DOMDocument_Type* theXercesDocument, bool threadSafe, bool buildWrapper, bool buildMaps) { // As we did not create the underlying DOMDocument - ensure we don't // delete it later. return doCreateDocument(theXercesDocument, threadSafe, buildWrapper, buildMaps, false); } #if defined(XALAN_BUILD_DEPRECATED_DOM_BRIDGE) XercesDocumentBridge* XercesParserLiaison::mapDocument(const XalanDocument* theDocument) const { const DocumentMapType::const_iterator i = m_documentMap.find(theDocument); return i != m_documentMap.end() ? (*i).second.m_isDeprecated == true ? (*i).second.m_bridge : 0 : 0; } #endif XercesDocumentWrapper* XercesParserLiaison::mapDocumentToWrapper(const XalanDocument* theDocument) const { const DocumentMapType::const_iterator i = m_documentMap.find(theDocument); return i != m_documentMap.end() ? (*i).second.isDeprecated() == false ? (*i).second.m_wrapper : 0 : 0; } #if defined(XALAN_BUILD_DEPRECATED_DOM_BRIDGE) DOM_Document_Type XercesParserLiaison::mapXercesDocument(const XalanDocument* theDocument) const { const DocumentMapType::const_iterator i = m_documentMap.find(theDocument); return i != m_documentMap.end() ? (*i).second.isDeprecated() == true ? (*i).second.m_bridge->getXercesDocument() : DOM_Document_Type() : DOM_Document_Type(); } #endif const DOMDocument_Type* XercesParserLiaison::mapToXercesDocument(const XalanDocument* theDocument) const { const DocumentMapType::const_iterator i = m_documentMap.find(theDocument); return i != m_documentMap.end() ? (*i).second.isDeprecated() == false ? (*i).second.m_wrapper->getXercesDocument() : 0 : 0; } void XercesParserLiaison::fatalError(const SAXParseExceptionType& e) { XalanDOMString theMessage = XalanMessageLoader::getMessage(XalanMessages::FatalError); formatErrorMessage(e, theMessage); if (m_executionContext != 0) { // We call warning() because we don't want the execution // context to potentially throw an exception. m_executionContext->warn(theMessage); } else { XALAN_USING_STD(cerr) XALAN_USING_STD(endl) cerr << endl << theMessage << endl; } throw e; }
XalanDOMString XNumberBase::getTypeString() const { return StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("#NUMBER")); }
void ElemForEach::selectAndSortChildren( StylesheetExecutionContext& executionContext, const ElemTemplateElement* theTemplate, NodeSorter* sorter, int selectStackFrameIndex) const { typedef StylesheetExecutionContext::SetAndRestoreCurrentStackFrameIndex SetAndRestoreCurrentStackFrameIndex; assert(m_selectPattern != 0); typedef XPathExecutionContext::BorrowReturnMutableNodeRefList BorrowReturnMutableNodeRefList; BorrowReturnMutableNodeRefList theGuard(executionContext); const NodeRefListBase* sourceNodes = 0; XObjectPtr xobjectResult; { SetAndRestoreCurrentStackFrameIndex theSetAndRestore( executionContext, selectStackFrameIndex); xobjectResult = m_selectPattern->execute( *this, executionContext, *theGuard); if (xobjectResult.null() == true) { sourceNodes = &*theGuard; } else { theGuard.release(); sourceNodes = &xobjectResult->nodeset(); } } if(0 != executionContext.getTraceListeners()) { executionContext.fireSelectEvent( SelectionEvent( executionContext, executionContext.getCurrentNode(), *this, StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("select")), *m_selectPattern, *sourceNodes)); } const NodeRefListBase::size_type nNodes = sourceNodes->getLength(); if (nNodes > 0) { // If there's not NodeSorter, or we've only selected one node, // then just do the transform... if (sorter == 0 || nNodes == 1) { transformSelectedChildren( executionContext, theTemplate, *sourceNodes, nNodes); } else { typedef StylesheetExecutionContext::SetAndRestoreCurrentStackFrameIndex SetAndRestoreCurrentStackFrameIndex; typedef StylesheetExecutionContext::ContextNodeListPushAndPop ContextNodeListPushAndPop; typedef StylesheetExecutionContext::BorrowReturnMutableNodeRefList BorrowReturnMutableNodeRefList; BorrowReturnMutableNodeRefList sortedSourceNodes(executionContext); *sortedSourceNodes = *sourceNodes; { SetAndRestoreCurrentStackFrameIndex theStackFrameSetAndRestore( executionContext, selectStackFrameIndex); ContextNodeListPushAndPop theContextNodeListPushAndPop( executionContext, *sourceNodes); sorter->sort(executionContext, *sortedSourceNodes); } transformSelectedChildren( executionContext, theTemplate, *sortedSourceNodes, nNodes); } } }
const XalanDOMString FunctionSample::getError() const { return StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("The boolean() function takes one argument!")); }