This file is indexed.

/usr/share/doc/libxmlada-doc/html/dom.html is in libxmlada-doc 17.1.2017-5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>5. The DOM module &#8212; XML/Ada: the XML Library for Ada 18.0w documentation</title>
    
    <link rel="stylesheet" href="_static/sphinxdoc.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '18.0w',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true,
        SOURCELINK_SUFFIX: '.txt'
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="shortcut icon" href="_static/favicon.ico"/>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="6. The Schema module" href="schema.html" />
    <link rel="prev" title="4. The SAX module" href="sax.html" /> 
  </head>
  <body role="document">
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="schema.html" title="6. The Schema module"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="sax.html" title="4. The SAX module"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">XML/Ada: the XML Library for Ada 18.0w documentation</a> &#187;</li> 
      </ul>
    </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="index.html">
              <img class="logo" src="_static/adacore_transparent.png" alt="Logo"/>
            </a></p>
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">5. The DOM module</a><ul>
<li><a class="reference internal" href="#using-dom">5.1. Using DOM</a></li>
<li><a class="reference internal" href="#editing-dom-trees">5.2. Editing DOM trees</a></li>
<li><a class="reference internal" href="#printing-dom-tress">5.3. Printing DOM tress</a></li>
<li><a class="reference internal" href="#adding-information-to-the-tree">5.4. Adding information to the tree</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="sax.html"
                        title="previous chapter">4. The SAX module</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="schema.html"
                        title="next chapter">6. The Schema module</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="_sources/dom.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <div><input type="text" name="q" /></div>
      <div><input type="submit" value="Go" /></div>
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="the-dom-module">
<span id="id1"></span><h1>5. The DOM module<a class="headerlink" href="#the-dom-module" title="Permalink to this headline"></a></h1>
<p>DOM is another standard associated with XML, in which the XML stream is
represented as a tree in memory. This tree can be manipulated at will, to add
new nodes, remove existing nodes, change attributes,...</p>
<p>Since it contains the whole XML information, it can then in turn be dump to a
stream.</p>
<p>As an example, most modern web browsers provide a DOM interface to the document
currently loaded in the browser. Using javascript, one can thus modify
dynamically the document. The calls to do so are similar to the ones provided
by XML/Ada for manipulating a DOM tree, and all are defined in the DOM
standard.</p>
<p>The W3C commitee (<a class="reference external" href="http://www.w3c.org">http://www.w3c.org</a>) has defined
several version of the DOM, each building on the previous one and adding
several enhancements.</p>
<p>XML/Ada currently supports the second revision of DOM (DOM 2.0), which mostly
adds namespaces over the first revision. The third revision is not supported at
this point, and it adds support for loading and saving XML streams in a
standardized fashion.</p>
<p>Although it doesn&#8217;t support DOM 3.0, XML/Ada provides subprograms for doing
similar things.</p>
<p>Only the Core module of the DOM standard is currently implemented, other
modules will follow.</p>
<p>Note that the <code class="file docutils literal"><span class="pre">encodings.ads</span></code> file specifies the encoding to use to store
the tree in memory. Full compatibility with the XML standard requires that this
be UTF16, however, it is generally much more memory-efficient for European
languages to use UTF8. You can freely change this and recompile.</p>
<div class="section" id="using-dom">
<span id="id2"></span><h2>5.1. Using DOM<a class="headerlink" href="#using-dom" title="Permalink to this headline"></a></h2>
<p>In XML/Ada, the DOM tree is build through a special implementation of a
SAX parser, provided in the <cite>DOM.Readers</cite> package.</p>
<p>Using DOM to read an XML document is similar to using SAX: one must setup an
input stream, then parse the document and get the tree. This is done with a
code similar to the following:</p>
<div class="highlight-ada"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="kn">with</span> <span class="nn">Input_Sources.File</span><span class="p">;</span> <span class="kn">use</span> <span class="nn">Input_Sources.File</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Sax.Readers</span><span class="p">;</span>        <span class="kn">use</span> <span class="nn">Sax.Readers</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">DOM.Readers</span><span class="p">;</span>        <span class="kn">use</span> <span class="nn">DOM.Readers</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">DOM.Core</span><span class="p">;</span>           <span class="kn">use</span> <span class="nn">DOM.Core</span><span class="p">;</span>

<span class="kd">procedure</span> <span class="nf">DomExample</span> <span class="kr">is</span>
   <span class="n">Input</span>  <span class="p">:</span> <span class="n">File_Input</span><span class="p">;</span>
   <span class="n">Reader</span> <span class="p">:</span> <span class="n">Tree_Reader</span><span class="p">;</span>
   <span class="n">Doc</span>    <span class="p">:</span> <span class="n">Document</span><span class="p">;</span>
<span class="kr">begin</span>
   <span class="n">Set_Public_Id</span> <span class="p">(</span><span class="n">Input</span><span class="p">,</span> <span class="s">&quot;Preferences file&quot;</span><span class="p">);</span>
   <span class="n">Open</span> <span class="p">(</span><span class="s">&quot;pref.xml&quot;</span><span class="p">,</span> <span class="n">Input</span><span class="p">);</span>

   <span class="n">Set_Feature</span> <span class="p">(</span><span class="n">Reader</span><span class="p">,</span> <span class="n">Validation_Feature</span><span class="p">,</span> <span class="kc">False</span><span class="p">);</span>
   <span class="n">Set_Feature</span> <span class="p">(</span><span class="n">Reader</span><span class="p">,</span> <span class="n">Namespace_Feature</span><span class="p">,</span> <span class="kc">False</span><span class="p">);</span>

   <span class="n">Parse</span> <span class="p">(</span><span class="n">Reader</span><span class="p">,</span> <span class="n">Input</span><span class="p">);</span>
   <span class="n">Close</span> <span class="p">(</span><span class="n">Input</span><span class="p">);</span>

   <span class="n">Doc</span> <span class="p">:=</span> <span class="n">Get_Tree</span> <span class="p">(</span><span class="n">Reader</span><span class="p">);</span> 

   <span class="n">Free</span> <span class="p">(</span><span class="n">Reader</span><span class="p">);</span>
<span class="kr">end</span> <span class="nf">DomExample</span><span class="p">;</span>
</pre></div>
</td></tr></table></div>
<p>This code is almost exactly the same as the code that was used when
demonstrating the use of SAX (<a class="reference internal" href="sax.html#using-sax"><span class="std std-ref">Using SAX</span></a>).</p>
<p>The main two differences are:</p>
<ul class="simple">
<li>We no longer need to define our own XML reader, and we simply use the
one provided in <cite>DOM.Readers</cite>.</li>
<li>We therefore do not add our own callbacks to react to the XML events.
Instead, the last instruction of the program gets a handle on the tree that
was created in memory.</li>
</ul>
<p>The tree can now be manipulated to get access to the value stored.
If we want to implement the same thing we did for SAX, the code would look
like:</p>
<div class="highlight-ada"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="kn">with</span> <span class="nn">Input_Sources.File</span><span class="p">;</span> <span class="kn">use</span> <span class="nn">Input_Sources.File</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Sax.Readers</span><span class="p">;</span>        <span class="kn">use</span> <span class="nn">Sax.Readers</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">DOM.Readers</span><span class="p">;</span>        <span class="kn">use</span> <span class="nn">DOM.Readers</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">DOM.Core</span><span class="p">;</span>           <span class="kn">use</span> <span class="nn">DOM.Core</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">DOM.Core.Documents</span><span class="p">;</span> <span class="kn">use</span> <span class="nn">DOM.Core.Documents</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">DOM.Core.Nodes</span><span class="p">;</span>     <span class="kn">use</span> <span class="nn">DOM.Core.Nodes</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">DOM.Core.Attrs</span><span class="p">;</span>     <span class="kn">use</span> <span class="nn">DOM.Core.Attrs</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Ada.Text_IO</span><span class="p">;</span>        <span class="kn">use</span> <span class="nn">Ada.Text_IO</span><span class="p">;</span>

<span class="kd">procedure</span> <span class="nf">DomExample2</span> <span class="kr">is</span>
   <span class="n">Input</span>  <span class="p">:</span> <span class="n">File_Input</span><span class="p">;</span>
   <span class="n">Reader</span> <span class="p">:</span> <span class="n">Tree_Reader</span><span class="p">;</span>
   <span class="n">Doc</span>    <span class="p">:</span> <span class="n">Document</span><span class="p">;</span>
   <span class="n">List</span>   <span class="p">:</span> <span class="n">Node_List</span><span class="p">;</span>
   <span class="n">N</span>      <span class="p">:</span> <span class="n">Node</span><span class="p">;</span>
   <span class="n">A</span>      <span class="p">:</span> <span class="n">Attr</span><span class="p">;</span>
<span class="kr">begin</span>
   <span class="n">Set_Public_Id</span> <span class="p">(</span><span class="n">Input</span><span class="p">,</span> <span class="s">&quot;Preferences file&quot;</span><span class="p">);</span>
   <span class="n">Open</span> <span class="p">(</span><span class="s">&quot;pref.xml&quot;</span><span class="p">,</span> <span class="n">Input</span><span class="p">);</span>

   <span class="n">Set_Feature</span> <span class="p">(</span><span class="n">Reader</span><span class="p">,</span> <span class="n">Validation_Feature</span><span class="p">,</span> <span class="kc">False</span><span class="p">);</span>
   <span class="n">Set_Feature</span> <span class="p">(</span><span class="n">Reader</span><span class="p">,</span> <span class="n">Namespace_Feature</span><span class="p">,</span> <span class="kc">False</span><span class="p">);</span>

   <span class="n">Parse</span> <span class="p">(</span><span class="n">Reader</span><span class="p">,</span> <span class="n">Input</span><span class="p">);</span>
   <span class="n">Close</span> <span class="p">(</span><span class="n">Input</span><span class="p">);</span>

   <span class="n">Doc</span> <span class="p">:=</span> <span class="n">Get_Tree</span> <span class="p">(</span><span class="n">Reader</span><span class="p">);</span> 

   <span class="n">List</span> <span class="p">:=</span> <span class="n">Get_Elements_By_Tag_Name</span> <span class="p">(</span><span class="n">Doc</span><span class="p">,</span> <span class="s">&quot;pref&quot;</span><span class="p">);</span>

   <span class="kr">for</span> <span class="n">Index</span> <span class="ow">in</span> <span class="mi">1</span> <span class="p">..</span> <span class="n">Length</span> <span class="p">(</span><span class="n">List</span><span class="p">)</span> <span class="kr">loop</span>
       <span class="n">N</span> <span class="p">:=</span> <span class="n">Item</span> <span class="p">(</span><span class="n">List</span><span class="p">,</span> <span class="n">Index</span> <span class="o">-</span> <span class="mi">1</span><span class="p">);</span>
       <span class="n">A</span> <span class="p">:=</span> <span class="n">Get_Named_Item</span> <span class="p">(</span><span class="n">Attributes</span> <span class="p">(</span><span class="n">N</span><span class="p">),</span> <span class="s">&quot;name&quot;</span><span class="p">);</span>
       <span class="n">Put_Line</span> <span class="p">(</span><span class="s">&quot;Value of &quot;&quot;&quot;</span> <span class="o">&amp;</span> <span class="n">Value</span> <span class="p">(</span><span class="n">A</span><span class="p">)</span> <span class="o">&amp;</span> <span class="s">&quot;&quot;&quot; is &quot;</span>
                 <span class="o">&amp;</span> <span class="n">Node_Value</span> <span class="p">(</span><span class="n">First_Child</span> <span class="p">(</span><span class="n">N</span><span class="p">)));</span>
   <span class="kr">end</span> <span class="kr">loop</span><span class="p">;</span> 

   <span class="n">Free</span> <span class="p">(</span><span class="n">List</span><span class="p">);</span>

   <span class="n">Free</span> <span class="p">(</span><span class="n">Reader</span><span class="p">);</span>
<span class="kr">end</span> <span class="nf">DomExample2</span><span class="p">;</span>
</pre></div>
</td></tr></table></div>
<p>The code is much simpler than with SAX, since most of the work is done
internally by XML/Ada. In particular, for SAX we had to take into account the
fact that the textual contents of a node could be reported in several events.
For DOM, the tree is initially normalized, ie all text nodes are collapsed
together when possible.</p>
<p>This added simplicity has one drawback, which is the amount of memory required
to represent even a simple tree.</p>
<p>XML/Ada optimizes the memory necessary to represent a tree by sharing the
strings as much as possible (this is under control of constants at the
beginning of <code class="file docutils literal"><span class="pre">dom-core.ads</span></code>). Still, DOM requires a significant amount of
information to be kept for each node.</p>
<p>For really big XML streams, it might prove impossible to keep the whole tree in
memory, in which case ad hoc storage might be implemented through the use of a
SAX parser. The implementation of <cite>dom-readers.adb</cite> will prove helpful in
creating such a parser.</p>
</div>
<div class="section" id="editing-dom-trees">
<h2>5.2. Editing DOM trees<a class="headerlink" href="#editing-dom-trees" title="Permalink to this headline"></a></h2>
<p>Once in memory, DOM trees can be manipulated through subprograms provides by
the DOM API.</p>
<p>Each of these subprograms is fully documented both in the Ada specs (the
<code class="file docutils literal"><span class="pre">*.ads</span></code> files) and in the DOM standard itself, which XML/Ada follows
fully.</p>
<p>One important note however is related to the use of strings. Various
subprograms allows you to set the textual content of a node, modify its
attributes,.... Such subprograms take a Byte_Sequence as a parameter.</p>
<p>This Byte_Sequence must always be encoded in the encoding defined in the
package <cite>Sax.Encoding</cite> (as described earlier, changing this package requires
recompiling XML/Ada). By default, this is UTF-8.</p>
<p>Therefore, if you need to set an attribute to a string encoded for
instance in iso-8859-15, you should use the subprogram
<cite>Unicode.Encodings.Convert</cite> to convert it appropriately.
The code would thus look as follows:</p>
<div class="highlight-ada"><div class="highlight"><pre><span></span><span class="n">Set_Attribute</span> <span class="p">(</span><span class="n">N</span><span class="p">,</span> <span class="n">Convert</span> <span class="p">(</span><span class="s">&quot;å&quot;</span><span class="p">,</span> <span class="n">From</span> <span class="p">=&gt;</span> <span class="n">Get_By_Name</span> <span class="p">(</span><span class="s">&quot;iso-8859-15&quot;</span><span class="p">)));</span>
</pre></div>
</div>
</div>
<div class="section" id="printing-dom-tress">
<h2>5.3. Printing DOM tress<a class="headerlink" href="#printing-dom-tress" title="Permalink to this headline"></a></h2>
<p>The standard DOM 2.0 does not define a common way to read DOM trees from
input sources, nor how to write them back to output sources. This was
added in later revision of the standard (DOM 3.0), which is not yet
supported by XML/Ada.</p>
<p>However, the package <code class="file docutils literal"><span class="pre">DOM.Core.Nodes</span></code> provides a <cite>Write</cite>
procedure that can be used for that purpose. It outputs a given DOM tree
to an Ada stream. This stream can then be connected to a standard file
on the disk, to a socket, or be used to transform the tree into a string
in memory.</p>
<p>An example is provided in the XML/Ada distribution, called
<code class="file docutils literal"><span class="pre">dom/test/tostring.adb</span></code> which shows how you can create a stream to
convert the tree in memory, without going through a file on the disk</p>
</div>
<div class="section" id="adding-information-to-the-tree">
<h2>5.4. Adding information to the tree<a class="headerlink" href="#adding-information-to-the-tree" title="Permalink to this headline"></a></h2>
<p>The DOM standard does not mandate each node to have a pointer to the
location it was read from (for instance <cite>file:line:column</cite>). In fact,
storing that for each node would increase the size of the DOM tree
(not small by any means already) significantly.</p>
<p>But depending on your application, this might be a useful information
to have, for instance if you want to report error messages with a
correct location.</p>
<p>Fortunately, this can be done relatively easily by extending the
type <cite>DOM.Readers.Tree_Reader</cite>, and override the <cite>Start_Element</cite>.
You would then add a custom attribute to all the nodes that contain
the location for this node. Here is an example.</p>
<div class="highlight-ada"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="kn">with</span> <span class="nn">DOM.Readers</span><span class="p">;</span>       <span class="kn">use</span> <span class="nn">DOM.Readers</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Sax.Utils</span><span class="p">;</span>         <span class="kn">use</span> <span class="nn">Sax.Utils</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Sax.Readers</span><span class="p">;</span>       <span class="kn">use</span> <span class="nn">Sax.Readers</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Sax.Symbols</span><span class="p">;</span>       <span class="kn">use</span> <span class="nn">Sax.Symbols</span><span class="p">;</span>

<span class="kd">package</span> <span class="nc">DOM_With_Location</span> <span class="kr">is</span>

   <span class="kd">type</span> <span class="kt">Tree_Reader_With_Location</span> <span class="kr">is</span> <span class="kr">new</span> <span class="n">Tree_Reader</span> <span class="kr">with</span> <span class="kr">null record</span><span class="p">;</span>
   <span class="kr">overriding</span> <span class="kd">procedure</span> <span class="nf">Start_Element</span>
      <span class="p">(</span><span class="nv">Handler</span>     <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Tree_Reader_With_Location</span><span class="p">;</span>
       <span class="nv">NS</span>          <span class="p">: </span><span class="nv">Sax</span><span class="p">.</span><span class="nv">Utils</span><span class="p">.</span><span class="nv">XML_NS</span><span class="p">;</span>
       <span class="nv">Local_Name</span>  <span class="p">: </span><span class="nv">Sax</span><span class="p">.</span><span class="nv">Symbols</span><span class="p">.</span><span class="nv">Symbol</span><span class="p">;</span>
       <span class="nv">Atts</span>        <span class="p">: </span><span class="nv">Sax</span><span class="p">.</span><span class="nv">Readers</span><span class="p">.</span><span class="nv">Sax_Attribute_List</span><span class="p">);</span>

<span class="kr">end</span> <span class="nf">DOM_With_Location</span><span class="p">;</span>
</pre></div>
</td></tr></table></div>
<div class="highlight-ada"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30</pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="kn">with</span> <span class="nn">DOM.Core</span><span class="p">;</span>            <span class="kn">use</span> <span class="nn">DOM.Core</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">DOM.Core.Attrs</span><span class="p">;</span>      <span class="kn">use</span> <span class="nn">DOM.Core.Attrs</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">DOM.Core.Documents</span><span class="p">;</span>  <span class="kn">use</span> <span class="nn">DOM.Core.Documents</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">DOM.Core.Elements</span><span class="p">;</span>   <span class="kn">use</span> <span class="nn">DOM.Core.Elements</span><span class="p">;</span>
<span class="kn">with</span> <span class="nn">Sax.Locators</span><span class="p">;</span>        <span class="kn">use</span> <span class="nn">Sax.Locators</span><span class="p">;</span>

<span class="kd">package</span> <span class="kd">body</span> <span class="nc">DOM_With_Location</span> <span class="kr">is</span>

   <span class="kr">overriding</span> <span class="kd">procedure</span> <span class="nf">Start_Element</span>
      <span class="p">(</span><span class="nv">Handler</span>     <span class="p">: </span><span class="nv">in</span> <span class="nv">out</span> <span class="nv">Tree_Reader_With_Location</span><span class="p">;</span>
       <span class="nv">NS</span>          <span class="p">: </span><span class="nv">Sax</span><span class="p">.</span><span class="nv">Utils</span><span class="p">.</span><span class="nv">XML_NS</span><span class="p">;</span>
       <span class="nv">Local_Name</span>  <span class="p">: </span><span class="nv">Sax</span><span class="p">.</span><span class="nv">Symbols</span><span class="p">.</span><span class="nv">Symbol</span><span class="p">;</span>
       <span class="nv">Atts</span>        <span class="p">: </span><span class="nv">Sax_Attribute_List</span><span class="p">)</span>
   <span class="kr">is</span>
      <span class="n">Att</span><span class="p">,</span> <span class="n">Att2</span> <span class="p">:</span> <span class="n">Attr</span><span class="p">;</span>
   <span class="kr">begin</span>
      <span class="c1">--  First create the node as usual</span>
      <span class="n">Start_Element</span> <span class="p">(</span><span class="n">Tree_Reader</span> <span class="p">(</span><span class="n">Handler</span><span class="p">),</span> <span class="n">NS</span><span class="p">,</span> <span class="n">Local_Name</span><span class="p">,</span> <span class="n">Atts</span><span class="p">);</span>

      <span class="c1">--  Then add the new attribute</span>
      <span class="n">Att</span> <span class="p">:=</span> <span class="n">Create_Attribute_NS</span>
         <span class="p">(</span><span class="n">Get_Tree</span> <span class="p">(</span><span class="n">Handler</span><span class="p">),</span>
          <span class="n">Namespace_URI</span>  <span class="p">=&gt;</span> <span class="s">&quot;http://mydomain.com&quot;</span><span class="p">,</span>
          <span class="n">Qualified_Name</span> <span class="p">=&gt;</span> <span class="s">&quot;mydomain:location&quot;</span><span class="p">);</span>
      <span class="n">Set_Value</span> <span class="p">(</span><span class="n">Att</span><span class="p">,</span> <span class="n">To_String</span> <span class="p">(</span><span class="n">Current_Location</span> <span class="p">(</span><span class="n">Handler</span><span class="p">)));</span>

      <span class="n">Att2</span> <span class="p">:=</span> <span class="n">Set_Attribute_Node</span> <span class="p">(</span><span class="n">Handler</span><span class="p">.</span><span class="n">Current_Node</span><span class="p">,</span> <span class="n">Att</span><span class="p">);</span>
   <span class="kr">end</span> <span class="nf">Start_Element</span><span class="p">;</span>

<span class="kr">end</span> <span class="nf">DOM_With_Location</span><span class="p">;</span>
</pre></div>
</td></tr></table></div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="schema.html" title="6. The Schema module"
             >next</a> |</li>
        <li class="right" >
          <a href="sax.html" title="4. The SAX module"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">XML/Ada: the XML Library for Ada 18.0w documentation</a> &#187;</li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2003-2017, AdaCore.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.5.6.
    </div>
  </body>
</html>