libxml-ruby 0.8.1-x86-mswin32-60 → 0.8.2-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +21 -0
- data/RAKEFILE +213 -0
- data/README +32 -11
- data/doc/rdoc/classes/LibXML.html +4 -0
- data/doc/rdoc/classes/LibXML/XML.html +7 -0
- data/doc/rdoc/classes/LibXML/XML/Attr.html +187 -177
- data/doc/rdoc/classes/LibXML/XML/Attributes.html +62 -61
- data/doc/rdoc/classes/LibXML/XML/Document.html +318 -254
- data/doc/rdoc/classes/LibXML/XML/Dtd.html +62 -8
- data/doc/rdoc/classes/LibXML/XML/Error.html +6 -0
- data/doc/rdoc/classes/LibXML/XML/HTMLParser.html +59 -41
- data/doc/rdoc/classes/LibXML/XML/InputCallbacks.html +12 -6
- data/doc/rdoc/classes/LibXML/XML/NS.html +65 -50
- data/doc/rdoc/classes/LibXML/XML/Node.html +671 -630
- data/doc/rdoc/classes/LibXML/XML/Node/FailedModify.html +12 -0
- data/doc/rdoc/classes/LibXML/XML/Node/Set.html +64 -60
- data/doc/rdoc/classes/LibXML/XML/Node/SetNamespace.html +12 -0
- data/doc/rdoc/classes/LibXML/XML/Node/UnknownType.html +12 -0
- data/doc/rdoc/classes/LibXML/XML/Parser.html +407 -383
- data/doc/rdoc/classes/LibXML/XML/Parser/Context.html +241 -219
- data/doc/rdoc/classes/LibXML/XML/Parser/ParseError.html +12 -0
- data/doc/rdoc/classes/LibXML/XML/Reader.html +421 -331
- data/doc/rdoc/classes/LibXML/XML/RelaxNG.html +237 -0
- data/doc/rdoc/classes/LibXML/XML/SaxParser.html +79 -60
- data/doc/rdoc/classes/LibXML/XML/Schema.html +109 -22
- data/doc/rdoc/classes/LibXML/XML/State.html +6 -0
- data/doc/rdoc/classes/LibXML/XML/XInclude.html +6 -0
- data/doc/rdoc/classes/LibXML/XML/XInclude/Error.html +6 -0
- data/doc/rdoc/classes/LibXML/XML/XPath.html +4 -48
- data/doc/rdoc/classes/LibXML/XML/XPath/Context.html +6 -5
- data/doc/rdoc/classes/LibXML/XML/XPath/InvalidPath.html +61 -0
- data/doc/rdoc/classes/LibXML/XML/XPath/Object.html +12 -8
- data/doc/rdoc/classes/LibXML/XML/XPointer.html +14 -8
- data/doc/rdoc/classes/LibXML/XML/XPointer/Context.html +6 -0
- data/doc/rdoc/classes/LibXML/XML/XPointer/Context/InvalidPath.html +6 -0
- data/doc/rdoc/classes/LibXML/XML/XPointer/InvalidExpression.html +13 -0
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/CHANGES.html +38 -10
- data/doc/rdoc/files/LICENSE.html +1 -1
- data/doc/rdoc/files/README.html +57 -23
- data/doc/rdoc/files/VERSION.html +1 -1
- data/doc/rdoc/files/ext/libxml/cbg_c.html +1 -1
- data/doc/rdoc/files/ext/libxml/libxml_c.html +1 -1
- data/doc/rdoc/files/ext/libxml/ruby_xml_attr_c.html +1 -1
- data/doc/rdoc/files/ext/libxml/ruby_xml_attributes_c.html +1 -1
- data/doc/rdoc/files/ext/libxml/ruby_xml_document_c.html +1 -1
- data/doc/rdoc/files/ext/libxml/ruby_xml_dtd_c.html +1 -1
- data/doc/rdoc/files/ext/libxml/ruby_xml_html_parser_c.html +1 -1
- data/doc/rdoc/files/ext/libxml/ruby_xml_input_cbg_c.html +1 -1
- data/doc/rdoc/files/ext/libxml/ruby_xml_node_c.html +1 -1
- data/doc/rdoc/files/ext/libxml/ruby_xml_node_set_c.html +1 -1
- data/doc/rdoc/files/ext/libxml/ruby_xml_ns_c.html +1 -1
- data/doc/rdoc/files/ext/libxml/ruby_xml_parser_c.html +1 -1
- data/doc/rdoc/files/ext/libxml/ruby_xml_parser_context_c.html +1 -1
- data/doc/rdoc/files/ext/libxml/ruby_xml_reader_c.html +1 -1
- data/doc/rdoc/{classes/XML.html → files/ext/libxml/ruby_xml_relaxng_c.html} +16 -35
- data/doc/rdoc/files/ext/libxml/ruby_xml_sax_parser_c.html +1 -1
- data/doc/rdoc/files/ext/libxml/ruby_xml_schema_c.html +1 -1
- data/doc/rdoc/files/ext/libxml/ruby_xml_state_c.html +1 -1
- data/doc/rdoc/files/ext/libxml/ruby_xml_xinclude_c.html +1 -1
- data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_c.html +1 -1
- data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_context_c.html +1 -1
- data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_object_c.html +1 -1
- data/doc/rdoc/files/ext/libxml/ruby_xml_xpointer_c.html +1 -1
- data/doc/rdoc/files/ext/libxml/ruby_xml_xpointer_context_c.html +1 -1
- data/doc/rdoc/files/lib/libxml/attr_rb.html +1 -1
- data/doc/rdoc/files/lib/libxml/attributes_rb.html +1 -1
- data/doc/rdoc/files/lib/libxml/document_rb.html +1 -1
- data/doc/rdoc/files/lib/libxml/node_rb.html +1 -1
- data/doc/rdoc/files/lib/libxml/node_set_rb.html +1 -1
- data/doc/rdoc/files/lib/libxml/parser_options_rb.html +1 -1
- data/doc/rdoc/files/lib/libxml/parser_rb.html +1 -1
- data/doc/rdoc/files/lib/libxml/properties_rb.html +1 -1
- data/doc/rdoc/files/lib/libxml/tree_rb.html +1 -1
- data/doc/rdoc/files/lib/libxml_rb.html +2 -2
- data/doc/rdoc/files/lib/xml/libxml_rb.html +12 -2
- data/doc/rdoc/files/lib/xml_rb.html +134 -0
- data/doc/rdoc/fr_class_index.html +1 -1
- data/doc/rdoc/fr_file_index.html +2 -0
- data/doc/rdoc/fr_method_index.html +349 -344
- data/ext/libxml/libxml.c +2 -1
- data/ext/libxml/ruby_libxml.h +1 -0
- data/ext/libxml/ruby_xml_attr.c +8 -2
- data/ext/libxml/ruby_xml_attributes.c +5 -5
- data/ext/libxml/ruby_xml_document.c +41 -2
- data/ext/libxml/ruby_xml_dtd.c +169 -169
- data/ext/libxml/ruby_xml_html_parser.c +449 -449
- data/ext/libxml/ruby_xml_input_cbg.c +165 -165
- data/ext/libxml/ruby_xml_node.c +1 -1
- data/ext/libxml/ruby_xml_node_set.c +172 -172
- data/ext/libxml/ruby_xml_ns.c +145 -145
- data/ext/libxml/ruby_xml_parser.c +1398 -1398
- data/ext/libxml/ruby_xml_parser_context.c +697 -697
- data/ext/libxml/ruby_xml_reader.c +44 -0
- data/ext/libxml/ruby_xml_reader.h +14 -14
- data/ext/libxml/ruby_xml_relaxng.c +97 -0
- data/ext/libxml/ruby_xml_relaxng.h +15 -0
- data/ext/libxml/ruby_xml_sax_parser.c +486 -486
- data/ext/libxml/ruby_xml_schema.c +1 -1
- data/ext/libxml/ruby_xml_state.c +4 -4
- data/ext/libxml/ruby_xml_xinclude.c +21 -21
- data/ext/libxml/ruby_xml_xpath.c +89 -89
- data/ext/libxml/ruby_xml_xpath_context.c +283 -283
- data/ext/libxml/ruby_xml_xpath_object.c +5 -5
- data/ext/libxml/ruby_xml_xpointer.c +104 -104
- data/ext/libxml/ruby_xml_xpointer_context.c +22 -22
- data/ext/libxml/version.h +2 -2
- data/ext/libxml/version.h.rej +17 -0
- data/ext/mingw/Rakefile +41 -0
- data/{mingw → lib}/libiconv-2.dll +0 -0
- data/lib/libxml.rb +15 -4
- data/lib/libxml2-2.dll +0 -0
- data/lib/libxml_ruby.dll.a +0 -0
- data/lib/libxml_ruby.so +0 -0
- data/lib/xml.rb +14 -0
- data/lib/xml/libxml.rb +4 -1
- data/test/etc_doc_to_s.rb +1 -1
- data/test/ets_copy_bug.rb +1 -1
- data/test/ets_copy_bug3.rb +1 -1
- data/test/ets_doc_file.rb +1 -1
- data/test/ets_doc_to_s.rb +1 -1
- data/test/ets_node_gc.rb +1 -1
- data/test/ets_tsr.rb +1 -1
- data/test/model/shiporder.rnc +28 -0
- data/test/model/shiporder.rng +86 -0
- data/test/{tc_xml_attributes.rb → tc_attributes.rb} +1 -10
- data/test/{tc_xml_document.rb → tc_document.rb} +1 -1
- data/test/{tc_xml_document_write.rb → tc_document_write.rb} +1 -1
- data/test/{tc_xml_dtd.rb → tc_dtd.rb} +1 -1
- data/test/{tc_xml_html_parser.rb → tc_html_parser.rb} +1 -1
- data/test/{tc_xml_node.rb → tc_node.rb} +1 -1
- data/test/{tc_xml_node_attr.rb → tc_node_attr.rb} +1 -1
- data/test/{tc_xml_node_cdata.rb → tc_node_cdata.rb} +24 -5
- data/test/{tc_xml_node_comment.rb → tc_node_comment.rb} +1 -1
- data/test/{tc_xml_node_copy.rb → tc_node_copy.rb} +1 -1
- data/test/{tc_xml_node_edit.rb → tc_node_edit.rb} +1 -1
- data/test/{tc_xml_node_set.rb → tc_node_set.rb} +1 -1
- data/test/{tc_xml_node_set2.rb → tc_node_set2.rb} +1 -1
- data/test/{tc_xml_node_text.rb → tc_node_text.rb} +1 -1
- data/test/{tc_xml_node_xlink.rb → tc_node_xlink.rb} +2 -2
- data/test/{tc_xml_parser.rb → tc_parser.rb} +1 -1
- data/test/{tc_xml_parser_context.rb → tc_parser_context.rb} +1 -1
- data/test/{tc_xml_properties.rb → tc_properties.rb} +1 -7
- data/test/{tc_xml_reader.rb → tc_reader.rb} +1 -1
- data/test/tc_relaxng.rb +39 -0
- data/test/{tc_xml_sax_parser.rb → tc_sax_parser.rb} +1 -1
- data/test/{tc_xml_schema.rb → tc_schema.rb} +1 -1
- data/test/{tc_xml_traversal.rb → tc_traversal.rb} +1 -1
- data/test/{tc_xml_xinclude.rb → tc_xinclude.rb} +1 -1
- data/test/{tc_xml_xpath.rb → tc_xpath.rb} +1 -1
- data/test/{tc_xml_xpath_context.rb → tc_xpath_context.rb} +1 -1
- data/test/{tc_xml_xpointer.rb → tc_xpointer.rb} +1 -1
- data/test/test_suite.rb +26 -25
- metadata +103 -100
- data/benchmark/depixelate.rb +0 -632
- data/benchmark/hamlet.xml +0 -9055
- data/benchmark/sock_entries.xml +0 -507
- data/benchmark/throughput.rb +0 -39
- data/benchmark/xml_benchmarks.rb +0 -227
- data/mingw/libxml2-2.dll +0 -0
- data/mingw/libxml_ruby.so +0 -0
- data/test/gc.log +0 -0
- data/vc/libxml_ruby.sln +0 -20
- data/vc/libxml_ruby.vcproj +0 -389
@@ -78,6 +78,90 @@
|
|
78
78
|
|
79
79
|
<div id="contextContent">
|
80
80
|
|
81
|
+
<div id="description">
|
82
|
+
<pre>
|
83
|
+
TODO what is this patch doing here?
|
84
|
+
|
85
|
+
xmlSchemaParserCtxtPtr parser;
|
86
|
+
xmlSchemaPtr sptr;
|
87
|
+
xmlSchemaValidCtxtPtr vptr;
|
88
|
+
</pre>
|
89
|
+
<p>
|
90
|
+
+ int is_invalid;
|
91
|
+
</p>
|
92
|
+
<pre>
|
93
|
+
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &source) == FAILURE) {
|
94
|
+
return;
|
95
|
+
</pre>
|
96
|
+
<p>
|
97
|
+
@@ -598,26 +598,24 @@
|
98
|
+
</p>
|
99
|
+
<pre>
|
100
|
+
convert_to_string_ex(&source);
|
101
|
+
parser = xmlSchemaNewParserCtxt(Z_STRVAL_P(source));
|
102
|
+
sptr = xmlSchemaParse(parser);
|
103
|
+
break;
|
104
|
+
case SCHEMA_BLOB:
|
105
|
+
convert_to_string_ex(&source);
|
106
|
+
parser = xmlSchemaNewMemParserCtxt(Z_STRVAL_P(source), Z_STRLEN_P(source));
|
107
|
+
sptr = xmlSchemaParse(parser);
|
108
|
+
break;
|
109
|
+
}
|
110
|
+
|
111
|
+
vptr = xmlSchemaNewValidCtxt(sptr);
|
112
|
+
</pre>
|
113
|
+
<p>
|
114
|
+
+ is_invalid = xmlSchemaValidateDoc(vptr, (xmlDocPtr) sxe-><a
|
115
|
+
href="Schema.html#M000222">document</a>->ptr);
|
116
|
+
</p>
|
117
|
+
<pre>
|
118
|
+
xmlSchemaFree(sptr);
|
119
|
+
xmlSchemaFreeValidCtxt(vptr);
|
120
|
+
xmlSchemaFreeParserCtxt(parser);
|
121
|
+
</pre>
|
122
|
+
<ul>
|
123
|
+
<li>if (is_valid) {
|
124
|
+
|
125
|
+
</li>
|
126
|
+
<li>RETURN_TRUE;
|
127
|
+
|
128
|
+
</li>
|
129
|
+
<li>} else {
|
130
|
+
|
131
|
+
</li>
|
132
|
+
</ul>
|
133
|
+
<p>
|
134
|
+
+ if (is_invalid) {
|
135
|
+
</p>
|
136
|
+
<pre>
|
137
|
+
RETURN_FALSE;
|
138
|
+
</pre>
|
139
|
+
<p>
|
140
|
+
+ } else { + RETURN_TRUE;
|
141
|
+
</p>
|
142
|
+
<pre>
|
143
|
+
}
|
144
|
+
}
|
145
|
+
}}}
|
146
|
+
</pre>
|
147
|
+
<p>
|
148
|
+
@@ -695,7 +693,7 @@
|
149
|
+
</p>
|
150
|
+
<pre>
|
151
|
+
{
|
152
|
+
if (!strcmp(method, "xsearch")) {
|
153
|
+
simplexml_ce_xpath_search(INTERNAL_FUNCTION_PARAM_PASSTHRU);
|
154
|
+
</pre>
|
155
|
+
<p>
|
156
|
+
-ifdef xmlSchemaParserCtxtPtr +ifdef LIBXML_SCHEMAS_ENABLED
|
157
|
+
</p>
|
158
|
+
<pre>
|
159
|
+
} else if (!strcmp(method, "validate_schema_file")) {
|
160
|
+
simplexml_ce_schema_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, SCHEMA_FILE);
|
161
|
+
} else if (!strcmp(method, "validate_schema_buffer")) {
|
162
|
+
</pre>
|
163
|
+
|
164
|
+
</div>
|
81
165
|
|
82
166
|
|
83
167
|
</div>
|
@@ -86,9 +170,9 @@
|
|
86
170
|
<h3 class="section-bar">Methods</h3>
|
87
171
|
|
88
172
|
<div class="name-list">
|
89
|
-
<a href="#
|
90
|
-
<a href="#
|
91
|
-
<a href="#
|
173
|
+
<a href="#M000222">document</a>
|
174
|
+
<a href="#M000221">from_string</a>
|
175
|
+
<a href="#M000220">new</a>
|
92
176
|
</div>
|
93
177
|
</div>
|
94
178
|
|
@@ -110,11 +194,11 @@
|
|
110
194
|
<div id="methods">
|
111
195
|
<h3 class="section-bar">Public Class methods</h3>
|
112
196
|
|
113
|
-
<div id="method-
|
114
|
-
<a name="
|
197
|
+
<div id="method-M000222" class="method-detail">
|
198
|
+
<a name="M000222"></a>
|
115
199
|
|
116
200
|
<div class="method-heading">
|
117
|
-
<a href="#
|
201
|
+
<a href="#M000222" class="method-signature">
|
118
202
|
<span class="method-name">XML::Schema.document(document) → schema<br />
|
119
203
|
</span>
|
120
204
|
</a>
|
@@ -122,17 +206,18 @@
|
|
122
206
|
|
123
207
|
<div class="method-description">
|
124
208
|
<p>
|
125
|
-
Create a new schema from the specified
|
209
|
+
Create a <a href="Schema.html#M000220">new</a> schema from the specified <a
|
210
|
+
href="Schema.html#M000222">document</a>.
|
126
211
|
</p>
|
127
212
|
<p><a class="source-toggle" href="#"
|
128
|
-
onclick="toggleCode('
|
129
|
-
<div class="method-source-code" id="
|
213
|
+
onclick="toggleCode('M000222-source');return false;">[Source]</a></p>
|
214
|
+
<div class="method-source-code" id="M000222-source">
|
130
215
|
<pre>
|
131
216
|
/*
|
132
217
|
* call-seq:
|
133
218
|
* XML::Schema.document(document) -> schema
|
134
219
|
*
|
135
|
-
* Create a new schema from the specified
|
220
|
+
* Create a new schema from the specified document.
|
136
221
|
*/
|
137
222
|
VALUE
|
138
223
|
ruby_xml_schema_init_from_document(VALUE class, VALUE document) {
|
@@ -142,11 +227,11 @@ ruby_xml_schema_init_from_document(VALUE class, VALUE document) {
|
|
142
227
|
</div>
|
143
228
|
</div>
|
144
229
|
|
145
|
-
<div id="method-
|
146
|
-
<a name="
|
230
|
+
<div id="method-M000221" class="method-detail">
|
231
|
+
<a name="M000221"></a>
|
147
232
|
|
148
233
|
<div class="method-heading">
|
149
|
-
<a href="#
|
234
|
+
<a href="#M000221" class="method-signature">
|
150
235
|
<span class="method-name">XML::Schema.string("schema_data") → "value"<br />
|
151
236
|
</span>
|
152
237
|
</a>
|
@@ -154,11 +239,12 @@ ruby_xml_schema_init_from_document(VALUE class, VALUE document) {
|
|
154
239
|
|
155
240
|
<div class="method-description">
|
156
241
|
<p>
|
157
|
-
Create a new schema using the specified
|
242
|
+
Create a <a href="Schema.html#M000220">new</a> schema using the specified
|
243
|
+
string.
|
158
244
|
</p>
|
159
245
|
<p><a class="source-toggle" href="#"
|
160
|
-
onclick="toggleCode('
|
161
|
-
<div class="method-source-code" id="
|
246
|
+
onclick="toggleCode('M000221-source');return false;">[Source]</a></p>
|
247
|
+
<div class="method-source-code" id="M000221-source">
|
162
248
|
<pre>
|
163
249
|
/*
|
164
250
|
* call-seq:
|
@@ -174,11 +260,11 @@ ruby_xml_schema_init_from_string(VALUE self, VALUE schema_str) {
|
|
174
260
|
</div>
|
175
261
|
</div>
|
176
262
|
|
177
|
-
<div id="method-
|
178
|
-
<a name="
|
263
|
+
<div id="method-M000220" class="method-detail">
|
264
|
+
<a name="M000220"></a>
|
179
265
|
|
180
266
|
<div class="method-heading">
|
181
|
-
<a href="#
|
267
|
+
<a href="#M000220" class="method-signature">
|
182
268
|
<span class="method-name">XML::Schema.new(schema_uri) → schema<br />
|
183
269
|
</span>
|
184
270
|
</a>
|
@@ -186,11 +272,12 @@ ruby_xml_schema_init_from_string(VALUE self, VALUE schema_str) {
|
|
186
272
|
|
187
273
|
<div class="method-description">
|
188
274
|
<p>
|
189
|
-
Create a new schema from the specified
|
275
|
+
Create a <a href="Schema.html#M000220">new</a> schema from the specified
|
276
|
+
URI.
|
190
277
|
</p>
|
191
278
|
<p><a class="source-toggle" href="#"
|
192
|
-
onclick="toggleCode('
|
193
|
-
<div class="method-source-code" id="
|
279
|
+
onclick="toggleCode('M000220-source');return false;">[Source]</a></p>
|
280
|
+
<div class="method-source-code" id="M000220-source">
|
194
281
|
<pre>
|
195
282
|
/*
|
196
283
|
* call-seq:
|
@@ -74,59 +74,15 @@
|
|
74
74
|
|
75
75
|
<div id="description">
|
76
76
|
<p>
|
77
|
-
|
78
|
-
href="../XML.html">XML</a> documents. It is usually accessed via the <a
|
79
|
-
href="Document.html#M000354">XML::Document#find</a> or <a
|
80
|
-
href="Node.html#M000170">XML::Node#find</a> methods. For example:
|
77
|
+
call-seq:
|
81
78
|
</p>
|
82
79
|
<pre>
|
83
|
-
|
80
|
+
nodes.debug -> (true|false)
|
84
81
|
</pre>
|
85
82
|
<p>
|
86
|
-
|
83
|
+
Dump libxml debugging information to stdout. Requires Libxml be compiled
|
84
|
+
with debugging enabled.
|
87
85
|
</p>
|
88
|
-
<pre>
|
89
|
-
document.find('/foo', 'xlink:http://www.w3.org/1999/xlink')
|
90
|
-
document.find('/foo', ['xlink:http://www.w3.org/1999/xlink',
|
91
|
-
'xi:http://www.w3.org/2001/XInclude')
|
92
|
-
document.find('/foo', 'xlink' => 'http://www.w3.org/1999/xlink',
|
93
|
-
'xi' => 'http://www.w3.org/2001/XInclude')
|
94
|
-
</pre>
|
95
|
-
<h3>Working With Namespaces</h3>
|
96
|
-
<p>
|
97
|
-
Finding namespaced elements and attributes can be tricky. Lets work through
|
98
|
-
some examples using the following xml document:
|
99
|
-
</p>
|
100
|
-
<pre>
|
101
|
-
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
102
|
-
<soap:Body>
|
103
|
-
<getManufacturerNamesResponse xmlns="http://services.somewhere.com">
|
104
|
-
<IDAndNameList xmlns="http://services.somewhere.com">
|
105
|
-
<ns1:IdAndName xmlns:ns1="http://domain.somewhere.com"/>
|
106
|
-
</IDAndNameList>
|
107
|
-
</getManufacturerNamesResponse>
|
108
|
-
</soap:Envelope>
|
109
|
-
|
110
|
-
# Since the soap namespace is defined on the root
|
111
|
-
# node we can directly use it.
|
112
|
-
doc.find('/soap:Envelope')
|
113
|
-
|
114
|
-
# Since the ns1 namespace is not defined on the root node
|
115
|
-
# we have to first register it with the xpath engine.
|
116
|
-
doc.find('//ns1:IdAndName',
|
117
|
-
'ns1:http://domain.somewhere.com')
|
118
|
-
|
119
|
-
# Since the getManufacturerNamesResponse element uses a default
|
120
|
-
# namespace we first have to give it a prefix and register
|
121
|
-
# it with the xpath engine.
|
122
|
-
doc.find('//ns:getManufacturerNamesResponse',
|
123
|
-
'ns:http://services.somewhere.com')
|
124
|
-
|
125
|
-
# Here is an example showing a complex namespace aware
|
126
|
-
# xpath expression.
|
127
|
-
doc.find('/soap:Envelope/soap:Body/ns0:getManufacturerNamesResponse/ns0:IDAndNameList/ns1:IdAndName',
|
128
|
-
['ns0:http://services.somewhere.com', 'ns1:http://domain.somewhere.com'])
|
129
|
-
</pre>
|
130
86
|
|
131
87
|
</div>
|
132
88
|
|
@@ -85,8 +85,8 @@
|
|
85
85
|
The <a href="Context.html">XML::XPath::Context</a> class is used to
|
86
86
|
evaluate <a href="../XPath.html">XPath</a> expressions. Generally, you
|
87
87
|
should not directly use this class, but instead use the <a
|
88
|
-
href="../Document.html#
|
89
|
-
href="../Node.html#
|
88
|
+
href="../Document.html#M000359">XML::Document#find</a> and <a
|
89
|
+
href="../Node.html#M000173">XML::Node#find</a> methods.
|
90
90
|
</p>
|
91
91
|
<pre>
|
92
92
|
doc = XML::Document.string('<header>content</header>')
|
@@ -157,9 +157,10 @@ href="../Node.html#M000170">XML::Node#find</a> methods.
|
|
157
157
|
|
158
158
|
<div class="method-description">
|
159
159
|
<p>
|
160
|
-
Creates a
|
161
|
-
|
162
|
-
href="../XPath.html">XPath</a>
|
160
|
+
Creates a <a href="Context.html#M000001">new</a> <a
|
161
|
+
href="../XPath.html">XPath</a> context for the specified document. The
|
162
|
+
context can then be used to evaluate an <a href="../XPath.html">XPath</a>
|
163
|
+
expression.
|
163
164
|
</p>
|
164
165
|
<pre>
|
165
166
|
doc = XML::Document.string('<header><first>hi</first></header>')
|
@@ -78,6 +78,67 @@
|
|
78
78
|
|
79
79
|
<div id="contextContent">
|
80
80
|
|
81
|
+
<div id="description">
|
82
|
+
<p>
|
83
|
+
<a href="../Document.html">Document</a>-class: <a
|
84
|
+
href="../XPath.html">LibXML::XML::XPath</a>
|
85
|
+
</p>
|
86
|
+
<p>
|
87
|
+
The <a href="../XPath.html">XML::XPath</a> module is used to query <a
|
88
|
+
href="../../XML.html">XML</a> documents. It is usually accessed via the <a
|
89
|
+
href="../Document.html#M000359">XML::Document#find</a> or <a
|
90
|
+
href="../Node.html#M000173">XML::Node#find</a> methods. For example:
|
91
|
+
</p>
|
92
|
+
<pre>
|
93
|
+
document.find('/foo', namespaces) -> XML::XPath::Object
|
94
|
+
</pre>
|
95
|
+
<p>
|
96
|
+
The optional namespaces parameter can be a string, array or hash table.
|
97
|
+
</p>
|
98
|
+
<pre>
|
99
|
+
document.find('/foo', 'xlink:http://www.w3.org/1999/xlink')
|
100
|
+
document.find('/foo', ['xlink:http://www.w3.org/1999/xlink',
|
101
|
+
'xi:http://www.w3.org/2001/XInclude')
|
102
|
+
document.find('/foo', 'xlink' => 'http://www.w3.org/1999/xlink',
|
103
|
+
'xi' => 'http://www.w3.org/2001/XInclude')
|
104
|
+
</pre>
|
105
|
+
<h3>Working With Namespaces</h3>
|
106
|
+
<p>
|
107
|
+
Finding namespaced elements and attributes can be tricky. Lets work through
|
108
|
+
some examples using the following xml document:
|
109
|
+
</p>
|
110
|
+
<pre>
|
111
|
+
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
112
|
+
<soap:Body>
|
113
|
+
<getManufacturerNamesResponse xmlns="http://services.somewhere.com">
|
114
|
+
<IDAndNameList xmlns="http://services.somewhere.com">
|
115
|
+
<ns1:IdAndName xmlns:ns1="http://domain.somewhere.com"/>
|
116
|
+
</IDAndNameList>
|
117
|
+
</getManufacturerNamesResponse>
|
118
|
+
</soap:Envelope>
|
119
|
+
|
120
|
+
# Since the soap namespace is defined on the root
|
121
|
+
# node we can directly use it.
|
122
|
+
doc.find('/soap:Envelope')
|
123
|
+
|
124
|
+
# Since the ns1 namespace is not defined on the root node
|
125
|
+
# we have to first register it with the xpath engine.
|
126
|
+
doc.find('//ns1:IdAndName',
|
127
|
+
'ns1:http://domain.somewhere.com')
|
128
|
+
|
129
|
+
# Since the getManufacturerNamesResponse element uses a default
|
130
|
+
# namespace we first have to give it a prefix and register
|
131
|
+
# it with the xpath engine.
|
132
|
+
doc.find('//ns:getManufacturerNamesResponse',
|
133
|
+
'ns:http://services.somewhere.com')
|
134
|
+
|
135
|
+
# Here is an example showing a complex namespace aware
|
136
|
+
# xpath expression.
|
137
|
+
doc.find('/soap:Envelope/soap:Body/ns0:getManufacturerNamesResponse/ns0:IDAndNameList/ns1:IdAndName',
|
138
|
+
['ns0:http://services.somewhere.com', 'ns1:http://domain.somewhere.com'])
|
139
|
+
</pre>
|
140
|
+
|
141
|
+
</div>
|
81
142
|
|
82
143
|
|
83
144
|
</div>
|
@@ -160,7 +160,7 @@ href="../XPointer.html">XML::XPointer</a> expression.
|
|
160
160
|
|
161
161
|
<div class="method-description">
|
162
162
|
<p>
|
163
|
-
array index into set of nodes
|
163
|
+
array index into <a href="Object.html#M000017">set</a> of nodes
|
164
164
|
</p>
|
165
165
|
<p><a class="source-toggle" href="#"
|
166
166
|
onclick="toggleCode('M000014-source');return false;">[Source]</a></p>
|
@@ -226,7 +226,8 @@ ruby_xml_xpath_object_debug(VALUE self) {
|
|
226
226
|
|
227
227
|
<div class="method-description">
|
228
228
|
<p>
|
229
|
-
Call the supplied block for each node in
|
229
|
+
Call the supplied block for <a href="Object.html#M000007">each</a> node in
|
230
|
+
this <a href="Object.html#M000017">set</a>.
|
230
231
|
</p>
|
231
232
|
<p><a class="source-toggle" href="#"
|
232
233
|
onclick="toggleCode('M000007-source');return false;">[Source]</a></p>
|
@@ -303,7 +304,8 @@ ruby_xml_xpath_object_empty_q(VALUE self) {
|
|
303
304
|
|
304
305
|
<div class="method-description">
|
305
306
|
<p>
|
306
|
-
Returns the first node in this node
|
307
|
+
Returns the <a href="Object.html#M000010">first</a> node in this node <a
|
308
|
+
href="Object.html#M000017">set</a>, or nil if none exist.
|
307
309
|
</p>
|
308
310
|
<p><a class="source-toggle" href="#"
|
309
311
|
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
|
@@ -335,7 +337,8 @@ ruby_xml_xpath_object_first(VALUE self) {
|
|
335
337
|
|
336
338
|
<div class="method-description">
|
337
339
|
<p>
|
338
|
-
Obtain the length of the nodesetval node
|
340
|
+
Obtain the <a href="Object.html#M000011">length</a> of the nodesetval node
|
341
|
+
list.
|
339
342
|
</p>
|
340
343
|
<p><a class="source-toggle" href="#"
|
341
344
|
onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
|
@@ -413,7 +416,8 @@ ruby_xml_xpath_object_set(VALUE self)
|
|
413
416
|
|
414
417
|
<div class="method-description">
|
415
418
|
<p>
|
416
|
-
Obtain the length of the nodesetval node
|
419
|
+
Obtain the <a href="Object.html#M000011">length</a> of the nodesetval node
|
420
|
+
list.
|
417
421
|
</p>
|
418
422
|
<p><a class="source-toggle" href="#"
|
419
423
|
onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
|
@@ -445,8 +449,8 @@ ruby_xml_xpath_object_length(VALUE self) {
|
|
445
449
|
|
446
450
|
<div class="method-description">
|
447
451
|
<p>
|
448
|
-
Returns the original <a href="../XPath.html">XPath</a> expression as a
|
449
|
-
string
|
452
|
+
Returns the original <a href="../XPath.html">XPath</a> expression as a <a
|
453
|
+
href="Object.html#M000015">string</a>.
|
450
454
|
</p>
|
451
455
|
<p><a class="source-toggle" href="#"
|
452
456
|
onclick="toggleCode('M000015-source');return false;">[Source]</a></p>
|
@@ -487,7 +491,7 @@ ruby_xml_xpath_object_string(VALUE self)
|
|
487
491
|
|
488
492
|
<div class="method-description">
|
489
493
|
<p>
|
490
|
-
Obtain an array of the nodes in this set
|
494
|
+
Obtain an array of the nodes in this <a href="Object.html#M000017">set</a>.
|
491
495
|
</p>
|
492
496
|
<p><a class="source-toggle" href="#"
|
493
497
|
onclick="toggleCode('M000013-source');return false;">[Source]</a></p>
|