diff --git a/src/xercesc/util/PlatformUtils.hpp b/src/xercesc/util/PlatformUtils.hpp
index ef45f0e5dd4d17e6bbf8f4e4dcd3227391762e8d..f728786403c3f810277de44232d5ba3347530098 100644
--- a/src/xercesc/util/PlatformUtils.hpp
+++ b/src/xercesc/util/PlatformUtils.hpp
@@ -249,6 +249,30 @@ public :
       */
     static FileHandle openFile(const XMLCh* const fileName);
 
+    /** Open a named file to write
+      *
+      * This must be implemented by the per-platform driver, which should
+      * use local file services to open passed file. If it fails, a
+      * null handle pointer should be returned.
+      *
+      * @param fileName The string containing the name of the file
+      *
+      * @return The file handle of the opened file
+      */
+    static FileHandle openFileToWrite(const char* const fileName);
+
+    /** Open a named file to write
+      *
+      * This must be implemented by the per-platform driver, which should
+      * use local file services to open the passed file. If it fails, a
+      * null handle pointer should be returned.
+      *
+      * @param fileName The string containing the name of the file
+      *
+      * @return The file handle of the opened file
+      */
+    static FileHandle openFileToWrite(const XMLCh* const fileName);
+
     /** Opens the standard input as a file
       *
       * This must be implemented by the per-platform driver, which should
@@ -282,6 +306,27 @@ public :
         ,       XMLByte* const  toFill
     );
 
+    /** Writes the buffer to the file
+      *
+      * This must be implemented by the per-platform driver, which should
+      * use local file services to write up to 'toWrite' bytes of data to
+      * the passed file. Unless exception raised by local file services,
+      * 'toWrite' bytes of data is to be written to the passed file.
+      *
+      * @param theFile The file handle to be written to.
+      * @param toWrite The maximum number of byte to write from the current
+      * position
+      * @param toFlush The byte buffer to flush
+      *
+      * @return void
+      */
+    static void writeBufferToFile
+    (
+          FileHandle     const  theFile
+        , long                  toWrite
+        , const XMLByte* const  toFlush
+    );
+
     /** Resets the file handle
       *
       * This must be implemented by the per-platform driver which will use
diff --git a/src/xercesc/util/Platforms/AIX/AIXPlatformUtils.cpp b/src/xercesc/util/Platforms/AIX/AIXPlatformUtils.cpp
index fdc2bdc35a3e6512262a8db9c188acde6e196111..93a322ed18896448dcf6d9ee93023bba146e4a36 100644
--- a/src/xercesc/util/Platforms/AIX/AIXPlatformUtils.cpp
+++ b/src/xercesc/util/Platforms/AIX/AIXPlatformUtils.cpp
@@ -253,6 +253,18 @@ FileHandle XMLPlatformUtils::openFile(const char* const fileName)
     return retVal;
 }
 
+FileHandle XMLPlatformUtils::openFileToWrite(const XMLCh* const fileName)
+{
+    const char* tmpFileName = XMLString::transcode(fileName);
+    ArrayJanitor<char> janText((char*)tmpFileName);
+    return fopen( tmpFileName , "wb" );
+}
+
+FileHandle XMLPlatformUtils::openFileToWrite(const char* const fileName)
+{
+    return fopen( fileName , "wb" );
+}
+
 unsigned int
 XMLPlatformUtils::readFileBuffer(  FileHandle      theFile
                                 , const unsigned int    toRead
@@ -268,6 +280,42 @@ XMLPlatformUtils::readFileBuffer(  FileHandle      theFile
     return (unsigned int)noOfItemsRead;
 }
 
+void
+XMLPlatformUtils::writeBufferToFile( FileHandle     const  theFile
+                                   , long                  toWrite
+                                   , const XMLByte* const  toFlush)                                   
+{
+    if (!theFile        ||
+        (toWrite <= 0 ) ||
+        !toFlush        ||
+        !*toFlush        )
+        return;
+
+    const XMLByte* tmpFlush = (const XMLByte*) toFlush;
+    unsigned long  bytesWritten = 0;
+
+    while (true)
+    {
+        fwrite(theFile, tmpFlush, toWrite, &bytesWritten, 0);
+
+        if(ferror((FILE*)theFile))
+        {
+            ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotReadFromFile);
+          //ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotWriteToFile);
+        }
+
+        if (bytesWritten < (unsigned long) toWrite) //incomplete write
+        {
+            tmpFlush+=bytesWritten;
+            toWrite-=bytesWritten;
+            bytesWritten=0;
+        }
+        else
+            return;
+    }
+
+    return;
+}
 
 void XMLPlatformUtils::resetFile(FileHandle theFile)
 {
diff --git a/src/xercesc/util/Platforms/HPUX/HPPlatformUtils.cpp b/src/xercesc/util/Platforms/HPUX/HPPlatformUtils.cpp
index ab9462417744ed3e9675de1080c98157c7c61769..406ba4af3d0c156249b7c058295b620c6dbe7708 100644
--- a/src/xercesc/util/Platforms/HPUX/HPPlatformUtils.cpp
+++ b/src/xercesc/util/Platforms/HPUX/HPPlatformUtils.cpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.3  2002/06/19 22:00:57  peiyongz
+ * DOM3:DOMSave Interface support: openFiletoWrite(), writeBuffertoFile()
+ *
  * Revision 1.2  2002/05/21 20:31:47  tng
  * Minor update: Remove obsolete code
  *
@@ -357,6 +360,17 @@ FileHandle XMLPlatformUtils::openFile(const XMLCh* const fileName)
     return retVal;
 }
 
+FileHandle XMLPlatformUtils::openFileToWrite(const XMLCh* const fileName)
+{
+    const char* tmpFileName = XMLString::transcode(fileName);
+    ArrayJanitor<char> janText((char*)tmpFileName);
+    return fopen( tmpFileName , "wb" );
+}
+
+FileHandle XMLPlatformUtils::openFileToWrite(const char* const fileName)
+{
+    return fopen( fileName , "wb" );
+}
 
 FileHandle XMLPlatformUtils::openStdInHandle()
 {
@@ -380,6 +394,42 @@ XMLPlatformUtils::readFileBuffer(       FileHandle      theFile
     return (unsigned int) noOfItemsRead;
 }
 
+void
+XMLPlatformUtils::writeBufferToFile( FileHandle     const  theFile
+                                   , long                  toWrite
+                                   , const XMLByte* const  toFlush)                                   
+{
+    if (!theFile        ||
+        (toWrite <= 0 ) ||
+        !toFlush        ||
+        !*toFlush        )
+        return;
+
+    const XMLByte* tmpFlush = (const XMLByte*) toFlush;
+    unsigned long  bytesWritten = 0;
+
+    while (true)
+    {
+        fwrite(theFile, tmpFlush, toWrite, &bytesWritten, 0);
+
+        if(ferror((FILE*)theFile))
+        {
+            ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotReadFromFile);
+          //ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotWriteToFile);
+        }
+
+        if (bytesWritten < (unsigned long) toWrite) //incomplete write
+        {
+            tmpFlush+=bytesWritten;
+            toWrite-=bytesWritten;
+            bytesWritten=0;
+        }
+        else
+            return;
+    }
+
+    return;
+}
 
 void XMLPlatformUtils::resetFile(FileHandle theFile)
 {
diff --git a/src/xercesc/util/Platforms/Linux/LinuxPlatformUtils.cpp b/src/xercesc/util/Platforms/Linux/LinuxPlatformUtils.cpp
index a79478c6d73f4014cccb673d67f6693d7aca44d3..55ba681a52071f34459438f767371f51debeede3 100644
--- a/src/xercesc/util/Platforms/Linux/LinuxPlatformUtils.cpp
+++ b/src/xercesc/util/Platforms/Linux/LinuxPlatformUtils.cpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.3  2002/06/19 22:01:14  peiyongz
+ * DOM3:DOMSave Interface support: openFiletoWrite(), writeBuffertoFile()
+ *
  * Revision 1.2  2002/05/21 20:31:47  tng
  * Minor update: Remove obsolete code
  *
@@ -356,10 +359,21 @@ FileHandle XMLPlatformUtils::openFile(const char* const fileName)
     return retVal;
 }
 
+FileHandle XMLPlatformUtils::openFileToWrite(const XMLCh* const fileName)
+{
+    const char* tmpFileName = XMLString::transcode(fileName);
+    ArrayJanitor<char> janText((char*)tmpFileName);
+    return fopen( tmpFileName , "wb" );
+}
+
+FileHandle XMLPlatformUtils::openFileToWrite(const char* const fileName)
+{
+    return fopen( fileName , "wb" );
+}
 
 FileHandle XMLPlatformUtils::openStdInHandle()
 {
-        return (FileHandle)fdopen(dup(0), "rb");
+    return (FileHandle)fdopen(dup(0), "rb");
 }
 
 
@@ -380,6 +394,42 @@ XMLPlatformUtils::readFileBuffer( FileHandle          theFile
     return (unsigned int)noOfItemsRead;
 }
 
+void
+XMLPlatformUtils::writeBufferToFile( FileHandle     const  theFile
+                                   , long                  toWrite
+                                   , const XMLByte* const  toFlush)                                   
+{
+    if (!theFile        ||
+        (toWrite <= 0 ) ||
+        !toFlush        ||
+        !*toFlush        )
+        return;
+
+    const XMLByte* tmpFlush = (const XMLByte*) toFlush;
+    unsigned long  bytesWritten = 0;
+
+    while (true)
+    {
+        fwrite(theFile, tmpFlush, toWrite, &bytesWritten, 0);
+
+        if(ferror((FILE*)theFile))
+        {
+            ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotReadFromFile);
+          //ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotWriteToFile);
+        }
+
+        if (bytesWritten < (unsigned long) toWrite) //incomplete write
+        {
+            tmpFlush+=bytesWritten;
+            toWrite-=bytesWritten;
+            bytesWritten=0;
+        }
+        else
+            return;
+    }
+
+    return;
+}
 
 void XMLPlatformUtils::resetFile(FileHandle theFile)
 {
diff --git a/src/xercesc/util/Platforms/Solaris/SolarisPlatformUtils.cpp b/src/xercesc/util/Platforms/Solaris/SolarisPlatformUtils.cpp
index 7aa9d309aa6feb3b7868d8491277d5a5df2249a7..9daab3caea4b6f664147b255ddfd4ecaef3791c9 100644
--- a/src/xercesc/util/Platforms/Solaris/SolarisPlatformUtils.cpp
+++ b/src/xercesc/util/Platforms/Solaris/SolarisPlatformUtils.cpp
@@ -270,6 +270,18 @@ FileHandle XMLPlatformUtils::openFile(const XMLCh* const fileName)
     return retVal;
 }
 
+FileHandle XMLPlatformUtils::openFileToWrite(const XMLCh* const fileName)
+{
+    const char* tmpFileName = XMLString::transcode(fileName);
+    ArrayJanitor<char> janText((char*)tmpFileName);
+    return fopen( tmpFileName , "wb" );
+}
+
+FileHandle XMLPlatformUtils::openFileToWrite(const char* const fileName)
+{
+    return fopen( fileName , "wb" );
+}
+
 unsigned int
 XMLPlatformUtils::readFileBuffer(FileHandle              theFile
                                , const unsigned int      toRead
@@ -287,6 +299,42 @@ XMLPlatformUtils::readFileBuffer(FileHandle              theFile
     return (unsigned int) noOfItemsRead;
 }
 
+void
+XMLPlatformUtils::writeBufferToFile( FileHandle     const  theFile
+                                   , long                  toWrite
+                                   , const XMLByte* const  toFlush)                                   
+{
+    if (!theFile        ||
+        (toWrite <= 0 ) ||
+        !toFlush        ||
+        !*toFlush        )
+        return;
+
+    const XMLByte* tmpFlush = (const XMLByte*) toFlush;
+    unsigned long  bytesWritten = 0;
+
+    while (true)
+    {
+        fwrite(theFile, tmpFlush, toWrite, &bytesWritten, 0);
+
+        if(ferror((FILE*)theFile))
+        {
+            ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotReadFromFile);
+          //ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotWriteToFile);
+        }
+
+        if (bytesWritten < (unsigned long) toWrite) //incomplete write
+        {
+            tmpFlush+=bytesWritten;
+            toWrite-=bytesWritten;
+            bytesWritten=0;
+        }
+        else
+            return;
+    }
+
+    return;
+}
 
 void XMLPlatformUtils::resetFile(FileHandle theFile)
 {
diff --git a/src/xercesc/util/Platforms/Win32/Win32PlatformUtils.cpp b/src/xercesc/util/Platforms/Win32/Win32PlatformUtils.cpp
index adfb32afc61b896fe873868a21dbb23f1f82ed1c..00c8078418a11271d4a466f29a2422e7e6b5d92b 100644
--- a/src/xercesc/util/Platforms/Win32/Win32PlatformUtils.cpp
+++ b/src/xercesc/util/Platforms/Win32/Win32PlatformUtils.cpp
@@ -347,6 +347,121 @@ FileHandle XMLPlatformUtils::openFile(const XMLCh* const fileName)
     return retVal;
 }
 
+FileHandle XMLPlatformUtils::openFileToWrite(const char* const fileName)
+{
+    FileHandle retVal = ::CreateFileA
+    (
+        fileName
+        , GENERIC_WRITE
+        , 0              // no shared write
+        , 0
+        , CREATE_ALWAYS
+        , FILE_FLAG_WRITE_THROUGH
+        , 0
+    );
+
+    if (retVal == INVALID_HANDLE_VALUE)
+        return 0;
+
+    return retVal;
+}
+
+FileHandle XMLPlatformUtils::openFileToWrite(const XMLCh* const fileName)
+{
+    // Watch for obvious wierdness
+    if (!fileName)
+        return 0;
+
+    //  Ok, this might look stupid but its a semi-expedient way to deal
+    //  with a thorny problem. Shift-JIS and some other Asian encodings
+    //  are fundamentally broken and map both the backslash and the Yen
+    //  sign to the same code point. Transcoders have to pick one or the
+    //  other to map '\' to Unicode and tend to choose the Yen sign. 
+    //
+    //  Unicode Yen or Won signs as directory separators will fail.
+    //
+    //  So, we will check this path name for Yen or won signs and, if they are
+    //  there, we'll replace them with slashes.  
+    //
+    //  A further twist:  we replace Yen and Won with forward slashes rather 
+    //   than back slashes.  Either form of slash will work as a directory
+    //   separator.  On Win 95 and 98, though, Unicode back-slashes may
+    //   fail to transode back to 8-bit 0x5C with some Unicode converters
+    //   to  some of the problematic code pages.  Forward slashes always
+    //   transcode correctly back to 8 bit char * form.
+    //
+    XMLCh *tmpUName = 0;
+    const XMLCh *nameToOpen = fileName;
+    
+    const XMLCh* srcPtr = fileName;
+    while (*srcPtr)
+    {
+        if (*srcPtr == chYenSign ||
+            *srcPtr == chWonSign)
+            break;
+        srcPtr++;
+    }
+    
+    //
+    //  If we found a yen, then we have to create a temp file name. Else
+    //  go with the file name as is and save the overhead.
+    //
+    if (*srcPtr)
+    {
+        tmpUName = XMLString::replicate(fileName);
+        
+        XMLCh* tmpPtr = tmpUName;
+        while (*tmpPtr)
+        {
+            if (*tmpPtr == chYenSign ||
+                *tmpPtr == chWonSign)
+                *tmpPtr = chForwardSlash;
+            tmpPtr++;
+        }
+        nameToOpen = tmpUName;
+    }
+    FileHandle retVal = 0;
+    if (gOnNT)
+    {
+        retVal = ::CreateFileW
+            (
+            nameToOpen
+            , GENERIC_WRITE
+            , 0              // no shared write
+            , 0
+            , CREATE_ALWAYS
+            , FILE_FLAG_WRITE_THROUGH
+            , 0
+            );
+    }
+    else
+    {
+        //
+        //  We are Win 95 / 98.  Take the Unicode file name back to (char *)
+        //    so that we can open it.
+        //
+        char* tmpName = XMLString::transcode(nameToOpen);
+        retVal = ::CreateFileA
+            (
+            tmpName
+            , GENERIC_WRITE
+            , 0              // no shared write
+            , 0
+            , CREATE_ALWAYS
+            , FILE_FLAG_WRITE_THROUGH
+            , 0
+            );
+        delete [] tmpName;
+    }
+
+    if (tmpUName)  
+        delete [] tmpUName;
+    
+    if (retVal == INVALID_HANDLE_VALUE)
+        return 0;
+    
+    return retVal;
+}
 
 FileHandle XMLPlatformUtils::openStdInHandle()
 {
@@ -395,6 +510,38 @@ XMLPlatformUtils::readFileBuffer(       FileHandle      theFile
     return (unsigned int)bytesRead;
 }
 
+void
+XMLPlatformUtils::writeBufferToFile( FileHandle     const  theFile
+                                   , long                  toWrite
+                                   , const XMLByte* const  toFlush)                                   
+{
+    if (!theFile        ||
+        (toWrite <= 0 ) ||
+        !toFlush        ||
+        !*toFlush        )
+        return;
+
+    const XMLByte* tmpFlush = (const XMLByte*) toFlush;
+    unsigned long  bytesWritten = 0;
+
+    while (true)
+    {
+        if (!::WriteFile(theFile, tmpFlush, toWrite, &bytesWritten, 0))
+            ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotReadFromFile);
+          //ThrowXML(XMLPlatformUtilsException, XMLExcepts::File_CouldNotWriteToFile);
+
+        if (bytesWritten < (unsigned long) toWrite) //incomplete write
+        {
+            tmpFlush+=bytesWritten;
+            toWrite-=bytesWritten;
+            bytesWritten=0;
+        }
+        else
+            return;
+    }
+
+    return;
+}
 
 void XMLPlatformUtils::resetFile(FileHandle theFile)
 {