comp.lang.ada
 help / color / mirror / Atom feed
* generating an XML file using Ada code
@ 2016-06-24 14:44 Stephen Leake
  2016-06-25  5:32 ` Niklas Holsti
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Stephen Leake @ 2016-06-24 14:44 UTC (permalink / raw)


I'm working on syncing a database between Windows and Android. The Android framework for doing this requires a "changes" file, in either XML or JSON format.

So on the Windows side I need to log all db operations to either xml or json.

Using xmlada, I don't see any way to output a file; I searched for "Text_IO" in the installed library code, and found only input functions. One of the xml tutorials mentions the C function "xmlSaveFormatFile"; I can't find that in the Ada code.

This question has been asked before on this list, several years ago; I hope there is a better answer now.

How can I create an XML file?


For JSON, there is the GNATColl.JSON package, which provides a "Write" function that serializes a JSON object to a string. So I can use that, but I prefer XML (it feels more Ada-like :).

-- Stephe


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: generating an XML file using Ada code
  2016-06-24 14:44 generating an XML file using Ada code Stephen Leake
@ 2016-06-25  5:32 ` Niklas Holsti
  2016-06-25  7:11 ` Simon Wright
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Niklas Holsti @ 2016-06-25  5:32 UTC (permalink / raw)


On 16-06-24 17:44 , Stephen Leake wrote:
> I'm working on syncing a database between Windows and Android. The
> Android framework for doing this requires a "changes" file, in either
> XML or JSON format.
>
> So on the Windows side I need to log all db operations to either xml
> or json.
>
> Using xmlada, I don't see any way to output a file; I searched for
> "Text_IO" in the installed library code, and found only input
> functions. One of the xml tutorials mentions the C function
> "xmlSaveFormatFile"; I can't find that in the Ada code.
>
> This question has been asked before on this list, several years ago;
> I hope there is a better answer now.
>
> How can I create an XML file?

I have used XML EZ Out, http://www.mckae.com/xmlEz.html, with good results.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: generating an XML file using Ada code
  2016-06-24 14:44 generating an XML file using Ada code Stephen Leake
  2016-06-25  5:32 ` Niklas Holsti
@ 2016-06-25  7:11 ` Simon Wright
  2016-06-25 14:14 ` Georg Bauhaus
  2016-06-26 14:15 ` Vadim Godunko
  3 siblings, 0 replies; 5+ messages in thread
From: Simon Wright @ 2016-06-25  7:11 UTC (permalink / raw)


Stephen Leake <stephen_leake@stephe-leake.org> writes:

> How can I create an XML file?

In ASIS2XML[1] I say

   DOM.Core.Nodes.Print (Doc,
                         Print_Comments => True,
                         Print_XML_PI => True,
                         EOL_Sequence => "");

This produces a single very long line of XML; tidy will make a readable
version.

Looking at DOM.Core.Nodes.Print,

   procedure Print
     (N              : Node;
      Print_Comments : Boolean := False;
      Print_XML_PI   : Boolean := False;
      With_URI       : Boolean := False;
      EOL_Sequence   : String  := Sax.Encodings.Lf_Sequence;
      Encoding       : Unicode.Encodings.Unicode_Encoding :=
        Unicode.Encodings.Get_By_Name ("utf-8");
      Collapse_Empty_Nodes : Boolean := False);
   --  For debugging purposes only!
   --
   --  Same as Write, but the output is done on Stdout.
   --  Warning: the default values for the parameters are not the same as for
   --  write. For the latter, they are chosen so that by default the output is
   --  valid XML, whereas Print is mostly intended to be used for testsuite
   --  purposes, and the default match that goal.

I see I should have used DOM.Core.Nodes.Write! Another example of
scratch development code making it into production.

[1] https://sourceforge.net/p/asis2xml/code/ci/default/tree/asis2xml.adb


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: generating an XML file using Ada code
  2016-06-24 14:44 generating an XML file using Ada code Stephen Leake
  2016-06-25  5:32 ` Niklas Holsti
  2016-06-25  7:11 ` Simon Wright
@ 2016-06-25 14:14 ` Georg Bauhaus
  2016-06-26 14:15 ` Vadim Godunko
  3 siblings, 0 replies; 5+ messages in thread
From: Georg Bauhaus @ 2016-06-25 14:14 UTC (permalink / raw)


On 24.06.16 16:44, Stephen Leake wrote:
> I'm working on syncing a database between Windows and Android. The Android framework for doing this requires a "changes" file, in either XML or JSON format.
>
> So on the Windows side I need to log all db operations to either xml or json.
>
> Using xmlada, I don't see any way to output a file;

Maybe print a DOM like this?
http://docs.adacore.com/xmlada-docs/dom.html#printing-dom-tress

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: generating an XML file using Ada code
  2016-06-24 14:44 generating an XML file using Ada code Stephen Leake
                   ` (2 preceding siblings ...)
  2016-06-25 14:14 ` Georg Bauhaus
@ 2016-06-26 14:15 ` Vadim Godunko
  3 siblings, 0 replies; 5+ messages in thread
From: Vadim Godunko @ 2016-06-26 14:15 UTC (permalink / raw)


On Saturday, June 25, 2016 at 2:41:13 AM UTC+3, Stephen Leake wrote:
> 
> How can I create an XML file?
> 
You can use Matreshka's XML.SAX.Pretty_Writers package to generate XML text file and format it (if necessary). It uses "SAX events" to serialize data, thus you don't need to construct whole XML DOM tree in memory before writing to disk.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-06-26 14:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-24 14:44 generating an XML file using Ada code Stephen Leake
2016-06-25  5:32 ` Niklas Holsti
2016-06-25  7:11 ` Simon Wright
2016-06-25 14:14 ` Georg Bauhaus
2016-06-26 14:15 ` Vadim Godunko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox