You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by CP Lim <CP...@opentec.com.au> on 2001/02/23 05:27:21 UTC

Xerces-c in a read/write scenario

Hi,

I'm interested in using Xerces-c for a project my company's doing, so I
was looking at creating a class capable of reading and writing to a
single XML file.  Since there's no implementation for writing to a file,
I started thinking about writing my own.  

However, I am worried about using this (writer) class in a multi-process
environment (Solaris) as its possible for different processes to use
this new class to write to the file as another process is writing to it.
Looking at the 'SolarisPlatformUtils.cpp' file I realised that it uses a
FILE* to read the files.  From what I know about Solaris, I don't think
Solaris normally cares about the advisory locking imposed on files by
lockf() or fcntl(), so it is possible (I think) for multiple processes
to write to the same XML file, which causes me a whole lot of headache!

Am I being overly worried, or is this multi-process write scenario a
danger in the current(v1.4.0) implementation of Xerces-c?

Thanks in advance.
--
CP Lim                         cpl@opentec.com.au
Systems Integrator        http://www.opentec.com.au
Opentec Pty Ltd            http://www.iebusiness.com.au
6 Lyon Park Road         Phone: (02) 9878-1744
North Ryde NSW 2113  Fax: (02) 9878-1755

Re: Xerces-c in a read/write scenario

Posted by Dean Roddey <dr...@charmedquark.com>.
The file stuff in the platform utils is never used to write any XML out,
only to read. If you look at how the DOMPrint program writes stuff out, it
uses the XMLFormatter class, which can take a target class of any type you
want. Just provide your own formatter target, which does whatever locking
you want. If you want to use some other reading mechanism, then you can
provide your own InputSource and BinInputStream derivatives to do anything
you want. Look at how the MemBufInputSource and StdInputSource classes work.

--------------------------
Dean Roddey
The CIDLib C++ Frameworks
Charmed Quark Software
droddey@charmedquark.com
http://www.charmedquark.com

"We're gonna need a bigger boat"


----- Original Message -----
From: "CP Lim" <CP...@opentec.com.au>
To: "Xerces-C-Dev (E-mail)" <xe...@xml.apache.org>
Sent: Thursday, February 22, 2001 8:27 PM
Subject: Xerces-c in a read/write scenario


> Hi,
>
> I'm interested in using Xerces-c for a project my company's doing, so I
> was looking at creating a class capable of reading and writing to a
> single XML file.  Since there's no implementation for writing to a file,
> I started thinking about writing my own.
>
> However, I am worried about using this (writer) class in a multi-process
> environment (Solaris) as its possible for different processes to use
> this new class to write to the file as another process is writing to it.
> Looking at the 'SolarisPlatformUtils.cpp' file I realised that it uses a
> FILE* to read the files.  From what I know about Solaris, I don't think
> Solaris normally cares about the advisory locking imposed on files by
> lockf() or fcntl(), so it is possible (I think) for multiple processes
> to write to the same XML file, which causes me a whole lot of headache!
>
> Am I being overly worried, or is this multi-process write scenario a
> danger in the current(v1.4.0) implementation of Xerces-c?
>
> Thanks in advance.
> --
> CP Lim                         cpl@opentec.com.au
> Systems Integrator        http://www.opentec.com.au
> Opentec Pty Ltd            http://www.iebusiness.com.au
> 6 Lyon Park Road         Phone: (02) 9878-1744
> North Ryde NSW 2113  Fax: (02) 9878-1755
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>