New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
DOM.html in vendors/XMLF90/current/doc/Tutorial – NEMO

source: vendors/XMLF90/current/doc/Tutorial/DOM.html @ 1960

Last change on this file since 1960 was 1960, checked in by flavoni, 14 years ago

importing XMLF90 r_53 vendor

File size: 6.4 KB
Line 
1<html>
2
3<head>
4  <style>
5        TABLE {align: center; }
6        H1    {color: #ffffff; background: Navy; font-weight: bold; font-family: Tahoma, Verdana; margin: 0px; padding: 2px; }
7        H2    {color: #ffffff; background: #4682B4; font-weight: bold; font-family: Tahoma, Verdana; }
8        TH    {color: #ffffff; background: #4682B4; font-weight: bold; font-family: Tahoma, Verdana; }
9   LI    { font-family: Tahoma, Verdana; }
10  </style>
11</head>
12
13<body>
14 <h1>FDOM</h1>
15 <p>The FDOM is a DOM level 1.0 implementation written in F95.  There are two &quot;gotchas&quot; 
16 that the Fortran programmer should be aware of, and I can't stress either strongly enough.
17 Firstly the DOM, like many programming languages, starts counting from 0, and not 1, for this reason all do loops should run from 0 to length - 1. 
18 Secondly, we while we can not return an object in Fortran <i>per se</i>,
19 we can return a pointer to an arbitrary structure containing mulitple members, including substructures (which is very much like returning an object). 
20 Therefore, you must use the pointer syntax:
21 <pre>
22program main
23
24 use flib_dom
25 
26 type(fnode), pointer :: object
27 type(fnode), pointer :: myNode
28 
29 object => getParentNode(myNode)
30 </pre>
31 <p>and not</p> 
32 <pre>
33program main
34
35 use flib_dom
36 
37 type(fnode) :: object
38 type(fnode) :: myNode
39 
40 object = getParentNode(myNode)
41 </pre>
42 
43 <p>I can anticipate that these two issues (over running lists by
44 counting beyond the last item and trying to assign a pointer with =)
45 will be the cause of most programming errors using FDOM.  But fairly
46 soon you get used to it, if you already program in other languages,
47 or already use pointers in Fortran there shouldn't be any problem at
48 all.</p>
49
50<p>Here is a list of the the methods implemented:</p>
51
52
53 <br/>
54 
55  <h2>(Generic) Node Interface</h2>
56  <ul>
57  <li>getNodeName(<i>node</i>)</li>
58  <li>getNodevalue</i>)</li>
59  <li>getNodeType(<i>node</i>)</li>
60  <li>hasChildNodes(<i>node</i>)</li>
61  <li>hasAttributes(<i>node</i>)</li>
62  <li>getParentNode(<i>node</i>)</li>
63  <li>getFirstChild(<i>node</i>)</li>
64  <li>getLastChild(<i>node</i>)</li>
65  <li>getNextSibling(<i>node</i>)</li>
66  <li>getPreviousSibling(<i>node</i>)</li>
67  <li>getOwnerDocument(<i>node</i>)</li>
68  <li>getAttributes(<i>node</i>)</li>
69  <li>getChildNodes(<i>node</i>)</li>
70  <li>setNodeValue(<i>node, value</i>)</li>
71  <li>appendChild(<i>node, newChild</i>)</li>
72  <li>removeChild(<i>node, oldChild</i>)</li>
73  <li>replaceChild(<i>node, newChild, oldChild</i>)</li>
74  <li>cloneNode(<i>node, [deep]</i>)</li>
75  <li>isSameNode(<i>node, node2</i>)</li>
76  <li>insertBefore(<i>node, newChild, refChild</i>)</li>
77  </ul>
78  <h2>element Node Interface</h2>
79  <ul>
80  <li>getTagName(<i>element</i>)</li>
81  <li>getElementsByTagName(<i>elment, tag</i>)</li>
82  <li>getAttribute(<i>element, name</i>)        </li>
83  <li>getAttributeNode(<i>element, name</i>)</li>
84  <li>setAttribute(<i>element, name, value</i>)</li>
85  <li>setAttributeNode(<i>element, newAttribute</i>)</li>
86  <li>removeAttribute(<i>element, name</i>)</li>
87 </ul>
88  <h2>document Node Interface</h2>
89  <ul>
90  <li>createTextNode(<i>text</i>)</li>
91  <li>createAttribute(<i>name</i>)</li>
92  <li>createElement(<i>name</i>)</li>
93  <li>createComment(<i>data</i>)</li>
94  <li>getElementsByTagName(<i>document, tag</i>)</li>
95 </ul>
96  <h2>attribute Node Interface</h2> 
97  <ul>
98  <li>getName(<i>attr</i>)</li>
99  <li>getValue(<i>attr</i>)</li>
100  <li>setValue(<i>attr, value</i>)</li>
101 </ul>
102  <h2>nodeList Interface</h2>
103  <ul>
104  <li>item(<i>nodeList, i</i>)</li>
105  <li>getLength(<i>nodeList</i>)</li>
106 </ul>
107  <h2>namedNodeMap Interface</h2>
108  <ul>
109  <li>item(<i>namedNodeMap, i</i>)</li>
110  <li>getLength(<i>namedNodeMap</i>)</li>
111  <li>getNamedItem(<i>namedNodeMap, name</i>)</li>
112  <li>setNamedItem(<i>namedNodeMap, name</i>)</li>
113  <li>removeNamedItem(<i>namedNodeMap, name</i>)</li>
114 </ul>
115
116  <br/>
117  <br/>
118  <br/>
119  A partial list of the interfaces of the methods implemented
120 follows. For a full listing, please see the code in subdirectory
121 <tt>dom</tt> of the main distribution.
122  <br/>
123   <ul>
124    <LI>
125      <table border="1" width="90%">
126        <tr><th width="30%">method</th><th width="30%">arguments</th><th width="30%">returns</th><th width="10%">DOM Level</th></tr>
127        <tr><td>getNodeName(node)</td><td>type(fnode) :: node</td><td>string</td><td>1.0</td></tr>
128        <tr><td>getNodeValue(node)</td><td>type(fnode) :: node</td><td>string</td><td>1.0</td></tr>
129        <tr><td>getNodeType(node)</td><td>type(fnode) ::
130  node</td><td>(integer code)</td><td>1.0</td></tr>
131        <tr><td>getParentNode(node)</td><td>type(fnode) :: node</td><td>type(fnode)</td><td>1.0</td></tr>
132        <tr><td>getFirstChild(node)</td><td>type(fnode) :: node</td><td>type(fnode)</td><td>1.0</td></tr>
133        <tr><td>getLastChild(node)</td><td>type(fnode) :: node</td><td>type(fnode)</td><td>1.0</td></tr>
134        <tr><td>getPreviousSibling(node)</td><td>type(fnode) :: node</td><td>type(fnode)</td><td>1.0</td></tr>
135        <tr><td>getNextSibling(node)</td><td>type(fnode) :: node</td><td>type(fnode)</td><td>1.0</td></tr>
136        <tr><td>getOwnerDocument(node)</td><td>type(fnode) :: node</td><td>type(fnode)</td><td>1.0</td></tr>
137   <tr><td>getAttributes(node)</td><td>type(fnode) :: node</td><td>type(fnamedNodeMap)</td><td>1.0</td></tr>
138        <tr><td>getChildNodes(node)</td><td>type(fnode) :: node</td><td>type(fnodeList)</td><td>1.0</td></tr>
139        <tr><td>getOwnerDocument(node)</td><td>type(fnode) :: node</td><td>type(fnode)</td><td>1.0</td></tr>
140   
141   <tr><td>appendChild(node, newChild)</td><td>type(fnode) :: node<br/>type(fnode) :: newChild</td><td>type(fnode)</td><td>1.0</td></tr>
142   <tr><td>removeChild(node, oldChild)</td><td>type(fnode) :: node<br/>type(fnode) :: oldChild</td><td>type(fnode)</td><td>1.0</td></tr>
143   <tr><td>replaceChild(node, newChild, oldChild)</td><td>type(fnode) :: node<br/>type(fnode) :: newChild<br/>type(fnode) :: oldChild</td><td>type(fnode)</td><td>1.0</td></tr>
144        <tr><td>replaceChild(node, refChild, oldChild)</td><td>type(fnode) :: node<br/>type(fnode) :: refChild<br/>type(fnode) :: oldChild</td><td>type(fnode)</td><td>1.0</td></tr>
145        <tr><td>hasChildren(node)</td><td>type(fnode) :: node</td><td>logical</td><td>1.0</td></tr>
146        <tr><td>hasAttributes</td><td>type(fnode) :: node</td><td>logical</td><td>2.0</td></tr>
147        <tr><td>isSameNode(node, node2)</td><td>type(fnode) :: node<br>type(fnode) :: node2</br></td><td>logical</td><td>3.0</td></tr>
148      </table>
149    </LI>
150  </ul>
151 
152  <br/>
153  <br/>
154 
155  </ul>
156</body>
157
158</html>
Note: See TracBrowser for help on using the repository browser.