dbertoni    02/05/14 08:46:50

  Modified:    c/src/XSLT FunctionDocument.cpp FunctionDocument.hpp
  Log:
  Better scoping and modularity.
  
  Revision  Changes    Path
  1.30      +89 -47    xml-xalan/c/src/XSLT/FunctionDocument.cpp
  
  Index: FunctionDocument.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/FunctionDocument.cpp,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- FunctionDocument.cpp      26 Sep 2001 21:30:23 -0000      1.29
  +++ FunctionDocument.cpp      14 May 2002 15:46:50 -0000      1.30
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2000 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -91,48 +91,80 @@
   
   
   
  -static void
  -getDoc(
  +inline void
  +doWarn(
                        XPathExecutionContext&                          
executionContext,
                        const XalanDOMString&                           uri,
                        const XalanDOMString&                           base,
  -                     BorrowReturnMutableNodeRefList&         mnl)
  +                     const XalanNode*                                        
sourceNode,
  +                     const Locator*                                          
locator)
   {
  -     XalanDOMString  localURI(uri);
  +     XalanDOMString  theMessage(TranscodeFromLocalCodePage("Cannot load requested 
document: "));
   
  -    XalanDocument*   newDoc = executionContext.getSourceDocument(localURI);
  +     theMessage += uri;
   
  -     if(newDoc == 0)
  +     if (length(base) > 0)
        {
  -             if(length(localURI) == 0)
  -             {
  -                     assert(executionContext.getPrefixResolver() != 0);
  +             theMessage += TranscodeFromLocalCodePage(" (Base URI: ");
  +             theMessage += base;
  +             theMessage += TranscodeFromLocalCodePage(")");
  +     }
   
  -                     localURI = executionContext.getPrefixResolver()->getURI();
  -             }
  +     executionContext.warn(theMessage, sourceNode, locator);
  +}
   
  -             try
  -             {
  -                     newDoc = executionContext.parseXML(localURI, base);
  -             }
  -             catch(...)
  -             {
  -             }
   
  -             if(newDoc == 0)
  -             {
  -                     XalanDOMString  theMessage(TranscodeFromLocalCodePage("Cannot 
load requested doc: "));
   
  -                     theMessage += localURI;
  +inline XalanDocument*
  +parseDoc(
  +                     XPathExecutionContext&  executionContext,
  +                     const XalanDOMString&   uri,
  +                     const XalanDOMString&   base,
  +                     const XalanNode*                sourceNode,
  +                     const Locator*                  locator)
  +{
  +     try
  +     {
  +             return executionContext.parseXML(uri, base);
  +     }
  +     catch(...)
  +     {
  +             doWarn(executionContext, uri, base, sourceNode, locator);
  +     }
   
  -                     if (length(base) > 0)
  -                     {
  -                             theMessage += TranscodeFromLocalCodePage(" (Base URI: 
");
  -                             theMessage += base;
  -                             theMessage += TranscodeFromLocalCodePage(")");
  -                     }
  +     return 0;
  +}
  +
  +
  +
  +static void
  +getDoc(
  +                     XPathExecutionContext&                          
executionContext,
  +                     const XalanDOMString&                           uri,
  +                     const XalanDOMString&                           base,
  +                     BorrowReturnMutableNodeRefList&         mnl,
  +                     const XalanNode*                                        
sourceNode,
  +                     const Locator*                                          
locator)
  +{
  +    XalanDocument*   newDoc = executionContext.getSourceDocument(uri);
  +
  +     if(newDoc == 0)
  +     {
  +             if(length(uri) != 0)
  +             {
  +                     newDoc = parseDoc(executionContext, uri, base, sourceNode, 
locator);
  +             }
  +             else
  +             {
  +                     assert(executionContext.getPrefixResolver() != 0);
   
  -                     executionContext.warn(theMessage);
  +                     newDoc =
  +                             parseDoc(
  +                                     executionContext,
  +                                     executionContext.getPrefixResolver()->getURI(),
  +                                     base,
  +                                     sourceNode,
  +                                     locator);
                }
       }
   
  @@ -148,9 +180,11 @@
   getDoc(
                        XPathExecutionContext&                          
executionContext,
                        const XalanDOMString&                           uri,
  -                     BorrowReturnMutableNodeRefList&         mnl)
  +                     BorrowReturnMutableNodeRefList&         mnl,
  +                     const XalanNode*                                        
sourceNode,
  +                     const Locator*                                          
locator)
   {
  -     getDoc(executionContext, uri, XalanDOMString(), mnl);
  +     getDoc(executionContext, uri, XalanDOMString(), mnl, sourceNode, locator);
   }
   
   
  @@ -160,7 +194,8 @@
                        XPathExecutionContext&                          
executionContext,
                        const XalanDOMString&                           uri,
                        const XalanNode*                                        
resolver,
  -                     BorrowReturnMutableNodeRefList&         mnl)
  +                     BorrowReturnMutableNodeRefList&         mnl,
  +                     const Locator*                                          
locator)
   {
        assert(resolver != 0);
   
  @@ -172,7 +207,13 @@
   #endif
                        resolver->getOwnerDocument();
   
  -     getDoc(executionContext, uri, executionContext.findURIFromDoc(ownerDocument), 
mnl);
  +     getDoc(
  +             executionContext,
  +             uri,
  +             executionContext.findURIFromDoc(ownerDocument),
  +             mnl,
  +             resolver,
  +             locator);
   }
   
   
  @@ -182,13 +223,13 @@
                        XPathExecutionContext&  executionContext,
                        XalanNode*                              context,               
         
                        const XObjectPtr                arg1,
  -                     const Locator*                  /* locator */) const
  +                     const Locator*                  locator) const
   {
        assert(arg1.null() == false);
   
        if (arg1->getType() == XObject::eTypeNodeSet)
        {
  -             return doExecute(executionContext, context, arg1, 0, 1);
  +             return doExecute(executionContext, context, arg1, 0, 1, locator);
        }
        else
        {
  @@ -198,7 +239,7 @@
   
                base = executionContext.getPrefixResolver()->getURI();
   
  -             return doExecute(executionContext, context, arg1, &base, 1);
  +             return doExecute(executionContext, context, arg1, &base, 1, locator);
        }
   }
   
  @@ -262,18 +303,19 @@
                }
        }
   
  -     return doExecute(executionContext, context, arg1, &base, 2);
  +     return doExecute(executionContext, context, arg1, &base, 2, locator);
   }
   
   
   
   XObjectPtr
   FunctionDocument::doExecute(
  -             XPathExecutionContext&                  executionContext,
  -             XalanNode*                                              /* context */,
  -             const XObjectPtr                                arg,
  -             XalanDOMString*                                 base,
  -             int                                                             
argCount) const
  +                     XPathExecutionContext&                  executionContext,
  +                     XalanNode*                                              
context,
  +                     const XObjectPtr                                arg,
  +                     XalanDOMString*                                 base,
  +                     int                                                            
 argCount,
  +                     const Locator*                                  locator) const
   {
        typedef XPathExecutionContext::BorrowReturnMutableNodeRefList   
BorrowReturnMutableNodeRefList;
   
  @@ -346,7 +388,7 @@
                           indexOfColon < indexOfSlash)
                        {
                                // The ref is absolute...
  -                             getDoc(executionContext, ref, mnl);
  +                             getDoc(executionContext, ref, mnl, context, locator);
                        }
                        else
                        {
  @@ -354,7 +396,7 @@
                                // provided, use that...
                                if (base != 0)
                                {
  -                                     getDoc(executionContext, ref, *base, mnl);
  +                                     getDoc(executionContext, ref, *base, mnl, 
context, locator);
                                }
                                else
                                {
  @@ -362,11 +404,11 @@
                                        // relative ref...
                                        if (resolver == 0)
                                        {
  -                                             getDoc(executionContext, ref, mnl);
  +                                             getDoc(executionContext, ref, mnl, 
context, locator);
                                        }
                                        else
                                        {
  -                                             getDoc(executionContext, ref, 
resolver, mnl);
  +                                             getDoc(executionContext, ref, 
resolver, mnl, locator);
                                        }
                                }
                        }
  
  
  
  1.8       +7 -6      xml-xalan/c/src/XSLT/FunctionDocument.hpp
  
  Index: FunctionDocument.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/FunctionDocument.hpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- FunctionDocument.hpp      14 Sep 2001 20:49:43 -0000      1.7
  +++ FunctionDocument.hpp      14 May 2002 15:46:50 -0000      1.8
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -112,11 +112,12 @@
   
        XObjectPtr
        doExecute(
  -                     XPathExecutionContext&                  executionContext,
  -                     XalanNode*                                              
context,                        
  -                     const XObjectPtr                                arg,
  -                     XalanDOMString*                                 base,
  -                     int                                                            
 argCount) const;
  +                     XPathExecutionContext&  executionContext,
  +                     XalanNode*                              context,               
         
  +                     const XObjectPtr                arg,
  +                     XalanDOMString*                 base,
  +                     int                                             argCount,
  +                     const Locator*                  locator) const;
   
        // Not implemented...
        FunctionDocument&
  
  
  

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

Reply via email to