roxml 1.1 → 1.2

Sign up to get free protection for your applications and to get access to all the features.
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,34 @@
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>populate (ROXML::XMLTextRef)</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 169</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">populate</span>(<span class="ruby-identifier">xml</span>, <span class="ruby-identifier">instance</span>)
15
+ <span class="ruby-identifier">data</span> = <span class="ruby-keyword kw">nil</span>
16
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">text_content</span>
17
+ <span class="ruby-identifier">data</span> = <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">text</span>
18
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">array</span>
19
+ <span class="ruby-identifier">xpath</span> = (<span class="ruby-identifier">wrapper</span> <span class="ruby-value">? </span><span class="ruby-node">&quot;#{wrapper}/#{name}&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-node">&quot;#{name}&quot;</span>)
20
+ <span class="ruby-identifier">data</span> = []
21
+ <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">each_element</span>(<span class="ruby-identifier">xpath</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">e</span><span class="ruby-operator">|</span>
22
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">text</span>
23
+ <span class="ruby-identifier">data</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">e</span>.<span class="ruby-identifier">text</span>.<span class="ruby-identifier">strip</span>.<span class="ruby-identifier">to_latin</span>
24
+ <span class="ruby-keyword kw">end</span>
25
+ <span class="ruby-keyword kw">end</span>
26
+ <span class="ruby-keyword kw">else</span>
27
+ <span class="ruby-identifier">child</span> = <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">elements</span>[<span class="ruby-value">1</span>, <span class="ruby-identifier">name</span>]
28
+ <span class="ruby-identifier">data</span> = <span class="ruby-identifier">child</span>.<span class="ruby-identifier">text</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">child</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">child</span>.<span class="ruby-identifier">text</span>
29
+ <span class="ruby-keyword kw">end</span>
30
+ <span class="ruby-identifier">instance</span>.<span class="ruby-identifier">instance_variable_set</span>(<span class="ruby-node">&quot;@#{accessor}&quot;</span>, <span class="ruby-identifier">data</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">data</span>
31
+ <span class="ruby-identifier">instance</span>
32
+ <span class="ruby-keyword kw">end</span></pre>
33
+ </body>
34
+ </html>
@@ -0,0 +1,165 @@
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>Class: String</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>Class</strong></td>
53
+ <td class="class-name-in-header">String</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
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ Object
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+
77
+
78
+
79
+ <div id="contextContent">
80
+
81
+ <div id="description">
82
+ <p>
83
+ Extension of <a href="String.html">String</a> class to handle conversion
84
+ from/to UTF-8/ISO-8869-1
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="#M000002">to_latin</a>&nbsp;&nbsp;
97
+ <a href="#M000001">to_utf</a>&nbsp;&nbsp;
98
+ </div>
99
+ </div>
100
+
101
+ </div>
102
+
103
+
104
+ <!-- if includes -->
105
+
106
+ <div id="section">
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+ <!-- if method_list -->
116
+ <div id="methods">
117
+ <h3 class="section-bar">Public Instance methods</h3>
118
+
119
+ <div id="method-M000002" class="method-detail">
120
+ <a name="M000002"></a>
121
+
122
+ <div class="method-heading">
123
+ <a href="String.src/M000002.html" target="Code" class="method-signature"
124
+ onclick="popupCode('String.src/M000002.html');return false;">
125
+ <span class="method-name">to_latin</span><span class="method-args">()</span>
126
+ </a>
127
+ </div>
128
+
129
+ <div class="method-description">
130
+ <p>
131
+ Convert this string to iso-8850-1
132
+ </p>
133
+ </div>
134
+ </div>
135
+
136
+ <div id="method-M000001" class="method-detail">
137
+ <a name="M000001"></a>
138
+
139
+ <div class="method-heading">
140
+ <a href="String.src/M000001.html" target="Code" class="method-signature"
141
+ onclick="popupCode('String.src/M000001.html');return false;">
142
+ <span class="method-name">to_utf</span><span class="method-args">()</span>
143
+ </a>
144
+ </div>
145
+
146
+ <div class="method-description">
147
+ <p>
148
+ Return an utf-8 representation of this string.
149
+ </p>
150
+ </div>
151
+ </div>
152
+
153
+
154
+ </div>
155
+
156
+
157
+ </div>
158
+
159
+
160
+ <div id="validator-badges">
161
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
162
+ </div>
163
+
164
+ </body>
165
+ </html>
@@ -0,0 +1,23 @@
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_utf (String)</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 486</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_utf</span>
15
+ <span class="ruby-keyword kw">begin</span>
16
+ <span class="ruby-constant">Iconv</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">&quot;utf-8&quot;</span>, <span class="ruby-value str">&quot;iso-8859-1&quot;</span>).<span class="ruby-identifier">iconv</span>(<span class="ruby-keyword kw">self</span>)
17
+ <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Iconv</span><span class="ruby-operator">::</span><span class="ruby-constant">IllegalSequence</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
18
+ <span class="ruby-constant">STDERR</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;!! Failed converting from UTF-8 -&gt; ISO-8859-1 (#{self}). Already the right charset?&quot;</span>
19
+ <span class="ruby-keyword kw">self</span>
20
+ <span class="ruby-keyword kw">end</span>
21
+ <span class="ruby-keyword kw">end</span></pre>
22
+ </body>
23
+ </html>
@@ -0,0 +1,23 @@
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_latin (String)</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 498</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_latin</span>
15
+ <span class="ruby-keyword kw">begin</span>
16
+ <span class="ruby-constant">Iconv</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">&quot;iso-8859-1&quot;</span>, <span class="ruby-value str">&quot;utf-8&quot;</span>).<span class="ruby-identifier">iconv</span>(<span class="ruby-keyword kw">self</span>)
17
+ <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Iconv</span><span class="ruby-operator">::</span><span class="ruby-constant">IllegalSequence</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
18
+ <span class="ruby-constant">STDERR</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;!! Failed converting from ISO-8859-1 -&gt; UTF-8 (#{self}). Already the right charset?&quot;</span>
19
+ <span class="ruby-keyword kw">self</span>
20
+ <span class="ruby-keyword kw">end</span>
21
+ <span class="ruby-keyword kw">end</span></pre>
22
+ </body>
23
+ </html>
@@ -0,0 +1 @@
1
+ Sat Nov 10 13:51:57 -0500 2007
@@ -0,0 +1,234 @@
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>File: roxml.rb</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="fileHeader">
50
+ <h1>roxml.rb</h1>
51
+ <table class="header-table">
52
+ <tr class="top-aligned-row">
53
+ <td><strong>Path:</strong></td>
54
+ <td>lib/roxml.rb
55
+ </td>
56
+ </tr>
57
+ <tr class="top-aligned-row">
58
+ <td><strong>Last Update:</strong></td>
59
+ <td>Tue Oct 16 20:37:44 -0400 2007</td>
60
+ </tr>
61
+ </table>
62
+ </div>
63
+ <!-- banner header -->
64
+
65
+ <div id="bodyContent">
66
+
67
+
68
+
69
+ <div id="contextContent">
70
+
71
+ <div id="description">
72
+ <p>
73
+ <a href="../../classes/ROXML.html">ROXML</a> Ruby Object to XML mapping
74
+ library. For more information visit <a
75
+ href="http://roxml.rubyforge.org">roxml.rubyforge.org</a>
76
+ </p>
77
+ <p>
78
+ Copyright (c) 2004-2006 Zak Mandhro and Anders Engstrom
79
+ </p>
80
+ <p>
81
+ Permission is hereby granted, free of charge, to any person obtaining a
82
+ copy of this software and associated documentation files (the
83
+ &quot;Software&quot;), to deal in the Software without restriction,
84
+ including without limitation the rights to use, copy, modify, merge,
85
+ publish, distribute, sublicense, and/or sell copies of the Software, and to
86
+ permit persons to whom the Software is furnished to do so, subject to the
87
+ following conditions:
88
+ </p>
89
+ <p>
90
+ The above copyright notice and this permission notice shall be included in
91
+ all copies or substantial portions of the Software.
92
+ </p>
93
+ <p>
94
+ THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,
95
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
96
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
97
+ NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
98
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
99
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
100
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
101
+ </p>
102
+ <h1>Quick Start Guide</h1>
103
+ <p>
104
+ This is a short usage example. See <a
105
+ href="../../classes/ROXML/ROXML_Class.html">ROXML::ROXML_Class</a> and
106
+ packaged test cases for more information.
107
+ </p>
108
+ <p>
109
+ Consider an XML document representing a Library containing a number of
110
+ Books. You can map this structure to Ruby classes that provide addition
111
+ useful behavior. With <a href="../../classes/ROXML.html">ROXML</a>, you can
112
+ annotate the Ruby classes as follows:
113
+ </p>
114
+ <pre>
115
+ class Book
116
+ include ROXML
117
+
118
+ xml_attribute :isbn, &quot;ISBN&quot;
119
+ xml_text :title
120
+ xml_text :description, nil, ROXML::TAG_CDATA
121
+ xml_text :author
122
+ end
123
+
124
+ class Library
125
+ include ROXML
126
+
127
+ xml_text :name, &quot;NAME&quot;, ROXML::TAG_CDATA
128
+ xml_object :books, Book, ROXML::TAG_ARRAY, &quot;books&quot;
129
+ end
130
+ </pre>
131
+ <p>
132
+ To create a library and put a number of books in it we could run the
133
+ following code:
134
+ </p>
135
+ <pre>
136
+ book = Book.new()
137
+ book.isbn = &quot;0201710897&quot;
138
+ book.title = &quot;The PickAxe&quot;
139
+ book.description = &quot;Best Ruby book out there!&quot;
140
+ book.author = &quot;David Thomas, Andrew Hunt, Dave Thomas&quot;
141
+
142
+ lib = Library.new()
143
+ lib.name = &quot;Favorite Books&quot;
144
+ lib &lt;&lt; book
145
+ </pre>
146
+ <p>
147
+ To save this information to an XML file:
148
+ </p>
149
+ <pre>
150
+ File.open(&quot;library.xml&quot;, &quot;w&quot;) do |f|
151
+ lib.to_xml.write(f, 0)
152
+ end
153
+ </pre>
154
+ <p>
155
+ To later populate the library object from the XML file:
156
+ </p>
157
+ <pre>
158
+ lib = Library.parse(File.read(&quot;library.xml&quot;))
159
+ </pre>
160
+ <p>
161
+ Similarly, to do a one-to-one mapping between XML objects, such as book and
162
+ publisher, you would use the <b>xml_object</b> annotation. For example:
163
+ </p>
164
+ <pre>
165
+ &lt;book isbn=&quot;0974514055&quot;&gt;
166
+ &lt;title&gt;Programming Ruby - 2nd Edition&lt;/title&gt;
167
+ &lt;description&gt;Second edition of the great book.&lt;/description&gt;
168
+ &lt;publisher&gt;
169
+ &lt;name&gt;Pragmatic Bookshelf&lt;/name&gt;
170
+ &lt;/publisher&gt;
171
+ &lt;/book&gt;
172
+ </pre>
173
+ <p>
174
+ can be mapped using the following code:
175
+ </p>
176
+ <pre>
177
+ class BookWithPublisher
178
+ include ROXML
179
+
180
+ xml_name :book
181
+ xml_object :publisher, Publisher
182
+ end
183
+ </pre>
184
+ <p>
185
+ Note: In the above example, <em>xml_name</em> annotation tells <a
186
+ href="../../classes/ROXML.html">ROXML</a> to set the element name to
187
+ &quot;book&quot; for mapping to XML. The default is XML element name is the
188
+ class name in lowercase; &quot;bookwithpublisher&quot; in this case.
189
+ </p>
190
+ <p>
191
+ For more information on available annotations, see <a
192
+ href="../../classes/ROXML/ROXML_Class.html">ROXML::ROXML_Class</a>
193
+ </p>
194
+
195
+ </div>
196
+
197
+ <div id="requires-list">
198
+ <h3 class="section-bar">Required files</h3>
199
+
200
+ <div class="name-list">
201
+ rexml/document&nbsp;&nbsp;
202
+ iconv&nbsp;&nbsp;
203
+ </div>
204
+ </div>
205
+
206
+ </div>
207
+
208
+
209
+ </div>
210
+
211
+
212
+ <!-- if includes -->
213
+
214
+ <div id="section">
215
+
216
+
217
+
218
+
219
+
220
+
221
+
222
+
223
+ <!-- if method_list -->
224
+
225
+
226
+ </div>
227
+
228
+
229
+ <div id="validator-badges">
230
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
231
+ </div>
232
+
233
+ </body>
234
+ </html>