roxml 1.2 → 2.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +18 -0
- data/README.rdoc +126 -0
- data/Rakefile +100 -0
- data/lib/roxml.rb +479 -485
- data/lib/roxml/extensions/active_support.rb +32 -0
- data/lib/roxml/extensions/array.rb +5 -0
- data/lib/roxml/extensions/array/conversions.rb +25 -0
- data/lib/roxml/extensions/deprecation.rb +28 -0
- data/lib/roxml/extensions/string.rb +21 -0
- data/lib/roxml/extensions/string/conversions.rb +44 -0
- data/lib/roxml/extensions/string/iterators.rb +12 -0
- data/lib/roxml/options.rb +266 -0
- data/lib/roxml/xml.rb +223 -0
- data/lib/roxml/xml/libxml.rb +63 -0
- data/lib/roxml/xml/rexml.rb +64 -0
- data/roxml.gemspec +105 -0
- data/test/fixtures/book_text_with_attribute.xml +1 -1
- data/test/fixtures/book_valid.xml +2 -2
- data/test/fixtures/book_with_authors.xml +7 -0
- data/test/fixtures/book_with_contributors_attrs.xml +7 -0
- data/test/fixtures/book_with_default_namespace.xml +9 -0
- data/test/fixtures/book_with_depth.xml +6 -0
- data/test/fixtures/book_with_wrapped_attr.xml +3 -0
- data/test/fixtures/dictionary_of_attr_name_clashes.xml +8 -0
- data/test/fixtures/dictionary_of_attrs.xml +6 -0
- data/test/fixtures/dictionary_of_guarded_names.xml +6 -0
- data/test/fixtures/dictionary_of_mixeds.xml +4 -0
- data/test/fixtures/dictionary_of_name_clashes.xml +10 -0
- data/test/fixtures/dictionary_of_names.xml +4 -0
- data/test/fixtures/dictionary_of_texts.xml +10 -0
- data/test/fixtures/library.xml +1 -1
- data/test/fixtures/library_uppercase.xml +30 -0
- data/test/fixtures/muffins.xml +3 -0
- data/test/fixtures/nameless_ageless_youth.xml +2 -0
- data/test/fixtures/node_with_attr_name_conflicts.xml +1 -0
- data/test/fixtures/node_with_name_conflicts.xml +4 -0
- data/test/fixtures/numerology.xml +4 -0
- data/test/fixtures/person_with_guarded_mothers.xml +13 -0
- data/test/fixtures/person_with_mothers.xml +10 -0
- data/test/mocks/dictionaries.rb +56 -0
- data/test/mocks/mocks.rb +244 -48
- data/test/release/dependencies_test.rb +32 -0
- data/test/test_helper.rb +44 -0
- data/test/unit/inheritance_test.rb +19 -0
- data/test/unit/options_test.rb +102 -0
- data/test/unit/roxml_test.rb +24 -0
- data/test/unit/string_test.rb +11 -0
- data/test/unit/to_xml_test.rb +52 -0
- data/test/unit/xml_attribute_test.rb +39 -0
- data/test/unit/xml_block_test.rb +81 -0
- data/test/unit/xml_bool_test.rb +105 -0
- data/test/unit/xml_construct_test.rb +77 -0
- data/test/unit/xml_hash_test.rb +65 -0
- data/test/unit/xml_initialize_test.rb +50 -0
- data/test/unit/xml_name_test.rb +108 -0
- data/test/unit/xml_namespace_test.rb +38 -0
- data/test/unit/xml_object_test.rb +116 -0
- data/test/unit/xml_required_test.rb +93 -0
- data/test/unit/xml_text_test.rb +68 -0
- metadata +138 -87
- data/MIT-LICENSE.txt +0 -9
- data/README +0 -2
- data/doc/classes/ROXML.html +0 -374
- data/doc/classes/ROXML.src/M000003.html +0 -19
- data/doc/classes/ROXML.src/M000004.html +0 -25
- data/doc/classes/ROXML.src/M000005.html +0 -22
- data/doc/classes/ROXML/ROXML_Class.html +0 -429
- data/doc/classes/ROXML/ROXML_Class.src/M000006.html +0 -27
- data/doc/classes/ROXML/ROXML_Class.src/M000007.html +0 -18
- data/doc/classes/ROXML/ROXML_Class.src/M000008.html +0 -19
- data/doc/classes/ROXML/ROXML_Class.src/M000009.html +0 -25
- data/doc/classes/ROXML/ROXML_Class.src/M000010.html +0 -24
- data/doc/classes/ROXML/ROXML_Class.src/M000011.html +0 -18
- data/doc/classes/ROXML/ROXML_Class.src/M000012.html +0 -18
- data/doc/classes/ROXML/XMLAttributeRef.html +0 -175
- data/doc/classes/ROXML/XMLAttributeRef.src/M000015.html +0 -19
- data/doc/classes/ROXML/XMLAttributeRef.src/M000016.html +0 -19
- data/doc/classes/ROXML/XMLObjectRef.html +0 -175
- data/doc/classes/ROXML/XMLObjectRef.src/M000013.html +0 -26
- data/doc/classes/ROXML/XMLObjectRef.src/M000014.html +0 -32
- data/doc/classes/ROXML/XMLRef.html +0 -166
- data/doc/classes/ROXML/XMLRef.src/M000017.html +0 -21
- data/doc/classes/ROXML/XMLTextRef.html +0 -198
- data/doc/classes/ROXML/XMLTextRef.src/M000018.html +0 -28
- data/doc/classes/ROXML/XMLTextRef.src/M000019.html +0 -34
- data/doc/classes/String.html +0 -165
- data/doc/classes/String.src/M000001.html +0 -23
- data/doc/classes/String.src/M000002.html +0 -23
- data/doc/created.rid +0 -1
- data/doc/files/lib/roxml_rb.html +0 -234
- data/doc/fr_class_index.html +0 -33
- data/doc/fr_file_index.html +0 -27
- data/doc/fr_method_index.html +0 -45
- data/doc/index.html +0 -24
- data/doc/rdoc-style.css +0 -208
- data/test/fixture_helper.rb +0 -5
- data/test/test_roxml.rb +0 -105
@@ -1,28 +0,0 @@
|
|
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>update_xml (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 153</span>
|
14
|
-
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">update_xml</span>(<span class="ruby-identifier">xml</span>, <span class="ruby-identifier">value</span>)
|
15
|
-
<span class="ruby-identifier">parent</span> = (<span class="ruby-identifier">wrapper</span> <span class="ruby-value">? </span><span class="ruby-identifier">xml</span>.<span class="ruby-identifier">add_element</span>(<span class="ruby-identifier">wrapper</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">xml</span>)
|
16
|
-
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">text_content</span>
|
17
|
-
<span class="ruby-identifier">parent</span>.<span class="ruby-identifier">text</span> = (<span class="ruby-identifier">cdata</span> <span class="ruby-value">? </span><span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">CData</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">to_utf</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">to_utf</span>)
|
18
|
-
<span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">array</span>
|
19
|
-
<span class="ruby-identifier">value</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
|
20
|
-
<span class="ruby-identifier">parent</span>.<span class="ruby-identifier">add_element</span>(<span class="ruby-identifier">name</span>).<span class="ruby-identifier">text</span> = (<span class="ruby-identifier">cdata</span> <span class="ruby-value">? </span><span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">CData</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">v</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">to_utf</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">to_utf</span>)
|
21
|
-
<span class="ruby-keyword kw">end</span>
|
22
|
-
<span class="ruby-keyword kw">else</span>
|
23
|
-
<span class="ruby-identifier">parent</span>.<span class="ruby-identifier">add_element</span>(<span class="ruby-identifier">name</span>).<span class="ruby-identifier">text</span> = (<span class="ruby-identifier">cdata</span> <span class="ruby-value">? </span><span class="ruby-constant">REXML</span><span class="ruby-operator">::</span><span class="ruby-constant">CData</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">to_utf</span>) <span class="ruby-operator">:</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">to_utf</span>)
|
24
|
-
<span class="ruby-keyword kw">end</span>
|
25
|
-
<span class="ruby-identifier">xml</span>
|
26
|
-
<span class="ruby-keyword kw">end</span></pre>
|
27
|
-
</body>
|
28
|
-
</html>
|
@@ -1,34 +0,0 @@
|
|
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">"#{wrapper}/#{name}"</span> <span class="ruby-operator">:</span> <span class="ruby-node">"#{name}"</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"><<</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">&&</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">"@#{accessor}"</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>
|
data/doc/classes/String.html
DELETED
@@ -1,165 +0,0 @@
|
|
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>
|
97
|
-
<a href="#M000001">to_utf</a>
|
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>
|
@@ -1,23 +0,0 @@
|
|
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">"utf-8"</span>, <span class="ruby-value str">"iso-8859-1"</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">></span> <span class="ruby-identifier">e</span>
|
18
|
-
<span class="ruby-constant">STDERR</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"!! Failed converting from UTF-8 -> ISO-8859-1 (#{self}). Already the right charset?"</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>
|
@@ -1,23 +0,0 @@
|
|
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">"iso-8859-1"</span>, <span class="ruby-value str">"utf-8"</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">></span> <span class="ruby-identifier">e</span>
|
18
|
-
<span class="ruby-constant">STDERR</span> <span class="ruby-operator"><<</span> <span class="ruby-node">"!! Failed converting from ISO-8859-1 -> UTF-8 (#{self}). Already the right charset?"</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>
|
data/doc/created.rid
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Sat Nov 10 13:51:57 -0500 2007
|
data/doc/files/lib/roxml_rb.html
DELETED
@@ -1,234 +0,0 @@
|
|
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
|
-
"Software"), 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 "AS IS", 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, "ISBN"
|
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, "NAME", ROXML::TAG_CDATA
|
128
|
-
xml_object :books, Book, ROXML::TAG_ARRAY, "books"
|
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 = "0201710897"
|
138
|
-
book.title = "The PickAxe"
|
139
|
-
book.description = "Best Ruby book out there!"
|
140
|
-
book.author = "David Thomas, Andrew Hunt, Dave Thomas"
|
141
|
-
|
142
|
-
lib = Library.new()
|
143
|
-
lib.name = "Favorite Books"
|
144
|
-
lib << book
|
145
|
-
</pre>
|
146
|
-
<p>
|
147
|
-
To save this information to an XML file:
|
148
|
-
</p>
|
149
|
-
<pre>
|
150
|
-
File.open("library.xml", "w") 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("library.xml"))
|
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
|
-
<book isbn="0974514055">
|
166
|
-
<title>Programming Ruby - 2nd Edition</title>
|
167
|
-
<description>Second edition of the great book.</description>
|
168
|
-
<publisher>
|
169
|
-
<name>Pragmatic Bookshelf</name>
|
170
|
-
</publisher>
|
171
|
-
</book>
|
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
|
-
"book" for mapping to XML. The default is XML element name is the
|
188
|
-
class name in lowercase; "bookwithpublisher" 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
|
202
|
-
iconv
|
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>
|