roxml 1.1 → 1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. data/doc/classes/ROXML.html +374 -0
  2. data/doc/classes/ROXML.src/M000003.html +19 -0
  3. data/doc/classes/ROXML.src/M000004.html +25 -0
  4. data/doc/classes/ROXML.src/M000005.html +22 -0
  5. data/doc/classes/ROXML/ROXML_Class.html +429 -0
  6. data/doc/classes/ROXML/ROXML_Class.src/M000006.html +27 -0
  7. data/doc/classes/ROXML/ROXML_Class.src/M000007.html +18 -0
  8. data/doc/classes/ROXML/ROXML_Class.src/M000008.html +19 -0
  9. data/doc/classes/ROXML/ROXML_Class.src/M000009.html +25 -0
  10. data/doc/classes/ROXML/ROXML_Class.src/M000010.html +24 -0
  11. data/doc/classes/ROXML/ROXML_Class.src/M000011.html +18 -0
  12. data/doc/classes/ROXML/ROXML_Class.src/M000012.html +18 -0
  13. data/doc/classes/ROXML/XMLAttributeRef.html +175 -0
  14. data/doc/classes/ROXML/XMLAttributeRef.src/M000015.html +19 -0
  15. data/doc/classes/ROXML/XMLAttributeRef.src/M000016.html +19 -0
  16. data/doc/classes/ROXML/XMLObjectRef.html +175 -0
  17. data/doc/classes/ROXML/XMLObjectRef.src/M000013.html +26 -0
  18. data/doc/classes/ROXML/XMLObjectRef.src/M000014.html +32 -0
  19. data/doc/classes/ROXML/XMLRef.html +166 -0
  20. data/doc/classes/ROXML/XMLRef.src/M000017.html +21 -0
  21. data/doc/classes/ROXML/XMLTextRef.html +198 -0
  22. data/doc/classes/ROXML/XMLTextRef.src/M000018.html +28 -0
  23. data/doc/classes/ROXML/XMLTextRef.src/M000019.html +34 -0
  24. data/doc/classes/String.html +165 -0
  25. data/doc/classes/String.src/M000001.html +23 -0
  26. data/doc/classes/String.src/M000002.html +23 -0
  27. data/doc/created.rid +1 -0
  28. data/doc/files/lib/roxml_rb.html +234 -0
  29. data/doc/fr_class_index.html +33 -0
  30. data/doc/fr_file_index.html +27 -0
  31. data/doc/fr_method_index.html +45 -0
  32. data/doc/index.html +24 -0
  33. data/doc/rdoc-style.css +208 -0
  34. data/lib/roxml.rb +1 -1
  35. data/test/fixtures/person.xml +1 -0
  36. data/test/mocks/mocks.rb +4 -0
  37. data/test/test_roxml.rb +9 -1
  38. metadata +54 -12
@@ -0,0 +1,374 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Module: ROXML</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Module</strong></td>
53
+ <td class="class-name-in-header">ROXML</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/lib/roxml_rb.html">
59
+ lib/roxml.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ </table>
66
+ </div>
67
+ <!-- banner header -->
68
+
69
+ <div id="bodyContent">
70
+
71
+
72
+
73
+ <div id="contextContent">
74
+
75
+ <div id="description">
76
+ <p>
77
+ <a href="ROXML.html">ROXML</a> Ruby Object to XML mapping library. For more
78
+ information visit <a
79
+ href="http://roxml.rubyforge.org">roxml.rubyforge.org</a>
80
+ </p>
81
+ <p>
82
+ Copyright (c) 2004-2006 Zak Mandhro and Anders Engstrom
83
+ </p>
84
+ <p>
85
+ Permission is hereby granted, free of charge, to any person obtaining a
86
+ copy of this software and associated documentation files (the
87
+ &quot;Software&quot;), to deal in the Software without restriction,
88
+ including without limitation the rights to use, copy, modify, merge,
89
+ publish, distribute, sublicense, and/or sell copies of the Software, and to
90
+ permit persons to whom the Software is furnished to do so, subject to the
91
+ following conditions:
92
+ </p>
93
+ <p>
94
+ The above copyright notice and this permission notice shall be <a
95
+ href="ROXML.html#M000003">included</a> in all copies or substantial
96
+ portions of the Software.
97
+ </p>
98
+ <p>
99
+ THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,
100
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
101
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
102
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
103
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
104
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
105
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
106
+ </p>
107
+ <h1>Quick Start Guide</h1>
108
+ <p>
109
+ This is a short usage example. See <a
110
+ href="ROXML/ROXML_Class.html">ROXML::ROXML_Class</a> and packaged test
111
+ cases for more information.
112
+ </p>
113
+ <p>
114
+ Consider an XML document representing a Library containing a number of
115
+ Books. You can map this structure to Ruby classes that provide addition
116
+ useful behavior. With <a href="ROXML.html">ROXML</a>, you can annotate the
117
+ Ruby classes as follows:
118
+ </p>
119
+ <pre>
120
+ class Book
121
+ include ROXML
122
+
123
+ xml_attribute :isbn, &quot;ISBN&quot;
124
+ xml_text :title
125
+ xml_text :description, nil, ROXML::TAG_CDATA
126
+ xml_text :author
127
+ end
128
+
129
+ class Library
130
+ include ROXML
131
+
132
+ xml_text :name, &quot;NAME&quot;, ROXML::TAG_CDATA
133
+ xml_object :books, Book, ROXML::TAG_ARRAY, &quot;books&quot;
134
+ end
135
+ </pre>
136
+ <p>
137
+ To create a library and put a number of books in it we could run the
138
+ following code:
139
+ </p>
140
+ <pre>
141
+ book = Book.new()
142
+ book.isbn = &quot;0201710897&quot;
143
+ book.title = &quot;The PickAxe&quot;
144
+ book.description = &quot;Best Ruby book out there!&quot;
145
+ book.author = &quot;David Thomas, Andrew Hunt, Dave Thomas&quot;
146
+
147
+ lib = Library.new()
148
+ lib.name = &quot;Favorite Books&quot;
149
+ lib &lt;&lt; book
150
+ </pre>
151
+ <p>
152
+ To save this information to an XML file:
153
+ </p>
154
+ <pre>
155
+ File.open(&quot;library.xml&quot;, &quot;w&quot;) do |f|
156
+ lib.to_xml.write(f, 0)
157
+ end
158
+ </pre>
159
+ <p>
160
+ To later populate the library object from the XML file:
161
+ </p>
162
+ <pre>
163
+ lib = Library.parse(File.read(&quot;library.xml&quot;))
164
+ </pre>
165
+ <p>
166
+ Similarly, to do a one-to-one mapping between XML objects, such as book and
167
+ publisher, you would use the <b>xml_object</b> annotation. For example:
168
+ </p>
169
+ <pre>
170
+ &lt;book isbn=&quot;0974514055&quot;&gt;
171
+ &lt;title&gt;Programming Ruby - 2nd Edition&lt;/title&gt;
172
+ &lt;description&gt;Second edition of the great book.&lt;/description&gt;
173
+ &lt;publisher&gt;
174
+ &lt;name&gt;Pragmatic Bookshelf&lt;/name&gt;
175
+ &lt;/publisher&gt;
176
+ &lt;/book&gt;
177
+ </pre>
178
+ <p>
179
+ can be mapped using the following code:
180
+ </p>
181
+ <pre>
182
+ class BookWithPublisher
183
+ include ROXML
184
+
185
+ xml_name :book
186
+ xml_object :publisher, Publisher
187
+ end
188
+ </pre>
189
+ <p>
190
+ Note: In the above example, <em>xml_name</em> annotation tells <a
191
+ href="ROXML.html">ROXML</a> to set the element name to &quot;book&quot; for
192
+ mapping to XML. The default is XML element name is the class name in
193
+ lowercase; &quot;bookwithpublisher&quot; in this case.
194
+ </p>
195
+ <p>
196
+ For more information on available annotations, see <a
197
+ href="ROXML/ROXML_Class.html">ROXML::ROXML_Class</a>
198
+ </p>
199
+
200
+ </div>
201
+
202
+
203
+ </div>
204
+
205
+ <div id="method-list">
206
+ <h3 class="section-bar">Methods</h3>
207
+
208
+ <div class="name-list">
209
+ <a href="#M000003">included</a>&nbsp;&nbsp;
210
+ <a href="#M000005">method_missing</a>&nbsp;&nbsp;
211
+ <a href="#M000004">to_xml</a>&nbsp;&nbsp;
212
+ </div>
213
+ </div>
214
+
215
+ </div>
216
+
217
+
218
+ <!-- if includes -->
219
+
220
+ <div id="section">
221
+
222
+ <div id="class-list">
223
+ <h3 class="section-bar">Classes and Modules</h3>
224
+
225
+ Module <a href="ROXML/ROXML_Class.html" class="link">ROXML::ROXML_Class</a><br />
226
+ Class <a href="ROXML/XMLAttributeRef.html" class="link">ROXML::XMLAttributeRef</a><br />
227
+ Class <a href="ROXML/XMLObjectRef.html" class="link">ROXML::XMLObjectRef</a><br />
228
+ Class <a href="ROXML/XMLRef.html" class="link">ROXML::XMLRef</a><br />
229
+ Class <a href="ROXML/XMLTextRef.html" class="link">ROXML::XMLTextRef</a><br />
230
+
231
+ </div>
232
+
233
+ <div id="constants-list">
234
+ <h3 class="section-bar">Constants</h3>
235
+
236
+ <div class="name-list">
237
+ <table summary="Constants">
238
+ <tr class="top-aligned-row context-row">
239
+ <td class="context-item-name">TAG_DEFAULT</td>
240
+ <td>=</td>
241
+ <td class="context-item-value">0</td>
242
+ <td width="3em">&nbsp;</td>
243
+ <td class="context-item-desc">
244
+ Default tag behavior declaration with single read and write.
245
+
246
+ </td>
247
+ </tr>
248
+ <tr class="top-aligned-row context-row">
249
+ <td class="context-item-name">TAG_READONLY</td>
250
+ <td>=</td>
251
+ <td class="context-item-value">1</td>
252
+ <td width="3em">&nbsp;</td>
253
+ <td class="context-item-desc">
254
+ Option that may be used to declare that a variable accessor should be
255
+ read-only (no &quot;accessor=(val)&quot; is generated).
256
+
257
+ </td>
258
+ </tr>
259
+ <tr class="top-aligned-row context-row">
260
+ <td class="context-item-name">TAG_CDATA</td>
261
+ <td>=</td>
262
+ <td class="context-item-value">2</td>
263
+ <td width="3em">&nbsp;</td>
264
+ <td class="context-item-desc">
265
+ Option that declares that an XML text element&#8216;s value should be
266
+ wrapped in a CDATA section.
267
+
268
+ </td>
269
+ </tr>
270
+ <tr class="top-aligned-row context-row">
271
+ <td class="context-item-name">TAG_ARRAY</td>
272
+ <td>=</td>
273
+ <td class="context-item-value">4</td>
274
+ <td width="3em">&nbsp;</td>
275
+ <td class="context-item-desc">
276
+ Option that declares an accessor as an array (referencing &quot;many&quot;
277
+ items).
278
+
279
+ </td>
280
+ </tr>
281
+ <tr class="top-aligned-row context-row">
282
+ <td class="context-item-name">TEXT_CONTENT</td>
283
+ <td>=</td>
284
+ <td class="context-item-value">8</td>
285
+ <td width="3em">&nbsp;</td>
286
+ <td class="context-item-desc">
287
+ Option that declares an xml_text annotation to define the text content of
288
+ the container tag
289
+
290
+ </td>
291
+ </tr>
292
+ </table>
293
+ </div>
294
+ </div>
295
+
296
+
297
+
298
+
299
+
300
+
301
+ <!-- if method_list -->
302
+ <div id="methods">
303
+ <h3 class="section-bar">Public Class methods</h3>
304
+
305
+ <div id="method-M000003" class="method-detail">
306
+ <a name="M000003"></a>
307
+
308
+ <div class="method-heading">
309
+ <a href="ROXML.src/M000003.html" target="Code" class="method-signature"
310
+ onclick="popupCode('ROXML.src/M000003.html');return false;">
311
+ <span class="method-name">included</span><span class="method-args">(klass)</span>
312
+ </a>
313
+ </div>
314
+
315
+ <div class="method-description">
316
+ <p>
317
+ Extends the klass with the <a href="ROXML/ROXML_Class.html">ROXML_Class</a>
318
+ module methods.
319
+ </p>
320
+ </div>
321
+ </div>
322
+
323
+ <h3 class="section-bar">Public Instance methods</h3>
324
+
325
+ <div id="method-M000005" class="method-detail">
326
+ <a name="M000005"></a>
327
+
328
+ <div class="method-heading">
329
+ <a href="ROXML.src/M000005.html" target="Code" class="method-signature"
330
+ onclick="popupCode('ROXML.src/M000005.html');return false;">
331
+ <span class="method-name">method_missing</span><span class="method-args">(name, *args)</span>
332
+ </a>
333
+ </div>
334
+
335
+ <div class="method-description">
336
+ <p>
337
+ To make it easier to reference the class&#8216;s attributes all method
338
+ calls to the instance that doesn&#8216;t match an instance method are
339
+ forwarded to the class&#8216;s singleton instance. Only methods starting
340
+ with &#8216;tag_&#8217; are delegated.
341
+ </p>
342
+ </div>
343
+ </div>
344
+
345
+ <div id="method-M000004" class="method-detail">
346
+ <a name="M000004"></a>
347
+
348
+ <div class="method-heading">
349
+ <a href="ROXML.src/M000004.html" target="Code" class="method-signature"
350
+ onclick="popupCode('ROXML.src/M000004.html');return false;">
351
+ <span class="method-name">to_xml</span><span class="method-args">()</span>
352
+ </a>
353
+ </div>
354
+
355
+ <div class="method-description">
356
+ <p>
357
+ Returns an REXML::Element representing this object.
358
+ </p>
359
+ </div>
360
+ </div>
361
+
362
+
363
+ </div>
364
+
365
+
366
+ </div>
367
+
368
+
369
+ <div id="validator-badges">
370
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
371
+ </div>
372
+
373
+ </body>
374
+ </html>
@@ -0,0 +1,19 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>included (ROXML)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/roxml.rb, line 445</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">included</span>(<span class="ruby-identifier">klass</span>)
15
+ <span class="ruby-keyword kw">super</span>
16
+ <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">__send__</span>(<span class="ruby-identifier">:extend</span>, <span class="ruby-constant">ROXML_Class</span>)
17
+ <span class="ruby-keyword kw">end</span></pre>
18
+ </body>
19
+ </html>
@@ -0,0 +1,25 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>to_xml (ROXML)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/roxml.rb, line 454</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_xml</span>
15
+ <span class="ruby-identifier">root</span> = <span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">Element</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">tag_name</span>)
16
+ <span class="ruby-identifier">tag_refs</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ref</span><span class="ruby-operator">|</span>
17
+ <span class="ruby-identifier">v</span> = <span class="ruby-identifier">__send__</span>(<span class="ruby-identifier">ref</span>.<span class="ruby-identifier">accessor</span>)
18
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">v</span>
19
+ <span class="ruby-identifier">root</span> = <span class="ruby-identifier">ref</span>.<span class="ruby-identifier">update_xml</span>(<span class="ruby-identifier">root</span>, <span class="ruby-identifier">v</span>)
20
+ <span class="ruby-keyword kw">end</span>
21
+ <span class="ruby-keyword kw">end</span>
22
+ <span class="ruby-identifier">root</span>
23
+ <span class="ruby-keyword kw">end</span></pre>
24
+ </body>
25
+ </html>
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>method_missing (ROXML)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/roxml.rb, line 470</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">method_missing</span>(<span class="ruby-identifier">name</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
15
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">id2name</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/^tag_/</span>
16
+ <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">__send__</span>(<span class="ruby-identifier">name</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
17
+ <span class="ruby-keyword kw">else</span>
18
+ <span class="ruby-keyword kw">super</span>
19
+ <span class="ruby-keyword kw">end</span>
20
+ <span class="ruby-keyword kw">end</span></pre>
21
+ </body>
22
+ </html>
@@ -0,0 +1,429 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Module: ROXML::ROXML_Class</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Module</strong></td>
53
+ <td class="class-name-in-header">ROXML::ROXML_Class</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/roxml_rb.html">
59
+ lib/roxml.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ </table>
66
+ </div>
67
+ <!-- banner header -->
68
+
69
+ <div id="bodyContent">
70
+
71
+
72
+
73
+ <div id="contextContent">
74
+
75
+ <div id="description">
76
+ <p>
77
+ This class defines the annotation methods that are mixed into your Ruby
78
+ classes for XML mapping information and behavior.
79
+ </p>
80
+ <p>
81
+ See <a href="ROXML_Class.html#M000007">xml_name</a>, <a
82
+ href="ROXML_Class.html#M000009">xml_text</a>, <a
83
+ href="ROXML_Class.html#M000008">xml_attribute</a> and <a
84
+ href="ROXML_Class.html#M000010">xml_object</a> for available annotations.
85
+ </p>
86
+
87
+ </div>
88
+
89
+
90
+ </div>
91
+
92
+ <div id="method-list">
93
+ <h3 class="section-bar">Methods</h3>
94
+
95
+ <div class="name-list">
96
+ <a href="#M000006">parse</a>&nbsp;&nbsp;
97
+ <a href="#M000011">tag_name</a>&nbsp;&nbsp;
98
+ <a href="#M000012">tag_refs</a>&nbsp;&nbsp;
99
+ <a href="#M000008">xml_attribute</a>&nbsp;&nbsp;
100
+ <a href="#M000007">xml_name</a>&nbsp;&nbsp;
101
+ <a href="#M000010">xml_object</a>&nbsp;&nbsp;
102
+ <a href="#M000009">xml_text</a>&nbsp;&nbsp;
103
+ </div>
104
+ </div>
105
+
106
+ </div>
107
+
108
+
109
+ <!-- if includes -->
110
+
111
+ <div id="section">
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+ <!-- if method_list -->
121
+ <div id="methods">
122
+ <h3 class="section-bar">Public Instance methods</h3>
123
+
124
+ <div id="method-M000006" class="method-detail">
125
+ <a name="M000006"></a>
126
+
127
+ <div class="method-heading">
128
+ <a href="ROXML_Class.src/M000006.html" target="Code" class="method-signature"
129
+ onclick="popupCode('ROXML_Class.src/M000006.html');return false;">
130
+ <span class="method-name">parse</span><span class="method-args">(data)</span>
131
+ </a>
132
+ </div>
133
+
134
+ <div class="method-description">
135
+ <p>
136
+ Creates a new Ruby object from XML using mapping information annotated in
137
+ the class.
138
+ </p>
139
+ <p>
140
+ The input data is either a REXML::Element or a <a
141
+ href="../String.html">String</a> representing the XML document.
142
+ </p>
143
+ <p>
144
+ Example
145
+ </p>
146
+ <pre>
147
+ book = Book.parse(File.read(&quot;book.xml&quot;))
148
+ </pre>
149
+ <p>
150
+ or
151
+ </p>
152
+ <pre>
153
+ book = Book.parse(&quot;&lt;book&gt;&lt;name&gt;Beyond Java&lt;/name&gt;&lt;/book&gt;&quot;)
154
+ </pre>
155
+ </div>
156
+ </div>
157
+
158
+ <div id="method-M000011" class="method-detail">
159
+ <a name="M000011"></a>
160
+
161
+ <div class="method-heading">
162
+ <a href="ROXML_Class.src/M000011.html" target="Code" class="method-signature"
163
+ onclick="popupCode('ROXML_Class.src/M000011.html');return false;">
164
+ <span class="method-name">tag_name</span><span class="method-args">()</span>
165
+ </a>
166
+ </div>
167
+
168
+ <div class="method-description">
169
+ <p>
170
+ Returns the tag name (also known as <a
171
+ href="ROXML_Class.html#M000007">xml_name</a>) of the class. If no tag name
172
+ is set with <a href="ROXML_Class.html#M000007">xml_name</a> method, returns
173
+ default class name in lowercase.
174
+ </p>
175
+ </div>
176
+ </div>
177
+
178
+ <div id="method-M000012" class="method-detail">
179
+ <a name="M000012"></a>
180
+
181
+ <div class="method-heading">
182
+ <a href="ROXML_Class.src/M000012.html" target="Code" class="method-signature"
183
+ onclick="popupCode('ROXML_Class.src/M000012.html');return false;">
184
+ <span class="method-name">tag_refs</span><span class="method-args">()</span>
185
+ </a>
186
+ </div>
187
+
188
+ <div class="method-description">
189
+ <p>
190
+ Returns array of internal reference objects, such as attributes and
191
+ composed XML objects
192
+ </p>
193
+ </div>
194
+ </div>
195
+
196
+ <div id="method-M000008" class="method-detail">
197
+ <a name="M000008"></a>
198
+
199
+ <div class="method-heading">
200
+ <a href="ROXML_Class.src/M000008.html" target="Code" class="method-signature"
201
+ onclick="popupCode('ROXML_Class.src/M000008.html');return false;">
202
+ <span class="method-name">xml_attribute</span><span class="method-args">(sym, name = nil, options = 0)</span>
203
+ </a>
204
+ </div>
205
+
206
+ <div class="method-description">
207
+ <p>
208
+ Declare an accessor for the included class that should be represented as an
209
+ XML attribute.
210
+ </p>
211
+ <dl>
212
+ <dt>sym</dt><dd>Symbol representing the name of the accessor
213
+
214
+ </dd>
215
+ <dt>name</dt><dd>An optional name that should be used for the attribute in XML. Default is
216
+ sym.id2name.
217
+
218
+ </dd>
219
+ <dt>options</dt><dd>Valid options are TAG_READONLY to attribute as read-only
220
+
221
+ </dd>
222
+ </dl>
223
+ <p>
224
+ Example:
225
+ </p>
226
+ <pre>
227
+ class Book
228
+ xml_attribute :isbn, &quot;ISBN&quot;
229
+ end
230
+ </pre>
231
+ <p>
232
+ To map:
233
+ </p>
234
+ <pre>
235
+ &lt;book ISBN=&quot;0974514055&quot;&gt;&lt;/book&gt;
236
+ </pre>
237
+ </div>
238
+ </div>
239
+
240
+ <div id="method-M000007" class="method-detail">
241
+ <a name="M000007"></a>
242
+
243
+ <div class="method-heading">
244
+ <a href="ROXML_Class.src/M000007.html" target="Code" class="method-signature"
245
+ onclick="popupCode('ROXML_Class.src/M000007.html');return false;">
246
+ <span class="method-name">xml_name</span><span class="method-args">(name)</span>
247
+ </a>
248
+ </div>
249
+
250
+ <div class="method-description">
251
+ <p>
252
+ Sets the name of the XML element that represents this class. Use this to
253
+ override the default lowercase class name.
254
+ </p>
255
+ <p>
256
+ Example:
257
+ </p>
258
+ <pre>
259
+ class BookWithPublisher
260
+ xml_name :book
261
+ end
262
+ </pre>
263
+ <p>
264
+ Without the <a href="ROXML_Class.html#M000007">xml_name</a> annotation, the
265
+ XML mapped tag would have been &quot;bookwithpublisher&quot;.
266
+ </p>
267
+ </div>
268
+ </div>
269
+
270
+ <div id="method-M000010" class="method-detail">
271
+ <a name="M000010"></a>
272
+
273
+ <div class="method-heading">
274
+ <a href="ROXML_Class.src/M000010.html" target="Code" class="method-signature"
275
+ onclick="popupCode('ROXML_Class.src/M000010.html');return false;">
276
+ <span class="method-name">xml_object</span><span class="method-args">(sym, klass, options = 0, wrapper = nil)</span>
277
+ </a>
278
+ </div>
279
+
280
+ <div class="method-description">
281
+ <p>
282
+ Declares an accessor that represents another <a
283
+ href="../ROXML.html">ROXML</a> class as child XML element (one-to-one or
284
+ composition) or array of child elements (one-to-many or aggregation).
285
+ Default is one-to-one. Use TAG_ARRAY option for one-to-many.
286
+ </p>
287
+ <dl>
288
+ <dt>sym</dt><dd>Symbol representing the name of the accessor.
289
+
290
+ </dd>
291
+ <dt>name</dt><dd>An optional name that should be used for the attribute in XML. Default is
292
+ sym.id2name.
293
+
294
+ </dd>
295
+ <dt>options</dt><dd>TAG_ARRAY for one-to-many, and TAG_READONLY for read-only access.
296
+
297
+ </dd>
298
+ <dt>wrapper</dt><dd>An optional name of a wrapping tag for this XML accessor.
299
+
300
+ </dd>
301
+ </dl>
302
+ <p>
303
+ Composition example:
304
+ </p>
305
+ <pre>
306
+ &lt;book&gt;
307
+ &lt;publisher&gt;
308
+ &lt;name&gt;Pragmatic Bookshelf&lt;/name&gt;
309
+ &lt;/publisher&gt;
310
+ &lt;/book&gt;
311
+ </pre>
312
+ <p>
313
+ Can be mapped using the following code:
314
+ </p>
315
+ <pre>
316
+ class Book
317
+ xml_object :publisher, Publisher
318
+ end
319
+ </pre>
320
+ <p>
321
+ Aggregation example:
322
+ </p>
323
+ <pre>
324
+ &lt;library&gt;
325
+ &lt;name&gt;Ruby books&lt;/name&gt;
326
+ &lt;books&gt;
327
+ &lt;book/&gt;
328
+ &lt;book/&gt;
329
+ &lt;/books&gt;
330
+ &lt;/library&gt;
331
+ </pre>
332
+ <p>
333
+ Can be mapped using the following code:
334
+ </p>
335
+ <pre>
336
+ class Library
337
+ xml_text :name, nil, ROXML::TAG_CDATA
338
+ xml_object :books, Book, ROXML::TAG_ARRAY, &quot;books&quot;
339
+ end
340
+ </pre>
341
+ <p>
342
+ If you don&#8216;t have the &lt;books&gt; tag to wrap around the list of
343
+ &lt;book&gt; tags:
344
+ </p>
345
+ <pre>
346
+ &lt;library&gt;
347
+ &lt;name&gt;Ruby books&lt;/name&gt;
348
+ &lt;book/&gt;
349
+ &lt;book/&gt;
350
+ &lt;/library&gt;
351
+ </pre>
352
+ <p>
353
+ You can skip the wrapper argument:
354
+ </p>
355
+ <pre>
356
+ xml_object :books, Book, ROXML::TAG_ARRAY
357
+ </pre>
358
+ </div>
359
+ </div>
360
+
361
+ <div id="method-M000009" class="method-detail">
362
+ <a name="M000009"></a>
363
+
364
+ <div class="method-heading">
365
+ <a href="ROXML_Class.src/M000009.html" target="Code" class="method-signature"
366
+ onclick="popupCode('ROXML_Class.src/M000009.html');return false;">
367
+ <span class="method-name">xml_text</span><span class="method-args">(sym, name = nil, options = TAG_DEFAULT, wrapper = nil)</span>
368
+ </a>
369
+ </div>
370
+
371
+ <div class="method-description">
372
+ <p>
373
+ Declares an accessor that represents one or more XML text elements.
374
+ </p>
375
+ <dl>
376
+ <dt>sym</dt><dd>Symbol representing the name of the accessor.
377
+
378
+ </dd>
379
+ <dt>name</dt><dd>An optional name that should be used for the attribute in XML. Default is
380
+ sym.id2name.
381
+
382
+ </dd>
383
+ <dt>options</dt><dd>TAG_CDATA for character data, TAG_ARRAY for one-to-many, TEXT_CONTENT to
384
+ declare main text content for containing tag, and TAG_READONLY for
385
+ read-only access.
386
+
387
+ </dd>
388
+ <dt>wrapper</dt><dd>An optional name of a wrapping tag for this XML accessor.
389
+
390
+ </dd>
391
+ </dl>
392
+ <p>
393
+ Example:
394
+ </p>
395
+ <pre>
396
+ class Author
397
+ xml_attribute :role
398
+ xml_text :text, nil, ROXML::TEXT_CONTENT
399
+ end
400
+
401
+ class Book
402
+ xml_text :description, nil, ROXML::TAG_CDATA
403
+ end
404
+ </pre>
405
+ <p>
406
+ To map:
407
+ </p>
408
+ <pre>
409
+ &lt;book&gt;
410
+ &lt;description&gt;&lt;![CDATA[Probably the best Ruby book out there]]&gt;&lt;/description&gt;
411
+ &lt;author role=&quot;primary&quot;&gt;David Thomas&lt;/author&gt;
412
+ &lt;/book&gt;
413
+ </pre>
414
+ </div>
415
+ </div>
416
+
417
+
418
+ </div>
419
+
420
+
421
+ </div>
422
+
423
+
424
+ <div id="validator-badges">
425
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
426
+ </div>
427
+
428
+ </body>
429
+ </html>