dbertoni    02/05/05 22:31:58

  Modified:    c/src/XSLT AVT.cpp ElemAttribute.cpp ElemElement.cpp
                        ElemLiteralResult.cpp ElemNumber.cpp
                        ExtensionFunctionHandler.cpp
                        FunctionElementAvailable.cpp
                        FunctionFunctionAvailable.cpp
                        FunctionGenerateID.cpp FunctionSystemProperty.cpp
                        FunctionSystemProperty.hpp NamespacesHandler.cpp
                        Stylesheet.cpp StylesheetHandler.cpp
                        XSLTEngineImpl.cpp XSLTEngineImpl.hpp
  Log:
  More efficient string processing.
  
  Revision  Changes    Path
  1.16      +1 -1      xml-xalan/c/src/XSLT/AVT.cpp
  
  Index: AVT.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/AVT.cpp,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- AVT.cpp   7 Dec 2001 19:58:10 -0000       1.15
  +++ AVT.cpp   6 May 2002 05:31:57 -0000       1.16
  @@ -403,7 +403,7 @@
   {
        if (startsWith(theName, DOMServices::s_XMLNamespaceWithSeparator) == true)
        {
  -             return substring(theName, 
DOMServices::s_XMLNamespaceWithSeparatorLength);
  +             return XalanDOMString(theName, 
DOMServices::s_XMLNamespaceWithSeparatorLength);
        }
        else
        {
  
  
  
  1.37      +5 -5      xml-xalan/c/src/XSLT/ElemAttribute.cpp
  
  Index: ElemAttribute.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemAttribute.cpp,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- ElemAttribute.cpp 2 Apr 2002 06:12:50 -0000       1.36
  +++ ElemAttribute.cpp 6 May 2002 05:31:57 -0000       1.37
  @@ -239,7 +239,7 @@
                                                        attrName,
                                                        length(attrName) - 
(indexOfNSSep + 1) + DOMServices::s_XMLNamespaceSeparatorStringLength + 
length(*prefix) + 1);
   
  -                                             assign(attrName, substring(attrName, 
indexOfNSSep + 1));
  +                                             attrName.erase(0, indexOfNSSep + 1);
                                        }
                                        else
                                        {
  @@ -266,7 +266,7 @@
                                        if(indexOfNSSep < origAttrNameLength &&
                                            fPrefixIsXMLNS == false)
                                        {
  -                                             newPrefix = substring(origAttrName, 0, 
indexOfNSSep);
  +                                             substring(origAttrName, newPrefix, 0, 
indexOfNSSep);
   
                                                // OK, make sure that the prefix 
provided maps to
                                                // the same namespace as the one the 
user requested,
  @@ -283,7 +283,7 @@
                                                        clear(newPrefix);
   
                                                        // Strip the user-supplied 
prefix from the name...
  -                                                     attrName = 
substring(origAttrName, indexOfNSSep + 1);
  +                                                     substring(origAttrName, 
attrName, indexOfNSSep + 1);
                                                }
                                        }
   
  @@ -293,7 +293,7 @@
                                                // off...
                                                if (fPrefixIsXMLNS == true)
                                                {
  -                                                     assign(attrName, 
substring(attrName, indexOfNSSep + 1));
  +                                                     attrName.erase(0, indexOfNSSep 
+ 1);
                                                }
   
                                                // Get a new, unique namespace 
prefix...
  @@ -347,7 +347,7 @@
   
                                        XalanDOMString&         nsprefix = 
nsprefixGuard.get();
   
  -                                     nsprefix = substring(origAttrName, 0, 
indexOfNSSep);
  +                                     substring(origAttrName, nsprefix, 0, 
indexOfNSSep);
   
                                        const XalanDOMString* const             
theNamespace =
                                                getNamespaceForPrefix(nsprefix);
  
  
  
  1.37      +2 -2      xml-xalan/c/src/XSLT/ElemElement.cpp
  
  Index: ElemElement.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemElement.cpp,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- ElemElement.cpp   2 Apr 2002 06:12:50 -0000       1.36
  +++ ElemElement.cpp   6 May 2002 05:31:57 -0000       1.37
  @@ -207,7 +207,7 @@
   
                if (haveNamespace == true)
                {
  -                     prefix = substring(elemName, 0, indexOfNSSep);
  +                     substring(elemName, prefix, 0, indexOfNSSep);
   
                        const XalanDOMString* const             theNamespace =
                                executionContext.getResultNamespaceForPrefix(prefix);
  @@ -232,7 +232,7 @@
                                        {
                                                hasUnresolvedPrefix = true;
   
  -                                             elemName = substring(elemName, 
indexOfNSSep + 1);
  +                                             elemName.erase(0, indexOfNSSep + 1);
                                        }
                                        else
                                        {
  
  
  
  1.48      +13 -12    xml-xalan/c/src/XSLT/ElemLiteralResult.cpp
  
  Index: ElemLiteralResult.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ElemLiteralResult.cpp,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- ElemLiteralResult.cpp     23 Feb 2002 04:23:16 -0000      1.47
  +++ ElemLiteralResult.cpp     6 May 2002 05:31:57 -0000       1.48
  @@ -107,40 +107,41 @@
   
        m_avts.reserve(nAttrs);
   
  +     XalanDOMString  theBuffer;
  +
        for(unsigned int i = 0; i < nAttrs; i++)
        {
                const XalanDOMChar*     const   aname = atts.getName(i);
   
                bool                                                            
needToProcess = true;
                const XalanDOMString::size_type         indexOfNSSep = indexOf(aname, 
XalanUnicode::charColon);
  +             const XalanDOMString::size_type         len = length(aname);
   
  -             XalanDOMString                          prefix;
  -
  -             if(indexOfNSSep < length(aname))
  +             if(indexOfNSSep < len)
                {
  -                     prefix = substring(aname, 0, indexOfNSSep);
  +                     substring(aname, theBuffer, 0, indexOfNSSep);
   
  -                     if(!equals(prefix, DOMServices::s_XMLNamespace))
  +                     if(!equals(theBuffer, DOMServices::s_XMLNamespace))
                        {
                                const XalanDOMString* const             ns =
  -                                             getNamespaceForPrefixInternal(prefix);
  +                                             
getNamespaceForPrefixInternal(theBuffer);
   
                                if(ns == 0)
                                {
                                        constructionContext.error(
  -                                             "Cannot resolve namespace prefix: " + 
prefix,
  +                                             "Cannot resolve namespace prefix",
                                                0,
                                                this);
                                }
                                else if(equals(*ns, 
stylesheetTree.getXSLTNamespaceURI()))
                                {
  -                                     const XalanDOMString localName = 
substring(aname, indexOfNSSep + 1);
  +                                     theBuffer.assign(aname + indexOfNSSep + 1, len 
- (indexOfNSSep + 1));
   
  -                                     if(processPrefixControl(constructionContext, 
stylesheetTree, localName, atts.getValue(i)) == true)
  +                                     if(processPrefixControl(constructionContext, 
stylesheetTree, theBuffer, atts.getValue(i)) == true)
                                        {
                                                needToProcess = false;
                                        }
  -                                     else if (equals(localName, 
Constants::ATTRNAME_VERSION) == true)
  +                                     else if (equals(theBuffer, 
Constants::ATTRNAME_VERSION) == true)
                                        {
                                                const XalanDOMChar*     const   value 
= atts.getValue(i);
   
  @@ -223,7 +224,7 @@
   
                if (theColonIndex != length(theName))
                {
  -                     m_namespacesHandler.addActivePrefix(substring(theName, 0, 
theColonIndex));
  +                     m_namespacesHandler.addActivePrefix(XalanDOMString(theName, 0, 
theColonIndex));
                }
        }
   
  @@ -382,7 +383,7 @@
   
                if(indexOfNSSep < length(attrName))
                {
  -                     const XalanDOMString    prefix = substring(attrName, 0, 
indexOfNSSep);
  +                     const XalanDOMString    prefix(attrName, indexOfNSSep);
   
                        const XalanDOMString* const             ns = 
getStylesheet().getNamespaceForPrefixFromStack(prefix);
   
  
  
  
  1.56      +1 -1      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.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- ElemNumber.cpp    11 Apr 2002 05:54:50 -0000      1.55
  +++ ElemNumber.cpp    6 May 2002 05:31:57 -0000       1.56
  @@ -1664,7 +1664,7 @@
                }
        }
   
  -     return substring(*m_string, start, m_currentPosition);
  +     return XalanDOMString(*m_string, start, m_currentPosition);
   }
   
   
  
  
  
  1.9       +2 -2      xml-xalan/c/src/XSLT/ExtensionFunctionHandler.cpp
  
  Index: ExtensionFunctionHandler.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/ExtensionFunctionHandler.cpp,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ExtensionFunctionHandler.cpp      21 Nov 2000 22:33:49 -0000      1.8
  +++ ExtensionFunctionHandler.cpp      6 May 2002 05:31:57 -0000       1.9
  @@ -186,13 +186,13 @@
        {
                try 
                {
  -                     XalanDOMString  cname = m_scriptSrcURL;
  +                     XalanDOMString  cname(m_scriptSrcURL);
   
                        bool isClass = false;
   
                        if (startsWith(m_scriptSrcURL, "class:")) 
                        {
  -                             cname = substring(m_scriptSrcURL, 6);
  +                             substring(m_scriptSrcURL, cname, 6);
   
                                isClass = true;
                        }
  
  
  
  1.16      +11 -5     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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- FunctionElementAvailable.cpp      26 Sep 2001 21:30:23 -0000      1.15
  +++ FunctionElementAvailable.cpp      6 May 2002 05:31:57 -0000       1.16
  @@ -92,11 +92,17 @@
        const XalanDOMString::size_type         nameLength = length(fullName);
        const XalanDOMString::size_type         indexOfNSSep = indexOf(fullName, 
XalanUnicode::charColon);
   
  -     const XalanDOMString                    prefix =
  -             indexOfNSSep < nameLength ? substring(fullName, 0, indexOfNSSep) : 
XalanDOMString();
  +     XPathExecutionContext::GetAndReleaseCachedString        
guard(executionContext);
  +
  +     XalanDOMString&         theBuffer = guard.get();
  +
  +     if (indexOfNSSep < nameLength)
  +     {
  +             substring(fullName, theBuffer, 0, indexOfNSSep);
  +     }
   
        const XalanDOMString* const             theNamespace =
  -             executionContext.getNamespaceForPrefix(prefix);
  +             executionContext.getNamespaceForPrefix(theBuffer);
   
        if (theNamespace == 0 || length(*theNamespace) == 0)
        {
  @@ -110,9 +116,9 @@
                }
                else
                {
  -                     const XalanDOMString    elementName =  substring(fullName, 
indexOfNSSep + 1);
  +                     substring(fullName, theBuffer, indexOfNSSep + 1);
   
  -                     return 
executionContext.getXObjectFactory().createBoolean(executionContext.elementAvailable(*theNamespace,
 elementName));
  +                     return 
executionContext.getXObjectFactory().createBoolean(executionContext.elementAvailable(*theNamespace,
 theBuffer));
                }
        }
   }
  
  
  
  1.15      +18 -5     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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- FunctionFunctionAvailable.cpp     26 Sep 2001 21:30:23 -0000      1.14
  +++ FunctionFunctionAvailable.cpp     6 May 2002 05:31:57 -0000       1.15
  @@ -96,20 +96,33 @@
        const XalanDOMString::size_type         nameLength = length(fullName);
        const XalanDOMString::size_type         indexOfNSSep = indexOf(fullName, 
XalanUnicode::charColon);
   
  -     const XalanDOMString    prefix = indexOfNSSep < nameLength ? 
substring(fullName, 0, indexOfNSSep) : XalanDOMString();
  +     XPathExecutionContext::GetAndReleaseCachedString        
guard(executionContext);
  +
  +     XalanDOMString&         theBuffer = guard.get();
  +
  +     if (indexOfNSSep < nameLength)
  +     {
  +             substring(fullName, theBuffer, 0, indexOfNSSep);
  +     }
   
        const XalanDOMString*   theNamespace =
  -                     executionContext.getNamespaceForPrefix(prefix);
  +                     executionContext.getNamespaceForPrefix(theBuffer);
   
        if (theNamespace == 0)
        {
                theNamespace = &s_emptyString;
        }
   
  -     const XalanDOMString    functionName =
  -                     indexOfNSSep == nameLength ? fullName : substring(fullName, 
indexOfNSSep + 1);
  +     if (indexOfNSSep == nameLength)
  +     {
  +             return 
executionContext.getXObjectFactory().createBoolean(executionContext.functionAvailable(*theNamespace,
 fullName));
  +     }
  +     else
  +     {
  +             substring(fullName, theBuffer, indexOfNSSep + 1);
   
  -     return 
executionContext.getXObjectFactory().createBoolean(executionContext.functionAvailable(*theNamespace,
 functionName));
  +             return 
executionContext.getXObjectFactory().createBoolean(executionContext.functionAvailable(*theNamespace,
 theBuffer));
  +     }
   }
   
   
  
  
  
  1.22      +7 -5      xml-xalan/c/src/XSLT/FunctionGenerateID.cpp
  
  Index: FunctionGenerateID.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/FunctionGenerateID.cpp,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- FunctionGenerateID.cpp    6 Apr 2002 19:38:39 -0000       1.21
  +++ FunctionGenerateID.cpp    6 May 2002 05:31:57 -0000       1.22
  @@ -97,14 +97,16 @@
                XalanDOMString&         theResult)
   {
        assert(theNode != 0);
  -     assert(theNode->getOwnerDocument() != 0);
  -
  -     PointerToDOMString(theNode->getOwnerDocument(), theResult);
  -
  -     append(theResult, XalanDOMChar(XalanUnicode::charFullStop));
   
        // We're assuming here that each node has an implementation with a 
        // unique address that we can convert into a string...
  +     if (theNode->getOwnerDocument() != 0)
  +     {
  +             PointerToDOMString(theNode->getOwnerDocument(), theResult);
  +
  +             append(theResult, XalanDOMChar(XalanUnicode::charFullStop));
  +     }
  +
        PointerToDOMString(theNode, theResult);
   }
   
  
  
  
  1.24      +21 -11    xml-xalan/c/src/XSLT/FunctionSystemProperty.cpp
  
  Index: FunctionSystemProperty.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/FunctionSystemProperty.cpp,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- FunctionSystemProperty.cpp        11 Apr 2002 05:54:50 -0000      1.23
  +++ FunctionSystemProperty.cpp        6 May 2002 05:31:57 -0000       1.24
  @@ -74,7 +74,13 @@
   
   
   FunctionSystemProperty::FunctionSystemProperty() :
  -     Function()
  +     Function(),
  +     
m_xsltNamespaceURI(XALAN_STATIC_UCODE_STRING("http://www.w3.org/1999/XSL/Transform";)),
  +     m_versionPropertyString(XALAN_STATIC_UCODE_STRING("version")),
  +     m_vendorPropertyString(XALAN_STATIC_UCODE_STRING("vendor")),
  +     m_vendorURLPropertyString(XALAN_STATIC_UCODE_STRING("vendor-url")),
  +     m_vendorString(XALAN_STATIC_UCODE_STRING("Apache Software Foundation")),
  +     m_vendorURLString(XALAN_STATIC_UCODE_STRING("http://xml.apache.org/xalan-c";))
   {
   }
   
  @@ -107,34 +113,38 @@
   
        if(indexOfNSSep < fullNameLength)
        {
  -             const XalanDOMString    prefix = substring(fullName, 0, indexOfNSSep);
  +             XPathExecutionContext::GetAndReleaseCachedString        
guard(executionContext);
   
  -             const XalanDOMString* const             nspace = 
executionContext.getNamespaceForPrefix(prefix);
  +             XalanDOMString&         theBuffer = guard.get();
  +
  +             substring(fullName, theBuffer, 0, indexOfNSSep);
  +
  +             const XalanDOMString* const             nspace = 
executionContext.getNamespaceForPrefix(theBuffer);
   
                if (nspace != 0)
                {
  -                     const XalanDOMString    propName = substring(fullName, 
indexOfNSSep + 1);
  +                     substring(fullName, theBuffer, indexOfNSSep + 1);
   
  -                     if(startsWith(*nspace, 
XALAN_STATIC_UCODE_STRING("http://www.w3.org/1999/XSL/Transform";)))
  +                     if(startsWith(*nspace, m_xsltNamespaceURI))
                        {
  -                             if(equals(propName, 
XALAN_STATIC_UCODE_STRING("version")))
  +                             if(equals(theBuffer, m_versionPropertyString))
                                {
                                        numberResult = 1.0;
   
                                        fNumberResult = true;
                                }
  -                             else if(equals(propName, 
XALAN_STATIC_UCODE_STRING("vendor")))
  +                             else if(equals(theBuffer, m_vendorPropertyString))
                                {
  -                                     result = XALAN_STATIC_UCODE_STRING("Apache 
Software Foundation");
  +                                     result = m_vendorString;
                                }
  -                             else if(equals(propName, 
XALAN_STATIC_UCODE_STRING("vendor-url")))
  +                             else if(equals(theBuffer, m_vendorURLPropertyString))
                                {
  -                                     result = 
XALAN_STATIC_UCODE_STRING("http://xml.apache.org/xalan-c";);
  +                                     result = m_vendorURLString;
                                }
                                else
                                {
                                        executionContext.error(
  -                                             "XSL Property not supported: " + 
fullName,
  +                                             "Unknown property in 
system-property()",
                                                context,
                                                locator);
                                }
  
  
  
  1.8       +9 -0      xml-xalan/c/src/XSLT/FunctionSystemProperty.hpp
  
  Index: FunctionSystemProperty.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/FunctionSystemProperty.hpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- FunctionSystemProperty.hpp        14 Sep 2001 20:49:43 -0000      1.7
  +++ FunctionSystemProperty.hpp        6 May 2002 05:31:57 -0000       1.8
  @@ -108,6 +108,15 @@
   
        bool
        operator==(const FunctionSystemProperty&) const;
  +
  +
  +     // Data members...
  +     const XalanDOMString    m_xsltNamespaceURI;
  +     const XalanDOMString    m_versionPropertyString;
  +     const XalanDOMString    m_vendorPropertyString;
  +     const XalanDOMString    m_vendorURLPropertyString;
  +     const XalanDOMString    m_vendorString;
  +     const XalanDOMString    m_vendorURLString;
   };
   
   
  
  
  
  1.19      +6 -2      xml-xalan/c/src/XSLT/NamespacesHandler.cpp
  
  Index: NamespacesHandler.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/NamespacesHandler.cpp,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- NamespacesHandler.cpp     19 Dec 2001 17:57:31 -0000      1.18
  +++ NamespacesHandler.cpp     6 May 2002 05:31:57 -0000       1.19
  @@ -321,8 +321,12 @@
        // don't exclude its prefix.
        const XalanDOMString::size_type         indexOfNSSep = indexOf(theElementName, 
XalanUnicode::charColon);
   
  -     const XalanDOMString    thePrefix = indexOfNSSep < length(theElementName) ?
  -                                     substring(theElementName, 0, indexOfNSSep) : 
XalanDOMString();
  +     XalanDOMString  thePrefix;
  +     
  +     if (indexOfNSSep < length(theElementName))
  +     {
  +             substring(theElementName, thePrefix, 0, indexOfNSSep);
  +     }
   
        processExcludeResultPrefixes(thePrefix);
   
  
  
  
  1.75      +20 -9     xml-xalan/c/src/XSLT/Stylesheet.cpp
  
  Index: Stylesheet.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/Stylesheet.cpp,v
  retrieving revision 1.74
  retrieving revision 1.75
  diff -u -r1.74 -r1.75
  --- Stylesheet.cpp    6 Apr 2002 19:38:39 -0000       1.74
  +++ Stylesheet.cpp    6 May 2002 05:31:57 -0000       1.75
  @@ -301,6 +301,8 @@
   
        NamespaceVectorType     namespaces;
   
  +     XalanDOMString                  prefix;
  +
        for(unsigned int i = 0; i < nAttrs; i++)
        {
                const XalanDOMChar* const       aname = atts.getName(i);
  @@ -310,9 +312,16 @@
   
                if (equals(aname, DOMServices::s_XMLNamespace) || isPrefix) 
                {
  -                     const XalanDOMString    p = isPrefix ? substring(aname, 6) : 
XalanDOMString();
  +                     if (isPrefix == false)
  +                     {
  +                             prefix.clear();
  +                     }
  +                     else
  +                     {
  +                             substring(aname, prefix, 
DOMServices::s_XMLNamespaceWithSeparatorLength);
  +                     }
   
  -                     namespaces.push_back(NameSpace(p, XalanDOMString(value)));
  +                     namespaces.push_back(NameSpace(prefix, XalanDOMString(value)));
                }
        }
   
  @@ -480,7 +489,7 @@
   
                if(indexOfNSSep < length(attrName))
                {
  -                     const XalanDOMString    prefix = substring(attrName, 0, 
indexOfNSSep);
  +                     const XalanDOMString    prefix(attrName, indexOfNSSep);
                        const XalanDOMString*   ns = 
getNamespaceForPrefixFromStack(prefix);
   
                        attrOK = ns != 0 && !::isEmpty(*ns) && !equals(*ns, 
constructionContext.getXSLTNamespaceURI());
  @@ -503,12 +512,14 @@
   
        const XalanDOMString::size_type         indexOfNSSep = indexOf(nodeName, 
XalanUnicode::charColon);
   
  -     const XalanDOMString    prefix =
  -             indexOfNSSep < length(nodeName) ?
  -                             substring(nodeName, 0, indexOfNSSep) :
  -                             XalanDOMString();
  -
  -     return getNamespaceForPrefixFromStack(prefix);
  +     if (indexOfNSSep == length(nodeName))
  +     {
  +             return getNamespaceForPrefixFromStack(s_emptyString);
  +     }
  +     else
  +     {
  +             return getNamespaceForPrefixFromStack(XalanDOMString(nodeName, 
indexOfNSSep));
  +     }
   }
   
   
  
  
  
  1.77      +8 -3      xml-xalan/c/src/XSLT/StylesheetHandler.cpp
  
  Index: StylesheetHandler.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/StylesheetHandler.cpp,v
  retrieving revision 1.76
  retrieving revision 1.77
  diff -u -r1.76 -r1.77
  --- StylesheetHandler.cpp     28 Mar 2002 04:55:39 -0000      1.76
  +++ StylesheetHandler.cpp     6 May 2002 05:31:57 -0000       1.77
  @@ -370,11 +370,16 @@
                const XalanDOMString::size_type         nameLength = length(name);
                const XalanDOMString::size_type         index = indexOf(name, 
XalanUnicode::charColon);
   
  -             const XalanDOMString    localName = index == nameLength ? 
XalanDOMString(name) : substring(name, index + 1);
  -
  -             if(length(ns) == 0 && nameLength != length(localName))
  +             if(length(ns) == 0 && index < nameLength)
                {
                        error("Could not resolve prefix.", locator);
  +             }
  +
  +             XalanDOMString  localName(name, nameLength);
  +
  +             if (index < nameLength)
  +             {
  +                     localName.erase(0, index + 1);
                }
   
                ElemTemplateElement* elem = 0;
  
  
  
  1.141     +110 -75   xml-xalan/c/src/XSLT/XSLTEngineImpl.cpp
  
  Index: XSLTEngineImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/XSLTEngineImpl.cpp,v
  retrieving revision 1.140
  retrieving revision 1.141
  diff -u -r1.140 -r1.141
  --- XSLTEngineImpl.cpp        30 Apr 2002 04:43:23 -0000      1.140
  +++ XSLTEngineImpl.cpp        6 May 2002 05:31:57 -0000       1.141
  @@ -280,73 +280,62 @@
        {
                // Didn't get a stylesheet from the input source, so look for a
                // stylesheet processing instruction...
  -             XalanDOMString                  stylesheetURI;
   
                // The PI must be a child of the document...
  -             XalanNode*                              child = 
sourceTree->getFirstChild();
  +             const XalanNode*        child = sourceTree->getFirstChild();
   
  -#if !defined(XALAN_NO_NAMESPACES)
  -             using std::vector;
  -#endif
  +             XalanDOMString          theCurrentToken;
  +             XalanDOMString          theStylesheetURI;
   
  -             vector<XalanDOMString>  hrefs;
  +             bool                    isOK = false;
   
  -             const XalanDOMString    
stylesheetNodeName(XALAN_STATIC_UCODE_STRING("xml-stylesheet"));
  -             const XalanDOMString    typeString(XALAN_STATIC_UCODE_STRING("type"));
  -             const XalanDOMString    
typeValueString1(XALAN_STATIC_UCODE_STRING("text/xml"));
  -             const XalanDOMString    
typeValueString2(XALAN_STATIC_UCODE_STRING("text/xsl"));
  -             const XalanDOMString    
typeValueString3(XALAN_STATIC_UCODE_STRING("application/xml"));
  -             const XalanDOMString    
typeValueString4(XALAN_STATIC_UCODE_STRING("application/xml+xslt"));
  -
  -             // $$$ ToDo: This code is much like that in getStyleSheetURIFromDoc().
  -             // Why is it repeated???
  -             // $$$ ToDo: Move these embedded strings from inside these loops
  -             // out here...
  -             // $$$ ToDo: These loops are a mess of repeated use of the
  -             // same data values.
  -             while(child != 0)
  +             while(child != 0 && isOK == false && theStylesheetURI.empty() == true)
                {
                        if(XalanNode::PROCESSING_INSTRUCTION_NODE == 
child->getNodeType())
                        {
                                const XalanDOMString&   nodeName = 
child->getNodeName();
   
  -                             if(equals(nodeName, stylesheetNodeName))
  +                             if(equals(nodeName, s_stylesheetNodeName))
                                {
  -                                     bool isOK = false;
  +                                     StringTokenizer         
tokenizer(child->getNodeValue(), s_piTokenizerString);
   
  -                                     StringTokenizer         
tokenizer(child->getNodeValue(), XALAN_STATIC_UCODE_STRING(" \t="));
  -
  -                                     while(tokenizer.hasMoreTokens())
  +                                     while(tokenizer.hasMoreTokens() == true && 
(isOK == false || theStylesheetURI.empty() == true))
                                        {
  -                                             if(equals(tokenizer.nextToken(), 
typeString)) // "type"
  +                                             tokenizer.nextToken(theCurrentToken);
  +
  +                                             if(equals(theCurrentToken, 
s_typeString))
                                                {
  -                                                     XalanDOMString  typeVal = 
tokenizer.nextToken();
  +                                                     
tokenizer.nextToken(theCurrentToken);
   
  -                                                     typeVal = substring(typeVal, 
1, length(typeVal) - 1);
   
  -                                                     if(equals(typeVal, 
typeValueString1) ||
  -                                                             equals(typeVal, 
typeValueString2) ||
  -                                                             equals(typeVal, 
typeValueString3) ||
  -                                                             equals(typeVal, 
typeValueString4))
  +                                                     const 
XalanDOMString::size_type         theLength =
  +                                                                     
theCurrentToken.length();
  +
  +                                                     if (theLength > 2)
                                                        {
  -                                                             isOK = true;
  +                                                             
theCurrentToken.erase(theLength - 1, 1);
  +                                                             
theCurrentToken.erase(0, 1);
  +
  +                                                             
if(equals(theCurrentToken, s_typeValueString1) ||
  +                                                                     
equals(theCurrentToken, s_typeValueString2) ||
  +                                                                     
equals(theCurrentToken, s_typeValueString3) ||
  +                                                                     
equals(theCurrentToken, s_typeValueString4))
  +                                                             {
  +                                                                     isOK = true;
  +                                                             }
                                                        }
                                                }
  -                                     }
  -
  -                                     if(isOK)
  -                                     {
  -                                             StringTokenizer         
tokenizer(child->getNodeValue(), XALAN_STATIC_UCODE_STRING(" \t="));
  -
  -                                             while(tokenizer.hasMoreTokens())
  +                                             else if(equals(theCurrentToken, 
s_hrefString))
                                                {
  -                                                     const XalanDOMString    
theCurrentToken = tokenizer.nextToken();
  +                                                     
tokenizer.nextToken(theCurrentToken);
  +
  +                                                     const 
XalanDOMString::size_type         theLength =
  +                                                                     
theCurrentToken.length();
   
  -                                                     if(equals(theCurrentToken, 
XALAN_STATIC_UCODE_STRING("href")))
  +                                                     if (theLength > 2)
                                                        {
  -                                                             stylesheetURI = 
tokenizer.nextToken();
  -                                                             stylesheetURI = 
substring(stylesheetURI, 1, length(stylesheetURI) - 1);
  -                                                             
hrefs.push_back(stylesheetURI);
  +                                                             // Trim of the 
starting and trailing delimiters...
  +                                                             
theStylesheetURI.assign(theCurrentToken, 1, theLength - 2);
                                                        }
                                                }
                                        }
  @@ -356,36 +345,18 @@
                        child = child->getNextSibling();
                }
   
  -             bool isRoot = true;
  -             Stylesheet* prevStylesheet = 0;
  -                     
  -             if (hrefs.empty() == false)
  +             if (isOK == true && theStylesheetURI.empty() == false)
                {
                        const XalanDOMChar* const       pxch = 
inputSource.getSystemId();
   
                        const XalanDOMString            sysid(pxch == 0 ? 
&s_dummyString : pxch); 
   
  -                     do
  -                     {
  -                             const XalanDOMString&   ref =  hrefs.back();
  -
  -                             Stylesheet* stylesheet =
  -                                                     getStylesheetFromPIURL(
  -                                                             ref,
  -                                                             *sourceTree,
  -                                                             sysid,
  -                                                             isRoot,
  -                                                             constructionContext);
  -
  -                             if(false == isRoot)
  -                             {
  -                                     prevStylesheet->addImport(stylesheet, false);
  -                             }
  -
  -                             prevStylesheet = stylesheet;
  -                             isRoot = false;
  -                             hrefs.pop_back();
  -                     } while(!hrefs.empty());
  +                     getStylesheetFromPIURL(
  +                                     theStylesheetURI,
  +                                     *sourceTree,
  +                                     sysid,
  +                                     true,
  +                                     constructionContext);
                }
        }
   
  @@ -686,7 +657,7 @@
        {
                diag("Locating stylesheet from fragment identifier...");
   
  -             const XalanDOMString    fragID = substring(localXSLURLString, 1);
  +             const XalanDOMString    fragID(localXSLURLString, 1);
   
                const XalanElement*             nsNode = 0;
   
  @@ -1772,7 +1743,7 @@
   
                        XalanDOMString&         prefix = prefixGuard.get();
   
  -                     prefix = substring(aname, 
DOMServices::s_XMLNamespaceWithSeparatorLength);
  +                     substring(aname, prefix, 
DOMServices::s_XMLNamespaceWithSeparatorLength);
   
                        const XalanDOMString* const     theNamespace = 
getResultNamespaceForPrefix(prefix);
   
  @@ -3432,11 +3403,28 @@
   
   
   
  -static XalanDOMString                                                        
s_XSLNameSpaceURL;
  +static XalanDOMString        s_XSLNameSpaceURL;
  +
  +static XalanDOMString        s_XSLT4JNameSpaceURL;
  +
  +static XalanDOMString        s_uniqueNamespacePrefix;
  +
  +static XalanDOMString        s_stylesheetNodeName;
  +
  +static XalanDOMString        s_typeString;
  +
  +static XalanDOMString        s_hrefString;
  +
  +static XalanDOMString        s_piTokenizerString;
  +
  +static XalanDOMString        s_typeValueString1;
   
  -static XalanDOMString                                                        
s_XSLT4JNameSpaceURL;
  +static XalanDOMString        s_typeValueString2;
  +
  +static XalanDOMString        s_typeValueString3;
  +
  +static XalanDOMString        s_typeValueString4;
   
  -static XalanDOMString                                                        
s_uniqueNamespacePrefix;
   
   static XSLTEngineImpl::AttributeKeysMapType          s_attributeKeys;
   
  @@ -3452,6 +3440,21 @@
   
   const XalanDOMString&        XSLTEngineImpl::s_uniqueNamespacePrefix = 
::s_uniqueNamespacePrefix;
   
  +const XalanDOMString&        XSLTEngineImpl::s_stylesheetNodeName = 
::s_stylesheetNodeName;
  +
  +const XalanDOMString&        XSLTEngineImpl::s_typeString = ::s_typeString;
  +
  +const XalanDOMString&        XSLTEngineImpl::s_hrefString = ::s_hrefString;
  +
  +const XalanDOMString&        XSLTEngineImpl::s_piTokenizerString = 
::s_piTokenizerString;
  +
  +const XalanDOMString&        XSLTEngineImpl::s_typeValueString1 = 
::s_typeValueString1;
  +
  +const XalanDOMString&        XSLTEngineImpl::s_typeValueString2 = 
::s_typeValueString2;
  +
  +const XalanDOMString&        XSLTEngineImpl::s_typeValueString3 = 
::s_typeValueString3;
  +
  +const XalanDOMString&        XSLTEngineImpl::s_typeValueString4 = 
::s_typeValueString4;
   
   const XSLTEngineImpl::AttributeKeysMapType&          
XSLTEngineImpl::s_attributeKeys = ::s_attributeKeys;
   
  @@ -3468,6 +3471,22 @@
   
        ::s_uniqueNamespacePrefix = XALAN_STATIC_UCODE_STRING("ns");
   
  +     ::s_stylesheetNodeName = XALAN_STATIC_UCODE_STRING("xml-stylesheet");
  +
  +     ::s_typeString = XALAN_STATIC_UCODE_STRING("type");
  +
  +     ::s_hrefString = XALAN_STATIC_UCODE_STRING("href");
  +
  +     ::s_piTokenizerString = XALAN_STATIC_UCODE_STRING(" \t=");
  +
  +     ::s_typeValueString1 = XALAN_STATIC_UCODE_STRING("text/xml");
  +
  +     ::s_typeValueString2 = XALAN_STATIC_UCODE_STRING("text/xsl");
  +
  +     ::s_typeValueString3 = XALAN_STATIC_UCODE_STRING("application/xml");
  +
  +     ::s_typeValueString4 = XALAN_STATIC_UCODE_STRING("application/xml+xslt");
  +
        installFunctions();
   
        initializeAttributeKeysTable(::s_attributeKeys);
  @@ -3491,4 +3510,20 @@
        releaseMemory(::s_XSLT4JNameSpaceURL);
   
        releaseMemory(::s_XSLNameSpaceURL);
  +
  +     releaseMemory(::s_stylesheetNodeName);
  +
  +     releaseMemory(::s_typeString);
  +
  +     releaseMemory(::s_hrefString);
  +
  +     releaseMemory(::s_piTokenizerString);
  +
  +     releaseMemory(::s_typeValueString1);
  +
  +     releaseMemory(::s_typeValueString2);
  +
  +     releaseMemory(::s_typeValueString3);
  +
  +     releaseMemory(::s_typeValueString4);
   }
  
  
  
  1.86      +10 -1     xml-xalan/c/src/XSLT/XSLTEngineImpl.hpp
  
  Index: XSLTEngineImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XSLT/XSLTEngineImpl.hpp,v
  retrieving revision 1.85
  retrieving revision 1.86
  diff -u -r1.85 -r1.86
  --- XSLTEngineImpl.hpp        30 Apr 2002 04:43:23 -0000      1.85
  +++ XSLTEngineImpl.hpp        6 May 2002 05:31:57 -0000       1.86
  @@ -1668,7 +1668,16 @@
   
        static const XalanDOMString             s_emptyString;
   
  -    // Not implemented...
  +     static const XalanDOMString&    s_stylesheetNodeName;
  +     static const XalanDOMString&    s_typeString;
  +     static const XalanDOMString&    s_hrefString;
  +     static const XalanDOMString&    s_piTokenizerString;
  +     static const XalanDOMString&    s_typeValueString1;
  +     static const XalanDOMString&    s_typeValueString2;
  +     static const XalanDOMString&    s_typeValueString3;
  +     static const XalanDOMString&    s_typeValueString4;
  +
  +     // Not implemented...
       XSLTEngineImpl(const XSLTEngineImpl&);
   
       XSLTEngineImpl&
  
  
  

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

Reply via email to