[Lazarus] TSynMemo + TSynXMLSyn: How format a XML after load it?

Mattias Gaertner nc-gaertnma at netcologne.de
Wed Oct 28 13:32:44 CET 2015


On Wed, 28 Oct 2015 09:43:23 -0200
Marcos Douglas <md at delfire.net> wrote:

> On Wed, Oct 28, 2015 at 6:48 AM, Mattias Gaertner
> <nc-gaertnma at netcologne.de> wrote:
> > On Wed, 28 Oct 2015 01:17:23 -0200
> > Marcos Douglas <md at delfire.net> wrote:
> >
> >> Hi,
> >>
> >> I'm using TSynMemo and TSynXMLSyn.
> >> How format a XML after load it?
> >
> > Please define "format".
> 
> Ok, sorry.
> 
> I meant format this:
> <?xml version="1.0" encoding="utf-8"?><soap12:Envelope
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> mlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"><soap12:Body>
> <ConsultaAndamentos>     <Result> <Andamento> <Pasta>int</Pasta>
> <Processo>string</Processo> </Andamento>
> </Result></ConsultaAndamentos></soap12:Body>/soap12:Envelope>
> 
> in this:
> 
> <?xml version="1.0" encoding="utf-8"?>
> <soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
>   <soap12:Body>
>     <ConsultaAndamentos>
>       <Result>
>         <Andamento>
>           <Pasta>int</Pasta>
>           <Processo>string</Processo>
>         </Andamento>
>       </Result>
>     </ConsultaAndamentos>
>   </soap12:Body>
> </soap12:Envelope>
> 
> ...automatically, by set a property or use a method.
> Is it possible?

You have to define what to do with text elements containing only
space (e.g. <element> </element>). By default it should keep the
spaces (Note: spaces include tabs and line breaks).

Further complications: CDATA.

The current fpc xml writer creates the indentation, but messes up text
element.
The laz2_xml writer has a flag to keep the indentation and
preserving text elements. This could be extended with a further flag to
indent elements gaps while preserving text elements.

Or you can simply write a function that works for your xml files.

Mattias




More information about the Lazarus mailing list