libxml-ruby 0.9.5-x86-mswin32-60 → 0.9.6-x86-mswin32-60
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.
- data/CHANGES +28 -0
- data/README +8 -12
- data/ext/libxml/cbg.c +86 -86
- data/ext/libxml/libxml.c +875 -899
- data/ext/libxml/ruby_libxml.h +91 -65
- data/ext/libxml/ruby_xml_attr.c +485 -485
- data/ext/libxml/ruby_xml_attr.h +3 -3
- data/ext/libxml/ruby_xml_attributes.h +2 -2
- data/ext/libxml/ruby_xml_document.c +124 -307
- data/ext/libxml/ruby_xml_document.h +3 -3
- data/ext/libxml/ruby_xml_dtd.c +119 -119
- data/ext/libxml/ruby_xml_dtd.h +2 -2
- data/ext/libxml/ruby_xml_error.c +1 -1
- data/ext/libxml/ruby_xml_error.h +2 -2
- data/ext/libxml/ruby_xml_html_parser.c +119 -119
- data/ext/libxml/ruby_xml_html_parser.h +3 -3
- data/ext/libxml/ruby_xml_input.c +13 -11
- data/ext/libxml/ruby_xml_input.h +3 -3
- data/ext/libxml/ruby_xml_input_cbg.c +197 -197
- data/ext/libxml/ruby_xml_namespace.c +158 -0
- data/ext/libxml/ruby_xml_namespace.h +12 -0
- data/ext/libxml/ruby_xml_namespaces.c +303 -0
- data/ext/libxml/{ruby_xml_ns.h → ruby_xml_namespaces.h} +4 -5
- data/ext/libxml/ruby_xml_node.c +88 -293
- data/ext/libxml/ruby_xml_node.h +4 -4
- data/ext/libxml/ruby_xml_parser.c +152 -152
- data/ext/libxml/ruby_xml_parser.h +3 -3
- data/ext/libxml/ruby_xml_parser_context.c +630 -657
- data/ext/libxml/ruby_xml_parser_context.h +3 -3
- data/ext/libxml/ruby_xml_reader.c +899 -904
- data/ext/libxml/ruby_xml_reader.h +2 -2
- data/ext/libxml/ruby_xml_relaxng.h +2 -2
- data/ext/libxml/ruby_xml_sax_parser.c +175 -175
- data/ext/libxml/ruby_xml_sax_parser.h +3 -3
- data/ext/libxml/ruby_xml_schema.c +165 -165
- data/ext/libxml/ruby_xml_schema.h +2 -2
- data/ext/libxml/ruby_xml_state.h +2 -2
- data/ext/libxml/ruby_xml_xinclude.c +24 -24
- data/ext/libxml/ruby_xml_xinclude.h +3 -3
- data/ext/libxml/ruby_xml_xpath.c +108 -108
- data/ext/libxml/ruby_xml_xpath.h +3 -3
- data/ext/libxml/ruby_xml_xpath_context.c +84 -35
- data/ext/libxml/ruby_xml_xpath_context.h +3 -3
- data/ext/libxml/ruby_xml_xpath_expression.c +5 -7
- data/ext/libxml/ruby_xml_xpath_expression.h +2 -2
- data/ext/libxml/ruby_xml_xpath_object.c +7 -7
- data/ext/libxml/ruby_xml_xpath_object.h +2 -2
- data/ext/libxml/ruby_xml_xpointer.c +107 -107
- data/ext/libxml/ruby_xml_xpointer.h +3 -3
- data/ext/libxml/version.h +2 -2
- data/ext/mingw/libxml_ruby.dll.a +0 -0
- data/ext/mingw/libxml_ruby.so +0 -0
- data/ext/vc/libxml_ruby.vcproj +13 -5
- data/lib/libxml.rb +4 -1
- data/lib/libxml/document.rb +40 -6
- data/lib/libxml/hpricot.rb +76 -76
- data/lib/libxml/namespace.rb +60 -0
- data/lib/libxml/namespaces.rb +36 -0
- data/lib/libxml/node.rb +90 -26
- data/lib/libxml/ns.rb +20 -0
- data/test/model/bands.xml +5 -0
- data/test/tc_attributes.rb +1 -1
- data/test/tc_document.rb +24 -41
- data/test/tc_document_write.rb +87 -115
- data/test/tc_namespace.rb +59 -0
- data/test/tc_namespaces.rb +174 -0
- data/test/tc_node.rb +41 -33
- data/test/tc_node_copy.rb +1 -1
- data/test/tc_node_edit.rb +6 -0
- data/test/tc_node_write.rb +76 -0
- data/test/tc_xinclude.rb +2 -9
- data/test/tc_xpath.rb +38 -11
- data/test/test_suite.rb +3 -1
- metadata +16 -9
- data/ext/libxml/ruby_xml_ns.c +0 -150
- data/test/ets_copy_bug.rb +0 -21
- data/test/ets_copy_bug3.rb +0 -38
- data/test/model/default_validation_bug.rb +0 -0
- data/test/tc_ns.rb +0 -18
@@ -0,0 +1,158 @@
|
|
1
|
+
/* $Id: ruby_xml_namespace.c 671 2008-12-08 06:06:10Z cfis $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#include "ruby_libxml.h"
|
6
|
+
#include "ruby_xml_namespace.h"
|
7
|
+
|
8
|
+
VALUE cXMLNamespace;
|
9
|
+
|
10
|
+
/* Document-class: LibXML::XML::Namespace
|
11
|
+
*
|
12
|
+
* The Namespace class represents an XML namespace.
|
13
|
+
* To add a namespace to a node, create a new instance
|
14
|
+
* of this class. Note that this does *not* assign the
|
15
|
+
* node to the namespace. To do that see the
|
16
|
+
* XML::Namespaces#namespace method.
|
17
|
+
*
|
18
|
+
* Usage:
|
19
|
+
*
|
20
|
+
* node = XML::Node.new('<Envelope>')
|
21
|
+
* XML::Namespace.new(node, 'soap', 'http://schemas.xmlsoap.org/soap/envelope/')
|
22
|
+
* assert_equal("<Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"/>", node.to_s)
|
23
|
+
* assert_nil(node.namespaces.namespace)
|
24
|
+
*/
|
25
|
+
|
26
|
+
static VALUE rxml_namespace_free(xmlNsPtr xns)
|
27
|
+
{
|
28
|
+
xns->_private = NULL;
|
29
|
+
}
|
30
|
+
|
31
|
+
static VALUE rxml_namespace_alloc(VALUE klass)
|
32
|
+
{
|
33
|
+
return Data_Wrap_Struct(klass, NULL, rxml_namespace_free, NULL);
|
34
|
+
}
|
35
|
+
|
36
|
+
/*
|
37
|
+
* call-seq:
|
38
|
+
* initialize(node, "prefix", "href") -> XML::Namespace
|
39
|
+
*
|
40
|
+
* Create a new namespace and adds it to the specified node.
|
41
|
+
* Note this does *not* assign the node to the namespace.
|
42
|
+
* To do that see the XML::Namespaces#namespace method.
|
43
|
+
*/
|
44
|
+
static VALUE rxml_namespace_initialize(VALUE self, VALUE node, VALUE prefix,
|
45
|
+
VALUE href)
|
46
|
+
{
|
47
|
+
xmlNodePtr xnode;
|
48
|
+
xmlChar *xmlPrefix;
|
49
|
+
xmlNsPtr xns;
|
50
|
+
|
51
|
+
Check_Type(node, T_DATA);
|
52
|
+
Data_Get_Struct(node, xmlNode, xnode);
|
53
|
+
|
54
|
+
/* Prefix can be null - that means its the default namespace */
|
55
|
+
xmlPrefix = NIL_P(prefix) ? NULL : (xmlChar *)StringValuePtr(prefix);
|
56
|
+
xns = xmlNewNs(xnode, (xmlChar*) StringValuePtr(href), xmlPrefix);
|
57
|
+
|
58
|
+
if (!xns)
|
59
|
+
rxml_raise(&xmlLastError);
|
60
|
+
|
61
|
+
xns->_private = (void*)self;
|
62
|
+
DATA_PTR(self) = xns;
|
63
|
+
return self;
|
64
|
+
}
|
65
|
+
|
66
|
+
VALUE rxml_namespace_wrap(xmlNsPtr xns)
|
67
|
+
{
|
68
|
+
if (xns->_private)
|
69
|
+
{
|
70
|
+
return (VALUE)xns->_private;
|
71
|
+
}
|
72
|
+
else
|
73
|
+
{
|
74
|
+
VALUE ns = Data_Wrap_Struct(cXMLNamespace, NULL, rxml_namespace_free, xns);
|
75
|
+
xns->_private = (void*)ns;
|
76
|
+
return ns;
|
77
|
+
}
|
78
|
+
}
|
79
|
+
|
80
|
+
/*
|
81
|
+
* call-seq:
|
82
|
+
* ns.href -> "href"
|
83
|
+
*
|
84
|
+
* Usage:
|
85
|
+
*
|
86
|
+
* doc = XML::Document.string('<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"/>')
|
87
|
+
* ns = doc.root.namespaces.find_by_href('http://schemas.xmlsoap.org/soap/envelope/')
|
88
|
+
* assert_equal('http://schemas.xmlsoap.org/soap/envelope/', ns.href)
|
89
|
+
*/
|
90
|
+
static VALUE rxml_namespace_href_get(VALUE self)
|
91
|
+
{
|
92
|
+
xmlNsPtr xns;
|
93
|
+
Data_Get_Struct(self, xmlNs, xns);
|
94
|
+
if (xns == NULL || xns->href == NULL)
|
95
|
+
return (Qnil);
|
96
|
+
else
|
97
|
+
return (rb_str_new2((const char*) xns->href));
|
98
|
+
}
|
99
|
+
|
100
|
+
/*
|
101
|
+
* call-seq:
|
102
|
+
* ns.prefix -> "prefix"
|
103
|
+
*
|
104
|
+
* Obtain the namespace's prefix.
|
105
|
+
*
|
106
|
+
* Usage:
|
107
|
+
*
|
108
|
+
* doc = XML::Document.string('<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"/>')
|
109
|
+
* ns = doc.root.namespaces.find_by_href('http://schemas.xmlsoap.org/soap/envelope/')
|
110
|
+
* assert_equal('soap', ns.prefix)
|
111
|
+
*/
|
112
|
+
static VALUE rxml_namespace_prefix_get(VALUE self)
|
113
|
+
{
|
114
|
+
xmlNsPtr xns;
|
115
|
+
Data_Get_Struct(self, xmlNs, xns);
|
116
|
+
if (xns == NULL || xns->prefix == NULL)
|
117
|
+
return (Qnil);
|
118
|
+
else
|
119
|
+
return (rb_str_new2((const char*) xns->prefix));
|
120
|
+
}
|
121
|
+
|
122
|
+
/*
|
123
|
+
* call-seq:
|
124
|
+
* ns.next -> XML::Namespace
|
125
|
+
*
|
126
|
+
* Obtain the next namespace.
|
127
|
+
*
|
128
|
+
* Usage:
|
129
|
+
*
|
130
|
+
* doc = XML::Document.string('<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"/>')
|
131
|
+
* ns = doc.root.namespaces.find_by_href('http://schemas.xmlsoap.org/soap/envelope/')
|
132
|
+
* assert_nil(ns.next)
|
133
|
+
*/
|
134
|
+
static VALUE rxml_namespace_next(VALUE self)
|
135
|
+
{
|
136
|
+
xmlNsPtr xns;
|
137
|
+
Data_Get_Struct(self, xmlNs, xns);
|
138
|
+
if (xns == NULL || xns->next == NULL)
|
139
|
+
return (Qnil);
|
140
|
+
else
|
141
|
+
return (rxml_namespace_wrap(xns->next));
|
142
|
+
}
|
143
|
+
|
144
|
+
// Rdoc needs to know
|
145
|
+
#ifdef RDOC_NEVER_DEFINED
|
146
|
+
mLibXML = rb_define_module("LibXML");
|
147
|
+
mXML = rb_define_module_under(mLibXML, "XML");
|
148
|
+
#endif
|
149
|
+
|
150
|
+
void ruby_init_xml_namespace(void)
|
151
|
+
{
|
152
|
+
cXMLNamespace = rb_define_class_under(mXML, "Namespace", rb_cObject);
|
153
|
+
rb_define_alloc_func(cXMLNamespace, rxml_namespace_alloc);
|
154
|
+
rb_define_method(cXMLNamespace, "initialize", rxml_namespace_initialize, 3);
|
155
|
+
rb_define_method(cXMLNamespace, "href", rxml_namespace_href_get, 0);
|
156
|
+
rb_define_method(cXMLNamespace, "next", rxml_namespace_next, 0);
|
157
|
+
rb_define_method(cXMLNamespace, "prefix", rxml_namespace_prefix_get, 0);
|
158
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
/* $Id: ruby_xml_namespace.h 666 2008-12-07 00:16:50Z cfis $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#ifndef __RXML_NAMESPACE__
|
6
|
+
#define __RXML_NAMESPACE__
|
7
|
+
|
8
|
+
extern VALUE cXMLNamespace;
|
9
|
+
|
10
|
+
void ruby_init_xml_namespace(void);
|
11
|
+
VALUE rxml_namespace_wrap(xmlNsPtr ns);
|
12
|
+
#endif
|
@@ -0,0 +1,303 @@
|
|
1
|
+
/* $Id: ruby_xml_ns.c 660 2008-12-02 08:52:06Z cfis $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#include "ruby_libxml.h"
|
6
|
+
#include "ruby_xml_namespaces.h"
|
7
|
+
|
8
|
+
VALUE cXMLNamespaces;
|
9
|
+
|
10
|
+
/* Document-class: LibXML::XML::Namespaces
|
11
|
+
*
|
12
|
+
* The XML::Namespaces class is used to access information about
|
13
|
+
* a node's namespaces. For each node, libxml maintains:
|
14
|
+
*
|
15
|
+
* * The node's namespace (#namespace)
|
16
|
+
* * Which namespaces are defined on the node (#definnitions)
|
17
|
+
* * Which namespaces are in scope for the node (#each)
|
18
|
+
*
|
19
|
+
* Let's look at an example:
|
20
|
+
*
|
21
|
+
* <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
|
22
|
+
* xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
23
|
+
* <soap:Body>
|
24
|
+
* <order xmlns="http://mynamespace.com"/>
|
25
|
+
* </soap:Body>
|
26
|
+
* </soap>
|
27
|
+
*
|
28
|
+
* The Envelope node is in the soap namespace. It contains
|
29
|
+
* two namespace definitions, one for soap and one for xsd.
|
30
|
+
*
|
31
|
+
* The Body node is also in the soap namespace and does not
|
32
|
+
* contain any namespaces. However, the soap and xsd namespaces
|
33
|
+
* are both in context.
|
34
|
+
*
|
35
|
+
* The order node is in its default namespace and contains
|
36
|
+
* one namespace definition (http://mynamespace.com). There
|
37
|
+
* are three namespaces in context soap, xsd and the
|
38
|
+
* default namespace.
|
39
|
+
*/
|
40
|
+
|
41
|
+
static VALUE rxml_namespaces_alloc(VALUE klass)
|
42
|
+
{
|
43
|
+
return Data_Wrap_Struct(klass, NULL, NULL, NULL);
|
44
|
+
}
|
45
|
+
|
46
|
+
/*
|
47
|
+
* call-seq:
|
48
|
+
* initialize(XML::Node) -> XML::Namespaces
|
49
|
+
*
|
50
|
+
* Creates a new namespaces object. Generally you
|
51
|
+
* do not call this method directly, but instead
|
52
|
+
* access a namespaces object via XML::Node#namespaces.
|
53
|
+
*
|
54
|
+
* Usage:
|
55
|
+
*
|
56
|
+
* doc = XML::Document.string('<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"/>')
|
57
|
+
* namespaces = new XML::Namespaces(doc.root)
|
58
|
+
*/
|
59
|
+
static VALUE rxml_namespaces_initialize(VALUE self, VALUE node)
|
60
|
+
{
|
61
|
+
xmlNodePtr xnode;
|
62
|
+
|
63
|
+
Check_Type(node, T_DATA);
|
64
|
+
Data_Get_Struct(node, xmlNode, xnode);
|
65
|
+
|
66
|
+
DATA_PTR(self) = xnode;
|
67
|
+
return self;
|
68
|
+
}
|
69
|
+
|
70
|
+
/*
|
71
|
+
* call-seq:
|
72
|
+
* namespaces.definitions -> [XML::Namespace, XML::Namespace]
|
73
|
+
*
|
74
|
+
* Returns an array of XML::Namespace objects that are
|
75
|
+
* defined on this node.
|
76
|
+
*
|
77
|
+
* Usage:
|
78
|
+
*
|
79
|
+
* doc = XML::Document.string('<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"/>')
|
80
|
+
* defs = doc.root.namespaces.definitions
|
81
|
+
*/
|
82
|
+
static VALUE rxml_namespaces_definitions(VALUE self)
|
83
|
+
{
|
84
|
+
xmlNodePtr xnode;
|
85
|
+
xmlNsPtr xns;
|
86
|
+
VALUE arr;
|
87
|
+
|
88
|
+
Data_Get_Struct(self, xmlNode, xnode);
|
89
|
+
|
90
|
+
arr = rb_ary_new();
|
91
|
+
xns = xnode->nsDef;
|
92
|
+
|
93
|
+
while (xns)
|
94
|
+
{
|
95
|
+
VALUE anamespace = rxml_namespace_wrap(xns);
|
96
|
+
rb_ary_push(arr, anamespace);
|
97
|
+
xns = xns->next;
|
98
|
+
}
|
99
|
+
|
100
|
+
return arr;
|
101
|
+
}
|
102
|
+
|
103
|
+
/*
|
104
|
+
* call-seq:
|
105
|
+
* namespaces.each {|XML::Namespace|}
|
106
|
+
*
|
107
|
+
* Iterates over the namespace objects that are
|
108
|
+
* in context for this node.
|
109
|
+
*
|
110
|
+
* Usage:
|
111
|
+
*
|
112
|
+
* doc = XML::Document.string('<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"/>')
|
113
|
+
* doc.root.namespaces.each do |ns|
|
114
|
+
* ..
|
115
|
+
* end
|
116
|
+
*/
|
117
|
+
static VALUE rxml_namespaces_each(VALUE self)
|
118
|
+
{
|
119
|
+
xmlNodePtr xnode;
|
120
|
+
xmlNsPtr *nsList, *xns;
|
121
|
+
|
122
|
+
Data_Get_Struct(self, xmlNode, xnode);
|
123
|
+
|
124
|
+
nsList = xmlGetNsList(xnode->doc, xnode);
|
125
|
+
|
126
|
+
if (nsList == NULL)
|
127
|
+
return (Qnil);
|
128
|
+
|
129
|
+
for (xns = nsList; *xns != NULL; xns++)
|
130
|
+
{
|
131
|
+
VALUE ns = rxml_namespace_wrap(*xns);
|
132
|
+
rb_yield(ns);
|
133
|
+
}
|
134
|
+
xmlFree(nsList);
|
135
|
+
|
136
|
+
return Qnil;
|
137
|
+
}
|
138
|
+
|
139
|
+
/*
|
140
|
+
* call-seq:
|
141
|
+
* namespaces.find_by_href(href) -> XML::Namespace
|
142
|
+
*
|
143
|
+
* Searches for a namespace that has the specified href.
|
144
|
+
* The search starts at the current node and works upward
|
145
|
+
* through the node's parents. If a namespace is found,
|
146
|
+
* then an XML::Namespace instance is returned, otherwise nil
|
147
|
+
* is returned.
|
148
|
+
*
|
149
|
+
* Usage:
|
150
|
+
*
|
151
|
+
* doc = XML::Document.string('<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"/>')
|
152
|
+
* ns = doc.root.namespaces.find_by_href('http://schemas.xmlsoap.org/soap/envelope/')
|
153
|
+
* assert_equal('soap', ns.prefix)
|
154
|
+
* assert_equal('http://schemas.xmlsoap.org/soap/envelope/', ns.href)
|
155
|
+
*/
|
156
|
+
static VALUE rxml_namespaces_find_by_href(VALUE self, VALUE href)
|
157
|
+
{
|
158
|
+
xmlNodePtr xnode;
|
159
|
+
xmlNsPtr xns;
|
160
|
+
|
161
|
+
Check_Type(href, T_STRING);
|
162
|
+
Data_Get_Struct(self, xmlNode, xnode);
|
163
|
+
|
164
|
+
xns = xmlSearchNsByHref(xnode->doc, xnode, (xmlChar*) StringValuePtr(href));
|
165
|
+
if (xns)
|
166
|
+
return rxml_namespace_wrap(xns);
|
167
|
+
else
|
168
|
+
return Qnil;
|
169
|
+
}
|
170
|
+
|
171
|
+
/*
|
172
|
+
* call-seq:
|
173
|
+
* namespaces.find_by_prefix(prefix=nil) -> XML::Namespace
|
174
|
+
*
|
175
|
+
* Searches for a namespace that has the specified prefix.
|
176
|
+
* The search starts at the current node and works upward
|
177
|
+
* through the node's parents. If a namespace is found,
|
178
|
+
* then an XML::Namespace instance is returned, otherwise nil
|
179
|
+
* is returned.
|
180
|
+
*
|
181
|
+
* Usage:
|
182
|
+
*
|
183
|
+
* doc = XML::Document.string('<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"/>')
|
184
|
+
* ns = doc.root.namespaces.find_by_prefix('soap')
|
185
|
+
* assert_equal('soap', ns.prefix)
|
186
|
+
* assert_equal('http://schemas.xmlsoap.org/soap/envelope/', ns.href)
|
187
|
+
*/
|
188
|
+
static VALUE rxml_namespaces_find_by_prefix(VALUE self, VALUE prefix)
|
189
|
+
{
|
190
|
+
xmlNodePtr xnode;
|
191
|
+
xmlNsPtr xns;
|
192
|
+
xmlChar* xprefix = NULL;
|
193
|
+
|
194
|
+
|
195
|
+
if (!NIL_P(prefix))
|
196
|
+
{
|
197
|
+
Check_Type(prefix, T_STRING);
|
198
|
+
xprefix = (xmlChar*) StringValuePtr(prefix);
|
199
|
+
}
|
200
|
+
|
201
|
+
Data_Get_Struct(self, xmlNode, xnode);
|
202
|
+
|
203
|
+
xns = xmlSearchNs(xnode->doc, xnode, xprefix);
|
204
|
+
if (xns)
|
205
|
+
return rxml_namespace_wrap(xns);
|
206
|
+
else
|
207
|
+
return Qnil;
|
208
|
+
}
|
209
|
+
|
210
|
+
/*
|
211
|
+
* call-seq:
|
212
|
+
* namespaces.namespace -> XML::Namespace
|
213
|
+
*
|
214
|
+
* Returns the current node's namespace.
|
215
|
+
*
|
216
|
+
* Usage:
|
217
|
+
*
|
218
|
+
* doc = XML::Document.string('<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"/>')
|
219
|
+
* ns = doc.root.namespaces.namespace
|
220
|
+
* assert_equal('soap', ns.prefix)
|
221
|
+
* assert_equal('http://schemas.xmlsoap.org/soap/envelope/', ns.href)
|
222
|
+
*/
|
223
|
+
static VALUE rxml_namespaces_namespace_get(VALUE self)
|
224
|
+
{
|
225
|
+
xmlNodePtr xnode;
|
226
|
+
Data_Get_Struct(self, xmlNode, xnode);
|
227
|
+
|
228
|
+
if (xnode->ns)
|
229
|
+
return rxml_namespace_wrap(xnode->ns);
|
230
|
+
else
|
231
|
+
return Qnil;
|
232
|
+
}
|
233
|
+
|
234
|
+
/*
|
235
|
+
* call-seq:
|
236
|
+
* namespaces.namespace = XML::Namespace
|
237
|
+
*
|
238
|
+
* Sets the current node's namespace.
|
239
|
+
*
|
240
|
+
* Basic usage:
|
241
|
+
*
|
242
|
+
* # Create a node
|
243
|
+
* node = XML::Node.new('Envelope')
|
244
|
+
*
|
245
|
+
* # Define the soap namespace - this does *not* put the node in the namespace
|
246
|
+
* ns = XML::Namespace.new(node, 'soap', 'http://schemas.xmlsoap.org/soap/envelope/')
|
247
|
+
* assert_equal("<Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"/>", node.to_s)
|
248
|
+
*
|
249
|
+
* # Now put the node in the soap namespace, not how the string representation changes
|
250
|
+
* node.namespaces.namespace = ns
|
251
|
+
* assert_equal("<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"/>", node.to_s)
|
252
|
+
*/
|
253
|
+
static VALUE rxml_namespaces_namespace_set(VALUE self, VALUE ns)
|
254
|
+
{
|
255
|
+
xmlNodePtr xnode;
|
256
|
+
xmlNsPtr xns;
|
257
|
+
|
258
|
+
Data_Get_Struct(self, xmlNode, xnode);
|
259
|
+
|
260
|
+
Check_Type(ns, T_DATA);
|
261
|
+
Data_Get_Struct(ns, xmlNs, xns);
|
262
|
+
|
263
|
+
xmlSetNs(xnode, xns);
|
264
|
+
return self;
|
265
|
+
}
|
266
|
+
|
267
|
+
/*
|
268
|
+
* call-seq:
|
269
|
+
* namespaces.node -> XML::Node
|
270
|
+
*
|
271
|
+
* Returns the current node.
|
272
|
+
*/
|
273
|
+
static VALUE rxml_namespaces_node_get(VALUE self)
|
274
|
+
{
|
275
|
+
xmlNodePtr xnode;
|
276
|
+
Data_Get_Struct(self, xmlNode, xnode);
|
277
|
+
return rxml_node_wrap(cXMLNode, xnode);
|
278
|
+
}
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
// Rdoc needs to know
|
283
|
+
#ifdef RDOC_NEVER_DEFINED
|
284
|
+
mLibXML = rb_define_module("LibXML");
|
285
|
+
mXML = rb_define_module_under(mLibXML, "XML");
|
286
|
+
#endif
|
287
|
+
|
288
|
+
void ruby_init_xml_namespaces(void)
|
289
|
+
{
|
290
|
+
cXMLNamespaces = rb_define_class_under(mXML, "Namespaces", rb_cObject);
|
291
|
+
rb_include_module(cXMLNamespaces, rb_mEnumerable);
|
292
|
+
|
293
|
+
rb_define_alloc_func(cXMLNamespaces, rxml_namespaces_alloc);
|
294
|
+
rb_define_method(cXMLNamespaces, "initialize", rxml_namespaces_initialize, 1);
|
295
|
+
|
296
|
+
rb_define_method(cXMLNamespaces, "definitions", rxml_namespaces_definitions, 0);
|
297
|
+
rb_define_method(cXMLNamespaces, "each", rxml_namespaces_each, 0);
|
298
|
+
rb_define_method(cXMLNamespaces, "find_by_href", rxml_namespaces_find_by_href, 1);
|
299
|
+
rb_define_method(cXMLNamespaces, "find_by_prefix", rxml_namespaces_find_by_prefix, 1);
|
300
|
+
rb_define_method(cXMLNamespaces, "namespace", rxml_namespaces_namespace_get, 0);
|
301
|
+
rb_define_method(cXMLNamespaces, "namespace=", rxml_namespaces_namespace_set, 1);
|
302
|
+
rb_define_method(cXMLNamespaces, "node", rxml_namespaces_node_get, 0);
|
303
|
+
}
|