libxml-ruby 0.7.0-x86-mswin32-60 → 0.8.0-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +24 -1
- data/README +48 -3
- data/benchmark/depixelate.rb +632 -0
- data/benchmark/hamlet.xml +9055 -0
- data/benchmark/sock_entries.xml +507 -0
- data/benchmark/throughput.rb +39 -0
- data/benchmark/xml_benchmarks.rb +222 -0
- data/doc/classes/LibXML.html +237 -0
- data/doc/classes/LibXML/XML.html +178 -0
- data/doc/classes/{XML → LibXML/XML}/Attr.html +213 -182
- data/doc/classes/{XML → LibXML/XML}/Attributes.html +126 -54
- data/doc/classes/{XML → LibXML/XML}/Document.html +299 -297
- data/doc/classes/{XML → LibXML/XML}/Dtd.html +10 -10
- data/doc/classes/{XML/XInclude → LibXML/XML}/Error.html +4 -4
- data/doc/classes/{XML → LibXML/XML}/HTMLParser.html +40 -40
- data/doc/classes/{XML → LibXML/XML}/InputCallbacks.html +10 -10
- data/doc/classes/{XML → LibXML/XML}/NS.html +46 -46
- data/doc/classes/{XML → LibXML/XML}/Node.html +935 -788
- data/doc/classes/LibXML/XML/Node/FailedModify.html +111 -0
- data/doc/classes/{XML → LibXML/XML}/Node/Set.html +69 -68
- data/doc/classes/{XML → LibXML/XML}/Node/SetNamespace.html +4 -4
- data/doc/classes/{XML/Node/FailedModify.html → LibXML/XML/Node/UnknownType.html} +4 -4
- data/doc/classes/{XML → LibXML/XML}/Parser.html +426 -389
- data/doc/classes/{XML → LibXML/XML}/Parser/Context.html +208 -208
- data/doc/classes/{XML → LibXML/XML}/Parser/ParseError.html +4 -4
- data/doc/classes/{XML → LibXML/XML}/Reader.html +288 -287
- data/doc/classes/{XML → LibXML/XML}/SaxParser.html +52 -52
- data/doc/classes/{XML/XPath/Context.html → LibXML/XML/Schema.html} +60 -32
- data/doc/classes/{XML → LibXML/XML}/State.html +4 -4
- data/doc/classes/{XML/Node/UnknownType.html → LibXML/XML/Tree.html} +5 -5
- data/doc/classes/{XML → LibXML/XML}/XInclude.html +5 -5
- data/doc/classes/{XML → LibXML/XML/XInclude}/Error.html +5 -5
- data/doc/classes/{XML → LibXML/XML}/XMLParserOptions.html +5 -5
- data/doc/classes/{XML → LibXML/XML}/XPath.html +23 -64
- data/doc/classes/LibXML/XML/XPath/Context.html +403 -0
- data/doc/classes/{XML/XPointer/Context → LibXML/XML/XPath}/InvalidPath.html +4 -4
- data/doc/classes/LibXML/XML/XPath/Object.html +623 -0
- data/doc/classes/{XML → LibXML/XML}/XPointer.html +12 -12
- data/doc/classes/{XML → LibXML/XML}/XPointer/Context.html +5 -5
- data/doc/classes/{XML/XPath → LibXML/XML/XPointer/Context}/InvalidPath.html +5 -5
- data/doc/classes/{XML → LibXML/XML}/XPointer/InvalidExpression.html +4 -4
- data/doc/classes/XML.html +17 -123
- data/doc/created.rid +1 -1
- data/doc/files/CHANGES.html +49 -25
- data/doc/files/LICENSE.html +1 -1
- data/doc/files/README.html +79 -4
- data/doc/files/VERSION.html +2 -2
- data/doc/files/ext/libxml/cbg_c.html +1 -1
- data/doc/files/ext/libxml/libxml_c.html +1 -1
- data/doc/files/ext/libxml/ruby_xml_attr_c.html +1 -1
- data/doc/files/ext/libxml/ruby_xml_attributes_c.html +1 -1
- data/doc/files/ext/libxml/ruby_xml_document_c.html +1 -1
- data/doc/files/ext/libxml/ruby_xml_dtd_c.html +1 -1
- data/doc/files/ext/libxml/ruby_xml_html_parser_c.html +1 -1
- data/doc/files/ext/libxml/ruby_xml_input_cbg_c.html +1 -1
- data/doc/files/ext/libxml/ruby_xml_node_c.html +1 -1
- data/doc/files/ext/libxml/ruby_xml_node_set_c.html +1 -1
- data/doc/files/ext/libxml/ruby_xml_ns_c.html +1 -1
- data/doc/files/ext/libxml/ruby_xml_parser_c.html +1 -1
- data/doc/files/ext/libxml/ruby_xml_parser_context_c.html +1 -1
- data/doc/files/ext/libxml/ruby_xml_reader_c.html +1 -1
- data/doc/files/ext/libxml/ruby_xml_sax_parser_c.html +1 -1
- data/doc/files/ext/libxml/ruby_xml_schema_c.html +1 -1
- data/doc/files/ext/libxml/ruby_xml_state_c.html +1 -1
- data/doc/files/ext/libxml/ruby_xml_xinclude_c.html +1 -1
- data/doc/files/ext/libxml/ruby_xml_xpath_c.html +1 -1
- data/doc/files/ext/libxml/ruby_xml_xpath_context_c.html +1 -1
- data/doc/files/ext/libxml/ruby_xml_xpath_object_c.html +1 -1
- data/doc/files/ext/libxml/ruby_xml_xpointer_c.html +1 -1
- data/doc/files/ext/libxml/ruby_xml_xpointer_context_c.html +1 -1
- data/doc/files/lib/libxml/attr_rb.html +108 -0
- data/doc/files/lib/libxml/attributes_rb.html +108 -0
- data/doc/files/lib/libxml/document_rb.html +108 -0
- data/doc/files/lib/libxml/node_rb.html +108 -0
- data/doc/files/lib/libxml/node_set_rb.html +108 -0
- data/doc/files/lib/libxml/parser_options_rb.html +107 -0
- data/doc/files/{ext/libxml/ruby_xml_tree_c.html → lib/libxml/parser_rb.html} +4 -4
- data/doc/files/lib/libxml/properties_rb.html +108 -0
- data/doc/files/lib/libxml/tree_rb.html +107 -0
- data/doc/files/lib/libxml_rb.html +12 -3
- data/doc/fr_class_index.html +34 -32
- data/doc/fr_file_index.html +9 -1
- data/doc/fr_method_index.html +362 -347
- data/ext/libxml/cbg.c +76 -76
- data/ext/libxml/libxml.c +4 -3
- data/ext/libxml/ruby_libxml.h +1 -1
- data/ext/libxml/ruby_xml_attr.c +4 -3
- data/ext/libxml/ruby_xml_attr.h +16 -16
- data/ext/libxml/ruby_xml_attributes.c +267 -266
- data/ext/libxml/ruby_xml_attributes.h +17 -17
- data/ext/libxml/ruby_xml_document.c +30 -59
- data/ext/libxml/ruby_xml_document.h +27 -27
- data/ext/libxml/ruby_xml_dtd.c +2 -1
- data/ext/libxml/ruby_xml_dtd.h +17 -17
- data/ext/libxml/ruby_xml_html_parser.c +3 -2
- data/ext/libxml/ruby_xml_html_parser.h +29 -29
- data/ext/libxml/ruby_xml_input_cbg.c +2 -1
- data/ext/libxml/ruby_xml_input_cbg.h +20 -20
- data/ext/libxml/ruby_xml_node.c +127 -470
- data/ext/libxml/ruby_xml_node.h +17 -17
- data/ext/libxml/ruby_xml_node_set.c +5 -4
- data/ext/libxml/ruby_xml_node_set.h +20 -20
- data/ext/libxml/ruby_xml_ns.c +3 -2
- data/ext/libxml/ruby_xml_ns.h +12 -12
- data/ext/libxml/ruby_xml_parser.c +20 -48
- data/ext/libxml/ruby_xml_parser.h +31 -31
- data/ext/libxml/ruby_xml_parser_context.c +3 -2
- data/ext/libxml/ruby_xml_parser_context.h +20 -20
- data/ext/libxml/ruby_xml_reader.c +2 -1
- data/ext/libxml/ruby_xml_sax_parser.c +3 -2
- data/ext/libxml/ruby_xml_sax_parser.h +56 -56
- data/ext/libxml/ruby_xml_schema.c +6 -0
- data/ext/libxml/ruby_xml_schema.h +16 -16
- data/ext/libxml/ruby_xml_state.c +13 -12
- data/ext/libxml/ruby_xml_state.h +1 -1
- data/ext/libxml/ruby_xml_xinclude.c +3 -2
- data/ext/libxml/ruby_xml_xinclude.h +13 -13
- data/ext/libxml/ruby_xml_xpath.c +35 -228
- data/ext/libxml/ruby_xml_xpath.h +22 -23
- data/ext/libxml/ruby_xml_xpath_context.c +223 -62
- data/ext/libxml/ruby_xml_xpath_context.h +15 -20
- data/ext/libxml/ruby_xml_xpath_object.c +63 -19
- data/ext/libxml/ruby_xml_xpointer.c +19 -15
- data/ext/libxml/ruby_xml_xpointer.h +27 -27
- data/ext/libxml/ruby_xml_xpointer_context.c +3 -2
- data/ext/libxml/ruby_xml_xpointer_context.h +18 -18
- data/ext/libxml/version.h +9 -9
- data/lib/libxml.rb +16 -128
- data/lib/libxml/attr.rb +45 -0
- data/lib/libxml/attributes.rb +15 -0
- data/lib/libxml/document.rb +54 -0
- data/lib/libxml/node.rb +132 -0
- data/lib/libxml/node_set.rb +27 -0
- data/lib/libxml/parser.rb +42 -0
- data/lib/libxml/parser_options.rb +25 -0
- data/lib/libxml/properties.rb +19 -0
- data/lib/libxml/tree.rb +29 -0
- data/lib/libxml_ruby.so +0 -0
- data/mingw/libxml_ruby.so +0 -0
- data/{work/task/setup → setup.rb} +1585 -1616
- data/test/gc.log +0 -0
- data/test/model/books.xml +147 -0
- data/{work/test/runner.rb → test/model/default_validation_bug.rb} +0 -0
- data/test/model/merge_bug_data.xml +58 -0
- data/test/model/rubynet.xml +78 -0
- data/test/model/rubynet_project +1 -0
- data/test/model/saxtest.xml +5 -0
- data/test/model/shiporder.xml +23 -0
- data/test/model/shiporder.xsd +31 -0
- data/test/model/simple.xml +7 -0
- data/test/model/soap.xml +27 -0
- data/test/model/xinclude.xml +5 -0
- data/test/tc_deprecated_require.rb +13 -0
- data/test/tc_xml_document.rb +57 -16
- data/test/tc_xml_document_write.rb +125 -10
- data/test/tc_xml_dtd.rb +22 -1
- data/test/tc_xml_node.rb +13 -0
- data/test/tc_xml_node_edit.rb +1 -1
- data/test/tc_xml_node_xlink.rb +1 -1
- data/test/tc_xml_parser.rb +64 -7
- data/test/tc_xml_properties.rb +42 -0
- data/test/tc_xml_reader.rb +4 -4
- data/test/tc_xml_sax_parser.rb +50 -50
- data/test/tc_xml_schema.rb +2 -2
- data/test/tc_xml_traversal.rb +220 -0
- data/test/tc_xml_xinclude.rb +12 -15
- data/test/tc_xml_xpath.rb +74 -6
- data/test/tc_xml_xpath_context.rb +72 -0
- data/test/test_suite.rb +6 -4
- data/vc/libxml_ruby.vcproj +1 -9
- metadata +92 -65
- data/doc/classes/XML/SiblingEnum.html +0 -142
- data/doc/classes/XML/Tree.html +0 -224
- data/doc/classes/XML/XPath/Object.html +0 -439
- data/ext/libxml/ruby_xml_tree.c +0 -43
- data/ext/libxml/ruby_xml_tree.h +0 -12
- data/test/ets_copy_bug2.rb +0 -21
- data/test/tc_xml_document_write2.rb +0 -54
- data/test/tc_xml_document_write3.rb +0 -96
- data/test/tc_xml_sax_parser2.rb +0 -51
- data/work/Rakefile +0 -247
- data/work/task/make +0 -26
- data/work/task/memory +0 -37
- data/work/task/rdoc +0 -39
- data/work/task/test +0 -29
- data/work/test/ets_runner.rb +0 -33
- data/work/test/libxml_test.rb +0 -3
- data/work/test/runner_ets.rb +0 -33
@@ -1,4 +1,4 @@
|
|
1
|
-
/* $Id: ruby_xml_xpointer.c
|
1
|
+
/* $Id: ruby_xml_xpointer.c 461 2008-07-15 21:35:56Z cfis $ */
|
2
2
|
|
3
3
|
/* Please see the LICENSE file for copyright and distribution information */
|
4
4
|
|
@@ -12,9 +12,12 @@ VALUE
|
|
12
12
|
ruby_xml_xpointer_point(VALUE class, VALUE rnode, VALUE xptr_str) {
|
13
13
|
#ifdef LIBXML_XPTR_ENABLED
|
14
14
|
xmlNodePtr xnode;
|
15
|
-
xmlXPathContextPtr
|
16
|
-
|
17
|
-
|
15
|
+
xmlXPathContextPtr xctxt;
|
16
|
+
xmlXPathObjectPtr xpop;
|
17
|
+
|
18
|
+
VALUE context;
|
19
|
+
VALUE result;
|
20
|
+
VALUE argv[1];
|
18
21
|
|
19
22
|
Check_Type(xptr_str, T_STRING);
|
20
23
|
if (rb_obj_is_kind_of(rnode, cXMLNode) == Qfalse)
|
@@ -22,18 +25,18 @@ ruby_xml_xpointer_point(VALUE class, VALUE rnode, VALUE xptr_str) {
|
|
22
25
|
|
23
26
|
Data_Get_Struct(rnode, xmlNode, xnode);
|
24
27
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
if (NIL_P(rxptr_xpth_ctxt))
|
29
|
-
return(Qnil);
|
28
|
+
argv[0] = rb_funcall(rnode, rb_intern("doc"), 0);
|
29
|
+
context = rb_class_new_instance(1, argv, cXMLXPathContext);
|
30
|
+
Data_Get_Struct(context, xmlXPathContext, xctxt);
|
30
31
|
|
31
|
-
|
32
|
-
if (
|
33
|
-
rb_raise(eXMLXPointerInvalidExpression, "
|
32
|
+
xpop = xmlXPtrEval((xmlChar*)StringValuePtr(xptr_str), xctxt);
|
33
|
+
if (!xpop)
|
34
|
+
rb_raise(eXMLXPointerInvalidExpression, "Invalid xpointer expression");
|
34
35
|
|
35
|
-
|
36
|
-
|
36
|
+
result = ruby_xml_xpath_object_wrap(xpop);
|
37
|
+
rb_iv_set(result, "@context", context);
|
38
|
+
|
39
|
+
return(result);
|
37
40
|
#else
|
38
41
|
rb_warn("libxml was compiled without XPointer support");
|
39
42
|
return(Qfalse);
|
@@ -88,7 +91,8 @@ ruby_xml_xpointer_range(VALUE class, VALUE rstart, VALUE rend) {
|
|
88
91
|
|
89
92
|
// Rdoc needs to know
|
90
93
|
#ifdef RDOC_NEVER_DEFINED
|
91
|
-
|
94
|
+
mLibXML = rb_define_module("LibXML");
|
95
|
+
mXML = rb_define_module_under(mLibXML, "XML");
|
92
96
|
#endif
|
93
97
|
|
94
98
|
void
|
@@ -1,27 +1,27 @@
|
|
1
|
-
/* $Id: ruby_xml_xpointer.h 39 2006-02-21 20:40:16Z roscopeco $ */
|
2
|
-
|
3
|
-
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
-
|
5
|
-
#ifndef __RUBY_XML_XPOINTER__
|
6
|
-
#define __RUBY_XML_XPOINTER__
|
7
|
-
|
8
|
-
extern VALUE cXMLXPointer;
|
9
|
-
extern VALUE eXMLXPointerInvalidExpression;
|
10
|
-
|
11
|
-
typedef struct ruby_xml_xpointer {
|
12
|
-
VALUE xd;
|
13
|
-
VALUE ctxt;
|
14
|
-
/*
|
15
|
-
* This needs to go into a xpointer data struct:
|
16
|
-
*
|
17
|
-
* xmlLocationSetPtr xptr;
|
18
|
-
*
|
19
|
-
* I also need an xpointer data struct type.
|
20
|
-
*/
|
21
|
-
} ruby_xml_xpointer;
|
22
|
-
|
23
|
-
VALUE ruby_xml_xpointer_point(VALUE class, VALUE node, VALUE xptr_string);
|
24
|
-
VALUE ruby_xml_xpointer_point2(VALUE node, VALUE xptr_string);
|
25
|
-
void ruby_init_xml_xpointer(void);
|
26
|
-
|
27
|
-
#endif
|
1
|
+
/* $Id: ruby_xml_xpointer.h 39 2006-02-21 20:40:16Z roscopeco $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#ifndef __RUBY_XML_XPOINTER__
|
6
|
+
#define __RUBY_XML_XPOINTER__
|
7
|
+
|
8
|
+
extern VALUE cXMLXPointer;
|
9
|
+
extern VALUE eXMLXPointerInvalidExpression;
|
10
|
+
|
11
|
+
typedef struct ruby_xml_xpointer {
|
12
|
+
VALUE xd;
|
13
|
+
VALUE ctxt;
|
14
|
+
/*
|
15
|
+
* This needs to go into a xpointer data struct:
|
16
|
+
*
|
17
|
+
* xmlLocationSetPtr xptr;
|
18
|
+
*
|
19
|
+
* I also need an xpointer data struct type.
|
20
|
+
*/
|
21
|
+
} ruby_xml_xpointer;
|
22
|
+
|
23
|
+
VALUE ruby_xml_xpointer_point(VALUE class, VALUE node, VALUE xptr_string);
|
24
|
+
VALUE ruby_xml_xpointer_point2(VALUE node, VALUE xptr_string);
|
25
|
+
void ruby_init_xml_xpointer(void);
|
26
|
+
|
27
|
+
#endif
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/* $Id: ruby_xml_xpointer_context.c
|
1
|
+
/* $Id: ruby_xml_xpointer_context.c 461 2008-07-15 21:35:56Z cfis $ */
|
2
2
|
|
3
3
|
/* Please see the LICENSE file for copyright and distribution information */
|
4
4
|
|
@@ -10,7 +10,8 @@ VALUE eXMLXPointerContextInvalidPath;
|
|
10
10
|
|
11
11
|
// Rdoc needs to know
|
12
12
|
#ifdef RDOC_NEVER_DEFINED
|
13
|
-
|
13
|
+
mLibXML = rb_define_module("LibXML");
|
14
|
+
mXML = rb_define_module_under(mLibXML, "XML");
|
14
15
|
cXMLXPointer = rb_define_class_under(mXML, "XPointer", rb_cObject);
|
15
16
|
#endif
|
16
17
|
|
@@ -1,18 +1,18 @@
|
|
1
|
-
/* $Id: ruby_xml_xpointer_context.h 39 2006-02-21 20:40:16Z roscopeco $ */
|
2
|
-
|
3
|
-
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
-
|
5
|
-
#ifndef __RUBY_XML_XPOINTER_CONTEXT__
|
6
|
-
#define __RUBY_XML_XPOINTER_CONTEXT__
|
7
|
-
|
8
|
-
extern VALUE cXMLXPointerContext;
|
9
|
-
extern VALUE eXMLXPointerContextInvalidPath;
|
10
|
-
|
11
|
-
typedef struct ruby_xml_xpointer_context {
|
12
|
-
VALUE xd;
|
13
|
-
xmlXPathContextPtr ctxt;
|
14
|
-
} ruby_xml_xpointer_context;
|
15
|
-
|
16
|
-
void ruby_init_xml_xpointer_context(void);
|
17
|
-
|
18
|
-
#endif
|
1
|
+
/* $Id: ruby_xml_xpointer_context.h 39 2006-02-21 20:40:16Z roscopeco $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#ifndef __RUBY_XML_XPOINTER_CONTEXT__
|
6
|
+
#define __RUBY_XML_XPOINTER_CONTEXT__
|
7
|
+
|
8
|
+
extern VALUE cXMLXPointerContext;
|
9
|
+
extern VALUE eXMLXPointerContextInvalidPath;
|
10
|
+
|
11
|
+
typedef struct ruby_xml_xpointer_context {
|
12
|
+
VALUE xd;
|
13
|
+
xmlXPathContextPtr ctxt;
|
14
|
+
} ruby_xml_xpointer_context;
|
15
|
+
|
16
|
+
void ruby_init_xml_xpointer_context(void);
|
17
|
+
|
18
|
+
#endif
|
data/ext/libxml/version.h
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
/* Don't nuke this block! It is used for automatically updating the
|
2
|
-
* versions below. VERSION = string formatting, VERNUM = numbered
|
3
|
-
* version for inline testing: increment both or none at all.*/
|
4
|
-
#define RUBY_LIBXML_VERSION "0.
|
5
|
-
#define RUBY_LIBXML_VERNUM 0
|
6
|
-
#define RUBY_LIBXML_VER_MAJ 0
|
7
|
-
#define RUBY_LIBXML_VER_MIN
|
8
|
-
#define RUBY_LIBXML_VER_MIC 0
|
9
|
-
#define RUBY_LIBXML_VER_PATCH 0
|
1
|
+
/* Don't nuke this block! It is used for automatically updating the
|
2
|
+
* versions below. VERSION = string formatting, VERNUM = numbered
|
3
|
+
* version for inline testing: increment both or none at all.*/
|
4
|
+
#define RUBY_LIBXML_VERSION "0.8.0"
|
5
|
+
#define RUBY_LIBXML_VERNUM 0
|
6
|
+
#define RUBY_LIBXML_VER_MAJ 0
|
7
|
+
#define RUBY_LIBXML_VER_MIN 8
|
8
|
+
#define RUBY_LIBXML_VER_MIC 0
|
9
|
+
#define RUBY_LIBXML_VER_PATCH 0
|
data/lib/libxml.rb
CHANGED
@@ -1,134 +1,22 @@
|
|
1
|
-
# $Id: libxml.rb
|
1
|
+
# $Id: libxml.rb 458 2008-07-15 21:10:55Z cfis $
|
2
2
|
# Please see the LICENSE file for copyright and distribution information
|
3
3
|
|
4
|
-
require 'libxml_ruby
|
4
|
+
require 'libxml_ruby'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
XML_PARSE_PEDANTIC = 128 # pedantic error reporting
|
15
|
-
XML_PARSE_NOBLANKS = 256 # remove blank nodes
|
16
|
-
XML_PARSE_SAX1 = 512 # use the SAX1 interface internally
|
17
|
-
XML_PARSE_XINCLUDE = 1024 # Implement XInclude substitition
|
18
|
-
XML_PARSE_NONET = 2048 # Forbid network access
|
19
|
-
XML_PARSE_NODICT = 4096 # Do not reuse the context dictionnary
|
20
|
-
XML_PARSE_NSCLEAN = 8192 # remove redundant namespaces declarations
|
21
|
-
XML_PARSE_NOCDATA = 16384 # merge CDATA as text nodes
|
22
|
-
XML_PARSE_NOXINCNODE = 32768 # do not generate XINCLUDE START/END nodes
|
23
|
-
XML_PARSE_COMPACT = 65536 # compact small text nodes; no modification of the tree allowed afterwards (will possibly crash if you try to modify the tree)
|
24
|
-
end
|
6
|
+
require 'libxml/parser'
|
7
|
+
require 'libxml/parser_options'
|
8
|
+
require 'libxml/document'
|
9
|
+
require 'libxml/node'
|
10
|
+
require 'libxml/node_set'
|
11
|
+
require 'libxml/attributes'
|
12
|
+
require 'libxml/attr'
|
13
|
+
require 'libxml/tree'
|
25
14
|
|
26
|
-
|
27
|
-
|
15
|
+
# Deprecated
|
16
|
+
require 'libxml/properties'
|
28
17
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
class XML::Node::Set
|
36
|
-
include Enumerable
|
37
|
-
|
38
|
-
# inefficient, but maybe can find a way to cache the
|
39
|
-
# ary and dump on change?
|
40
|
-
def [](i, count = nil)
|
41
|
-
if count
|
42
|
-
to_a[i,count]
|
43
|
-
else
|
44
|
-
to_a[i]
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def to_s #:nodoc:
|
49
|
-
to_a.to_s
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
module XML::SiblingEnum
|
54
|
-
def length
|
55
|
-
inject(0) do |result, node|
|
56
|
-
result + 1
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
private
|
61
|
-
|
62
|
-
# Iterates nodes and attributes
|
63
|
-
def siblings(node, &blk)
|
64
|
-
if n = node
|
65
|
-
loop do
|
66
|
-
blk.call(n)
|
67
|
-
break unless n = n.next
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
class XML::Node
|
74
|
-
include XML::SiblingEnum
|
75
|
-
include Enumerable
|
76
|
-
|
77
|
-
# maybe these don't belong on all nodes...
|
78
|
-
def each_child(&blk)
|
79
|
-
siblings(child, &blk)
|
80
|
-
end
|
81
|
-
|
82
|
-
def each_attr(&blk)
|
83
|
-
siblings(properties, &blk)
|
84
|
-
end
|
85
|
-
|
86
|
-
# all siblings INCLUDING self
|
87
|
-
def each_sibling(&blk)
|
88
|
-
siblings(self, &blk)
|
89
|
-
end
|
90
|
-
|
91
|
-
# I guess this is what you'd expect?
|
92
|
-
alias :each :each_child
|
93
|
-
|
94
|
-
def to_a
|
95
|
-
inject([]) do |ary,n|
|
96
|
-
ary << n
|
97
|
-
ary
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def clone
|
102
|
-
copy(false)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
class XML::Attr
|
107
|
-
include XML::SiblingEnum
|
108
|
-
include Enumerable
|
109
|
-
|
110
|
-
def each_sibling(&blk)
|
111
|
-
siblings(self,&blk)
|
112
|
-
end
|
113
|
-
|
114
|
-
alias :each_attr :each_sibling
|
115
|
-
alias :each :each_sibling
|
116
|
-
|
117
|
-
def to_h
|
118
|
-
inject({}) do |h,a|
|
119
|
-
h[a.name] = a.value
|
120
|
-
h
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
def to_a
|
125
|
-
inject([]) do |ary,a|
|
126
|
-
ary << [a.name, a.value]
|
127
|
-
ary
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
def to_s
|
132
|
-
"#{name} = #{value}"
|
133
|
-
end
|
18
|
+
# Map the LibXML module into the XML module for both backwards
|
19
|
+
# compatibility and ease of use.
|
20
|
+
module XML
|
21
|
+
include LibXML::XML
|
134
22
|
end
|
data/lib/libxml/attr.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# $Id: libxml.rb 374 2008-07-11 04:51:41Z cfis $
|
2
|
+
# Please see the LICENSE file for copyright and distribution information
|
3
|
+
|
4
|
+
module LibXML
|
5
|
+
module XML
|
6
|
+
class Attr
|
7
|
+
include Enumerable
|
8
|
+
|
9
|
+
# Iterates nodes and attributes
|
10
|
+
def siblings(node, &blk)
|
11
|
+
if n = node
|
12
|
+
loop do
|
13
|
+
blk.call(n)
|
14
|
+
break unless n = n.next
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def each_sibling(&blk)
|
20
|
+
siblings(self,&blk)
|
21
|
+
end
|
22
|
+
|
23
|
+
alias :each_attr :each_sibling
|
24
|
+
alias :each :each_sibling
|
25
|
+
|
26
|
+
def to_h
|
27
|
+
inject({}) do |h,a|
|
28
|
+
h[a.name] = a.value
|
29
|
+
h
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def to_a
|
34
|
+
inject([]) do |ary,a|
|
35
|
+
ary << [a.name, a.value]
|
36
|
+
ary
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_s
|
41
|
+
"#{name} = #{value}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# $Id: libxml.rb 374 2008-07-11 04:51:41Z cfis $
|
2
|
+
# Please see the LICENSE file for copyright and distribution information
|
3
|
+
|
4
|
+
module LibXML
|
5
|
+
module XML
|
6
|
+
class Attributes
|
7
|
+
def to_h
|
8
|
+
inject({}) do |hash, attr|
|
9
|
+
hash[attr.name] = attr.value
|
10
|
+
hash
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# $Id: libxml.rb 374 2008-07-11 04:51:41Z cfis $
|
2
|
+
# Please see the LICENSE file for copyright and distribution information
|
3
|
+
|
4
|
+
module LibXML
|
5
|
+
module XML
|
6
|
+
class Document
|
7
|
+
# Return the nodes matching the specified xpath expression,
|
8
|
+
# optionally using the specified namespace. For more
|
9
|
+
# information about working with namespaces, please refer
|
10
|
+
# to the XML::XPath documentation.
|
11
|
+
#
|
12
|
+
# Parameters:
|
13
|
+
# * xpath - The xpath expression as a string
|
14
|
+
# * namespaces - An optional list of namespaces (see XML::XPath for information).
|
15
|
+
# * Returns - XML::XPath::Object
|
16
|
+
#
|
17
|
+
# document.find('/foo', 'xlink:http://www.w3.org/1999/xlink')
|
18
|
+
#
|
19
|
+
# IMPORTANT - The returned XML::Node::Set must be freed before
|
20
|
+
# its associated document. In a running Ruby program this will
|
21
|
+
# happen automatically via Ruby's mark and sweep garbage collector.
|
22
|
+
# However, if the program exits, Ruby does not guarantee the order
|
23
|
+
# in which objects are freed
|
24
|
+
# (see http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/17700).
|
25
|
+
# As a result, the associated document may be freed before the node
|
26
|
+
# list, which will cause a segmentation fault.
|
27
|
+
# To avoid this, use the following (non-ruby like) coding style:
|
28
|
+
#
|
29
|
+
# nodes = doc.find('/header')
|
30
|
+
# nodes.each do |node|
|
31
|
+
# ... do stuff ...
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# nodes = nil
|
35
|
+
# GC.start
|
36
|
+
#
|
37
|
+
def find(xpath, nslist = nil)
|
38
|
+
context = XPath::Context.new(self)
|
39
|
+
context.node = self.root
|
40
|
+
context.register_namespaces_from_node(self.root)
|
41
|
+
context.register_namespaces(nslist) if nslist
|
42
|
+
|
43
|
+
context.find(xpath)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Return the first node matching the specified xpath expression.
|
47
|
+
# For more information, please refer to the documentation
|
48
|
+
# for XML::Document#find.
|
49
|
+
def find_first(xpath, nslist = nil)
|
50
|
+
find(xpath, nslist).first
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|