comp.lang.ada
 help / color / mirror / Atom feed
From: Marc C <mc.provisional@gmail.com>
Subject: Re: Generating an XML DOM tree from scratch withXML/Ada 2013
Date: Mon, 24 Mar 2014 13:18:13 -0700 (PDT)
Date: 2014-03-24T13:18:13-07:00	[thread overview]
Message-ID: <caa03d8d-8fa2-48bf-b5fd-2b770134d0eb@googlegroups.com> (raw)
In-Reply-To: <lghocs$ohn$1@loke.gir.dk>

On Friday, March 21, 2014 11:12:11 AM UTC-5, J Kimball wrote:
> I have done this. The organization and documentation of XML is perplexing and I've also spent hours banging my head against a wall trying to use namespaces and validation.

I appreciate the effort on your part, but it didn't address my problem of programmatically creating an XML document from scratch.

Fortunately I figured out how to go about it, by sorta abusing some of the XML/Ada services (in the following code fragments the withs and uses are omitted, and suitable variable declarations are presumed):

You have to have a DOM_Implementation variable, such as DOM_Impl. Don't worry about getting it or initializing it. Merely declaring it is sufficient.

  DOM_Impl : DOM.Core.DOM_Implementation;

Create a document:

   Doc := Create_Document(DOM_Impl);

Create the root element with its namespace reference:

   Root_Element := Create_Element_NS(Doc, "myNS",
                                          "myNS:rootElement");

Abuse the set attribute service:

   Elements.Set_Attribute_NS
       (Root_Element,
        "xmlns",
        "xmlns:myNS",
        "http://path-to-namespace/more/and/more");

And from this point on you can build the document using Create_Element_NS, Append_Child, etc. to your heart's content.

Marc


      reply	other threads:[~2014-03-24 20:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-20 17:00 Generating an XML DOM tree from scratch withXML/Ada 2013 Marc C
2014-03-21 16:12 ` J Kimball
2014-03-24 20:18   ` Marc C [this message]
replies disabled

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