dbertoni    00/04/20 09:28:31

  Modified:    c/src/XPath FunctionName.hpp
  Log:
  Fixed default argument code and updated code for certain types of nodes.
  
  Revision  Changes    Path
  1.5       +24 -24    xml-xalan/c/src/XPath/FunctionName.hpp
  
  Index: FunctionName.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionName.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FunctionName.hpp  2000/04/11 14:46:06     1.4
  +++ FunctionName.hpp  2000/04/20 16:28:31     1.5
  @@ -119,19 +119,21 @@
                        }
                        else
                        {
  -                             // Make a temporary XObject from the context 
node.
  -                             XObjectFactory&                                 
        theFactory =
  -                                                     
executionContext.getXObjectFactory();
  -
  -                             FactoryObjectAutoPointer<XObject>       
theXObject(&theFactory,
  -                                                                             
                                           theFactory.createNodeSet(*context));
  -
  -                             theResult = 
getNameFromNodeList(theXObject->nodeset());
  +                             theResult = getNameFromNode(*context);
                        }
                }
                else if (theSize == 1)
                {
  -                     theResult = getNameFromNodeList(args[0]->nodeset());
  +                     assert(args[0] != 0);
  +
  +                     const NodeRefListBase&  theNodeList = 
args[0]->nodeset();
  +
  +                     if (theNodeList.getLength() != 0)
  +                     {
  +                             assert(theNodeList.item(0) != 0);
  +
  +                             theResult = 
getNameFromNode(*theNodeList.item(0));
  +                     }
                }
                else
                {
  @@ -161,26 +163,24 @@
         * @return name string of node, or an empty string if node list is empty
         */
        virtual XalanDOMString
  -     getNameFromNodeList(const NodeRefListBase&      theNodeList) const
  +     getNameFromNode(const XalanNode&        theNode) const
        {
                XalanDOMString  theResult;
   
  -             if (theNodeList.getLength() > 0)
  -             {
  -                     const XalanNode* const  theNode = theNodeList.item(0);
  -                     assert(theNode != 0);
  +             const XalanNode::NodeType       theNodeType =
  +                             theNode.getNodeType();
   
  -                     if (XalanNode::ATTRIBUTE_NODE == theNode->getNodeType())
  -                     {
  -                             const XalanAttr* const  theAttributeNode =
  -                                     reinterpret_cast<const 
XalanAttr*>(theNode);
  +             if (theNodeType == XalanNode::ATTRIBUTE_NODE)
  +             {
  +                     const XalanAttr&        theAttributeNode =
  +                                     reinterpret_cast<const 
XalanAttr&>(theNode);
   
  -                             theResult = theAttributeNode->getName();
  -                     }
  -                     else
  -                     {
  -                             theResult = theNode->getNodeName();
  -                     }
  +                     theResult = theAttributeNode.getName();
  +             }
  +             else if (theNodeType == XalanNode::ELEMENT_NODE ||
  +                              theNodeType == 
XalanNode::PROCESSING_INSTRUCTION_NODE)
  +             {
  +                     theResult = theNode.getNodeName();
                }
   
                return theResult;
  
  
  

Reply via email to