[Pharo-users] Lost in stream
monty2 at programmer.net
Sun Jun 17 20:18:41 EDT 2018
<drgenius><drgeo name="Triangle homothétie"/></drgenius>' parseXML
and you should get (with any recent XMLParser lib):
<?xml version="1.0"?><drgenius><drgeo name="Triangle homothétie"/></drgenius>
If you don't want entity replacement, set #replacesContentEntityReferences: to false. Also consider using XMLParser's built-in file reading support: #parseFileNamed:/#onFileNamed:. They work cross platform (Squeak, GS), and handle character decoding.
> Sent: Saturday, June 16, 2018 at 4:27 AM
> From: Hilaire <hilaire at drgeo.eu>
> To: pharo-users at lists.pharo.org
> Subject: Re: [Pharo-users] Lost in stream
> Sometime you just need a good sleep, which I was fortunate to have.
> My newer code append contents to existing file, so it lead to corrupted
> files at the end. Ensuring it is deleted first solved the problem:
> (location asFileReference / filename) ensureDelete binaryWriteStreamDo:
> [ :fileStream |
> fileStream nextPutAll: stream contents]
> There is still the issue of XML entity I described in an previous email,
> the impact is minor for Dr. Geo though. Do other have issues with that?
> Le 15/06/2018 à 18:31, Hilaire a écrit :
> > This fromer code to save file (xml or PNG file):
> > " |streamOnDisk|
> > [streamOnDisk := MultiByteFileStream forceNewFileNamed: (self
> > absolutePath: filename).
> > streamOnDisk nextPutAll: stream contents] ensure:
> > [streamOnDisk close]"
> > and the newer one:
> > (location asFileReference / filename) binaryWriteStreamDo: [
> > :fileStream |
> > fileStream nextPutAll: stream contents]
> > The new one produce both wrong XML file and PNG file. The file looks
> > short cuted at the end.
> Dr. Geo
More information about the Pharo-users