dbertoni    2003/01/02 09:39:19

  Modified:    c/src/XSLT AVTPartXPath.cpp AVTPartXPath.hpp ElemChoose.cpp
                        ElemForEach.cpp ElemIf.cpp ElemNumber.cpp
                        ElemValueOf.cpp KeyTable.hpp NodeSorter.cpp
                        SelectionEvent.cpp SelectionEvent.hpp
                        TraceListenerDefault.cpp TraceListenerDefault.hpp
  Log:
  Changes for new type-specific XPath execution and "inlining" of function 
calls.
  
  Revision  Changes    Path
  1.10      +1 -17     xml-xalan/c/src/XSLT/AVTPartXPath.cpp
  
  Index: AVTPartXPath.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/AVTPartXPath.cpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- AVTPartXPath.cpp  25 Nov 2002 18:11:51 -0000      1.9
  +++ AVTPartXPath.cpp  2 Jan 2003 17:39:18 -0000       1.10
  @@ -82,17 +82,6 @@
   
   
   
  -XObjectPtr
  -AVTPartXPath::evaluate(
  -                     XalanNode*                              contextNode,
  -                     const PrefixResolver&   prefixResolver,
  -                     XPathExecutionContext&  executionContext) const
  -{
  -     return m_pXPath->execute(contextNode, prefixResolver, executionContext);
  -}
  -
  -
  -
   void
   AVTPartXPath::evaluate(
                        XalanDOMString&                 buf,
  @@ -100,12 +89,7 @@
                        const PrefixResolver&   prefixResolver,
                        XPathExecutionContext&  executionContext) const
   {
  -     const XObjectPtr        xobj(m_pXPath->execute(contextNode, 
prefixResolver, executionContext));
  -
  -     if(0 != xobj.get())
  -     {
  -             xobj->str(buf);
  -     }
  +     m_pXPath->execute(contextNode, prefixResolver, executionContext, buf);
   }
   
   
  
  
  
  1.8       +1 -7      xml-xalan/c/src/XSLT/AVTPartXPath.hpp
  
  Index: AVTPartXPath.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/AVTPartXPath.hpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- AVTPartXPath.hpp  25 Nov 2002 18:11:51 -0000      1.7
  +++ AVTPartXPath.hpp  2 Jan 2003 17:39:18 -0000       1.8
  @@ -104,12 +104,6 @@
        AVTPartXPath(const XPath*       xpath);
   
   
  -     virtual XObjectPtr
  -     evaluate(
  -                     XalanNode*                              contextNode,
  -                     const PrefixResolver&   prefixResolver,
  -                     XPathExecutionContext&  executionContext) const;
  -
        // These methods are inherited from AVTPart ...
        
        virtual void
  
  
  
  1.21      +4 -3      xml-xalan/c/src/XSLT/ElemChoose.cpp
  
  Index: ElemChoose.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemChoose.cpp,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- ElemChoose.cpp    25 Nov 2002 18:11:52 -0000      1.20
  +++ ElemChoose.cpp    2 Jan 2003 17:39:18 -0000       1.21
  @@ -145,8 +145,9 @@
                        const XPath* const              theXPath = 
when->getXPath();
                        assert(theXPath != 0);
   
  -                     const XObjectPtr        
test(theXPath->execute(sourceNode, *this, executionContext));
  -                     assert(test.null() == false);
  +                     bool    test;
  +
  +                     theXPath->execute(sourceNode, *this, executionContext, 
test);
   
                        if(0 != executionContext.getTraceListeners())
                        {
  @@ -159,7 +160,7 @@
                                        test));
                        }
   
  -                     if(test->boolean() == true)
  +                     if(test == true)
                        {
                                node->execute(executionContext);
   
  
  
  
  1.32      +63 -57    xml-xalan/c/src/XSLT/ElemForEach.cpp
  
  Index: ElemForEach.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemForEach.cpp,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- ElemForEach.cpp   21 Dec 2002 00:21:25 -0000      1.31
  +++ ElemForEach.cpp   2 Jan 2003 17:39:18 -0000       1.32
  @@ -429,84 +429,90 @@
   
        assert(m_selectPattern != 0);
   
  -     XObjectPtr      theXObject;
  +     typedef XPathExecutionContext::BorrowReturnMutableNodeRefList   
BorrowReturnMutableNodeRefList;
  +
  +     BorrowReturnMutableNodeRefList  theGuard(executionContext);
  +
  +     const NodeRefListBase*  sourceNodes = 0;
  +
  +     XObjectPtr                              xobjectResult;
   
        {
                SetAndRestoreCurrentStackFrameIndex             
theSetAndRestore(
                                        executionContext,
                                        selectStackFrameIndex);
   
  -             theXObject = m_selectPattern->execute(
  +             xobjectResult = m_selectPattern->execute(
                                                sourceNodeContext,
                                                *this,
  -                                             executionContext);
  -     }
  +                                             executionContext,
  +                                             *theGuard);
   
  -     if (theXObject.null() == false)
  -     {
  -             if (theXObject->getType() != XObject::eTypeNodeSet)
  +             if (xobjectResult.null() == true)
                {
  -                     executionContext.error(
  -                             "xsl:for-each 'select' must evaluate to a 
node-set",
  -                             sourceNodeContext,
  -                             getLocator());
  +                     sourceNodes = &*theGuard;
                }
  -
  -             const NodeRefListBase&  sourceNodes = theXObject->nodeset();
  -
  -             if(0 != executionContext.getTraceListeners())
  +             else
                {
  -                     executionContext.fireSelectEvent(
  -                                     SelectionEvent(executionContext, 
  -                                             sourceNodeContext,
  -                                             *this,
  -                                             
StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("select")),
  -                                             *m_selectPattern,
  -                                             theXObject));
  -             }
  +                     theGuard.release();
   
  -             const NodeRefListBase::size_type        nNodes = 
sourceNodes.getLength();
  +                     sourceNodes = &xobjectResult->nodeset();
  +             }
  +     }
   
  -             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::ContextNodeListSetAndRestore                        
ContextNodeListSetAndRestore;
  -                             typedef 
StylesheetExecutionContext::BorrowReturnMutableNodeRefList                      
BorrowReturnMutableNodeRefList;
  +     if(0 != executionContext.getTraceListeners())
  +     {
  +             executionContext.fireSelectEvent(
  +                             SelectionEvent(
  +                                     executionContext, 
  +                                     sourceNodeContext,
  +                                     *this,
  +                                     
StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("select")),
  +                                     *m_selectPattern,
  +                                     *sourceNodes));
  +     }
   
  -                             BorrowReturnMutableNodeRefList  
sortedSourceNodes(executionContext);
  +     const NodeRefListBase::size_type        nNodes = 
sourceNodes->getLength();
   
  -                             *sortedSourceNodes = sourceNodes;
  +     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::ContextNodeListSetAndRestore                        
ContextNodeListSetAndRestore;
  +                     typedef 
StylesheetExecutionContext::BorrowReturnMutableNodeRefList                      
BorrowReturnMutableNodeRefList;
   
  -                             {
  -                                     SetAndRestoreCurrentStackFrameIndex     
        theStackFrameSetAndRestore(
  -                                                     executionContext,
  -                                                     selectStackFrameIndex);
  +                     BorrowReturnMutableNodeRefList  
sortedSourceNodes(executionContext);
   
  -                                     ContextNodeListSetAndRestore            
        theContextNodeListSetAndRestore(
  -                                                     executionContext,
  -                                                     sourceNodes);
  +                     *sortedSourceNodes = *sourceNodes;
   
  -                                     sorter->sort(executionContext, 
*sortedSourceNodes);
  -                             }
  +                     {
  +                             SetAndRestoreCurrentStackFrameIndex             
theStackFrameSetAndRestore(
  +                                             executionContext,
  +                                             selectStackFrameIndex);
  +
  +                             ContextNodeListSetAndRestore                    
theContextNodeListSetAndRestore(
  +                                             executionContext,
  +                                             *sourceNodes);
   
  -                             transformSelectedChildren(
  -                                     executionContext,
  -                                     theTemplate,
  -                                     *sortedSourceNodes,
  -                                     nNodes);
  +                             sorter->sort(executionContext, 
*sortedSourceNodes);
                        }
  +
  +                     transformSelectedChildren(
  +                             executionContext,
  +                             theTemplate,
  +                             *sortedSourceNodes,
  +                             nNodes);
                }
        }
   }
  
  
  
  1.23      +5 -4      xml-xalan/c/src/XSLT/ElemIf.cpp
  
  Index: ElemIf.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemIf.cpp,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- ElemIf.cpp        25 Nov 2002 18:11:52 -0000      1.22
  +++ ElemIf.cpp        2 Jan 2003 17:39:18 -0000       1.23
  @@ -145,8 +145,9 @@
   
        XalanNode* sourceNode = executionContext.getCurrentNode();
   
  -     const XObjectPtr        test(m_test->execute(sourceNode, *this, 
executionContext));
  -     assert(test.null() == false);
  +     bool    fResult;
  +
  +     m_test->execute(sourceNode, *this, executionContext, fResult);
   
        if(0 != executionContext.getTraceListeners())
        {
  @@ -156,10 +157,10 @@
                        *this,
                        
StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("test")),
                        *m_test,
  -                     test));
  +                     fResult));
        }
   
  -     if(test->boolean())
  +     if(fResult == true)
        {
                executeChildren(executionContext);
        }
  
  
  
  1.71      +2 -3      xml-xalan/c/src/XSLT/ElemNumber.cpp
  
  Index: ElemNumber.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemNumber.cpp,v
  retrieving revision 1.70
  retrieving revision 1.71
  diff -u -r1.70 -r1.71
  --- ElemNumber.cpp    25 Nov 2002 18:11:52 -0000      1.70
  +++ ElemNumber.cpp    2 Jan 2003 17:39:18 -0000       1.71
  @@ -504,10 +504,9 @@
   
        if(0 != m_valueExpr)
        {
  -             const XObjectPtr        
countObj(m_valueExpr->execute(sourceNode, *this, executionContext));
  -             assert(countObj.null() == false);
  +             double  theValue;
   
  -             const double    theValue = countObj->num();
  +             m_valueExpr->execute(sourceNode, *this, executionContext, 
theValue);
   
                CountType       theNumber = 0;
   
  
  
  
  1.35      +113 -17   xml-xalan/c/src/XSLT/ElemValueOf.cpp
  
  Index: ElemValueOf.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemValueOf.cpp,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- ElemValueOf.cpp   25 Nov 2002 18:11:52 -0000      1.34
  +++ ElemValueOf.cpp   2 Jan 2003 17:39:18 -0000       1.35
  @@ -170,6 +170,109 @@
   
   
   
  +class FormatterListenerAdapater : public FormatterListener
  +{
  +public:
  +
  +     FormatterListenerAdapater(StylesheetExecutionContext&   
executionContext) :
  +             FormatterListener(OUTPUT_METHOD_NONE),
  +             m_executionContext(executionContext)
  +     {
  +     }
  +
  +     ~FormatterListenerAdapater()
  +     {
  +     }
  +
  +     void
  +     setDocumentLocator(const LocatorType* const     /* locator */)
  +     {
  +     }
  +
  +     void
  +     startDocument()
  +     {
  +     }
  +
  +     void
  +     endDocument()
  +     {
  +     }
  +
  +     void
  +     startElement(
  +                             const   XMLCh* const    /* name */,
  +                             AttributeListType&              /* attrs */)
  +     {
  +     }
  +
  +     void
  +     endElement(const        XMLCh* const    /* name */)
  +     {
  +     }
  +
  +     void
  +     characters(
  +                             const XMLCh* const      chars,
  +                             const unsigned int      length)
  +     {
  +             m_executionContext.characters(chars, 0, length);
  +     }
  +
  +     void
  +     charactersRaw(
  +                     const XMLCh* const      chars,
  +                     const unsigned int      length)
  +     {
  +             m_executionContext.charactersRaw(chars, 0, length);
  +     }
  +
  +     void
  +     entityReference(const XMLCh* const      /* name */)
  +     {
  +     }
  +
  +     void
  +     ignorableWhitespace(
  +                             const XMLCh* const      /* chars */,
  +                             const unsigned int      /* length */)
  +     {
  +     }
  +
  +     void
  +     processingInstruction(
  +                             const XMLCh* const      target,
  +                             const XMLCh* const      data)
  +     {
  +             m_executionContext.processingInstruction(target, data);
  +     }
  +
  +     void
  +     resetDocument()
  +     {
  +     }
  +
  +     void
  +     comment(const XMLCh* const      data)
  +     {
  +             m_executionContext.comment(data);
  +     }
  +
  +     void
  +     cdata(
  +                             const XMLCh* const      /* ch */,
  +                             const unsigned int      /* length */)
  +     {
  +     }
  +
  +private:
  +
  +     StylesheetExecutionContext&             m_executionContext;
  +
  +};
  +
  +
  +
   void
   ElemValueOf::execute(StylesheetExecutionContext&     executionContext) const
   {
  @@ -200,27 +303,20 @@
        }
        else
        {
  -             const XObjectPtr        
value(m_selectPattern->execute(sourceNode, *this, executionContext));
  +             FormatterListenerAdapater       theAdapter(executionContext);
   
  -             if(value.null() == false)       
  -             {
  -                     if(0 != executionContext.getTraceListeners())
  -                     {
  -                             fireSelectionEvent(executionContext, 
sourceNode, value);
  -                     }
  +             XPath::MemberFunctionPtr        theFunction = 
disableOutputEscaping() == false ?
  +                     &FormatterListener::characters : 
&FormatterListener::charactersRaw;
   
  -                     const XObject::eObjectType      type = value->getType();
  +             m_selectPattern->execute(sourceNode, *this, executionContext, 
theAdapter, theFunction);
   
  -                     if (XObject::eTypeNull != type)
  +             if(0 != executionContext.getTraceListeners())
  +             {
  +                     const XObjectPtr        
value(m_selectPattern->execute(sourceNode, *this, executionContext));
  +
  +                     if (value.null() == false)
                        {
  -                             if (disableOutputEscaping() == false)
  -                             {
  -                                     executionContext.characters(value);
  -                             }
  -                             else
  -                             {
  -                                     executionContext.charactersRaw(value);
  -                             }
  +                             fireSelectionEvent(executionContext, 
sourceNode, value);
                        }
                }
        }
  
  
  
  1.16      +13 -1     xml-xalan/c/src/XSLT/KeyTable.hpp
  
  Index: KeyTable.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/KeyTable.hpp,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- KeyTable.hpp      25 Nov 2002 18:11:52 -0000      1.15
  +++ KeyTable.hpp      2 Jan 2003 17:39:18 -0000       1.16
  @@ -71,7 +71,11 @@
   
   
   
  +#if defined(XALAN_USE_HASH_MAP)
  +#include <hash_map>
  +#else
   #include <map>
  +#endif
   #include <vector>
   
   
  @@ -123,11 +127,19 @@
   #else
        typedef std::vector<KeyDeclaration>             
KeyDeclarationVectorType;
   
  +#if defined(XALAN_USE_HASH_MAP)
  +     typedef std::hash_map<XalanDOMString,
  +                                               MutableNodeRefList>   
NodeListMapType;
  +
  +     typedef std::hash_map<XalanQNameByReference,
  +                                               NodeListMapType>              
KeysMapType;
  +#else
        typedef std::map<XalanDOMString,
                                         MutableNodeRefList>    NodeListMapType;
   
        typedef std::map<XalanQNameByReference,
                                         NodeListMapType>               
KeysMapType;
  +#endif
   #endif
   
   
  
  
  
  1.27      +9 -7      xml-xalan/c/src/XSLT/NodeSorter.cpp
  
  Index: NodeSorter.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/NodeSorter.cpp,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- NodeSorter.cpp    25 Nov 2002 18:11:52 -0000      1.26
  +++ NodeSorter.cpp    2 Jan 2003 17:39:18 -0000       1.27
  @@ -306,6 +306,8 @@
                                unsigned int                    theKeyIndex,
                                first_argument_type             theEntry) const
   {
  +     assert(theKey.getPrefixResolver() != 0);
  +
        const XPath* const      xpath = theKey.getSelectPattern();
        assert(xpath != 0);
   
  @@ -330,8 +332,11 @@
        {
                if 
(DoubleSupport::equal(theCache[theKeyIndex][theEntry.m_position], 
theDummyValue) == true)
                {
  -                     theCache[theKeyIndex][theEntry.m_position] =
  -                             xpath->execute(theEntry.m_node, 
*theKey.getPrefixResolver(), m_executionContext)->num();
  +                     xpath->execute(
  +                             theEntry.m_node,
  +                             *theKey.getPrefixResolver(),
  +                             m_executionContext,
  +                             theCache[theKeyIndex][theEntry.m_position]);
                }
   
                return theCache[theKeyIndex][theEntry.m_position];
  @@ -348,12 +353,9 @@
                        theCache[theKeyIndex].end(),
                        theDummyValue);
   
  -             const XObjectPtr        result(xpath->execute(theEntry.m_node, 
*theKey.getPrefixResolver(), m_executionContext));
  -             assert(result.null() == false);
  -
  -             const double    theResult = result->num();
  +             double&         theResult = 
theCache[theKeyIndex][theEntry.m_position];
   
  -             theCache[theKeyIndex][theEntry.m_position] = theResult;
  +             xpath->execute(theEntry.m_node, *theKey.getPrefixResolver(), 
m_executionContext, theResult);
   
                return theResult;
        }
  
  
  
  1.9       +50 -2     xml-xalan/c/src/XSLT/SelectionEvent.cpp
  
  Index: SelectionEvent.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/SelectionEvent.cpp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SelectionEvent.cpp        25 Nov 2002 18:11:53 -0000      1.8
  +++ SelectionEvent.cpp        2 Jan 2003 17:39:18 -0000       1.9
  @@ -78,7 +78,10 @@
        m_styleNode(styleNode),
        m_attributeName(attributeName),
        m_xpathExpression(xpath.getExpression().getCurrentPattern()),
  -     m_selection(selection)
  +     m_selection(selection),
  +     m_type(selection.null() == true ? eNone : eUnknown),
  +     m_boolean(false),
  +     m_nodeList(0)
   {
   }
   
  @@ -96,7 +99,52 @@
        m_styleNode(styleNode),
        m_attributeName(attributeName),
        m_xpathExpression(xpathExpression),
  -     m_selection(selection)
  +     m_selection(selection),
  +     m_type(selection.null() == true ? eNone : eUnknown),
  +     m_boolean(false),
  +     m_nodeList(0)
  +{
  +}
  +
  +
  +
  +SelectionEvent::SelectionEvent(
  +                     StylesheetExecutionContext&             
executionContext,
  +                     const XalanNode*                                
sourceNode,
  +                     const ElemTemplateElement&              styleNode,
  +                     const XalanDOMString&                   attributeName,
  +                     const XPath&                                    xpath,
  +                     bool                                                    
selection) :
  +     m_executionContext(executionContext),
  +     m_sourceNode(sourceNode),
  +     m_styleNode(styleNode),
  +     m_attributeName(attributeName),
  +     m_xpathExpression(xpath.getExpression().getCurrentPattern()),
  +     m_selection(),
  +     m_type(eBoolean),
  +     m_boolean(selection),
  +     m_nodeList(0)
  +{
  +}
  +
  +
  +
  +SelectionEvent::SelectionEvent(
  +                     StylesheetExecutionContext&             
executionContext,
  +                     const XalanNode*                                
sourceNode,
  +                     const ElemTemplateElement&              styleNode,
  +                     const XalanDOMString&                   attributeName,
  +                     const XPath&                                    xpath,
  +                     const NodeRefListBase&                  selection) :
  +     m_executionContext(executionContext),
  +     m_sourceNode(sourceNode),
  +     m_styleNode(styleNode),
  +     m_attributeName(attributeName),
  +     m_xpathExpression(xpath.getExpression().getCurrentPattern()),
  +     m_selection(),
  +     m_type(eNodeSet),
  +     m_boolean(false),
  +     m_nodeList(&selection)
   {
   }
   
  
  
  
  1.10      +51 -1     xml-xalan/c/src/XSLT/SelectionEvent.hpp
  
  Index: SelectionEvent.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/SelectionEvent.hpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SelectionEvent.hpp        25 Nov 2002 18:11:53 -0000      1.9
  +++ SelectionEvent.hpp        2 Jan 2003 17:39:18 -0000       1.10
  @@ -125,9 +125,49 @@
                        const XalanDOMString&                   xpathExpression,
                        const XObjectPtr                                
selection);
   
  +     /**
  +      * Create an event originating at the given node of the style tree.
  +      *
  +      * @param executionContext The current execution context
  +      * @param sourceNode The source node selected.
  +      * @param styleNode The node in the style tree reference for the event
  +      * @param attributeName The attribute name where the XPath expression 
was supplied
  +      * @param xpath The XPath instance executed
  +      * @param selection The result of evaluating the XPath
  +      *
  +      */
  +     SelectionEvent(
  +                     StylesheetExecutionContext&             
executionContext,
  +                     const XalanNode*                                
sourceNode,
  +                     const ElemTemplateElement&              styleNode,
  +                     const XalanDOMString&                   attributeName,
  +                     const XPath&                                    xpath,
  +                     bool                                                    
selection);
  +
  +     /**
  +      * Create an event originating at the given node of the style tree.
  +      *
  +      * @param executionContext The current execution context
  +      * @param sourceNode The source node selected.
  +      * @param styleNode The node in the style tree reference for the event
  +      * @param attributeName The attribute name where the XPath expression 
was supplied
  +      * @param xpath The XPath instance executed
  +      * @param selection The result of evaluating the XPath
  +      *
  +      */
  +     SelectionEvent(
  +                     StylesheetExecutionContext&             
executionContext,
  +                     const XalanNode*                                
sourceNode,
  +                     const ElemTemplateElement&              styleNode,
  +                     const XalanDOMString&                   attributeName,
  +                     const XPath&                                    xpath,
  +                     const NodeRefListBase&                  selection);
  +
        virtual
        ~SelectionEvent();
   
  +     enum eSelectionType { eNone, eBoolean, eNodeSet, eUnknown };
  +
        /**
         * The executionContext instance.
         */
  @@ -155,9 +195,19 @@
     
        /**
         * The result of the selection.  If it's null, m_sourceNode
  -      * was selected.
  +      * was selected, or some specific type was selected.  See
  +      * the above enums.
         */
        const XObjectPtr                                        m_selection;
  +
  +     /**
  +      * The type of the selection.
  +      */
  +     const eSelectionType                            m_type;
  +
  +     bool                                                            
m_boolean;
  +
  +     const NodeRefListBase* const            m_nodeList;
   
   private:
   
  
  
  
  1.16      +35 -24    xml-xalan/c/src/XSLT/TraceListenerDefault.cpp
  
  Index: TraceListenerDefault.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/TraceListenerDefault.cpp,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- TraceListenerDefault.cpp  25 Nov 2002 18:11:53 -0000      1.15
  +++ TraceListenerDefault.cpp  2 Jan 2003 17:39:18 -0000       1.16
  @@ -205,6 +205,31 @@
   
   
   void
  +TraceListenerDefault::processNodeList(const NodeRefListBase&         nl)
  +{
  +     m_printWriter.println();
  +
  +     const NodeRefListBase::size_type        n = nl.getLength();
  +
  +     if(n == 0)
  +     {
  +             m_printWriter.println(XALAN_STATIC_UCODE_STRING("     [empty 
node list]"));
  +     }
  +     else
  +     {
  +             for(NodeRefListBase::size_type i = 0; i < n; i++)
  +             {
  +                     assert(nl.item(i) != 0);
  +
  +                     m_printWriter.print(XALAN_STATIC_UCODE_STRING("     "));
  +                     
m_printWriter.println(DOMServices::getNodeData(*nl.item(i)));
  +             }
  +     }
  +}
  +
  +
  +
  +void
   TraceListenerDefault::selected(const SelectionEvent& ev)
   {
       if(m_traceSelection == true)
  @@ -250,34 +275,20 @@
   
                if (ev.m_selection.null() == true)
                {
  -                     assert(ev.m_sourceNode != 0);
  -                     m_printWriter.println();
  -
  -                     m_printWriter.print(XALAN_STATIC_UCODE_STRING("     "));
  -                     
m_printWriter.println(DOMServices::getNodeData(*ev.m_sourceNode));
  -             }
  -             else if(ev.m_selection->getType() == XObject::eTypeNodeSet)
  -             {
  -                     m_printWriter.println();
  -
  -                     const NodeRefListBase&  nl = ev.m_selection->nodeset();
  -
  -                     const NodeRefListBase::size_type        n = 
nl.getLength();
  -
  -                     if(n == 0)
  +                     if (ev.m_type == SelectionEvent::eBoolean)
                        {
  -                             
m_printWriter.println(XALAN_STATIC_UCODE_STRING("     [empty node list]"));
  +                             m_printWriter.println(ev.m_boolean == true ? 
"true" : "false");
                        }
  -                     else
  +                     else if (ev.m_type == SelectionEvent::eNodeSet)
                        {
  -                             for(NodeRefListBase::size_type i = 0; i < n; 
i++)
  -                             {
  -                                     assert(nl.item(i) != 0);
  -
  -                                     
m_printWriter.print(XALAN_STATIC_UCODE_STRING("     "));
  -                                     
m_printWriter.println(DOMServices::getNodeData(*nl.item(i)));
  -                             }
  +                             assert(ev.m_nodeList != 0);
  +
  +                             processNodeList(*ev.m_nodeList);
                        }
  +             }
  +             else if(ev.m_selection->getType() == XObject::eTypeNodeSet)
  +             {
  +                     processNodeList(ev.m_selection->nodeset());
                }
                else
                {
  
  
  
  1.3       +6 -0      xml-xalan/c/src/XSLT/TraceListenerDefault.hpp
  
  Index: TraceListenerDefault.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/TraceListenerDefault.hpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TraceListenerDefault.hpp  25 Nov 2002 18:11:53 -0000      1.2
  +++ TraceListenerDefault.hpp  2 Jan 2003 17:39:18 -0000       1.3
  @@ -74,6 +74,7 @@
   
   
   class DOMSupport;
  +class NodeRefListBase;
   class PrintWriter;
   
   
  @@ -151,6 +152,11 @@
   
   private:
   
  +     void
  +     processNodeList(const NodeRefListBase&  nl);
  +
  +
  +     // Data members...
        PrintWriter&    m_printWriter;
   
        bool                    m_traceTemplates;
  
  
  

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

Reply via email to