tng         2002/12/10 13:01:33

  Modified:    c/src/xercesc/dom/impl DOMWriterImpl.cpp DOMWriterImpl.hpp
  Log:
  NLS: DOMWriter should use message loader to load message instead of using hardcoded 
static stirng
  
  Revision  Changes    Path
  1.25      +41 -37    xml-xerces/c/src/xercesc/dom/impl/DOMWriterImpl.cpp
  
  Index: DOMWriterImpl.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMWriterImpl.cpp,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- DOMWriterImpl.cpp 10 Dec 2002 18:59:14 -0000      1.24
  +++ DOMWriterImpl.cpp 10 Dec 2002 21:01:32 -0000      1.25
  @@ -57,6 +57,9 @@
   /*
    * $Id$
    * $Log$
  + * Revision 1.25  2002/12/10 21:01:32  tng
  + * NLS: DOMWriter should use message loader to load message instead of using 
hardcoded static stirng
  + *
    * Revision 1.24  2002/12/10 18:59:14  tng
    * pretty format print: consistent newline
    *
  @@ -137,6 +140,7 @@
   #include "DOMWriterImpl.hpp"
   #include "DOMErrorImpl.hpp"
   #include "DOMLocatorImpl.hpp"
  +#include "DOMImplementationImpl.hpp"
   
   #include <xercesc/framework/MemBufFormatTarget.hpp>
   
  @@ -145,6 +149,8 @@
   #include <xercesc/util/Janitor.hpp>
   #include <xercesc/util/XMLString.hpp>
   #include <xercesc/util/XMLUniDefs.hpp>
  +#include <xercesc/util/XMLMsgLoader.hpp>
  +
   
   XERCES_CPP_NAMESPACE_BEGIN
   
  @@ -325,31 +331,6 @@
       chSpace,   chDoubleQuote, chNull
   };
   
  -// Unrecognized node type
  -static const XMLCh  gUnrecognizedNodeType[] =
  -{
  -    chLatin_U, chLatin_n, chLatin_r, chLatin_e, chLatin_c, chLatin_o,
  -    chLatin_g, chLatin_n, chLatin_i, chLatin_z, chLatin_e, chLatin_d,
  -    chSpace,   chLatin_N, chLatin_o, chLatin_d, chLatin_e, chSpace,
  -    chLatin_T, chLatin_y, chLatin_p, chLatin_e, chNull
  -};
  -
  -// nested cdata
  -static const XMLCh  gNestedCdata[] =
  -{
  -    chLatin_N, chLatin_e, chLatin_s, chLatin_t, chLatin_e, chLatin_d,
  -    chLatin_C, chLatin_D, chLatin_a, chLatin_t, chLatin_a, chNull
  -};
  -
  -// Unrepresentable char
  -static const XMLCh  gUnrepresentableChar[] =
  -{
  -    chLatin_U, chLatin_n, chLatin_r, chLatin_e, chLatin_p, chLatin_r,
  -    chLatin_e, chLatin_s, chLatin_e, chLatin_n, chLatin_t, chLatin_a,
  -    chLatin_b, chLatin_l, chLatin_e, chSpace,   chLatin_C, chLatin_h,
  -    chLatin_a, chLatin_r, chNull
  -};
  -
   //Feature
   static const XMLCh  gFeature[] =
   {
  @@ -569,7 +550,7 @@
           return false;
       }
   
  -    catch (const DOMException&)
  +    catch (const XMLDOMMsg::Codes)
       {
           return false;
       }
  @@ -1031,8 +1012,7 @@
                   // search for "]]>"
                   if (XMLString::patternMatch((XMLCh* const) nodeValue, gEndCDATA) != 
-1)
                   {
  -                    reportError(nodeToWrite, DOMError::DOM_SEVERITY_FATAL_ERROR, 
gNestedCdata);
  -                    throw DOMException(DOMException::SYNTAX_ERR, gNestedCdata);
  +                    reportError(nodeToWrite, DOMError::DOM_SEVERITY_FATAL_ERROR, 
XMLDOMMsg::Writer_NestedCDATA);
                   }
   
                   TRY_CATCH_THROW
  @@ -1099,8 +1079,7 @@
                           // [75] ExternalID ::= 'SYSTEM' S SystemLiteral
                           //                   | 'PUBLIC' S PubidLiteral S 
SystemLiteral
                           //
  -                        reportError(nodeToWrite, 
DOMError::DOM_SEVERITY_FATAL_ERROR, gUnrecognizedNodeType);
  -                        throw DOMException(DOMException::NOT_FOUND_ERR, 0);
  +                        reportError(nodeToWrite, 
DOMError::DOM_SEVERITY_FATAL_ERROR, XMLDOMMsg::Writer_NotRecognizedType);
                           // systemLiteral not found
                       }
                   }
  @@ -1162,8 +1141,7 @@
               once unrecognized node type encountered.
            ***/
           {
  -            reportError(nodeToWrite, DOMError::DOM_SEVERITY_FATAL_ERROR, 
gUnrecognizedNodeType);
  -            throw DOMException(DOMException::NOT_FOUND_ERR, 0);
  +            reportError(nodeToWrite, DOMError::DOM_SEVERITY_FATAL_ERROR, 
XMLDOMMsg::Writer_NotRecognizedType);
               // UnreognizedNodeType;
           }
   
  @@ -1247,6 +1225,33 @@
       }
   
       fErrorCount++;
  +
  +    return toContinueProcess;
  +}
  +
  +bool DOMWriterImpl::reportError(const DOMNode* const    errorNode
  +                              , DOMError::ErrorSeverity errorType
  +                              , XMLDOMMsg::Codes        toEmit)
  +{
  +    const unsigned int msgSize = 1023;
  +    XMLCh errText[msgSize + 1];
  +
  +    DOMImplementationImpl::getMsgLoader4DOM()->loadMsg(toEmit, errText, msgSize);
  +
  +    bool toContinueProcess = true;   // default value for no error handler
  +
  +    if (fErrorHandler)
  +    {
  +        DOMLocatorImpl  locator(0, 0, (DOMNode* const) errorNode, 0, 0);
  +        DOMErrorImpl    domError(errorType , errText, &locator);
  +        toContinueProcess = fErrorHandler->handleError(domError);
  +    }
  +
  +    fErrorCount++;
  +
  +    if (errorType == DOMError::DOM_SEVERITY_FATAL_ERROR)
  +        throw toEmit;
  +
       return toContinueProcess;
   }
   
  @@ -1277,8 +1282,7 @@
           {
               nextPtr = curPtr + endTagPos + offset;  // skip the ']]>'
               *(curPtr + endTagPos) = chNull;         //nullify the first ']'
  -
  -            reportError(nodeToWrite, DOMError::DOM_SEVERITY_WARNING, gNestedCdata);
  +            reportError(nodeToWrite, DOMError::DOM_SEVERITY_WARNING, 
XMLDOMMsg::Writer_NestedCDATA);
           }
           else
           {
  @@ -1381,7 +1385,7 @@
               //
   
               // one warning for consective unrep chars
  -            reportError(nodeToWrite, DOMError::DOM_SEVERITY_WARNING, 
gUnrepresentableChar);
  +            reportError(nodeToWrite, DOMError::DOM_SEVERITY_WARNING, 
XMLDOMMsg::Writer_NotRepresentChar);
   
               while (srcPtr < endPtr)
               {
  @@ -1426,7 +1430,7 @@
       {
           fCurrentLine++;
           *fFormatter << fNewLineUsed;
  -}
  +    }
   }
   
   void DOMWriterImpl::printIndent(int level) const
  
  
  
  1.10      +10 -3     xml-xerces/c/src/xercesc/dom/impl/DOMWriterImpl.hpp
  
  Index: DOMWriterImpl.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/dom/impl/DOMWriterImpl.hpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- DOMWriterImpl.hpp 9 Dec 2002 11:46:08 -0000       1.9
  +++ DOMWriterImpl.hpp 10 Dec 2002 21:01:32 -0000      1.10
  @@ -57,6 +57,9 @@
   /*
    * $Id$
    * $Log$
  + * Revision 1.10  2002/12/10 21:01:32  tng
  + * NLS: DOMWriter should use message loader to load message instead of using 
hardcoded static stirng
  + *
    * Revision 1.9  2002/12/09 11:46:08  gareth
    * More pretty pretty print feature. Patch by Kevin King. Closes bug #13840.
    *
  @@ -308,6 +311,7 @@
   
   #include <xercesc/dom/DOM.hpp>
   #include <xercesc/dom/DOMWriter.hpp>
  +#include <xercesc/util/XMLDOMMsg.hpp>
   
   XERCES_CPP_NAMESPACE_BEGIN
   
  @@ -380,6 +384,9 @@
       bool                          reportError(const DOMNode* const    errorNode
                                               , DOMError::ErrorSeverity errorType
                                               , const XMLCh*   const    errorMsg);
  +    bool                          reportError(const DOMNode* const    errorNode
  +                                            , DOMError::ErrorSeverity errorType
  +                                            , XMLDOMMsg::Codes        toEmit);
   
       void                          procCdataSection(const XMLCh*   const nodeValue
                                                    , const DOMNode* const 
nodeToWrite);
  @@ -436,8 +443,8 @@
       //      based on this value.
       //
       //  fCurrentLine
  -    //      the current line. Used to track the line number the current 
  -    //      node begins on      
  +    //      the current line. Used to track the line number the current
  +    //      node begins on
       //
       // -----------------------------------------------------------------------
   
  
  
  

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

Reply via email to