You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by am...@apache.org on 2009/09/02 17:52:23 UTC

svn commit: r810580 - in /xerces/c/trunk: src/xercesc/internal/ src/xercesc/parsers/ src/xercesc/util/ src/xercesc/validators/DTD/ src/xercesc/validators/common/ tests/src/DOM/DOMTest/

Author: amassari
Date: Wed Sep  2 15:52:22 2009
New Revision: 810580

URL: http://svn.apache.org/viewvc?rev=810580&view=rev
Log:
A few performance improvements

Modified:
    xerces/c/trunk/src/xercesc/internal/DGXMLScanner.cpp
    xerces/c/trunk/src/xercesc/internal/DGXMLScanner.hpp
    xerces/c/trunk/src/xercesc/internal/ElemStack.cpp
    xerces/c/trunk/src/xercesc/internal/ElemStack.hpp
    xerces/c/trunk/src/xercesc/internal/IGXMLScanner.cpp
    xerces/c/trunk/src/xercesc/internal/IGXMLScanner.hpp
    xerces/c/trunk/src/xercesc/internal/IGXMLScanner2.cpp
    xerces/c/trunk/src/xercesc/internal/ReaderMgr.cpp
    xerces/c/trunk/src/xercesc/internal/ReaderMgr.hpp
    xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp
    xerces/c/trunk/src/xercesc/internal/SGXMLScanner.hpp
    xerces/c/trunk/src/xercesc/internal/ValidationContextImpl.cpp
    xerces/c/trunk/src/xercesc/internal/WFXMLScanner.cpp
    xerces/c/trunk/src/xercesc/internal/WFXMLScanner.hpp
    xerces/c/trunk/src/xercesc/internal/XMLReader.cpp
    xerces/c/trunk/src/xercesc/internal/XMLReader.hpp
    xerces/c/trunk/src/xercesc/internal/XMLScanner.cpp
    xerces/c/trunk/src/xercesc/internal/XMLScanner.hpp
    xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.cpp
    xerces/c/trunk/src/xercesc/parsers/SAX2XMLReaderImpl.cpp
    xerces/c/trunk/src/xercesc/util/QName.cpp
    xerces/c/trunk/src/xercesc/util/QName.hpp
    xerces/c/trunk/src/xercesc/util/XMLString.cpp
    xerces/c/trunk/src/xercesc/util/XMLString.hpp
    xerces/c/trunk/src/xercesc/validators/DTD/DTDScanner.cpp
    xerces/c/trunk/src/xercesc/validators/common/CMStateSet.hpp
    xerces/c/trunk/tests/src/DOM/DOMTest/DTest.cpp

Modified: xerces/c/trunk/src/xercesc/internal/DGXMLScanner.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/DGXMLScanner.cpp?rev=810580&r1=810579&r2=810580&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/DGXMLScanner.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/DGXMLScanner.cpp Wed Sep  2 15:52:22 2009
@@ -760,7 +760,9 @@
         fDocTypeHandler->resetDocType();
 
     // There must be some space after DOCTYPE
-    if (!fReaderMgr.skipPastSpaces())
+    bool skippedSomething;
+    fReaderMgr.skipPastSpaces(skippedSomething);
+    if (!skippedSomething)
     {
         emitError(XMLErrs::ExpectedWhitespace);
 
@@ -1968,62 +1970,6 @@
     return true;
 }
 
-unsigned int
-DGXMLScanner::resolveQName(const   XMLCh* const qName
-                           ,       XMLBuffer&   prefixBuf
-                           , const short        mode
-                           ,       int&         prefixColonPos)
-{
-    //  Lets split out the qName into a URI and name buffer first. The URI
-    //  can be empty.
-    prefixColonPos = XMLString::indexOf(qName, chColon);
-    if (prefixColonPos == -1)
-    {
-        //  Its all name with no prefix, so put the whole thing into the name
-        //  buffer. Then map the empty string to a URI, since the empty string
-        //  represents the default namespace. This will either return some
-        //  explicit URI which the default namespace is mapped to, or the
-        //  the default global namespace.
-        bool unknown = false;
-
-        prefixBuf.reset();
-        return fElemStack.mapPrefixToURI(XMLUni::fgZeroLenString, (ElemStack::MapModes) mode, unknown);
-    }
-    else
-    {
-        //  Copy the chars up to but not including the colon into the prefix
-        //  buffer.
-        prefixBuf.set(qName, prefixColonPos);
-
-        //  Watch for the special namespace prefixes. We always map these to
-        //  special URIs. 'xml' gets mapped to the official URI that its defined
-        //  to map to by the NS spec. xmlns gets mapped to a special place holder
-        //  URI that we define (so that it maps to something checkable.)
-        const XMLCh* prefixRawBuf = prefixBuf.getRawBuffer();
-        if (XMLString::equals(prefixRawBuf, XMLUni::fgXMLNSString)) {
-
-            // if this is an element, it is an error to have xmlns as prefix
-            if (mode == ElemStack::Mode_Element)
-                emitError(XMLErrs::NoXMLNSAsElementPrefix, qName);
-
-            return fXMLNSNamespaceId;
-        }
-        else if (XMLString::equals(prefixRawBuf, XMLUni::fgXMLString)) {
-            return  fXMLNamespaceId;
-        }
-        else
-        {
-            bool unknown = false;
-            unsigned int uriId = fElemStack.mapPrefixToURI(prefixRawBuf, (ElemStack::MapModes) mode, unknown);
-
-            if (unknown)
-                emitError(XMLErrs::UnknownPrefix, prefixRawBuf);
-
-            return uriId;
-        }
-    }
-}
-
 // ---------------------------------------------------------------------------
 //  DGXMLScanner: Grammar preparsing
 // ---------------------------------------------------------------------------
@@ -2442,39 +2388,6 @@
 }
 
 
-unsigned int
-DGXMLScanner::resolvePrefix(  const   XMLCh* const        prefix
-                              , const ElemStack::MapModes mode)
-{
-    //  Watch for the special namespace prefixes. We always map these to
-    //  special URIs. 'xml' gets mapped to the official URI that its defined
-    //  to map to by the NS spec. xmlns gets mapped to a special place holder
-    //  URI that we define (so that it maps to something checkable.)
-    if (XMLString::equals(prefix, XMLUni::fgXMLNSString))
-        return fXMLNSNamespaceId;
-    else if (XMLString::equals(prefix, XMLUni::fgXMLString))
-        return fXMLNamespaceId;
-
-    //  Ask the element stack to search up itself for a mapping for the
-    //  passed prefix.
-    bool unknown;
-    unsigned int uriId = fElemStack.mapPrefixToURI(prefix, mode, unknown);
-
-    // If it was unknown, then the URI was faked in but we have to issue an error
-    if (unknown)
-        emitError(XMLErrs::UnknownPrefix, prefix);
-
-    // check to see if uriId is empty; in XML 1.1 an emptynamespace is okay unless
-    // we are trying to use it.
-    if (*prefix &&
-        mode == ElemStack::Mode_Element &&
-        fXMLVersion != XMLReader::XMLV1_0 &&
-        uriId == fElemStack.getEmptyNamespaceId())
-        emitError(XMLErrs::UnknownPrefix, prefix);
-
-    return uriId;
-}
-
 //  This method will reset the scanner data structures, and related plugged
 //  in stuff, for a new scan session. We get the input source for the primary
 //  XML entity, create the reader for it, and push it on the stack so that

Modified: xerces/c/trunk/src/xercesc/internal/DGXMLScanner.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/DGXMLScanner.hpp?rev=810580&r1=810579&r2=810580&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/DGXMLScanner.hpp (original)
+++ xerces/c/trunk/src/xercesc/internal/DGXMLScanner.hpp Wed Sep  2 15:52:22 2009
@@ -66,13 +66,6 @@
     virtual const XMLCh* getName() const;
     virtual NameIdPool<DTDEntityDecl>* getEntityDeclPool();
     virtual const NameIdPool<DTDEntityDecl>* getEntityDeclPool() const;
-    virtual unsigned int resolveQName
-    (
-        const   XMLCh* const        qName
-        ,       XMLBuffer&          prefixBufToFill
-        , const short               mode
-        ,       int&                prefixColonPos
-    );
     virtual void scanDocument
     (
         const   InputSource&    src
@@ -125,11 +118,6 @@
         ,       XMLElementDecl*             elemDecl
         ,       RefVectorOf<XMLAttr>&       toFill
     );
-    unsigned int resolvePrefix
-    (
-        const   XMLCh* const        prefix
-        , const ElemStack::MapModes mode
-    );
     void updateNSMap
     (
         const   XMLCh* const attrPrefix

Modified: xerces/c/trunk/src/xercesc/internal/ElemStack.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/ElemStack.cpp?rev=810580&r1=810579&r2=810580&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/ElemStack.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/ElemStack.cpp Wed Sep  2 15:52:22 2009
@@ -292,21 +292,12 @@
 
 
 unsigned int ElemStack::mapPrefixToURI( const   XMLCh* const    prefixToMap
-                                        , const MapModes        mode
                                         ,       bool&           unknown) const
 {
     // Assume we find it
     unknown = false;
 
     //
-    //  If the prefix is empty, and we are in attribute mode, then we assign
-    //  it to the empty namespace because the default namespace does not
-    //  apply to attributes.
-    //
-    if (!*prefixToMap && (mode == Mode_Attribute))
-        return fEmptyNamespaceId;
-
-    //
     //  Map the prefix to its unique id, from the prefix string pool. If its
     //  not a valid prefix, then its a failure.
     //
@@ -689,7 +680,6 @@
 
 
 unsigned int WFElemStack::mapPrefixToURI( const   XMLCh* const    prefixToMap
-                                          , const MapModes        mode
                                           ,       bool&           unknown) const
 {
     // Assume we find it
@@ -707,14 +697,6 @@
     }
 
     //
-    //  If the prefix is empty, and we are in attribute mode, then we assign
-    //  it to the empty namespace because the default namespace does not
-    //  apply to attributes.
-    //
-    if (!*prefixToMap && (mode == Mode_Attribute))
-        return fEmptyNamespaceId;
-
-    //
     //  Check for the special prefixes 'xml' and 'xmlns' since they cannot
     //  be overridden.
     //

Modified: xerces/c/trunk/src/xercesc/internal/ElemStack.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/ElemStack.hpp?rev=810580&r1=810579&r2=810580&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/ElemStack.hpp (original)
+++ xerces/c/trunk/src/xercesc/internal/ElemStack.hpp Wed Sep  2 15:52:22 2009
@@ -185,7 +185,6 @@
     unsigned int mapPrefixToURI
     (
         const   XMLCh* const    prefixToMap
-        , const MapModes        mode
         ,       bool&           unknown
     )   const;
     ValueVectorOf<PrefMapElem*>* getNamespaceMap() const;
@@ -361,7 +360,6 @@
     unsigned int mapPrefixToURI
     (
         const   XMLCh* const    prefixToMap
-        , const MapModes        mode
         ,       bool&           unknown
     )   const;
 

Modified: xerces/c/trunk/src/xercesc/internal/IGXMLScanner.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/IGXMLScanner.cpp?rev=810580&r1=810579&r2=810580&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/IGXMLScanner.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/IGXMLScanner.cpp Wed Sep  2 15:52:22 2009
@@ -605,18 +605,15 @@
         {
             if ((nextCh != chForwardSlash) && (nextCh != chCloseAngle))
             {
-                if (fReaderMgr.getCurrentReader()->isWhitespace(nextCh))
-                {
-                    // Ok, skip by them and get another char
-                    fReaderMgr.getNextChar();
-                    fReaderMgr.skipPastSpaces();
-                    nextCh = fReaderMgr.peekNextChar();
-                }
-                 else
+                bool bFoundSpace;
+                fReaderMgr.skipPastSpaces(bFoundSpace);
+                if (!bFoundSpace)
                 {
                     // Emit the error but keep on going
                     emitError(XMLErrs::ExpectedWhitespace);
                 }
+                // Ok, peek another char
+                nextCh = fReaderMgr.peekNextChar();
             }
         }
 
@@ -626,7 +623,7 @@
         //  the special case checks.
         if (!fReaderMgr.getCurrentReader()->isSpecialStartTagChar(nextCh))
         {
-            //  Assume its going to be an attribute, so get a name from
+            //  Assume it's going to be an attribute, so get a name from
             //  the input.
             int colonPosition;
             if (!fReaderMgr.getQName(fAttNameBuf, &colonPosition))
@@ -748,10 +745,8 @@
             if (attCount >= fRawAttrColonListSize) {
                 resizeRawAttrColonList();
             }
-            fRawAttrColonList[attCount] = colonPosition;
-
-            // And bump the count of attributes we've gotten
-            attCount++;
+            // Set the position of the colon and bump the count of attributes we've gotten
+            fRawAttrColonList[attCount++] = colonPosition;
 
             // And go to the top again for another attribute
             continue;
@@ -1237,7 +1232,9 @@
         fDocTypeHandler->resetDocType();
 
     // There must be some space after DOCTYPE
-    if (!fReaderMgr.skipPastSpaces())
+    bool skippedSomething;
+    fReaderMgr.skipPastSpaces(skippedSomething);
+    if (!skippedSomething)
     {
         emitError(XMLErrs::ExpectedWhitespace);
 
@@ -1681,17 +1678,15 @@
         {
             if ((nextCh != chForwardSlash) && (nextCh != chCloseAngle))
             {
-                if (fReaderMgr.getCurrentReader()->isWhitespace(nextCh))
-                {
-                    // Ok, skip by them and peek another char
-                    fReaderMgr.skipPastSpaces();
-                    nextCh = fReaderMgr.peekNextChar();
-                }
-                 else
+                bool bFoundSpace;
+                fReaderMgr.skipPastSpaces(bFoundSpace);
+                if (!bFoundSpace)
                 {
                     // Emit the error but keep on going
                     emitError(XMLErrs::ExpectedWhitespace);
                 }
+                // Ok, peek another char
+                nextCh = fReaderMgr.peekNextChar();
             }
         }
 
@@ -2844,76 +2839,6 @@
 }
 
 
-unsigned int
-IGXMLScanner::resolveQName(const   XMLCh* const qName
-                           ,       XMLBuffer&   prefixBuf
-                           , const short        mode
-                           ,       int&         prefixColonPos)
-{
-    prefixColonPos = XMLString::indexOf(qName, chColon);
-    return resolveQNameWithColon(qName, prefixBuf, mode, prefixColonPos);
-}
-
-unsigned int
-IGXMLScanner::resolveQNameWithColon(const   XMLCh* const qName
-                                    ,       XMLBuffer&   prefixBuf
-                                    , const short        mode
-                                    , const int          prefixColonPos)
-{
-    //  Lets split out the qName into a URI and name buffer first. The URI
-    //  can be empty.
-    if (prefixColonPos == -1)
-    {
-        //  Its all name with no prefix, so put the whole thing into the name
-        //  buffer. Then map the empty string to a URI, since the empty string
-        //  represents the default namespace. This will either return some
-        //  explicit URI which the default namespace is mapped to, or the
-        //  the default global namespace.
-        bool unknown = false;
-
-        prefixBuf.reset();
-        return fElemStack.mapPrefixToURI(XMLUni::fgZeroLenString, (ElemStack::MapModes) mode, unknown);
-    }
-    else
-    {
-        //  Copy the chars up to but not including the colon into the prefix
-        //  buffer.
-        prefixBuf.set(qName, prefixColonPos);
-
-        //  Watch for the special namespace prefixes. We always map these to
-        //  special URIs. 'xml' gets mapped to the official URI that its defined
-        //  to map to by the NS spec. xmlns gets mapped to a special place holder
-        //  URI that we define (so that it maps to something checkable.)
-        const XMLCh* prefixRawBuf = prefixBuf.getRawBuffer();
-        if (XMLString::equals(prefixRawBuf, XMLUni::fgXMLNSString)) {
-
-            // if this is an element, it is an error to have xmlns as prefix
-            if (mode == ElemStack::Mode_Element)
-                emitError(XMLErrs::NoXMLNSAsElementPrefix, qName);
-
-            return fXMLNSNamespaceId;
-        }
-        else if (XMLString::equals(prefixRawBuf, XMLUni::fgXMLString)) {
-            return  fXMLNamespaceId;
-        }
-        else
-        {
-            bool unknown = false;
-            unsigned int uriId = fElemStack.mapPrefixToURI(prefixRawBuf, (ElemStack::MapModes) mode, unknown);
-
-            if (unknown)
-                emitError(XMLErrs::UnknownPrefix, prefixRawBuf);
-
-            // check to see if uriId is empty
-            if (fXMLVersion != XMLReader::XMLV1_0 &&
-                uriId == fElemStack.getEmptyNamespaceId())
-                emitError(XMLErrs::UnknownPrefix, prefixRawBuf);
-
-            return uriId;
-        }
-    }
-}
-
 // ---------------------------------------------------------------------------
 //  IGXMLScanner: Helper methos
 // ---------------------------------------------------------------------------

Modified: xerces/c/trunk/src/xercesc/internal/IGXMLScanner.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/IGXMLScanner.hpp?rev=810580&r1=810579&r2=810580&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/IGXMLScanner.hpp (original)
+++ xerces/c/trunk/src/xercesc/internal/IGXMLScanner.hpp Wed Sep  2 15:52:22 2009
@@ -77,13 +77,6 @@
     virtual const XMLCh* getName() const;
     virtual NameIdPool<DTDEntityDecl>* getEntityDeclPool();
     virtual const NameIdPool<DTDEntityDecl>* getEntityDeclPool() const;
-    virtual unsigned int resolveQName
-    (
-        const   XMLCh* const        qName
-        ,       XMLBuffer&          prefixBufToFill
-        , const short               mode
-        ,       int&                prefixColonPos
-    );
     virtual void scanDocument
     (
         const   InputSource&    src
@@ -150,17 +143,6 @@
         , const XMLCh* const        value
         ,       XMLBuffer&          toFill
     );
-    unsigned int resolvePrefix
-    (
-        const   XMLCh* const        prefix
-        , const ElemStack::MapModes mode
-    );
-    unsigned int resolvePrefix
-    (
-        const   XMLCh* const        prefix
-        ,       XMLBuffer&          uriBufToFill
-        , const ElemStack::MapModes mode
-    );
     void updateNSMap
     (
         const   XMLCh* const    attrName
@@ -188,13 +170,6 @@
 
     void resizeRawAttrColonList();
 
-    unsigned int resolveQNameWithColon
-    (
-        const   XMLCh* const        qName
-        ,       XMLBuffer&          prefixBufToFill
-        , const short               mode
-        , const int                 prefixColonPos
-    );
     // -----------------------------------------------------------------------
     //  Private scanning methods
     // -----------------------------------------------------------------------

Modified: xerces/c/trunk/src/xercesc/internal/IGXMLScanner2.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/IGXMLScanner2.cpp?rev=810580&r1=810579&r2=810580&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/IGXMLScanner2.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/IGXMLScanner2.cpp Wed Sep  2 15:52:22 2009
@@ -130,9 +130,13 @@
         setAttrDupChkRegistry(attCount, toUseHashTable);
     }
 
+    XMLBufBid bbPrefix(&fBufMgr);
+    XMLBuffer& prefixBuf = bbPrefix.getBuffer();
+
     //  Loop through our explicitly provided attributes, which are in the raw
     //  scanned form, and build up XMLAttr objects.
     XMLSize_t index;
+    const XMLCh* prefPtr, *suffPtr;
     for (index = 0; index < attCount; index++)
     {
         PSVIItem::VALIDITY_STATE attrValid = PSVIItem::VALIDITY_VALID;
@@ -142,50 +146,33 @@
         //  We have to split the name into its prefix and name parts. Then
         //  we map the prefix to its URI.
         const XMLCh* const namePtr = curPair->getKey();
-        ArrayJanitor<XMLCh> janName(0);
-
-        // use a stack-based buffer when possible.
-        XMLCh tempBuffer[100];
 
         const int colonInd = fRawAttrColonList[index];
-        const XMLCh* prefPtr = XMLUni::fgZeroLenString;
-        const XMLCh* suffPtr = XMLUni::fgZeroLenString;
+        unsigned int uriId;
         if (colonInd != -1)
         {
-            // We have to split the string, so make a copy.
-            if (XMLString::stringLen(namePtr) < sizeof(tempBuffer) / sizeof(tempBuffer[0]))
-            {
-                XMLString::copyString(tempBuffer, namePtr);
-                tempBuffer[colonInd] = chNull;
-                prefPtr = tempBuffer;
-            }
-            else
-            {
-                janName.reset(XMLString::replicate(namePtr, fMemoryManager), fMemoryManager);
-                janName[colonInd] = chNull;
-                prefPtr = janName.get();
-            }
-
+            prefixBuf.set(namePtr, colonInd);
+            prefPtr = prefixBuf.getRawBuffer();
             suffPtr = namePtr + colonInd + 1;
+            //  Map the prefix to a URI id
+            uriId = resolvePrefix(prefPtr, ElemStack::Mode_Attribute);
         }
         else
         {
             // No colon, so we just have a name with no prefix
+            prefPtr = XMLUni::fgZeroLenString;
             suffPtr = namePtr;
+            // an empty prefix is always the empty namespace, when dealing with attributes
+            uriId = fEmptyNamespaceId;
         }
 
-        //  Map the prefix to a URI id. We tell him that we are mapping an
-        //  attr prefix, so any xmlns attrs at this level will not affect it.
-        const unsigned int uriId = resolvePrefix(prefPtr, ElemStack::Mode_Attribute);
-
         //  If the uri comes back as the xmlns or xml URI or its just a name
         //  and that name is 'xmlns', then we handle it specially. So set a
         //  boolean flag that lets us quickly below know which we are dealing
         //  with.
-        const bool isNSAttr = (uriId == fXMLNSNamespaceId)
-
-                              || XMLString::equals(suffPtr, XMLUni::fgXMLNSString)
-                              || XMLString::equals(getURIText(uriId), SchemaSymbols::fgURI_XSI);
+        const bool isNSAttr = (uriId == fEmptyNamespaceId)?
+                                XMLString::equals(suffPtr, XMLUni::fgXMLNSString) : 
+                                (uriId == fXMLNSNamespaceId || XMLString::equals(getURIText(uriId), SchemaSymbols::fgURI_XSI));
 
 
         //  If its not a special case namespace attr of some sort, then we
@@ -712,7 +699,7 @@
         if (fGrammarType == Grammar::DTDGrammarType) {
             if (!toUseHashTable)
             {
-                for (unsigned int attrIndex=0; attrIndex < retCount; attrIndex++) {
+                for (XMLSize_t attrIndex=0; attrIndex < retCount; attrIndex++) {
                     curAttr = toFill.elementAt(attrIndex);
                     if (uriId == curAttr->getURIId() &&
                         XMLString::equals(suffPtr, curAttr->getName())) {
@@ -988,71 +975,62 @@
     };
 
     // Get the type and name
-    const XMLAttDef::AttTypes type = (attDef)
-                    ?attDef->getType()
-                    :XMLAttDef::CData;
+    const XMLAttDef::AttTypes type = (attDef)?attDef->getType():XMLAttDef::CData;
 
     // Assume its going to go fine, and empty the target buffer in preperation
     bool retVal = true;
     toFill.reset();
 
-    // Get attribute def - to check to see if it's declared externally or not
-    bool  isAttExternal = (attDef)
-                ?attDef->isExternal()
-                :false;
-
     //  Loop through the chars of the source value and normalize it according
     //  to the type.
-    States curState = InContent;
-    bool firstNonWS = false;
     XMLCh nextCh;
     const XMLCh* srcPtr = value;
 
     if (type == XMLAttDef::CData || type > XMLAttDef::Notation) {
-        while (*srcPtr) {
-            //  Get the next character from the source. We have to watch for
-            //  escaped characters (which are indicated by a 0xFFFF value followed
-            //  by the char that was escaped.)
-            nextCh = *srcPtr;
-
-            // Do we have an escaped character ?
-            if (nextCh == 0xFFFF)
+        //  Get the next character from the source. We have to watch for
+        //  escaped characters (which are indicated by a 0xFFFF value followed
+        //  by the char that was escaped.)
+        while ((nextCh = *srcPtr++)!=0) 
+        {
+            switch(nextCh)
             {
-                nextCh = *++srcPtr;
-            }
-            else if ( (nextCh <= 0x0D) && (nextCh == 0x09 || nextCh == 0x0A || nextCh == 0x0D) ) {
+            // Do we have an escaped character ?
+            case 0xFFFF:
+                nextCh = *srcPtr++;
+                break;
+            case 0x09:
+            case 0x0A:
+            case 0x0D:
                 // Check Validity Constraint for Standalone document declaration
                 // XML 1.0, Section 2.9
-                if (fStandalone && fValidate && isAttExternal)
+                if (fStandalone && fValidate && attDef && attDef->isExternal())
                 {
                      // Can't have a standalone document declaration of "yes" if  attribute
                      // values are subject to normalisation
                      fValidator->emitError(XMLValid::NoAttNormForStandalone, attName);
                 }
                 nextCh = chSpace;
-            }
-            else if (nextCh == chOpenAngle) {
+                break;
+            case chOpenAngle:
                 //  If its not escaped, then make sure its not a < character, which is
                 //  not allowed in attribute values.
                 emitError(XMLErrs::BracketInAttrValue, attName);
                 retVal = false;
+                break;
             }
 
             // Add this char to the target buffer
             toFill.append(nextCh);
-
-            // And move up to the next character in the source
-            srcPtr++;
         }
     }
     else {
-        while (*srcPtr)
+        States curState = InContent;
+        bool firstNonWS = false;
+        //  Get the next character from the source. We have to watch for
+        //  escaped characters (which are indicated by a 0xFFFF value followed
+        //  by the char that was escaped.)
+        while ((nextCh = *srcPtr)!=0)
         {
-            //  Get the next character from the source. We have to watch for
-            //  escaped characters (which are indicated by a 0xFFFF value followed
-            //  by the char that was escaped.)
-            nextCh = *srcPtr;
-
             // Do we have an escaped character ?
             if (nextCh == 0xFFFF)
             {
@@ -1089,7 +1067,7 @@
 
                     // Check Validity Constraint for Standalone document declaration
                     // XML 1.0, Section 2.9
-                    if (fStandalone && fValidate && isAttExternal)
+                    if (fStandalone && fValidate && attDef && attDef->isExternal())
                     {
                         if (!firstNonWS || (nextCh != chSpace) || (!*srcPtr) || fReaderMgr.getCurrentReader()->isWhitespace(*srcPtr))
                         {
@@ -1165,60 +1143,6 @@
     return retVal;
 }
 
-unsigned int
-IGXMLScanner::resolvePrefix(  const   XMLCh* const        prefix
-                              , const ElemStack::MapModes mode)
-{
-    //  Watch for the special namespace prefixes. We always map these to
-    //  special URIs. 'xml' gets mapped to the official URI that its defined
-    //  to map to by the NS spec. xmlns gets mapped to a special place holder
-    //  URI that we define (so that it maps to something checkable.)
-    if (XMLString::equals(prefix, XMLUni::fgXMLNSString))
-        return fXMLNSNamespaceId;
-    else if (XMLString::equals(prefix, XMLUni::fgXMLString))
-        return fXMLNamespaceId;
-
-    //  Ask the element stack to search up itself for a mapping for the
-    //  passed prefix.
-    bool unknown;
-    unsigned int uriId = fElemStack.mapPrefixToURI(prefix, mode, unknown);
-
-    // If it was unknown, then the URI was faked in but we have to issue an error
-    if (unknown)
-        emitError(XMLErrs::UnknownPrefix, prefix);
-
-    return uriId;
-}
-
-unsigned int
-IGXMLScanner::resolvePrefix(  const   XMLCh* const        prefix
-                              ,       XMLBuffer&          bufToFill
-                              , const ElemStack::MapModes mode)
-{
-    //  Watch for the special namespace prefixes. We always map these to
-    //  special URIs. 'xml' gets mapped to the official URI that its defined
-    //  to map to by the NS spec. xmlns gets mapped to a special place holder
-    //  URI that we define (so that it maps to something checkable.)
-    if (XMLString::equals(prefix, XMLUni::fgXMLNSString))
-        return fXMLNSNamespaceId;
-    else if (XMLString::equals(prefix, XMLUni::fgXMLString))
-        return fXMLNamespaceId;
-
-    //  Ask the element stack to search up itself for a mapping for the
-    //  passed prefix.
-    bool unknown;
-    unsigned int uriId = fElemStack.mapPrefixToURI(prefix, mode, unknown);
-
-    // If it was unknown, then the URI was faked in but we have to issue an error
-    if (unknown)
-        emitError(XMLErrs::UnknownPrefix, prefix);
-
-    getURIText(uriId,bufToFill);
-
-    return uriId;
-}
-
-
 //  This method will reset the scanner data structures, and related plugged
 //  in stuff, for a new scan session. We get the input source for the primary
 //  XML entity, create the reader for it, and push it on the stack so that
@@ -1662,8 +1586,7 @@
     //  schema attributes.
     //  When we find one, send it off to be used to update the element stack's
     //  namespace mappings.
-    XMLSize_t index = 0;
-    for (index = 0; index < attCount; index++)
+    for (XMLSize_t index = 0; index < attCount; index++)
     {
         // each attribute has the prefix:suffix="value"
         const KVStringPair* curPair = fRawAttrList->elementAt(index);
@@ -1692,7 +1615,7 @@
         XMLBufBid bbXsi(&fBufMgr);
         XMLBuffer& fXsiType = bbXsi.getBuffer();
 
-        for (index = 0; index < attCount; index++)
+        for (XMLSize_t index = 0; index < attCount; index++)
         {
             // each attribute has the prefix:suffix="value"
             const KVStringPair* curPair = fRawAttrList->elementAt(index);

Modified: xerces/c/trunk/src/xercesc/internal/ReaderMgr.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/ReaderMgr.cpp?rev=810580&r1=810579&r2=810580&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/ReaderMgr.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/ReaderMgr.cpp Wed Sep  2 15:52:22 2009
@@ -240,26 +240,39 @@
     return false;
 }
 
+void ReaderMgr::skipPastSpaces(bool& skippedSomething, bool inDecl /* = false */)
+{
+    // we rely on the fact that fCurReader->skipSpaces will NOT reset the flag to false, but only
+    // set it to true if a space is found
+    skippedSomething = false;
+    //
+    //  Skip all the spaces in the current reader. If it returned because
+    //  it hit a non-space, break out. Else we have to pop another entity
+    //  and keep going.
+    //
+    while (!fCurReader->skipSpaces(skippedSomething, inDecl))
+    {
+        // Try to pop another entity. If we can't then we are done
+        if (!popReader())
+            break;
+    }
+}
 
-bool ReaderMgr::skipPastSpaces(bool inDecl)
+void ReaderMgr::skipPastSpaces()
 {
-    bool skippedSomething = false;
+    // we are not using it, so we don't care to initialize it
     bool tmpFlag;
     //
     //  Skip all the spaces in the current reader. If it returned because
     //  it hit a non-space, break out. Else we have to pop another entity
     //  and keep going.
     //
-    while (!fCurReader->skipSpaces(tmpFlag, inDecl))
+    while (!fCurReader->skipSpaces(tmpFlag, false))
     {
-        if (tmpFlag)
-            skippedSomething = true;
-
-        // Try to pop another enitity. If we can't then we are done
+        // Try to pop another entity. If we can't then we are done
         if (!popReader())
             break;
     }
-    return (tmpFlag || skippedSomething);
 }
 
 void ReaderMgr::skipQuotedString(const XMLCh quoteCh)

Modified: xerces/c/trunk/src/xercesc/internal/ReaderMgr.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/ReaderMgr.hpp?rev=810580&r1=810579&r2=810580&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/ReaderMgr.hpp (original)
+++ xerces/c/trunk/src/xercesc/internal/ReaderMgr.hpp Wed Sep  2 15:52:22 2009
@@ -89,7 +89,8 @@
     XMLCh peekNextChar();
     bool skipIfQuote(XMLCh& chGotten);
     void skipPastChar(const XMLCh toSkip);
-    bool skipPastSpaces(bool inDecl = false);
+    void skipPastSpaces(bool& skippedSomething, bool inDecl = false);
+    void skipPastSpaces();
     void skipToChar(const XMLCh toSkipTo);
     bool skippedChar(const XMLCh toSkip);
     bool skippedSpace();

Modified: xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp?rev=810580&r1=810579&r2=810580&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/SGXMLScanner.cpp Wed Sep  2 15:52:22 2009
@@ -1824,76 +1824,6 @@
 }
 
 
-unsigned int
-SGXMLScanner::resolveQName(const   XMLCh* const qName
-                           ,       XMLBuffer&   prefixBuf
-                           , const short        mode
-                           ,       int&         prefixColonPos)
-{
-    prefixColonPos = XMLString::indexOf(qName, chColon);
-    return resolveQNameWithColon(qName, prefixBuf, mode, prefixColonPos);
-}
-
-unsigned int
-SGXMLScanner::resolveQNameWithColon(const   XMLCh* const qName
-                                    ,       XMLBuffer&   prefixBuf
-                                    , const short        mode
-                                    , const int          prefixColonPos)
-{
-    //  Lets split out the qName into a URI and name buffer first. The URI
-    //  can be empty.
-    if (prefixColonPos == -1)
-    {
-        //  Its all name with no prefix, so put the whole thing into the name
-        //  buffer. Then map the empty string to a URI, since the empty string
-        //  represents the default namespace. This will either return some
-        //  explicit URI which the default namespace is mapped to, or the
-        //  the default global namespace.
-        bool unknown = false;
-
-        prefixBuf.reset();
-        return fElemStack.mapPrefixToURI(XMLUni::fgZeroLenString, (ElemStack::MapModes) mode, unknown);
-    }
-    else
-    {
-        //  Copy the chars up to but not including the colon into the prefix
-        //  buffer.
-        prefixBuf.set(qName, prefixColonPos);
-
-        //  Watch for the special namespace prefixes. We always map these to
-        //  special URIs. 'xml' gets mapped to the official URI that its defined
-        //  to map to by the NS spec. xmlns gets mapped to a special place holder
-        //  URI that we define (so that it maps to something checkable.)
-        const XMLCh* prefixRawBuf = prefixBuf.getRawBuffer();
-        if (XMLString::equals(prefixRawBuf, XMLUni::fgXMLNSString)) {
-
-            // if this is an element, it is an error to have xmlns as prefix
-            if (mode == ElemStack::Mode_Element)
-                emitError(XMLErrs::NoXMLNSAsElementPrefix, qName);
-
-            return fXMLNSNamespaceId;
-        }
-        else if (XMLString::equals(prefixRawBuf, XMLUni::fgXMLString)) {
-            return  fXMLNamespaceId;
-        }
-        else
-        {
-            bool unknown = false;
-            unsigned int uriId = fElemStack.mapPrefixToURI(prefixRawBuf, (ElemStack::MapModes) mode, unknown);
-
-            if (unknown)
-                emitError(XMLErrs::UnknownPrefix, prefixRawBuf);
-
-            // check to see if uriId is empty
-            if (fXMLVersion != XMLReader::XMLV1_0 &&
-                uriId == fElemStack.getEmptyNamespaceId())
-                emitError(XMLErrs::UnknownPrefix, prefixRawBuf);
-
-            return uriId;
-        }
-    }
-}
-
 // ---------------------------------------------------------------------------
 //  SGXMLScanner: Grammar preparsing
 // ---------------------------------------------------------------------------
@@ -2174,9 +2104,13 @@
     XMLBufBid bbNormal(&fBufMgr);
     XMLBuffer& normBuf = bbNormal.getBuffer();
 
+    XMLBufBid bbPrefix(&fBufMgr);
+    XMLBuffer& prefixBuf = bbPrefix.getBuffer();
+
     //  Loop through our explicitly provided attributes, which are in the raw
     //  scanned form, and build up XMLAttr objects.
     XMLSize_t index;
+    const XMLCh* prefPtr, *suffPtr;
     for (index = 0; index < attCount; index++)
     {
         PSVIItem::VALIDITY_STATE attrValid = PSVIItem::VALIDITY_VALID;
@@ -2186,51 +2120,33 @@
         //  We have to split the name into its prefix and name parts. Then
         //  we map the prefix to its URI.
         const XMLCh* const namePtr = curPair->getKey();
-        ArrayJanitor <XMLCh> janName(0);
-
-        // use a stack-based buffer when possible.
-        XMLCh tempBuffer[100];
 
         const int colonInd = fRawAttrColonList[index];
-        const XMLCh* prefPtr = XMLUni::fgZeroLenString;
-        const XMLCh* suffPtr = XMLUni::fgZeroLenString;
+        unsigned int uriId;
         if (colonInd != -1)
         {
-            // We have to split the string, so make a copy.
-            if (XMLString::stringLen(namePtr) < sizeof(tempBuffer) / sizeof(tempBuffer[0]))
-            {
-                XMLString::copyString(tempBuffer, namePtr);
-                tempBuffer[colonInd] = chNull;
-                prefPtr = tempBuffer;
-            }
-            else
-            {
-                janName.reset(XMLString::replicate(namePtr, fMemoryManager), fMemoryManager);
-                janName[colonInd] = chNull;
-                prefPtr = janName.get();
-            }
-
+            prefixBuf.set(namePtr, colonInd);
+            prefPtr = prefixBuf.getRawBuffer();
             suffPtr = namePtr + colonInd + 1;
+            //  Map the prefix to a URI id
+            uriId = resolvePrefix(prefPtr, ElemStack::Mode_Attribute);
         }
         else
         {
             // No colon, so we just have a name with no prefix
+            prefPtr = XMLUni::fgZeroLenString;
             suffPtr = namePtr;
+            // an empty prefix is always the empty namespace, when dealing with attributes
+            uriId = fEmptyNamespaceId;
         }
 
-        //  Map the prefix to a URI id. We tell him that we are mapping an
-        //  attr prefix, so any xmlns attrs at this level will not affect it.
-        const unsigned int uriId = resolvePrefix(prefPtr, ElemStack::Mode_Attribute);
-
         //  If the uri comes back as the xmlns or xml URI or its just a name
         //  and that name is 'xmlns', then we handle it specially. So set a
         //  boolean flag that lets us quickly below know which we are dealing
         //  with.
-        const bool isNSAttr = (uriId == fXMLNSNamespaceId)
-
-                              || XMLString::equals(suffPtr, XMLUni::fgXMLNSString)
-                              || XMLString::equals(getURIText(uriId), SchemaSymbols::fgURI_XSI);
-
+        const bool isNSAttr = (uriId == fEmptyNamespaceId)?
+                                XMLString::equals(suffPtr, XMLUni::fgXMLNSString) : 
+                                (uriId == fXMLNSNamespaceId || XMLString::equals(getURIText(uriId), SchemaSymbols::fgURI_XSI));
 
         //  If its not a special case namespace attr of some sort, then we
         //  do normal checking and processing.
@@ -3108,60 +3024,6 @@
     return retVal;
 }
 
-unsigned int
-SGXMLScanner::resolvePrefix(  const   XMLCh* const        prefix
-                              , const ElemStack::MapModes mode)
-{
-    //  Watch for the special namespace prefixes. We always map these to
-    //  special URIs. 'xml' gets mapped to the official URI that its defined
-    //  to map to by the NS spec. xmlns gets mapped to a special place holder
-    //  URI that we define (so that it maps to something checkable.)
-    if (XMLString::equals(prefix, XMLUni::fgXMLNSString))
-        return fXMLNSNamespaceId;
-    else if (XMLString::equals(prefix, XMLUni::fgXMLString))
-        return fXMLNamespaceId;
-
-    //  Ask the element stack to search up itself for a mapping for the
-    //  passed prefix.
-    bool unknown;
-    unsigned int uriId = fElemStack.mapPrefixToURI(prefix, mode, unknown);
-
-    // If it was unknown, then the URI was faked in but we have to issue an error
-    if (unknown)
-        emitError(XMLErrs::UnknownPrefix, prefix);
-
-    return uriId;
-}
-
-unsigned int
-SGXMLScanner::resolvePrefix(  const   XMLCh* const        prefix
-                              ,       XMLBuffer&          bufToFill
-                              , const ElemStack::MapModes mode)
-{
-    //  Watch for the special namespace prefixes. We always map these to
-    //  special URIs. 'xml' gets mapped to the official URI that its defined
-    //  to map to by the NS spec. xmlns gets mapped to a special place holder
-    //  URI that we define (so that it maps to something checkable.)
-    if (XMLString::equals(prefix, XMLUni::fgXMLNSString))
-        return fXMLNSNamespaceId;
-    else if (XMLString::equals(prefix, XMLUni::fgXMLString))
-        return fXMLNamespaceId;
-
-    //  Ask the element stack to search up itself for a mapping for the
-    //  passed prefix.
-    bool unknown;
-    unsigned int uriId = fElemStack.mapPrefixToURI(prefix, mode, unknown);
-
-    // If it was unknown, then the URI was faked in but we have to issue an error
-    if (unknown)
-        emitError(XMLErrs::UnknownPrefix, prefix);
-
-    getURIText(uriId,bufToFill);
-
-    return uriId;
-}
-
-
 //  This method will reset the scanner data structures, and related plugged
 //  in stuff, for a new scan session. We get the input source for the primary
 //  XML entity, create the reader for it, and push it on the stack so that
@@ -3552,8 +3414,7 @@
     //  schema attributes.
     //  When we find one, send it off to be used to update the element stack's
     //  namespace mappings.
-    XMLSize_t index;
-    for (index = 0; index < attCount; index++)
+    for (XMLSize_t index = 0; index < attCount; index++)
     {
         // each attribute has the prefix:suffix="value"
         const KVStringPair* curPair = fRawAttrList->elementAt(index);
@@ -3582,7 +3443,7 @@
         XMLBufBid bbXsi(&fBufMgr);
         XMLBuffer& fXsiType = bbXsi.getBuffer();
 
-        for (index = 0; index < attCount; index++)
+        for (XMLSize_t index = 0; index < attCount; index++)
         {
             // each attribute has the prefix:suffix="value"
             const KVStringPair* curPair = fRawAttrList->elementAt(index);

Modified: xerces/c/trunk/src/xercesc/internal/SGXMLScanner.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/SGXMLScanner.hpp?rev=810580&r1=810579&r2=810580&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/SGXMLScanner.hpp (original)
+++ xerces/c/trunk/src/xercesc/internal/SGXMLScanner.hpp Wed Sep  2 15:52:22 2009
@@ -75,13 +75,6 @@
     virtual const XMLCh* getName() const;
     virtual NameIdPool<DTDEntityDecl>* getEntityDeclPool();
     virtual const NameIdPool<DTDEntityDecl>* getEntityDeclPool() const;
-    virtual unsigned int resolveQName
-    (
-        const   XMLCh* const        qName
-        ,       XMLBuffer&          prefixBufToFill
-        , const short               mode
-        ,       int&                prefixColonPos
-    );
     virtual void scanDocument
     (
         const   InputSource&    src
@@ -131,11 +124,6 @@
         const   XMLCh* const    attrName
         , const XMLCh* const    attrValue
     );
-    unsigned int resolvePrefix
-    (
-        const   XMLCh* const        prefix
-        , const ElemStack::MapModes mode
-    );
     void resizeElemState();
 
     void updateNSMap
@@ -145,13 +133,6 @@
         , const int             colonPosition
     );
     void resizeRawAttrColonList();
-    unsigned int resolveQNameWithColon
-    (
-        const   XMLCh* const        qName
-        ,       XMLBuffer&          prefixBufToFill
-        , const short               mode
-        , const int                 prefixColonPos
-    );
     // -----------------------------------------------------------------------
     //  Data members
     //
@@ -254,12 +235,6 @@
         , const XMLCh* const        value
         ,       XMLBuffer&          toFill
     );
-    unsigned int resolvePrefix
-    (
-        const   XMLCh* const        prefix
-        ,       XMLBuffer&          uriBufToFill
-        , const ElemStack::MapModes mode
-    );
     void scanRawAttrListforNameSpaces(XMLSize_t attCount);
     void parseSchemaLocation(const XMLCh* const schemaLocationStr);
     void resolveSchemaGrammar(const XMLCh* const loc, const XMLCh* const uri);

Modified: xerces/c/trunk/src/xercesc/internal/ValidationContextImpl.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/ValidationContextImpl.cpp?rev=810580&r1=810579&r2=810580&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/ValidationContextImpl.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/ValidationContextImpl.cpp Wed Sep  2 15:52:22 2009
@@ -191,7 +191,7 @@
     }            
     else if (!XMLString::equals(prefix, XMLUni::fgXMLString)) {
         if(fElemStack && !fElemStack->isEmpty())
-            fElemStack->mapPrefixToURI(prefix, (ElemStack::MapModes) ElemStack::Mode_Element, unknown);
+            fElemStack->mapPrefixToURI(prefix, unknown);
         else if(fNamespaceScope)
             unknown = (fNamespaceScope->getNamespaceForPrefix(prefix)==fNamespaceScope->getEmptyNamespaceId());
     }                
@@ -202,7 +202,7 @@
     bool unknown = false;
     unsigned int uriId;
     if(fElemStack)
-        uriId = fElemStack->mapPrefixToURI(prefix, (ElemStack::MapModes) ElemStack::Mode_Element, unknown);
+        uriId = fElemStack->mapPrefixToURI(prefix, unknown);
     else if(fNamespaceScope)
         unknown = ((uriId = fNamespaceScope->getNamespaceForPrefix(prefix))==fNamespaceScope->getEmptyNamespaceId());
     if (!unknown)

Modified: xerces/c/trunk/src/xercesc/internal/WFXMLScanner.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/WFXMLScanner.cpp?rev=810580&r1=810579&r2=810580&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/WFXMLScanner.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/WFXMLScanner.cpp Wed Sep  2 15:52:22 2009
@@ -445,39 +445,6 @@
     delete fElements;
 }
 
-unsigned int
-WFXMLScanner::resolvePrefix(const   XMLCh* const          prefix
-                            , const ElemStack::MapModes mode)
-{
-    //  Watch for the special namespace prefixes. We always map these to
-    //  special URIs. 'xml' gets mapped to the official URI that its defined
-    //  to map to by the NS spec. xmlns gets mapped to a special place holder
-    //  URI that we define (so that it maps to something checkable.)
-    if (XMLString::equals(prefix, XMLUni::fgXMLNSString))
-        return fXMLNSNamespaceId;
-    else if (XMLString::equals(prefix, XMLUni::fgXMLString))
-        return fXMLNamespaceId;
-
-    //  Ask the element stack to search up itself for a mapping for the
-    //  passed prefix.
-    bool unknown;
-    unsigned int uriId = fElemStack.mapPrefixToURI(prefix, mode, unknown);
-
-    // If it was unknown, then the URI was faked in but we have to issue an error
-    if (unknown)
-        emitError(XMLErrs::UnknownPrefix, prefix);
-
-    // check to see if uriId is empty; in XML 1.1 an emptynamespace is okay unless
-    // we are trying to use it.
-    if (*prefix &&
-        mode == ElemStack::Mode_Element &&
-        fXMLVersion != XMLReader::XMLV1_0 &&
-        uriId == fElemStack.getEmptyNamespaceId())             
-        emitError(XMLErrs::UnknownPrefix, prefix);
-
-    return uriId;
-}
-
 //  This method will reset the scanner data structures, and related plugged
 //  in stuff, for a new scan session. We get the input source for the primary
 //  XML entity, create the reader for it, and push it on the stack so that
@@ -839,17 +806,15 @@
         {
             if ((nextCh != chForwardSlash) && (nextCh != chCloseAngle))
             {
-                if (fReaderMgr.getCurrentReader()->isWhitespace(nextCh))
-                {
-                    // Ok, skip by them and peek another char
-                    fReaderMgr.skipPastSpaces();
-                    nextCh = fReaderMgr.peekNextChar();
-                }
-                 else
+                bool bFoundSpace;
+                fReaderMgr.skipPastSpaces(bFoundSpace);
+                if (!bFoundSpace)
                 {
                     // Emit the error but keep on going
                     emitError(XMLErrs::ExpectedWhitespace);
                 }
+                // Ok, peek another char
+                nextCh = fReaderMgr.peekNextChar();
             }
         }
 
@@ -1170,17 +1135,15 @@
         {
             if ((nextCh != chForwardSlash) && (nextCh != chCloseAngle))
             {
-                if (fReaderMgr.getCurrentReader()->isWhitespace(nextCh))
-                {
-                    // Ok, skip by them and peek another char
-                    fReaderMgr.skipPastSpaces();
-                    nextCh = fReaderMgr.peekNextChar();
-                }
-                else
+                bool bFoundSpace;
+                fReaderMgr.skipPastSpaces(bFoundSpace);
+                if (!bFoundSpace)
                 {
                     // Emit the error but keep on going
                     emitError(XMLErrs::ExpectedWhitespace);
                 }
+                // Ok, peek another char
+                nextCh = fReaderMgr.peekNextChar();
             }
         }
 
@@ -1538,62 +1501,6 @@
     return true;
 }
 
-unsigned int
-WFXMLScanner::resolveQName(const   XMLCh* const qName
-                           ,       XMLBuffer&   prefixBuf
-                           , const short        mode
-                           ,       int&         prefixColonPos)
-{
-    //  Lets split out the qName into a URI and name buffer first. The URI
-    //  can be empty.
-    prefixColonPos = XMLString::indexOf(qName, chColon);
-    if (prefixColonPos == -1)
-    {
-        //  Its all name with no prefix, so put the whole thing into the name
-        //  buffer. Then map the empty string to a URI, since the empty string
-        //  represents the default namespace. This will either return some
-        //  explicit URI which the default namespace is mapped to, or the
-        //  the default global namespace.
-        bool unknown = false;
-
-        prefixBuf.reset();
-        return fElemStack.mapPrefixToURI(XMLUni::fgZeroLenString, (ElemStack::MapModes) mode, unknown);
-    }
-    else
-    {
-        //  Copy the chars up to but not including the colon into the prefix
-        //  buffer.
-        prefixBuf.set(qName, prefixColonPos);
-
-        //  Watch for the special namespace prefixes. We always map these to
-        //  special URIs. 'xml' gets mapped to the official URI that its defined
-        //  to map to by the NS spec. xmlns gets mapped to a special place holder
-        //  URI that we define (so that it maps to something checkable.)
-        const XMLCh* prefixRawBuf = prefixBuf.getRawBuffer();
-        if (XMLString::equals(prefixRawBuf, XMLUni::fgXMLNSString)) {
-
-            // if this is an element, it is an error to have xmlns as prefix
-            if (mode == ElemStack::Mode_Element)
-                emitError(XMLErrs::NoXMLNSAsElementPrefix, qName);
-
-            return fXMLNSNamespaceId;
-        }
-        else if (XMLString::equals(prefixRawBuf, XMLUni::fgXMLString)) {
-            return  fXMLNamespaceId;
-        }
-        else
-        {
-            bool unknown = false;
-            unsigned int uriId = fElemStack.mapPrefixToURI(prefixRawBuf, (ElemStack::MapModes) mode, unknown);
-
-            if (unknown)
-                emitError(XMLErrs::UnknownPrefix, prefixRawBuf);
-
-            return uriId;
-        }
-    }
-}
-
 // ---------------------------------------------------------------------------
 //  XMLScanner: Private parsing methods
 // ---------------------------------------------------------------------------

Modified: xerces/c/trunk/src/xercesc/internal/WFXMLScanner.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/WFXMLScanner.hpp?rev=810580&r1=810579&r2=810580&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/WFXMLScanner.hpp (original)
+++ xerces/c/trunk/src/xercesc/internal/WFXMLScanner.hpp Wed Sep  2 15:52:22 2009
@@ -62,13 +62,6 @@
     virtual const XMLCh* getName() const;
     virtual NameIdPool<DTDEntityDecl>* getEntityDeclPool();
     virtual const NameIdPool<DTDEntityDecl>* getEntityDeclPool() const;
-    virtual unsigned int resolveQName
-    (
-        const   XMLCh* const        qName
-        ,       XMLBuffer&          prefixBufToFill
-        , const short               mode
-        ,       int&                prefixColonPos
-    );
     virtual void scanDocument
     (
         const   InputSource&    src
@@ -112,11 +105,6 @@
     // -----------------------------------------------------------------------
     void commonInit();
     void cleanUp();
-    unsigned int resolvePrefix
-    (
-        const   XMLCh* const        prefix
-        , const ElemStack::MapModes mode
-    );
 
     // -----------------------------------------------------------------------
     //  Private scanning methods

Modified: xerces/c/trunk/src/xercesc/internal/XMLReader.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/XMLReader.cpp?rev=810580&r1=810579&r2=810580&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/XMLReader.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/XMLReader.cpp Wed Sep  2 15:52:22 2009
@@ -703,108 +703,100 @@
     return !toFill.isEmpty();
 }
 
-bool XMLReader::getQName(XMLBuffer& toFill, int* colonPosition)
+bool XMLReader::getNCName(XMLBuffer& toFill)
 {
-    XMLSize_t charIndex_start;
-    bool checkNextCharacterForFirstNCName = true;
+    if (fCharIndex == fCharsAvail && !refreshCharBuffer())
+        return false;
 
-    // We are only looking for two iterations (i.e. 'NCANAME':'NCNAME').
-    // We will stop when we finished scanning for a QName (i.e. either a second
-    // colon or an invalid char).
-    *colonPosition = -1;
-    for (;;) {
+    XMLSize_t charIndex_start = fCharIndex, count;
+    //  Lets check the first char for being a first name char. If not, then
+    //  what's the point in living mannnn? Just give up now. We only do this
+    //  if its a name and not a name token that they want.
+    if (fXMLVersion == XMLV1_1
+        && ((fCharBuf[fCharIndex] >= 0xD800) && (fCharBuf[fCharIndex] <= 0xDB7F))) {
+        // make sure one more char is in the buffer, the transcoder
+        // should put only a complete surrogate pair into the buffer
+        assert(fCharIndex+1 < fCharsAvail);
+        if ((fCharBuf[fCharIndex+1] < 0xDC00) || (fCharBuf[fCharIndex+1] > 0xDFFF))
+            return false;
 
-        //  Ok, first lets see if we have chars in the buffer. If not, then lets
-        //  reload.
-        if (fCharIndex == fCharsAvail) {
-            if (!refreshCharBuffer()) {
-                break;
-            }
+        // Looks ok, so lets eat it
+        fCharIndex += 2;
+    }
+    else {
+        if (!isFirstNCNameChar(fCharBuf[fCharIndex])) {
+            return false;
         }
 
-        charIndex_start = fCharIndex;
-        if (checkNextCharacterForFirstNCName) {
-
-            checkNextCharacterForFirstNCName = false;
-            //  Lets check the first char for being a first name char. If not, then
-            //  what's the point in living mannnn? Just give up now. We only do this
-            //  if its a name and not a name token that they want.
-            if (fXMLVersion == XMLV1_1
-                && ((fCharBuf[fCharIndex] >= 0xD800) && (fCharBuf[fCharIndex] <= 0xDB7F))) {
-                // make sure one more char is in the buffer, the transcoder
-                // should put only a complete surrogate pair into the buffer
-                assert(fCharIndex+1 < fCharsAvail);
-                if ((fCharBuf[fCharIndex+1] < 0xDC00) || (fCharBuf[fCharIndex+1] > 0xDFFF))
-                    return false;
-
-                // Looks ok, so lets eat it
-                fCharIndex += 2;
-            }
-            else {
-                if (!isFirstNCNameChar(fCharBuf[fCharIndex])) {
-                    return false;
-                }
-
-                // Looks ok, so lets eat it
-                fCharIndex++;
-            }
-        }
+        // Looks ok, so lets eat it
+        fCharIndex++;
+    }
 
-        while(true)
+    do
+    {
+        if (fCharIndex == fCharsAvail)
         {
-            //  Check the current char and take it if it's a name char. Else
-            //  break out.
-            for (;(fCharIndex < fCharsAvail) && ((fgCharCharsTable[fCharBuf[fCharIndex]] & gNCNameCharMask) != 0);fCharIndex++);
-
-            // if it isn't a NameChar, it could be a surrogate
-            if ( (fCharIndex < fCharsAvail) && (fCharBuf[fCharIndex] >= 0xD800) && (fCharBuf[fCharIndex] <= 0xDB7F) )
+            // we have to copy the accepted character(s), and update the column number, 
+            // before getting new data and losing the value of fCharIndex
+            if((count = fCharIndex - charIndex_start)!=0)
             {
-                // make sure one more char is in the buffer, the transcoder
-                // should put only a complete surrogate pair into the buffer
-                assert(fCharIndex+1 < fCharsAvail);
-                if ( (fXMLVersion == XMLV1_0) ||
-                     (fCharBuf[fCharIndex+1] < 0xDC00) ||
-                     (fCharBuf[fCharIndex+1] > 0xDFFF)  ) {
-                    break;
-                }
-
-                fCharIndex += 2;
-                continue;
+                fCurCol += (XMLFileLoc)count;
+                toFill.append(&fCharBuf[charIndex_start], count);
             }
-            break;
+            if(!refreshCharBuffer())
+                return true;
+            charIndex_start = fCharIndex;
         }
 
-        // we have to copy the accepted character(s), and update column
-        if (fCharIndex != charIndex_start)
+        //  Check the current char and take it if it's a name char
+        if (fXMLVersion == XMLV1_1) 
         {
-            fCurCol += (XMLFileLoc)(fCharIndex - charIndex_start);
-            toFill.append(&fCharBuf[charIndex_start], fCharIndex - charIndex_start);
-        }
-
-        // something is wrong if there is still something in the buffer
-        // or if we don't get no more, then break out.
-        if (fCharIndex < fCharsAvail) {
-            if (fCharBuf[fCharIndex] != chColon) {
-                break;
-            }
-
-            if (*colonPosition != -1) {
-                return false;
+            while(fCharIndex < fCharsAvail)
+            {
+                if(isNCNameChar(fCharBuf[fCharIndex])) fCharIndex++;
+                else if((fCharBuf[fCharIndex] >= 0xD800) && (fCharBuf[fCharIndex] <= 0xDB7F) && ((fCharBuf[fCharIndex+1] < 0xDC00) || (fCharBuf[fCharIndex+1] > 0xDFFF))) fCharIndex+=2;
             }
-
-            *colonPosition = (int)toFill.getLen();
-            toFill.append(chColon);
-            fCharIndex++;
-            fCurCol++;
-            checkNextCharacterForFirstNCName = true;
         }
+        else
+            while(fCharIndex < fCharsAvail && isNCNameChar(fCharBuf[fCharIndex])) fCharIndex++;
+        // if we didn't consume the entire buffer, we are done
+    } while(fCharIndex == fCharsAvail);
+
+    // we have to copy the accepted character(s), and update column
+    if((count = fCharIndex - charIndex_start)!=0)
+    {
+        fCurCol += (XMLFileLoc)count;
+        toFill.append(&fCharBuf[charIndex_start], count);
     }
+    return true;
+}
 
-    if (checkNextCharacterForFirstNCName) {
+bool XMLReader::getQName(XMLBuffer& toFill, int* colonPosition)
+{
+    // We are only looking for two iterations (i.e. 'NCNAME':'NCNAME').
+    // We will stop when we finished scanning for a QName (i.e. either a second
+    // colon or an invalid char).
+    if(!getNCName(toFill))
+    {
+        *colonPosition = -1;
         return false;
     }
+    if (fCharIndex == fCharsAvail && !refreshCharBuffer())
+    {
+        *colonPosition = -1;
+        return true;
+    }
+    if (fCharBuf[fCharIndex] != chColon)
+    {
+        *colonPosition = -1;
+        return true;
+    }
 
-    return !toFill.isEmpty();
+    *colonPosition = (int)toFill.getLen();
+    toFill.append(chColon);
+    fCharIndex++;
+    fCurCol++;
+    return getNCName(toFill);
 }
 
 bool XMLReader::getSpaces(XMLBuffer& toFill)
@@ -945,16 +937,12 @@
 
 bool XMLReader::skipIfQuote(XMLCh& chGotten)
 {
-    if (fCharIndex == fCharsAvail)
-    {
-        if (!refreshCharBuffer())
-            return false;
-    }
+    if (fCharIndex == fCharsAvail && !refreshCharBuffer())
+        return false;
 
-    const XMLCh curCh = fCharBuf[fCharIndex];
-    if ((curCh == chDoubleQuote) || (curCh == chSingleQuote))
+    chGotten = fCharBuf[fCharIndex];
+    if ((chGotten == chDoubleQuote) || (chGotten == chSingleQuote))
     {
-        chGotten = curCh;
         fCharIndex++;
         fCurCol++;
         return true;
@@ -965,14 +953,12 @@
 
 bool XMLReader::skipSpaces(bool& skippedSomething, bool inDecl)
 {
-    // Remember the current line and column
-    XMLFileLoc orgLine = fCurLine;
-    XMLFileLoc orgCol  = fCurCol;
+    //  DO NOT set the skippedSomething to 'false', but change it to be 'true' only
 
     //  We enter a loop where we skip over spaces until we hit the end of
     //  this reader or a non-space value. The return indicates whether we
     //  hit the non-space (true) or the end (false).
-    while (true)
+    do
     {
         // Loop through the current chars in the buffer
         while (fCharIndex < fCharsAvail)
@@ -983,7 +969,7 @@
             {
                 // Get the current char out of the buffer and eat it
                 XMLCh curCh = fCharBuf[fCharIndex++];
-
+                skippedSomething = true;
                 //
                 //  'curCh' is a whitespace(x20|x9|xD|xA), so we only can have
                 //  end-of-line combinations with a leading chCR(xD) or chLF(xA)
@@ -1006,24 +992,17 @@
                 {
                     handleEOL(curCh, inDecl);
                 }
-
             }
             else
-            {
-                skippedSomething = (orgLine != fCurLine) || (orgCol != fCurCol);
                 return true;
-            }
         }
 
         //  We've eaten up the current buffer, so lets try to reload it. If
         //  we don't get anything new, then break out. If we do, then we go
         //  back to the top to keep getting spaces.
-        if (!refreshCharBuffer())
-            break;
-    }
+    } while(refreshCharBuffer());
 
     // We never hit any non-space and ate up the whole reader
-    skippedSomething = (orgLine != fCurLine) || (orgCol != fCurCol);
     return false;
 }
 

Modified: xerces/c/trunk/src/xercesc/internal/XMLReader.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/XMLReader.hpp?rev=810580&r1=810579&r2=810580&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/XMLReader.hpp (original)
+++ xerces/c/trunk/src/xercesc/internal/XMLReader.hpp Wed Sep  2 15:52:22 2009
@@ -172,6 +172,7 @@
     // -----------------------------------------------------------------------
     bool getName(XMLBuffer& toFill, const bool token);
     bool getQName(XMLBuffer& toFill, int* colonPosition);
+    bool getNCName(XMLBuffer& toFill);
     bool getNextChar(XMLCh& chGotten);
     bool getNextCharIfNot(const XMLCh chNotToGet, XMLCh& chGotten);
     void movePlainContentChars(XMLBuffer &dest);

Modified: xerces/c/trunk/src/xercesc/internal/XMLScanner.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/XMLScanner.cpp?rev=810580&r1=810579&r2=810580&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/XMLScanner.cpp (original)
+++ xerces/c/trunk/src/xercesc/internal/XMLScanner.cpp Wed Sep  2 15:52:22 2009
@@ -1379,14 +1379,15 @@
     while (true)
     {
         // Skip any spaces
-        const bool spaceCount = fReaderMgr.skipPastSpaces(true);
+        bool skippedSomething;
+        fReaderMgr.skipPastSpaces(skippedSomething, true);
 
         // If we are looking at a question mark, then break out
         if (fReaderMgr.lookingAtChar(chQuestion))
             break;
 
         // If this is not the first string, then we require the spaces
-        if (!spaceCount && curCount)
+        if (!skippedSomething && curCount)
             emitError(XMLErrs::ExpectedWhitespace);
 
         //  Get characters up to the next whitespace or equal's sign.
@@ -2218,11 +2219,24 @@
 //  just makes the calling code cleaner by eating whitespace.
 bool XMLScanner::scanEq(bool inDecl)
 {
-    fReaderMgr.skipPastSpaces(inDecl);
-    if (fReaderMgr.skippedChar(chEqual))
+    if(inDecl)
     {
-        fReaderMgr.skipPastSpaces(inDecl);
-        return true;
+        bool skippedSomething;
+        fReaderMgr.skipPastSpaces(skippedSomething, inDecl);
+        if (fReaderMgr.skippedChar(chEqual))
+        {
+            fReaderMgr.skipPastSpaces(skippedSomething, inDecl);
+            return true;
+        }
+    }
+    else
+    {
+        fReaderMgr.skipPastSpaces();
+        if (fReaderMgr.skippedChar(chEqual))
+        {
+            fReaderMgr.skipPastSpaces();
+            return true;
+        }
     }
     return false;
 }
@@ -2294,4 +2308,86 @@
     fUIntPool[1] = 0;
 }
 
+unsigned int XMLScanner::resolvePrefix(  const XMLCh* const        prefix
+                                       , const ElemStack::MapModes mode)
+{
+    //
+    //  If the prefix is empty, and we are in attribute mode, then we assign
+    //  it to the empty namespace because the default namespace does not
+    //  apply to attributes.
+    //
+    if (!*prefix)
+    {
+        if(mode == ElemStack::Mode_Attribute)
+            return fEmptyNamespaceId;
+    }
+    //  Watch for the special namespace prefixes. We always map these to
+    //  special URIs. 'xml' gets mapped to the official URI that its defined
+    //  to map to by the NS spec. xmlns gets mapped to a special place holder
+    //  URI that we define (so that it maps to something checkable.)
+    else
+    {
+        if (XMLString::equals(prefix, XMLUni::fgXMLNSString))
+            return fXMLNSNamespaceId;
+        else if (XMLString::equals(prefix, XMLUni::fgXMLString))
+            return fXMLNamespaceId;
+    }
+
+    //  Ask the element stack to search up itself for a mapping for the
+    //  passed prefix.
+    bool unknown;
+    unsigned int uriId = fElemStack.mapPrefixToURI(prefix, unknown);
+
+    // If it was unknown, then the URI was faked in but we have to issue an error
+    if (unknown)
+        emitError(XMLErrs::UnknownPrefix, prefix);
+
+    // check to see if uriId is empty; in XML 1.1 an emptynamespace is okay unless
+    // we are trying to use it.
+    if (*prefix &&
+        mode == ElemStack::Mode_Element &&
+        fXMLVersion != XMLReader::XMLV1_0 &&
+        uriId == fElemStack.getEmptyNamespaceId())
+        emitError(XMLErrs::UnknownPrefix, prefix);
+
+    return uriId;
+}
+
+unsigned int
+XMLScanner::resolveQName(  const XMLCh* const           qName
+                         ,       XMLBuffer&             prefixBuf
+                         , const ElemStack::MapModes    mode
+                         ,       int&                   prefixColonPos)
+{
+    prefixColonPos = XMLString::indexOf(qName, chColon);
+    return resolveQNameWithColon(qName, prefixBuf, mode, prefixColonPos);
+}
+
+unsigned int
+XMLScanner::resolveQNameWithColon(  const XMLCh* const          qName
+                                  ,       XMLBuffer&            prefixBuf
+                                  , const ElemStack::MapModes   mode
+                                  , const int                   prefixColonPos)
+{
+    //  Lets split out the qName into a URI and name buffer first. The URI
+    //  can be empty.
+    if (prefixColonPos == -1)
+    {
+        //  Its all name with no prefix, so put the whole thing into the name
+        //  buffer. Then map the empty string to a URI, since the empty string
+        //  represents the default namespace. This will either return some
+        //  explicit URI which the default namespace is mapped to, or the
+        //  the default global namespace.
+        prefixBuf.reset();
+        return resolvePrefix(XMLUni::fgZeroLenString, mode);
+    }
+    else
+    {
+        //  Copy the chars up to but not including the colon into the prefix
+        //  buffer.
+        prefixBuf.set(qName, prefixColonPos);
+        return resolvePrefix(prefixBuf.getRawBuffer(), mode);
+    }
+}
+
 XERCES_CPP_NAMESPACE_END

Modified: xerces/c/trunk/src/xercesc/internal/XMLScanner.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/internal/XMLScanner.hpp?rev=810580&r1=810579&r2=810580&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/internal/XMLScanner.hpp (original)
+++ xerces/c/trunk/src/xercesc/internal/XMLScanner.hpp Wed Sep  2 15:52:22 2009
@@ -197,13 +197,6 @@
     virtual const XMLCh* getName() const = 0;
     virtual NameIdPool<DTDEntityDecl>* getEntityDeclPool() = 0;
     virtual const NameIdPool<DTDEntityDecl>* getEntityDeclPool() const = 0;
-    virtual unsigned int resolveQName
-    (
-        const   XMLCh* const        qName
-        ,       XMLBuffer&          prefixBufToFill
-        , const short               mode
-        ,       int&                prefixColonPos
-    ) = 0;
     virtual void scanDocument
     (
         const   InputSource&    src
@@ -446,6 +439,17 @@
         , const bool            toCache = false
     );
 
+    // -----------------------------------------------------------------------
+    //  Helper methods
+    // -----------------------------------------------------------------------
+    unsigned int resolveQName
+    (
+        const   XMLCh* const        qName
+        ,       XMLBuffer&          prefixBufToFill
+        , const ElemStack::MapModes mode
+        ,       int&                prefixColonPos
+    );
+
 protected:
     // -----------------------------------------------------------------------
     //  Protected pure virtual methods
@@ -490,6 +494,18 @@
     unsigned int *getNewUIntPtr();
     void resetUIntPool();
     void recreateUIntPool();
+    unsigned int resolvePrefix
+    (
+        const   XMLCh* const        prefix
+        , const ElemStack::MapModes mode
+    );
+    unsigned int resolveQNameWithColon
+    (
+        const   XMLCh* const        qName
+        ,       XMLBuffer&          prefixBufToFill
+        , const ElemStack::MapModes mode
+        , const int                 prefixColonPos
+    );
 
     inline
     void setAttrDupChkRegistry

Modified: xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.cpp?rev=810580&r1=810579&r2=810580&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.cpp (original)
+++ xerces/c/trunk/src/xercesc/parsers/AbstractDOMParser.cpp Wed Sep  2 15:52:22 2009
@@ -1010,9 +1010,10 @@
             //
             unsigned int attrURIId = oneAttrib->getURIId();
             const XMLCh* localName = oneAttrib->getName();
+            const XMLCh* prefix = oneAttrib->getPrefix();
             namespaceURI = 0;
 
-            if (XMLString::equals(localName, XMLUni::fgXMLNSString))
+            if ((prefix==0 || *prefix==0) && XMLString::equals(localName, XMLUni::fgXMLNSString))
             {
                 // xmlns=...
                 attrURIId = xmlnsNSId;
@@ -1024,7 +1025,7 @@
             }
 
             attr = (DOMAttrImpl*) createAttrNS (namespaceURI,
-                                                oneAttrib->getPrefix (),
+                                                prefix,
                                                 localName,
                                                 oneAttrib->getQName());
 

Modified: xerces/c/trunk/src/xercesc/parsers/SAX2XMLReaderImpl.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/parsers/SAX2XMLReaderImpl.cpp?rev=810580&r1=810579&r2=810580&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/parsers/SAX2XMLReaderImpl.cpp (original)
+++ xerces/c/trunk/src/xercesc/parsers/SAX2XMLReaderImpl.cpp Wed Sep  2 15:52:22 2009
@@ -724,11 +724,18 @@
                 const XMLCh*   nsURI    = 0;
 
                 const XMLAttr* tempAttr = attrList.elementAt(i);
-                if (XMLString::equals(tempAttr->getQName(), XMLUni::fgXMLNSString))
-                    nsURI = tempAttr->getValue();
-                if (XMLString::equals(tempAttr->getPrefix(), XMLUni::fgXMLNSString))
+                const XMLCh* prefix = tempAttr->getPrefix();
+                if(prefix && *prefix)
+                {
+                    if(XMLString::equals(prefix, XMLUni::fgXMLNSString))
+                    {
+                        nsPrefix = tempAttr->getName();
+                        nsURI = tempAttr->getValue();
+                    }
+                }
+                else if (XMLString::equals(tempAttr->getName(), XMLUni::fgXMLNSString))
                 {
-                    nsPrefix = tempAttr->getName();
+                    nsPrefix = XMLUni::fgZeroLenString;
                     nsURI = tempAttr->getValue();
                 }
                 if (!fNamespacePrefix)
@@ -738,8 +745,6 @@
                 }
                 if (nsURI != 0)
                 {
-                    if (nsPrefix == 0)
-                        nsPrefix = XMLUni::fgZeroLenString;
                     if(fDocHandler)
                         fDocHandler->startPrefixMapping(nsPrefix, nsURI);
                     unsigned int nPrefixId=fPrefixesStorage->addOrFind(nsPrefix);

Modified: xerces/c/trunk/src/xercesc/util/QName.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/QName.cpp?rev=810580&r1=810579&r2=810580&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/QName.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/QName.cpp Wed Sep  2 15:52:22 2009
@@ -308,7 +308,7 @@
     else
     {
         // No colon, so we just have a name with no prefix
-        setPrefix(XMLUni::fgZeroLenString);
+        setNPrefix(XMLUni::fgZeroLenString, 0);
 
         // And clean up any QName and leave it undone until/if asked for again
         if (fRawName)
@@ -321,23 +321,6 @@
     fURIId = uriId;
 }
 
-void QName::setPrefix(const XMLCh* prefix)
-{
-    if (!fPrefixBufSz || !XMLString::copyNString(fPrefix, prefix, fPrefixBufSz))
-    {
-        XMLSize_t newLen = XMLString::stringLen(prefix);
-        fMemoryManager->deallocate(fPrefix); //delete [] fPrefix;
-        fPrefix = 0;
-        fPrefixBufSz = newLen + 8;
-        fPrefix = (XMLCh*) fMemoryManager->allocate
-        (
-            (fPrefixBufSz + 1) * sizeof(XMLCh)
-        ); //new XMLCh[fPrefixBufSz + 1];
-        XMLString::moveChars(fPrefix, prefix, newLen);
-        fPrefix[newLen] = chNull;
-    }
-}
-
 void QName::setNPrefix(const XMLCh* prefix, const XMLSize_t newLen)
 {
     if (!fPrefixBufSz || (newLen > fPrefixBufSz))
@@ -354,23 +337,6 @@
     fPrefix[newLen] = chNull;
 }
 
-void QName::setLocalPart(const XMLCh* localPart)
-{
-    if (!fLocalPartBufSz || !XMLString::copyNString(fLocalPart, localPart, fLocalPartBufSz))
-    {
-        XMLSize_t newLen = XMLString::stringLen(localPart);
-        fMemoryManager->deallocate(fLocalPart); //delete [] fLocalPart;
-        fLocalPart = 0;
-        fLocalPartBufSz = newLen + 8;
-        fLocalPart = (XMLCh*) fMemoryManager->allocate
-        (
-            (fLocalPartBufSz + 1) * sizeof(XMLCh)
-        ); //new XMLCh[fLocalPartBufSz + 1];
-        XMLString::moveChars(fLocalPart, localPart, newLen);
-        fLocalPart[newLen] = chNull;
-    }
-}
-
 void QName::setNLocalPart(const XMLCh* localPart, const XMLSize_t newLen)
 {
     if (!fLocalPartBufSz || (newLen > fLocalPartBufSz))

Modified: xerces/c/trunk/src/xercesc/util/QName.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/QName.hpp?rev=810580&r1=810579&r2=810580&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/QName.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/QName.hpp Wed Sep  2 15:52:22 2009
@@ -202,6 +202,16 @@
     fURIId = uriId;
 }
 
+inline void QName::setPrefix(const XMLCh* prefix)
+{
+    setNPrefix(prefix, XMLString::stringLen(prefix));
+}
+
+inline void QName::setLocalPart(const XMLCh* localPart)
+{
+    setNLocalPart(localPart, XMLString::stringLen(localPart));
+}
+
 XERCES_CPP_NAMESPACE_END
 
 #endif

Modified: xerces/c/trunk/src/xercesc/util/XMLString.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/XMLString.cpp?rev=810580&r1=810579&r2=810580&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/XMLString.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/XMLString.cpp Wed Sep  2 15:52:22 2009
@@ -1338,7 +1338,7 @@
     while (*pszIn)
         *pszOut++ = *pszIn++;
 
-    // Capp off the target where we ended
+    // Cap off the target where we ended
     *pszOut = 0;
 }
 
@@ -1347,18 +1347,16 @@
                             , const XMLCh* const    src
                             , const XMLSize_t       maxChars)
 {
-    XMLCh* outPtr = target;
-    const XMLCh* srcPtr = src;
-    const XMLCh* endPtr = target + maxChars - 1;
-
-    while (*srcPtr && (outPtr <= endPtr))
-        *outPtr++ = *srcPtr++;
-
-    // Cap it off here
-    *outPtr = 0;
-
     // Return whether we copied it all or hit the max
-    return (*srcPtr == 0);
+    XMLSize_t len = stringLen(src);
+    if(len > maxChars)
+    {
+        XMLString::moveChars(target, src, maxChars);
+        target[maxChars] = 0;
+        return false;
+    }
+    XMLString::moveChars(target, src, len+1);
+    return true;
 }
 
 const XMLCh* XMLString::findAny(const   XMLCh* const    toSearch
@@ -1435,17 +1433,12 @@
 
 int XMLString::indexOf(const XMLCh* const toSearch, const XMLCh ch)
 {
-    if (toSearch)
-    {
-        const XMLCh* srcPtr = toSearch;
-        while (*srcPtr)
-        {
-            if (ch == *srcPtr)
-                return (int)(srcPtr - toSearch);
+    if (!toSearch || !*toSearch) return -1;
 
-            srcPtr++;
-        }
-    }
+    const XMLCh* srcPtr = toSearch;
+    while (*srcPtr)
+        if (ch == *srcPtr++)
+            return (int)(srcPtr - toSearch - 1);
     return -1;
 }
 
@@ -1458,14 +1451,13 @@
     const XMLSize_t len = stringLen(toSearch);
 
     // Make sure the start index is within the XMLString bounds
-	if ((int)fromIndex > ((int)len)-1)
+	if (fromIndex >= len)
         ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Str_StartIndexPastEnd, manager);
 
-    for (XMLSize_t i = fromIndex; i < len; i++)
-    {
-        if (toSearch[i] == ch)
-            return (int)i;
-    }
+    const XMLCh* srcPtr = toSearch+fromIndex;
+    while (*srcPtr)
+        if (ch == *srcPtr++)
+            return (int)(srcPtr - toSearch - 1);
     return -1;
 }
 
@@ -1473,11 +1465,10 @@
                            const XMLCh* const toSearch,
                            const XMLSize_t    toSearchLen)
 {
-    for (int i = (int)toSearchLen-1; i >= 0; i--)
-    {
-        if (toSearch[i] == ch)
-            return i;
-    }
+    const XMLCh* srcPtr = toSearch+toSearchLen;
+    while (srcPtr >= toSearch)
+        if (ch == *srcPtr--)
+            return (int)(srcPtr + 1 - toSearch);
     return -1;
 }
 
@@ -1486,15 +1477,14 @@
                             , const XMLSize_t       fromIndex
                             , MemoryManager* const  manager)
 {
-    const int len = (int)stringLen(toSearch);
-	if ((int)fromIndex > len-1)
+    const XMLSize_t len = stringLen(toSearch);
+	if (fromIndex >= len)
         ThrowXMLwithMemMgr(ArrayIndexOutOfBoundsException, XMLExcepts::Str_StartIndexPastEnd, manager);
 
-    for (int i = (int)fromIndex; i >= 0; i--)
-    {
-        if (toSearch[i] == ch)
-            return i;
-    }
+    const XMLCh* srcPtr = toSearch+fromIndex;
+    while (srcPtr >= toSearch)
+        if (ch == *srcPtr--)
+            return (int)(srcPtr + 1 - toSearch);
     return -1;
 }
 

Modified: xerces/c/trunk/src/xercesc/util/XMLString.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/XMLString.hpp?rev=810580&r1=810579&r2=810580&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/XMLString.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/XMLString.hpp Wed Sep  2 15:52:22 2009
@@ -432,9 +432,9 @@
       */
     static bool copyNString
     (
-                XMLCh* const    target
-        , const XMLCh* const    src
-        , const XMLSize_t       maxChars
+                XMLCh* const   target
+        , const XMLCh* const   src
+        , const XMLSize_t      maxChars
     );
     //@}
 

Modified: xerces/c/trunk/src/xercesc/validators/DTD/DTDScanner.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/DTD/DTDScanner.cpp?rev=810580&r1=810579&r2=810580&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/DTD/DTDScanner.cpp (original)
+++ xerces/c/trunk/src/xercesc/validators/DTD/DTDScanner.cpp Wed Sep  2 15:52:22 2009
@@ -2705,7 +2705,9 @@
         }
 
         // We must skip spaces
-        if (!fReaderMgr->skipPastSpaces())
+        bool skippedSomething;
+        fReaderMgr->skipPastSpaces(skippedSomething);
+        if (!skippedSomething)
         {
             fScanner->emitError(XMLErrs::ExpectedWhitespace);
             return false;
@@ -2730,7 +2732,9 @@
     //  So following this we must have whitespace, a public literal, whitespace,
     //  and a system literal.
     //
-    if (!fReaderMgr->skipPastSpaces())
+    bool skippedSomething;
+    fReaderMgr->skipPastSpaces(skippedSomething);
+    if (!skippedSomething)
     {
         fScanner->emitError(XMLErrs::ExpectedWhitespace);
 
@@ -2751,7 +2755,8 @@
         return true;
 
     // check if there is any space follows
-    bool hasSpace = fReaderMgr->skipPastSpaces();
+    bool hasSpace;
+    fReaderMgr->skipPastSpaces(hasSpace);
 
     //
     //  In order to recover best here we need to see if

Modified: xerces/c/trunk/src/xercesc/validators/common/CMStateSet.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/validators/common/CMStateSet.hpp?rev=810580&r1=810579&r2=810580&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/validators/common/CMStateSet.hpp (original)
+++ xerces/c/trunk/src/xercesc/validators/common/CMStateSet.hpp Wed Sep  2 15:52:22 2009
@@ -45,6 +45,7 @@
 
 class CMStateSetEnumerator;
 
+// This value must be 4 in order to use the SSE2 instruction set
 #define CMSTATE_CACHED_INT32_SIZE  4
 
 // This value must be a multiple of 128 in order to use the SSE2 instruction set
@@ -161,12 +162,24 @@
     {
         if(fDynamicBuffer==0)
         {
-           for (XMLSize_t index = 0; index < CMSTATE_CACHED_INT32_SIZE; index++)
-                if(setToOr.fBits[index])
-                    if(fBits[index])
-                        fBits[index] |= setToOr.fBits[index];
-                    else
-                        fBits[index] = setToOr.fBits[index];
+#ifdef XERCES_HAVE_SSE2_INTRINSIC
+            if(XMLPlatformUtils::fgSSE2ok)
+            {
+                __m128i xmm1 = _mm_loadu_si128((__m128i*)fBits);
+                __m128i xmm2 = _mm_loadu_si128((__m128i*)setToOr.fBits);
+                __m128i xmm3 = _mm_or_si128(xmm1, xmm2);     //  OR  4 32-bit words
+                _mm_storeu_si128((__m128i*)fBits, xmm3);
+            }
+            else
+#endif
+            {
+                for (XMLSize_t index = 0; index < CMSTATE_CACHED_INT32_SIZE; index++)
+                    if(setToOr.fBits[index])
+                        if(fBits[index])
+                            fBits[index] |= setToOr.fBits[index];
+                        else
+                            fBits[index] = setToOr.fBits[index];
+            }
         }
         else
         {

Modified: xerces/c/trunk/tests/src/DOM/DOMTest/DTest.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/tests/src/DOM/DOMTest/DTest.cpp?rev=810580&r1=810579&r2=810580&view=diff
==============================================================================
--- xerces/c/trunk/tests/src/DOM/DOMTest/DTest.cpp (original)
+++ xerces/c/trunk/tests/src/DOM/DOMTest/DTest.cpp Wed Sep  2 15:52:22 2009
@@ -5321,6 +5321,7 @@
     TEST_VALID_SCHEMA_REGEX("abbbbx", "ab{2,4}x", __LINE__);
     TEST_INVALID_SCHEMA_REGEX("abx", "ab{2,4}x", __LINE__);
     TEST_INVALID_SCHEMA_REGEX("abbbbbx", "ab{2,4}x", __LINE__);
+    TEST_VALID_SCHEMA_REGEX("PAG_1", "PAG_[0-9]{1,}", __LINE__);
 
     TEST_VALID_SCHEMA_REGEX("5 Bedford Street Boston , MA 15604-1536", "\\d{1,5}\\s([A-Z][a-z]{1,20}\\s){1}Street\\s([A-Z][a-z]{1,20}\\s){1},\\s[A-Z]{2}\\s15604-1536", __LINE__);
 
@@ -5586,6 +5587,7 @@
     XMLString::collapseWS(tempStr);
     TEST_STRING(tempStr, tempStr2);
 
+    // test removeWS
     XMLString::transcode("xyz", tempStr2, 3999);
     XMLString::transcode(" x\tyz ", tempStr, 3999);
     XMLString::removeWS(tempStr);
@@ -5632,6 +5634,76 @@
         OK = false;
     }
 
+    // test copyNString
+    XMLCh buffer[100];
+    XMLString::transcode("xyz", tempStr, 3999);
+    if(!XMLString::copyNString(buffer, tempStr, 100))
+    {
+        fprintf(stderr, "copyNString test failed at line %i\n", __LINE__);
+        OK = false;
+    }
+    if(!XMLString::copyNString(buffer, tempStr, 3))
+    {
+        fprintf(stderr, "copyNString test failed at line %i\n", __LINE__);
+        OK = false;
+    }
+    if(XMLString::copyNString(buffer, tempStr, 2))
+    {
+        fprintf(stderr, "copyNString test failed at line %i\n", __LINE__);
+        OK = false;
+    }
+    if(!XMLString::copyNString(buffer, tempStr, 4))
+    {
+        fprintf(stderr, "copyNString test failed at line %i\n", __LINE__);
+        OK = false;
+    }
+
+    // test indexOf
+    XMLString::transcode("1234567890", tempStr, 3999);
+    if(XMLString::indexOf(tempStr, '1')!=0)
+    {
+        fprintf(stderr, "indexOf test failed at line %i\n", __LINE__);
+        OK = false;
+    }
+    if(XMLString::indexOf(tempStr, '5')!=4)
+    {
+        fprintf(stderr, "indexOf test failed at line %i\n", __LINE__);
+        OK = false;
+    }
+    if(XMLString::indexOf(tempStr, '0')!=9)
+    {
+        fprintf(stderr, "indexOf test failed at line %i\n", __LINE__);
+        OK = false;
+    }
+    if(XMLString::indexOf(tempStr, 'A')!=-1)
+    {
+        fprintf(stderr, "indexOf test failed at line %i\n", __LINE__);
+        OK = false;
+    }
+
+    // test lastIndexOf
+    XMLString::transcode("1234567890", tempStr, 3999);
+    if(XMLString::lastIndexOf(tempStr, '1')!=0)
+    {
+        fprintf(stderr, "lastIndexOf test failed at line %i\n", __LINE__);
+        OK = false;
+    }
+    if(XMLString::lastIndexOf(tempStr, '5')!=4)
+    {
+        fprintf(stderr, "lastIndexOf test failed at line %i\n", __LINE__);
+        OK = false;
+    }
+    if(XMLString::lastIndexOf(tempStr, '0')!=9)
+    {
+        fprintf(stderr, "lastIndexOf test failed at line %i\n", __LINE__);
+        OK = false;
+    }
+    if(XMLString::lastIndexOf(tempStr, 'A')!=-1)
+    {
+        fprintf(stderr, "lastIndexOf test failed at line %i\n", __LINE__);
+        OK = false;
+    }
+
     // this tests the cached bit storage
     CMStateSet setT(60);
     setT.setBit(8);



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org