dbertoni    2002/12/12 14:24:56

  Modified:    c/src/XSLT ElemExtensionCall.cpp
                        FunctionElementAvailable.cpp
                        FunctionFunctionAvailable.cpp
                        FunctionFunctionAvailable.hpp
                        StylesheetExecutionContext.hpp
                        StylesheetExecutionContextDefault.cpp
                        StylesheetExecutionContextDefault.hpp
  Log:
  Consistent implementation of elementAvailable() and functionAvailable().  Fix 
for bugzilla 14785.
  
  Revision  Changes    Path
  1.16      +1 -1      xml-xalan/c/src/XSLT/ElemExtensionCall.cpp
  
  Index: ElemExtensionCall.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemExtensionCall.cpp,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ElemExtensionCall.cpp     25 Nov 2002 18:11:52 -0000      1.15
  +++ ElemExtensionCall.cpp     12 Dec 2002 22:24:56 -0000      1.16
  @@ -114,7 +114,7 @@
   bool
   ElemExtensionCall::elementAvailable(StylesheetExecutionContext&              
executionContext) const
   {
  -     return executionContext.elementAvailable(m_qname->getNamespace(), 
m_qname->getLocalPart());
  +     return executionContext.elementAvailable(*m_qname);
   }
   
   
  
  
  
  1.18      +2 -35     xml-xalan/c/src/XSLT/FunctionElementAvailable.cpp
  
  Index: FunctionElementAvailable.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/FunctionElementAvailable.cpp,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- FunctionElementAvailable.cpp      25 Nov 2002 18:11:52 -0000      1.17
  +++ FunctionElementAvailable.cpp      12 Dec 2002 22:24:56 -0000      1.18
  @@ -87,44 +87,11 @@
                        XPathExecutionContext&  executionContext,
                        XalanNode*                              /* context */,  
                
                        const XObjectPtr                arg1,
  -                     const LocatorType*              /* locator */) const
  +                     const LocatorType*              locator) const
   {
        assert(arg1.null() == false);
   
  -     const XalanDOMString&                           fullName = arg1->str();
  -
  -     const XalanDOMString::size_type         nameLength = length(fullName);
  -     const XalanDOMString::size_type         indexOfNSSep = 
indexOf(fullName, XalanUnicode::charColon);
  -
  -     XPathExecutionContext::GetAndReleaseCachedString        
guard(executionContext);
  -
  -     XalanDOMString&         theBuffer = guard.get();
  -
  -     if (indexOfNSSep < nameLength)
  -     {
  -             substring(fullName, theBuffer, 0, indexOfNSSep);
  -     }
  -
  -     const XalanDOMString* const             theNamespace =
  -             executionContext.getNamespaceForPrefix(theBuffer);
  -
  -     if (theNamespace == 0 || length(*theNamespace) == 0)
  -     {
  -             return 
executionContext.getXObjectFactory().createBoolean(false);
  -     }
  -     else
  -     {
  -             if (indexOfNSSep == nameLength)
  -             {
  -                     return 
executionContext.getXObjectFactory().createBoolean(executionContext.elementAvailable(*theNamespace,
 fullName));
  -             }
  -             else
  -             {
  -                     substring(fullName, theBuffer, indexOfNSSep + 1);
  -
  -                     return 
executionContext.getXObjectFactory().createBoolean(executionContext.elementAvailable(*theNamespace,
 theBuffer));
  -             }
  -     }
  +     return 
executionContext.getXObjectFactory().createBoolean(executionContext.elementAvailable(arg1->str(),
 locator));
   }
   
   
  
  
  
  1.17      +2 -37     xml-xalan/c/src/XSLT/FunctionFunctionAvailable.cpp
  
  Index: FunctionFunctionAvailable.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/FunctionFunctionAvailable.cpp,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- FunctionFunctionAvailable.cpp     25 Nov 2002 18:11:52 -0000      1.16
  +++ FunctionFunctionAvailable.cpp     12 Dec 2002 22:24:56 -0000      1.17
  @@ -70,10 +70,6 @@
   
   
   
  -const XalanDOMString FunctionFunctionAvailable::s_emptyString;
  -
  -
  -
   FunctionFunctionAvailable::FunctionFunctionAvailable()
   {
   }
  @@ -91,42 +87,11 @@
                        XPathExecutionContext&  executionContext,
                        XalanNode*                              /* context */,
                        const XObjectPtr                arg,
  -                     const LocatorType*              /* locator */) const
  +                     const LocatorType*              locator) const
   {
        assert(arg.null() == false);
   
  -     const XalanDOMString&                           fullName = arg->str();
  -
  -     const XalanDOMString::size_type         nameLength = length(fullName);
  -     const XalanDOMString::size_type         indexOfNSSep = 
indexOf(fullName, XalanUnicode::charColon);
  -
  -     XPathExecutionContext::GetAndReleaseCachedString        
guard(executionContext);
  -
  -     XalanDOMString&         theBuffer = guard.get();
  -
  -     if (indexOfNSSep < nameLength)
  -     {
  -             substring(fullName, theBuffer, 0, indexOfNSSep);
  -     }
  -
  -     const XalanDOMString*   theNamespace =
  -                     executionContext.getNamespaceForPrefix(theBuffer);
  -
  -     if (theNamespace == 0)
  -     {
  -             theNamespace = &s_emptyString;
  -     }
  -
  -     if (indexOfNSSep == nameLength)
  -     {
  -             return 
executionContext.getXObjectFactory().createBoolean(executionContext.functionAvailable(*theNamespace,
 fullName));
  -     }
  -     else
  -     {
  -             substring(fullName, theBuffer, indexOfNSSep + 1);
  -
  -             return 
executionContext.getXObjectFactory().createBoolean(executionContext.functionAvailable(*theNamespace,
 theBuffer));
  -     }
  +     return 
executionContext.getXObjectFactory().createBoolean(executionContext.functionAvailable(arg->str(),
 locator));
   }
   
   
  
  
  
  1.8       +0 -2      xml-xalan/c/src/XSLT/FunctionFunctionAvailable.hpp
  
  Index: FunctionFunctionAvailable.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/FunctionFunctionAvailable.hpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- FunctionFunctionAvailable.hpp     25 Nov 2002 18:11:52 -0000      1.7
  +++ FunctionFunctionAvailable.hpp     12 Dec 2002 22:24:56 -0000      1.8
  @@ -122,8 +122,6 @@
   
        bool
        operator==(const FunctionFunctionAvailable&) const;
  -
  -     static const XalanDOMString             s_emptyString;
   };
   
   
  
  
  
  1.82      +41 -4     xml-xalan/c/src/XSLT/StylesheetExecutionContext.hpp
  
  Index: StylesheetExecutionContext.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContext.hpp,v
  retrieving revision 1.81
  retrieving revision 1.82
  diff -u -r1.81 -r1.82
  --- StylesheetExecutionContext.hpp    25 Nov 2002 18:11:53 -0000      1.81
  +++ StylesheetExecutionContext.hpp    12 Dec 2002 22:24:56 -0000      1.82
  @@ -1858,15 +1858,52 @@
        virtual size_type
        getContextNodeListPosition(const XalanNode&             contextNode) 
const = 0;
   
  +     /**
  +      * Determine if an external element is available.
  +      *
  +      * @param theQName The QName of the element
  +      *
  +      * @return whether the given element is available or not
  +      */
  +     virtual bool
  +     elementAvailable(const XalanQName&      theQName) const = 0;
  +
  +     /**
  +      * Determine if an external element is available by resolving
  +      * a string to a QName.
  +      *
  +      * @param theName The name of the element
  +      * @param locator A LocatorType instance for error reporting
  +      *
  +      * @return whether the given element is available or not
  +      */
        virtual bool
        elementAvailable(
  -                     const XalanDOMString&   theNamespace, 
  -                     const XalanDOMString&   elementName) const = 0;
  +                     const XalanDOMString&   theName,
  +                     const LocatorType*              locator) const = 0;
  +
  +     /**
  +      * Determine if a function is available.
  +      *
  +      * @param theQName The QName of the function
  +      *
  +      * @return whether the function is available or not
  +      */
  +     virtual bool
  +     functionAvailable(const XalanQName&             theQName) const = 0;
   
  +     /**
  +      * Determine if a function is available.
  +      *
  +      * @param theName The name of the function
  +      * @param locator A LocatorType instance for error reporting
  +      *
  +      * @return whether the function is available or not
  +      */
        virtual bool
        functionAvailable(
  -                     const XalanDOMString&   theNamespace, 
  -                     const XalanDOMString&   functionName) const = 0;
  +                     const XalanDOMString&   theName,
  +                     const LocatorType*              locator) const = 0;
   
        virtual const XObjectPtr
        extFunction(
  
  
  
  1.107     +35 -15    
xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.cpp
  
  Index: StylesheetExecutionContextDefault.cpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.cpp,v
  retrieving revision 1.106
  retrieving revision 1.107
  diff -u -r1.106 -r1.107
  --- StylesheetExecutionContextDefault.cpp     3 Dec 2002 00:27:52 -0000       
1.106
  +++ StylesheetExecutionContextDefault.cpp     12 Dec 2002 22:24:56 -0000      
1.107
  @@ -174,8 +174,7 @@
        m_usePerInstanceDocumentFactory(false),
        m_cloneTextNodesOnly(false),
        m_escapeURLs(eEscapeURLsDefault),
  -     m_omitMETATag(eOmitMETATagDefault),
  -     m_scratchQName()
  +     m_omitMETATag(eOmitMETATagDefault)
   {
   }
   
  @@ -217,8 +216,7 @@
        m_documentAllocator(eDocumentAllocatorBlockSize),
        m_usePerInstanceDocumentFactory(false),
        m_cloneTextNodesOnly(false),
  -     m_escapeURLs(eEscapeURLsDefault),
  -     m_scratchQName()
  +     m_escapeURLs(eEscapeURLsDefault)
   {
   }
   
  @@ -1758,30 +1756,50 @@
   
   
   bool
  -StylesheetExecutionContextDefault::elementAvailable(
  -                     const XalanDOMString&   theNamespace, 
  -                     const XalanDOMString&   elementName) const
  +StylesheetExecutionContextDefault::elementAvailable(const XalanQName&        
theQName) const
   {
  -     if (equals(theNamespace, XSLTEngineImpl::getXSLNameSpaceURL()) == true)
  +     if (theQName.getNamespace() == XSLTEngineImpl::getXSLNameSpaceURL())
        {
  -             const int       xslToken = 
StylesheetConstructionContextDefault::getElementNameToken(elementName);
  +             const int       xslToken = 
StylesheetConstructionContextDefault::getElementNameToken(theQName.getLocalPart());
   
                return xslToken < 0 ? false : true;
        }
        else
        {
  -             return 
m_xpathExecutionContextDefault.elementAvailable(theNamespace, elementName);
  +             return 
m_xpathExecutionContextDefault.elementAvailable(theQName);
        }
   }
   
   
   
   bool
  +StylesheetExecutionContextDefault::elementAvailable(
  +                     const XalanDOMString&   theName, 
  +                     const LocatorType*              theLocator) const
  +{
  +     XalanQNameByValue&      theQName = 
m_xpathExecutionContextDefault.getScratchQName();
  +
  +     theQName.set(theName, getPrefixResolver(), theLocator);
  +
  +     return elementAvailable(theQName);
  +}
  +
  +
  +
  +bool
  +StylesheetExecutionContextDefault::functionAvailable(const XalanQName&       
theQName) const
  +{
  +     return m_xpathExecutionContextDefault.functionAvailable(theQName);
  +}
  +
  +
  +
  +bool
   StylesheetExecutionContextDefault::functionAvailable(
  -                     const XalanDOMString&   theNamespace, 
  -                     const XalanDOMString&   functionName) const
  +                     const XalanDOMString&   theName, 
  +                     const LocatorType*              theLocator) const
   {
  -     return m_xpathExecutionContextDefault.functionAvailable(theNamespace, 
functionName);
  +     return m_xpathExecutionContextDefault.functionAvailable(theName, 
theLocator);
   }
   
   
  @@ -1884,11 +1902,13 @@
                                getPrefixResolver();
        assert(resolver != 0);
   
  -     m_scratchQName.set(name, resolver, locator);
  +     XalanQNameByValue       theQName = 
m_xpathExecutionContextDefault.getScratchQName();
  +
  +     theQName.set(name, resolver, locator);
   
        m_stylesheetRoot->getNodeSetByKey(
                doc,
  -             m_scratchQName,
  +             theQName,
                ref,
                *resolver,
                nodelist,
  
  
  
  1.86      +10 -6     
xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.hpp
  
  Index: StylesheetExecutionContextDefault.hpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/XSLT/StylesheetExecutionContextDefault.hpp,v
  retrieving revision 1.85
  retrieving revision 1.86
  diff -u -r1.85 -r1.86
  --- StylesheetExecutionContextDefault.hpp     25 Nov 2002 18:11:53 -0000      
1.85
  +++ StylesheetExecutionContextDefault.hpp     12 Dec 2002 22:24:56 -0000      
1.86
  @@ -878,14 +878,20 @@
        getContextNodeListPosition(const XalanNode&             contextNode) 
const;
   
        virtual bool
  +     elementAvailable(const XalanQName&      theQName) const;
  +
  +     virtual bool
        elementAvailable(
  -                     const XalanDOMString&   theNamespace, 
  -                     const XalanDOMString&   elementName) const;
  +                     const XalanDOMString&   theName,
  +                     const LocatorType*              locator) const;
  +
  +     virtual bool
  +     functionAvailable(const XalanQName&             theQName) const;
   
        virtual bool
        functionAvailable(
  -                     const XalanDOMString&   theNamespace, 
  -                     const XalanDOMString&   functionName) const;
  +                     const XalanDOMString&   theName,
  +                     const LocatorType*              locator) const;
   
        virtual const XObjectPtr
        extFunction(
  @@ -1181,8 +1187,6 @@
   
        // Determines whether or not to override the property in the stylesheet.
        eOmitMETATag                                            m_omitMETATag;
  -
  -     XalanQNameByValue                                       m_scratchQName;
   
        static XalanNumberFormatFactory         
s_defaultXalanNumberFormatFactory;
   
  
  
  

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

Reply via email to