libxml-ruby 3.0.0-x64-mingw32 → 3.2.2-x64-mingw32
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.
- checksums.yaml +5 -5
- data/HISTORY +37 -0
- data/MANIFEST +34 -34
- data/README.rdoc +65 -36
- data/Rakefile +21 -3
- data/ext/libxml/extconf.rb +30 -26
- data/ext/libxml/ruby_libxml.h +0 -8
- data/ext/libxml/ruby_xml.c +40 -0
- data/ext/libxml/ruby_xml_document.c +1 -5
- data/ext/libxml/ruby_xml_dtd.c +6 -8
- data/ext/libxml/ruby_xml_encoding.c +1 -13
- data/ext/libxml/ruby_xml_encoding.h +0 -3
- data/ext/libxml/ruby_xml_error.c +1 -1
- data/ext/libxml/ruby_xml_error.h +1 -1
- data/ext/libxml/ruby_xml_io.c +14 -18
- data/ext/libxml/ruby_xml_io.h +1 -1
- data/ext/libxml/ruby_xml_node.c +16 -17
- data/ext/libxml/ruby_xml_parser_context.c +1 -1
- data/ext/libxml/ruby_xml_reader.c +7 -2
- data/ext/libxml/ruby_xml_schema.c +44 -66
- data/ext/libxml/ruby_xml_schema_element.c +15 -14
- data/ext/libxml/ruby_xml_schema_type.c +66 -93
- data/ext/libxml/ruby_xml_version.h +4 -4
- data/ext/libxml/ruby_xml_writer.c +189 -192
- data/lib/3.0/libxml_ruby.so +0 -0
- data/lib/libxml/schema/element.rb +0 -8
- data/lib/libxml/schema/type.rb +0 -8
- data/lib/libxml/schema.rb +0 -19
- data/lib/libxml-ruby.rb +30 -0
- data/lib/libxml.rb +3 -28
- data/libxml-ruby.gemspec +5 -4
- data/setup.rb +0 -1
- data/test/model/cwm_1_0.xml +11336 -0
- data/test/{tc_attr.rb → test_attr.rb} +18 -18
- data/test/{tc_attr_decl.rb → test_attr_decl.rb} +8 -8
- data/test/{tc_attributes.rb → test_attributes.rb} +10 -10
- data/test/{tc_canonicalize.rb → test_canonicalize.rb} +35 -39
- data/test/test_deprecated_require.rb +12 -0
- data/test/{tc_document.rb → test_document.rb} +31 -24
- data/test/test_document_write.rb +146 -0
- data/test/{tc_dtd.rb → test_dtd.rb} +26 -25
- data/test/{tc_encoding.rb → test_encoding.rb} +20 -17
- data/test/{tc_encoding_sax.rb → test_encoding_sax.rb} +3 -3
- data/test/test_error.rb +178 -0
- data/test/test_helper.rb +4 -11
- data/test/{tc_html_parser.rb → test_html_parser.rb} +31 -30
- data/test/test_html_parser_context.rb +23 -0
- data/test/test_namespace.rb +60 -0
- data/test/{tc_namespaces.rb → test_namespaces.rb} +29 -38
- data/test/{tc_node.rb → test_node.rb} +37 -31
- data/test/{tc_node_cdata.rb → test_node_cdata.rb} +10 -10
- data/test/{tc_node_comment.rb → test_node_comment.rb} +6 -6
- data/test/{tc_node_copy.rb → test_node_copy.rb} +3 -4
- data/test/{tc_node_edit.rb → test_node_edit.rb} +20 -21
- data/test/{tc_node_pi.rb → test_node_pi.rb} +8 -10
- data/test/{tc_node_text.rb → test_node_text.rb} +8 -9
- data/test/{tc_node_write.rb → test_node_write.rb} +16 -26
- data/test/test_node_xlink.rb +28 -0
- data/test/{tc_parser.rb → test_parser.rb} +72 -75
- data/test/{tc_parser_context.rb → test_parser_context.rb} +38 -44
- data/test/{tc_properties.rb → test_properties.rb} +5 -5
- data/test/test_reader.rb +364 -0
- data/test/{tc_relaxng.rb → test_relaxng.rb} +11 -11
- data/test/{tc_sax_parser.rb → test_sax_parser.rb} +38 -31
- data/test/{tc_schema.rb → test_schema.rb} +40 -33
- data/test/test_suite.rb +39 -40
- data/test/{tc_traversal.rb → test_traversal.rb} +4 -4
- data/test/{tc_writer.rb → test_writer.rb} +95 -74
- data/test/{tc_xinclude.rb → test_xinclude.rb} +3 -3
- data/test/test_xml.rb +263 -0
- data/test/{tc_xpath.rb → test_xpath.rb} +25 -25
- data/test/{tc_xpath_context.rb → test_xpath_context.rb} +5 -5
- data/test/{tc_xpath_expression.rb → test_xpath_expression.rb} +7 -7
- data/test/{tc_xpointer.rb → test_xpointer.rb} +15 -15
- metadata +92 -106
- data/lib/2.4/libxml_ruby.so +0 -0
- data/lib/libs/libiconv-2.dll +0 -0
- data/lib/libs/libxml2-2.dll +0 -0
- data/lib/libs/zlib1.dll +0 -0
- data/test/tc_deprecated_require.rb +0 -12
- data/test/tc_document_write.rb +0 -195
- data/test/tc_error.rb +0 -178
- data/test/tc_html_parser_context.rb +0 -23
- data/test/tc_namespace.rb +0 -61
- data/test/tc_node_xlink.rb +0 -28
- data/test/tc_reader.rb +0 -358
- data/test/tc_xml.rb +0 -225
    
        data/ext/libxml/ruby_xml_io.c
    CHANGED
    
    | @@ -1,13 +1,10 @@ | |
| 1 1 | 
             
            /* Please see the LICENSE file for copyright and distribution information */
         | 
| 2 2 |  | 
| 3 3 | 
             
            #include "ruby_libxml.h"
         | 
| 4 | 
            +
            #include <ruby/io.h>
         | 
| 4 5 |  | 
| 5 6 | 
             
            static ID READ_METHOD;
         | 
| 6 | 
            -
            #ifdef HAVE_RB_IO_BUFWRITE
         | 
| 7 | 
            -
            #include <ruby/io.h>
         | 
| 8 | 
            -
            #else
         | 
| 9 7 | 
             
            static ID WRITE_METHOD;
         | 
| 10 | 
            -
            #endif /* !HAVE_RB_IO_BUFWRITE */
         | 
| 11 8 |  | 
| 12 9 | 
             
            /* This method is called by libxml when it wants to read
         | 
| 13 10 | 
             
             more data from a stream. We go with the duck typing
         | 
| @@ -27,25 +24,24 @@ int rxml_read_callback(void *context, char *buffer, int len) | |
| 27 24 | 
             
              return (int)size;
         | 
| 28 25 | 
             
            }
         | 
| 29 26 |  | 
| 30 | 
            -
            int rxml_write_callback( | 
| 27 | 
            +
            int rxml_write_callback(VALUE io, const char *buffer, int len)
         | 
| 31 28 | 
             
            {
         | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 42 | 
            -
             | 
| 29 | 
            +
                if (rb_io_check_io(io) == Qnil)
         | 
| 30 | 
            +
                {
         | 
| 31 | 
            +
                    // Could be StringIO
         | 
| 32 | 
            +
                    VALUE written, string;
         | 
| 33 | 
            +
                    string = rb_external_str_new_with_enc(buffer, strlen(buffer), rb_enc_get(io));
         | 
| 34 | 
            +
                    written = rb_funcall(io, WRITE_METHOD, 1, string);
         | 
| 35 | 
            +
                    return NUM2INT(written);
         | 
| 36 | 
            +
                }
         | 
| 37 | 
            +
                else
         | 
| 38 | 
            +
                {
         | 
| 39 | 
            +
                    return (int)rb_io_bufwrite(io, buffer, (size_t)len);
         | 
| 40 | 
            +
                }
         | 
| 43 41 | 
             
            }
         | 
| 44 42 |  | 
| 45 43 | 
             
            void rxml_init_io(void)
         | 
| 46 44 | 
             
            {
         | 
| 47 45 | 
             
              READ_METHOD = rb_intern("read");
         | 
| 48 | 
            -
            #ifndef HAVE_RB_IO_BUFWRITE
         | 
| 49 46 | 
             
              WRITE_METHOD = rb_intern("write");
         | 
| 50 | 
            -
            #endif /* !HAVE_RB_IO_BUFWRITE */
         | 
| 51 47 | 
             
            }
         | 
    
        data/ext/libxml/ruby_xml_io.h
    CHANGED
    
    
    
        data/ext/libxml/ruby_xml_node.c
    CHANGED
    
    | @@ -57,7 +57,7 @@ static void rxml_node_free(xmlNodePtr xnode) | |
| 57 57 |  | 
| 58 58 | 
             
            void rxml_node_manage(xmlNodePtr xnode, VALUE node)
         | 
| 59 59 | 
             
            {
         | 
| 60 | 
            -
              RDATA(node)->dfree = rxml_node_free;
         | 
| 60 | 
            +
              RDATA(node)->dfree = (RUBY_DATA_FUNC)rxml_node_free;
         | 
| 61 61 | 
             
              xnode->_private = (void*)node;
         | 
| 62 62 | 
             
            }
         | 
| 63 63 |  | 
| @@ -83,8 +83,11 @@ void rxml_node_mark(xmlNodePtr xnode) | |
| 83 83 | 
             
            {
         | 
| 84 84 | 
             
               if (xnode->doc)
         | 
| 85 85 | 
             
               {
         | 
| 86 | 
            -
                  | 
| 87 | 
            -
             | 
| 86 | 
            +
                 if (xnode->doc->_private)
         | 
| 87 | 
            +
            	 {
         | 
| 88 | 
            +
            	   VALUE doc = (VALUE)xnode->doc->_private;
         | 
| 89 | 
            +
            	   rb_gc_mark(doc);
         | 
| 90 | 
            +
            	 }
         | 
| 88 91 | 
             
               }
         | 
| 89 92 | 
             
               else if (xnode->parent)
         | 
| 90 93 | 
             
               {
         | 
| @@ -120,8 +123,7 @@ VALUE rxml_node_wrap(xmlNodePtr xnode) | |
| 120 123 |  | 
| 121 124 | 
             
            static VALUE rxml_node_alloc(VALUE klass)
         | 
| 122 125 | 
             
            {
         | 
| 123 | 
            -
               | 
| 124 | 
            -
                 up mark and free yet until we assign the node. */
         | 
| 126 | 
            +
              // This node was created from Ruby so we are responsible for freeing it not libxml
         | 
| 125 127 | 
             
              return Data_Wrap_Struct(klass, rxml_node_mark, rxml_node_free, NULL);
         | 
| 126 128 | 
             
            }
         | 
| 127 129 |  | 
| @@ -308,25 +310,22 @@ static VALUE rxml_node_modify_dom(VALUE self, VALUE target, | |
| 308 310 | 
             
              xtarget = rxml_get_xnode(target);
         | 
| 309 311 |  | 
| 310 312 | 
             
              if (xtarget->doc != NULL && xtarget->doc != xnode->doc)
         | 
| 311 | 
            -
                rb_raise(eXMLError, "Nodes belong to different documents.  You must first import the node by calling XML::Document.import");
         | 
| 313 | 
            +
                rb_raise(eXMLError, "Nodes belong to different documents.  You must first import the node by calling LibXML::XML::Document.import");
         | 
| 312 314 |  | 
| 313 315 | 
             
              xmlUnlinkNode(xtarget);
         | 
| 314 316 |  | 
| 315 | 
            -
               | 
| 317 | 
            +
              // Target is about to have a parent, so stop having ruby manage it.
         | 
| 318 | 
            +
              rxml_node_unmanage(xtarget, target);
         | 
| 319 | 
            +
             | 
| 320 | 
            +
              // This target node could be freed here and be replaced by a different node 
         | 
| 316 321 | 
             
              xresult = xmlFunc(xnode, xtarget);
         | 
| 317 322 |  | 
| 318 323 | 
             
              if (!xresult)
         | 
| 319 | 
            -
             | 
| 320 | 
            -
             | 
| 321 | 
            -
              /* Was the target freed? If yes, then wrap the new node */
         | 
| 322 | 
            -
              if (xresult != xtarget)
         | 
| 323 | 
            -
              {
         | 
| 324 | 
            -
                RDATA(target)->data = xresult;
         | 
| 325 | 
            -
              }
         | 
| 324 | 
            +
            	  rxml_raise(&xmlLastError);
         | 
| 326 325 |  | 
| 327 | 
            -
               | 
| 328 | 
            -
             | 
| 329 | 
            -
               | 
| 326 | 
            +
              /* Assume the target was freed, we need to fix up the ruby object to point to the
         | 
| 327 | 
            +
                 newly returned node. */
         | 
| 328 | 
            +
              RDATA(target)->data = xresult;
         | 
| 330 329 |  | 
| 331 330 | 
             
              return target;
         | 
| 332 331 | 
             
            }
         | 
| @@ -47,7 +47,7 @@ static VALUE rxml_parser_context_document(VALUE klass, VALUE document) | |
| 47 47 | 
             
              int length;
         | 
| 48 48 |  | 
| 49 49 | 
             
              if (rb_obj_is_kind_of(document, cXMLDocument) == Qfalse)
         | 
| 50 | 
            -
                rb_raise(rb_eTypeError, "Must pass an XML::Document object");
         | 
| 50 | 
            +
                rb_raise(rb_eTypeError, "Must pass an LibXML::XML::Document object");
         | 
| 51 51 |  | 
| 52 52 | 
             
              Data_Get_Struct(document, xmlDoc, xdoc);
         | 
| 53 53 | 
             
              xmlDocDumpFormatMemoryEnc(xdoc, &buffer, &length, (const char*)xdoc->encoding, 0);
         | 
| @@ -23,7 +23,7 @@ | |
| 23 23 | 
             
             *  reader = XML::Reader.string("<foo><bar>1</bar><bar>2</bar><bar>3</bar></foo>")
         | 
| 24 24 | 
             
             *  reader.read
         | 
| 25 25 | 
             
             *  assert_equal('foo', reader.name)
         | 
| 26 | 
            -
             *   | 
| 26 | 
            +
             *  assert_nil(reader.value)
         | 
| 27 27 | 
             
             *
         | 
| 28 28 | 
             
             *  3.times do |i|
         | 
| 29 29 | 
             
             *    reader.read
         | 
| @@ -995,7 +995,12 @@ static VALUE rxml_reader_expand(VALUE self) | |
| 995 995 | 
             
              }
         | 
| 996 996 | 
             
              else
         | 
| 997 997 | 
             
              {
         | 
| 998 | 
            -
             | 
| 998 | 
            +
            	  /* We cannot call rxml_node_wrap here because its sets up a mark function
         | 
| 999 | 
            +
            	   for the node. But according to the libxml docs (http://xmlsoft.org/html/libxml-xmlreader.html#xmlTextReaderExpand)
         | 
| 1000 | 
            +
            	   this is only valid until the next xmlTextReaderRead call.  At that point the node is freed (from reading
         | 
| 1001 | 
            +
            	   the libxml2 source code.  So don't set a mark or free function, because they will get called in the next
         | 
| 1002 | 
            +
            	   garbage collection run and cause a segfault.*/
         | 
| 1003 | 
            +
            	return Data_Wrap_Struct(cXMLNode, NULL, NULL, xnode);
         | 
| 999 1004 | 
             
              }
         | 
| 1000 1005 | 
             
            }
         | 
| 1001 1006 |  | 
| @@ -8,7 +8,6 @@ | |
| 8 8 | 
             
            #include "ruby_xml_schema_attribute.h"
         | 
| 9 9 | 
             
            #include "ruby_xml_schema_facet.h"
         | 
| 10 10 |  | 
| 11 | 
            -
             | 
| 12 11 | 
             
            /*
         | 
| 13 12 | 
             
             * Document-class: LibXML::XML::Schema
         | 
| 14 13 | 
             
             *
         | 
| @@ -152,7 +151,6 @@ static VALUE rxml_schema_id(VALUE self) | |
| 152 151 | 
             
              QNIL_OR_STRING(xschema->id)
         | 
| 153 152 | 
             
            }
         | 
| 154 153 |  | 
| 155 | 
            -
             | 
| 156 154 | 
             
            static VALUE rxml_schema_document(VALUE self)
         | 
| 157 155 | 
             
            {
         | 
| 158 156 | 
             
              xmlSchemaPtr xschema;
         | 
| @@ -162,21 +160,20 @@ static VALUE rxml_schema_document(VALUE self) | |
| 162 160 | 
             
              return rxml_node_wrap(xmlDocGetRootElement(xschema->doc));
         | 
| 163 161 | 
             
            }
         | 
| 164 162 |  | 
| 165 | 
            -
            static void  | 
| 163 | 
            +
            static void scan_namespaces(xmlSchemaImportPtr ximport, VALUE array, xmlChar *nsname)
         | 
| 166 164 | 
             
            {
         | 
| 167 | 
            -
              VALUE schemas;
         | 
| 168 165 | 
             
              xmlNodePtr xnode;
         | 
| 169 166 | 
             
              xmlNsPtr xns;
         | 
| 170 167 |  | 
| 171 | 
            -
               | 
| 172 | 
            -
               | 
| 173 | 
            -
                xnode = xmlDocGetRootElement( | 
| 174 | 
            -
             | 
| 168 | 
            +
              if (ximport->doc)
         | 
| 169 | 
            +
              {
         | 
| 170 | 
            +
                xnode = xmlDocGetRootElement(ximport->doc);
         | 
| 175 171 | 
             
                xns = xnode->nsDef;
         | 
| 176 172 |  | 
| 177 | 
            -
                while (xns) | 
| 178 | 
            -
             | 
| 179 | 
            -
                   | 
| 173 | 
            +
                while (xns)
         | 
| 174 | 
            +
            	{
         | 
| 175 | 
            +
                  VALUE namespace = rxml_namespace_wrap(xns);
         | 
| 176 | 
            +
                  rb_ary_push(array, namespace);
         | 
| 180 177 | 
             
                  xns = xns->next;
         | 
| 181 178 | 
             
                }
         | 
| 182 179 | 
             
              }
         | 
| @@ -184,95 +181,76 @@ static void storeNs(xmlSchemaImportPtr import, VALUE self, xmlChar *nsname) | |
| 184 181 |  | 
| 185 182 | 
             
            static VALUE rxml_schema_namespaces(VALUE self)
         | 
| 186 183 | 
             
            {
         | 
| 187 | 
            -
              VALUE  | 
| 184 | 
            +
              VALUE result;
         | 
| 188 185 | 
             
              xmlSchemaPtr xschema;
         | 
| 189 186 |  | 
| 190 187 | 
             
              Data_Get_Struct(self, xmlSchema, xschema);
         | 
| 191 188 |  | 
| 192 | 
            -
               | 
| 193 | 
            -
             | 
| 194 | 
            -
                rb_iv_set(self, "@namespaces", schemas);
         | 
| 195 | 
            -
                xmlHashScan(xschema->schemasImports, (xmlHashScanner) storeNs, (void *)self);
         | 
| 196 | 
            -
              }
         | 
| 189 | 
            +
              result = rb_ary_new();
         | 
| 190 | 
            +
              xmlHashScan(xschema->schemasImports, (xmlHashScanner)scan_namespaces, (void *)result);
         | 
| 197 191 |  | 
| 198 | 
            -
              return  | 
| 192 | 
            +
              return result;
         | 
| 199 193 | 
             
            }
         | 
| 200 194 |  | 
| 201 | 
            -
            static void  | 
| 195 | 
            +
            static void scan_element(xmlSchemaElementPtr xelement, VALUE hash, xmlChar *name)
         | 
| 202 196 | 
             
            {
         | 
| 203 | 
            -
              VALUE  | 
| 204 | 
            -
               | 
| 205 | 
            -
             | 
| 206 | 
            -
              types = rb_iv_get(self, "@types");
         | 
| 207 | 
            -
              rtype = rxml_wrap_schema_type(type);
         | 
| 208 | 
            -
             | 
| 209 | 
            -
              rb_hash_aset(types, rb_str_new2((const char*)name), rtype);
         | 
| 197 | 
            +
              VALUE element = rxml_wrap_schema_element(xelement);
         | 
| 198 | 
            +
              rb_hash_aset(hash, rb_str_new2((const char*)name), element);
         | 
| 210 199 | 
             
            }
         | 
| 211 200 |  | 
| 212 | 
            -
            static VALUE  | 
| 213 | 
            -
             | 
| 214 | 
            -
            static VALUE rxml_schema_types(VALUE self)
         | 
| 201 | 
            +
            static VALUE rxml_schema_elements(VALUE self)
         | 
| 215 202 | 
             
            {
         | 
| 216 | 
            -
              VALUE  | 
| 203 | 
            +
              VALUE result = rb_hash_new();
         | 
| 217 204 | 
             
              xmlSchemaPtr xschema;
         | 
| 218 205 |  | 
| 219 206 | 
             
              Data_Get_Struct(self, xmlSchema, xschema);
         | 
| 207 | 
            +
              xmlHashScan(xschema->elemDecl, (xmlHashScanner)scan_element, (void *)result);
         | 
| 220 208 |  | 
| 221 | 
            -
               | 
| 222 | 
            -
                types = rb_hash_new();
         | 
| 223 | 
            -
                rb_iv_set(self, "@types", types);
         | 
| 224 | 
            -
                rxml_schema_collect_types(self);
         | 
| 225 | 
            -
                if(xschema != NULL && xschema->typeDecl != NULL)
         | 
| 226 | 
            -
                  xmlHashScan(xschema->typeDecl, (xmlHashScanner) storeType, (void *)self);
         | 
| 227 | 
            -
              }
         | 
| 228 | 
            -
             | 
| 229 | 
            -
              return rb_iv_get(self, "@types");
         | 
| 209 | 
            +
              return result;
         | 
| 230 210 | 
             
            }
         | 
| 231 211 |  | 
| 232 | 
            -
            static void  | 
| 212 | 
            +
            static void scan_type(xmlSchemaTypePtr xtype, VALUE hash, xmlChar *name)
         | 
| 233 213 | 
             
            {
         | 
| 234 | 
            -
             | 
| 235 | 
            -
             | 
| 236 | 
            -
             | 
| 237 | 
            -
              elements = rb_iv_get(self, "@elements");
         | 
| 238 | 
            -
              relement = rxml_wrap_schema_element(element);
         | 
| 239 | 
            -
              rb_hash_aset(elements, rb_str_new2((const char*)name), relement);
         | 
| 214 | 
            +
            	VALUE type = rxml_wrap_schema_type(xtype);
         | 
| 215 | 
            +
            	rb_hash_aset(hash, rb_str_new2((const char*)name), type);
         | 
| 240 216 | 
             
            }
         | 
| 241 217 |  | 
| 242 | 
            -
            static VALUE  | 
| 218 | 
            +
            static VALUE rxml_schema_types(VALUE self)
         | 
| 243 219 | 
             
            {
         | 
| 244 | 
            -
             | 
| 245 | 
            -
             | 
| 220 | 
            +
            	VALUE result = rb_hash_new();
         | 
| 221 | 
            +
            	xmlSchemaPtr xschema;
         | 
| 246 222 |  | 
| 247 | 
            -
             | 
| 223 | 
            +
            	Data_Get_Struct(self, xmlSchema, xschema);
         | 
| 248 224 |  | 
| 249 | 
            -
             | 
| 250 | 
            -
             | 
| 251 | 
            -
             | 
| 252 | 
            -
             | 
| 253 | 
            -
              }
         | 
| 225 | 
            +
            	if (xschema != NULL && xschema->typeDecl != NULL)
         | 
| 226 | 
            +
            	{
         | 
| 227 | 
            +
            		xmlHashScan(xschema->typeDecl, (xmlHashScanner)scan_type, (void *)result);
         | 
| 228 | 
            +
            	}
         | 
| 254 229 |  | 
| 255 | 
            -
             | 
| 230 | 
            +
            	return result;
         | 
| 256 231 | 
             
            }
         | 
| 257 232 |  | 
| 258 | 
            -
            static void  | 
| 233 | 
            +
            static void collect_imported_types(xmlSchemaImportPtr import, VALUE result)
         | 
| 259 234 | 
             
            {
         | 
| 260 | 
            -
              if (import->imported && import->schema) | 
| 261 | 
            -
             | 
| 235 | 
            +
              if (import->imported && import->schema)
         | 
| 236 | 
            +
              {
         | 
| 237 | 
            +
                xmlHashScan(import->schema->typeDecl, (xmlHashScanner)scan_type, (void *)result);
         | 
| 262 238 | 
             
              }
         | 
| 263 239 | 
             
            }
         | 
| 264 240 |  | 
| 265 | 
            -
            static VALUE  | 
| 241 | 
            +
            static VALUE rxml_schema_imported_types(VALUE self)
         | 
| 266 242 | 
             
            {
         | 
| 267 243 | 
             
              xmlSchemaPtr xschema;
         | 
| 244 | 
            +
              VALUE result = rb_hash_new();
         | 
| 268 245 |  | 
| 269 246 | 
             
              Data_Get_Struct(self, xmlSchema, xschema);
         | 
| 270 247 |  | 
| 271 | 
            -
              if(xschema) | 
| 272 | 
            -
             | 
| 248 | 
            +
              if (xschema)
         | 
| 249 | 
            +
              {
         | 
| 250 | 
            +
            	  xmlHashScan(xschema->schemasImports, (xmlHashScanner)collect_imported_types, (void *)result);
         | 
| 273 251 | 
             
              }
         | 
| 274 252 |  | 
| 275 | 
            -
              return  | 
| 253 | 
            +
              return result;
         | 
| 276 254 | 
             
            }
         | 
| 277 255 |  | 
| 278 256 | 
             
            void rxml_init_schema(void)
         | 
| @@ -288,10 +266,10 @@ void rxml_init_schema(void) | |
| 288 266 | 
             
              rb_define_method(cXMLSchema, "version", rxml_schema_version, 0);
         | 
| 289 267 | 
             
              rb_define_method(cXMLSchema, "document", rxml_schema_document, 0);
         | 
| 290 268 |  | 
| 291 | 
            -
              rb_define_method(cXMLSchema, "_namespaces", rxml_schema_namespaces, 0);
         | 
| 292 | 
            -
              rb_define_method(cXMLSchema, "_collect_types", rxml_schema_collect_types, 0);
         | 
| 293 | 
            -
              rb_define_method(cXMLSchema, "types", rxml_schema_types, 0);
         | 
| 294 269 | 
             
              rb_define_method(cXMLSchema, "elements", rxml_schema_elements, 0);
         | 
| 270 | 
            +
              rb_define_method(cXMLSchema, "imported_types", rxml_schema_imported_types, 0);
         | 
| 271 | 
            +
              rb_define_method(cXMLSchema, "namespaces", rxml_schema_namespaces, 0);
         | 
| 272 | 
            +
              rb_define_method(cXMLSchema, "types", rxml_schema_types, 0);
         | 
| 295 273 |  | 
| 296 274 | 
             
              rxml_init_schema_facet();
         | 
| 297 275 | 
             
              rxml_init_schema_element();
         | 
| @@ -64,22 +64,25 @@ static VALUE rxml_schema_element_value(VALUE self) | |
| 64 64 | 
             
              QNIL_OR_STRING(xelem->value)
         | 
| 65 65 | 
             
            }
         | 
| 66 66 |  | 
| 67 | 
            -
            static VALUE rxml_schema_element_min_occurs(VALUE self)
         | 
| 68 | 
            -
            {
         | 
| 69 | 
            -
              return rb_iv_get(self, "@min");
         | 
| 70 | 
            -
            }
         | 
| 71 | 
            -
             | 
| 72 | 
            -
            static VALUE rxml_schema_element_max_occurs(VALUE self)
         | 
| 73 | 
            -
            {
         | 
| 74 | 
            -
              return rb_iv_get(self, "@max");
         | 
| 75 | 
            -
            }
         | 
| 76 | 
            -
             | 
| 77 67 | 
             
            static VALUE rxml_schema_element_annot(VALUE self)
         | 
| 78 68 | 
             
            {
         | 
| 79 | 
            -
             | 
| 69 | 
            +
            	VALUE result = Qnil;
         | 
| 70 | 
            +
            	xmlSchemaElementPtr xelem;
         | 
| 71 | 
            +
             | 
| 72 | 
            +
            	Data_Get_Struct(self, xmlSchemaElement, xelem);
         | 
| 73 | 
            +
             | 
| 74 | 
            +
            	if (xelem != NULL && xelem->annot != NULL && xelem->annot->content != NULL)
         | 
| 75 | 
            +
            	{
         | 
| 76 | 
            +
            		xmlChar *content = xmlNodeGetContent(xelem->annot->content);
         | 
| 77 | 
            +
            		if (content)
         | 
| 78 | 
            +
            		{
         | 
| 79 | 
            +
            			result = rxml_new_cstr(content, NULL);
         | 
| 80 | 
            +
            			xmlFree(content);
         | 
| 81 | 
            +
            		}
         | 
| 82 | 
            +
            	}
         | 
| 83 | 
            +
            	return result;
         | 
| 80 84 | 
             
            }
         | 
| 81 85 |  | 
| 82 | 
            -
             | 
| 83 86 | 
             
            void rxml_init_schema_element(void)
         | 
| 84 87 | 
             
            {
         | 
| 85 88 | 
             
              cXMLSchemaElement = rb_define_class_under(cXMLSchema, "Element", rb_cObject);
         | 
| @@ -88,7 +91,5 @@ void rxml_init_schema_element(void) | |
| 88 91 | 
             
              rb_define_method(cXMLSchemaElement, "type", rxml_schema_element_type, 0);
         | 
| 89 92 | 
             
              rb_define_method(cXMLSchemaElement, "node", rxml_schema_element_node, 0);
         | 
| 90 93 | 
             
              rb_define_method(cXMLSchemaElement, "value", rxml_schema_element_value, 0);
         | 
| 91 | 
            -
              rb_define_method(cXMLSchemaElement, "min_occurs", rxml_schema_element_min_occurs, 0);
         | 
| 92 | 
            -
              rb_define_method(cXMLSchemaElement, "max_occurs", rxml_schema_element_max_occurs, 0);
         | 
| 93 94 | 
             
              rb_define_method(cXMLSchemaElement, "annotation", rxml_schema_element_annot, 0);
         | 
| 94 95 | 
             
            }
         | 
| @@ -50,28 +50,22 @@ static VALUE rxml_schema_type_base(VALUE self) | |
| 50 50 | 
             
            static VALUE rxml_schema_type_facets(VALUE self)
         | 
| 51 51 | 
             
            {
         | 
| 52 52 | 
             
              xmlSchemaTypePtr xtype;
         | 
| 53 | 
            -
              xmlSchemaFacetPtr  | 
| 54 | 
            -
              VALUE  | 
| 55 | 
            -
              VALUE  | 
| 53 | 
            +
              xmlSchemaFacetPtr xfacet;
         | 
| 54 | 
            +
              VALUE result = rb_ary_new();
         | 
| 55 | 
            +
              VALUE facet;
         | 
| 56 56 |  | 
| 57 | 
            -
               | 
| 58 | 
            -
             | 
| 59 | 
            -
              if (facets == Qnil) {
         | 
| 60 | 
            -
                facets = rb_ary_new();
         | 
| 61 | 
            -
                Data_Get_Struct(self, xmlSchemaType, xtype);
         | 
| 62 | 
            -
             | 
| 63 | 
            -
                facet = xtype->facets;
         | 
| 57 | 
            +
              Data_Get_Struct(self, xmlSchemaType, xtype);
         | 
| 64 58 |  | 
| 65 | 
            -
             | 
| 66 | 
            -
                  rfacet = rxml_wrap_schema_facet((xmlSchemaFacetPtr) facet);
         | 
| 67 | 
            -
                  rb_ary_push(facets, rfacet);
         | 
| 68 | 
            -
                  facet = facet->next;
         | 
| 69 | 
            -
                }
         | 
| 59 | 
            +
              xfacet = xtype->facets;
         | 
| 70 60 |  | 
| 71 | 
            -
             | 
| 61 | 
            +
              while (xfacet != NULL)
         | 
| 62 | 
            +
              {
         | 
| 63 | 
            +
                facet = rxml_wrap_schema_facet((xmlSchemaFacetPtr)xfacet);
         | 
| 64 | 
            +
                rb_ary_push(result, facet);
         | 
| 65 | 
            +
                xfacet = xfacet->next;
         | 
| 72 66 | 
             
              }
         | 
| 73 67 |  | 
| 74 | 
            -
              return  | 
| 68 | 
            +
              return result;
         | 
| 75 69 | 
             
            }
         | 
| 76 70 |  | 
| 77 71 | 
             
            static VALUE rxml_schema_type_node(VALUE self)
         | 
| @@ -95,67 +89,60 @@ static VALUE rxml_schema_type_kind(VALUE self) | |
| 95 89 | 
             
              return INT2NUM(xtype->type);
         | 
| 96 90 | 
             
            }
         | 
| 97 91 |  | 
| 98 | 
            -
            static VALUE get_annotation(xmlSchemaAnnotPtr annot)
         | 
| 99 | 
            -
            {
         | 
| 100 | 
            -
              if(annot != NULL && annot->content != NULL && annot->content->content != NULL)
         | 
| 101 | 
            -
                return rb_str_new2((const char *) annot->content->content);
         | 
| 102 | 
            -
              else
         | 
| 103 | 
            -
                return Qnil;
         | 
| 104 | 
            -
            }
         | 
| 105 | 
            -
             | 
| 106 92 | 
             
            static VALUE rxml_schema_type_annot(VALUE self)
         | 
| 107 93 | 
             
            {
         | 
| 94 | 
            +
              VALUE result = Qnil;
         | 
| 108 95 | 
             
              xmlSchemaTypePtr xtype;
         | 
| 109 96 |  | 
| 110 97 | 
             
              Data_Get_Struct(self, xmlSchemaType, xtype);
         | 
| 111 98 |  | 
| 112 | 
            -
              if(xtype != NULL && xtype->annot != NULL)
         | 
| 113 | 
            -
             | 
| 114 | 
            -
             | 
| 115 | 
            -
             | 
| 99 | 
            +
              if(xtype != NULL && xtype->annot != NULL && xtype->annot->content != NULL)
         | 
| 100 | 
            +
              {
         | 
| 101 | 
            +
                xmlChar *content = xmlNodeGetContent(xtype->annot->content);
         | 
| 102 | 
            +
            	if (content)
         | 
| 103 | 
            +
            	{
         | 
| 104 | 
            +
            	  result = rxml_new_cstr(content, NULL);
         | 
| 105 | 
            +
            	  xmlFree(content);
         | 
| 106 | 
            +
                }
         | 
| 107 | 
            +
              }
         | 
| 108 | 
            +
              return result;
         | 
| 116 109 | 
             
            }
         | 
| 117 110 |  | 
| 118 | 
            -
            static void rxmlSchemaCollectElements(xmlSchemaParticlePtr  | 
| 111 | 
            +
            static void rxmlSchemaCollectElements(xmlSchemaParticlePtr xparticle, VALUE hash)
         | 
| 119 112 | 
             
            {
         | 
| 120 | 
            -
              VALUE  | 
| 121 | 
            -
               | 
| 122 | 
            -
              xmlSchemaTreeItemPtr term;
         | 
| 113 | 
            +
              VALUE element;
         | 
| 114 | 
            +
              xmlSchemaTreeItemPtr xterm;
         | 
| 123 115 |  | 
| 124 | 
            -
              if ( | 
| 116 | 
            +
              if (xparticle == NULL)
         | 
| 125 117 | 
             
                return;
         | 
| 126 118 |  | 
| 127 | 
            -
               | 
| 128 | 
            -
             | 
| 129 | 
            -
              if (term != NULL) {
         | 
| 130 | 
            -
                elements = rb_iv_get(self, "@elements");
         | 
| 119 | 
            +
              xterm = xparticle->children;
         | 
| 131 120 |  | 
| 132 | 
            -
             | 
| 121 | 
            +
              if (xterm != NULL)
         | 
| 122 | 
            +
              {
         | 
| 123 | 
            +
                switch (xterm->type)
         | 
| 124 | 
            +
            	{
         | 
| 133 125 | 
             
                  case XML_SCHEMA_TYPE_ELEMENT:
         | 
| 134 | 
            -
                     | 
| 126 | 
            +
                    element = rxml_wrap_schema_element((xmlSchemaElementPtr)xterm);
         | 
| 127 | 
            +
                    rb_iv_set(element, "@min", INT2NUM(xparticle->minOccurs));
         | 
| 135 128 |  | 
| 136 | 
            -
             | 
| 137 | 
            -
             | 
| 138 | 
            -
             | 
| 139 | 
            -
                    if (particle->maxOccurs >= UNBOUNDED)
         | 
| 140 | 
            -
                      rb_iv_set(relement, "@max", rb_const_get(rb_path2class("Float"), rb_intern("INFINITY")));
         | 
| 129 | 
            +
                    if (xparticle->maxOccurs >= UNBOUNDED)
         | 
| 130 | 
            +
                      rb_iv_set(element, "@max", rb_const_get(rb_path2class("Float"), rb_intern("INFINITY")));
         | 
| 141 131 | 
             
                    else
         | 
| 142 | 
            -
                      rb_iv_set( | 
| 132 | 
            +
                      rb_iv_set(element, "@max", INT2NUM(xparticle->maxOccurs));
         | 
| 143 133 |  | 
| 144 | 
            -
                    if ( | 
| 134 | 
            +
                    if (xparticle->annot != NULL)
         | 
| 145 135 | 
             
                    {
         | 
| 146 | 
            -
                      xmlChar *content;
         | 
| 147 | 
            -
             | 
| 148 | 
            -
                      content = xmlNodeGetContent(particle->annot->content);
         | 
| 136 | 
            +
                      xmlChar *content = xmlNodeGetContent(xparticle->annot->content);
         | 
| 149 137 |  | 
| 150 138 | 
             
                      if (content != NULL)
         | 
| 151 139 | 
             
                      {
         | 
| 152 | 
            -
                        rb_iv_set( | 
| 140 | 
            +
                        rb_iv_set(element, "@annotation", rb_str_new2((const char *) content));
         | 
| 153 141 | 
             
                        xmlFree(content);
         | 
| 154 142 | 
             
                      }
         | 
| 155 143 | 
             
                    }
         | 
| 156 144 |  | 
| 157 | 
            -
                    rb_hash_aset( | 
| 158 | 
            -
             | 
| 145 | 
            +
                    rb_hash_aset(hash, rb_str_new2((const char *) ((xmlSchemaElementPtr)xterm)->name), element);
         | 
| 159 146 | 
             
                    break;
         | 
| 160 147 |  | 
| 161 148 | 
             
                  case XML_SCHEMA_TYPE_SEQUENCE:
         | 
| @@ -171,71 +158,57 @@ static void rxmlSchemaCollectElements(xmlSchemaParticlePtr particle, VALUE self) | |
| 171 158 | 
             
                    break;
         | 
| 172 159 |  | 
| 173 160 | 
             
                  default:
         | 
| 174 | 
            -
             | 
| 175 161 | 
             
                    return;
         | 
| 176 162 | 
             
                }
         | 
| 177 163 | 
             
              }
         | 
| 178 164 |  | 
| 179 | 
            -
              if ( | 
| 180 | 
            -
                  (( | 
| 181 | 
            -
             | 
| 182 | 
            -
             | 
| 183 | 
            -
             | 
| 184 | 
            -
             | 
| 185 | 
            -
                rxmlSchemaCollectElements((xmlSchemaParticlePtr) term->children, self);
         | 
| 165 | 
            +
              if (xterm &&
         | 
| 166 | 
            +
                  ((xterm->type == XML_SCHEMA_TYPE_SEQUENCE) || (xterm->type == XML_SCHEMA_TYPE_CHOICE) || (xterm->type == XML_SCHEMA_TYPE_ALL)) &&
         | 
| 167 | 
            +
                  (xterm->children != NULL))
         | 
| 168 | 
            +
              {
         | 
| 169 | 
            +
                rxmlSchemaCollectElements((xmlSchemaParticlePtr)xterm->children, hash);
         | 
| 186 170 | 
             
              }
         | 
| 187 171 |  | 
| 188 | 
            -
              if ( | 
| 189 | 
            -
             | 
| 172 | 
            +
              if (xparticle->next != NULL)
         | 
| 173 | 
            +
              {
         | 
| 174 | 
            +
            	rxmlSchemaCollectElements((xmlSchemaParticlePtr)xparticle->next, hash);
         | 
| 175 | 
            +
              }
         | 
| 190 176 | 
             
            }
         | 
| 191 177 |  | 
| 192 | 
            -
            static VALUE
         | 
| 193 | 
            -
            rxml_schema_type_elements(VALUE self)
         | 
| 178 | 
            +
            static VALUE rxml_schema_type_elements(VALUE self)
         | 
| 194 179 | 
             
            {
         | 
| 195 | 
            -
              VALUE  | 
| 180 | 
            +
              VALUE result = rb_hash_new();
         | 
| 196 181 | 
             
              xmlSchemaTypePtr xtype;
         | 
| 197 182 |  | 
| 198 183 | 
             
              Data_Get_Struct(self, xmlSchemaType, xtype);
         | 
| 184 | 
            +
              rxmlSchemaCollectElements((xmlSchemaParticlePtr) xtype->subtypes, result);
         | 
| 199 185 |  | 
| 200 | 
            -
               | 
| 201 | 
            -
                elements = rb_hash_new();
         | 
| 202 | 
            -
                rb_iv_set(self, "@elements", elements);
         | 
| 203 | 
            -
                rxmlSchemaCollectElements((xmlSchemaParticlePtr) xtype->subtypes, self);
         | 
| 204 | 
            -
              }
         | 
| 205 | 
            -
             | 
| 206 | 
            -
              return rb_iv_get(self, "@elements");
         | 
| 186 | 
            +
              return result;
         | 
| 207 187 | 
             
            }
         | 
| 208 188 |  | 
| 209 | 
            -
            static VALUE
         | 
| 210 | 
            -
            rxml_schema_type_attributes(VALUE self)
         | 
| 189 | 
            +
            static VALUE rxml_schema_type_attributes(VALUE self)
         | 
| 211 190 | 
             
            {
         | 
| 212 | 
            -
              VALUE  | 
| 191 | 
            +
              VALUE result = rb_ary_new();
         | 
| 213 192 | 
             
              xmlSchemaTypePtr xtype;
         | 
| 214 | 
            -
              xmlSchemaAttributeUsePtr  | 
| 215 | 
            -
              xmlSchemaItemListPtr  | 
| 193 | 
            +
              xmlSchemaAttributeUsePtr xuse;
         | 
| 194 | 
            +
              xmlSchemaItemListPtr xuses;
         | 
| 216 195 | 
             
              int i;
         | 
| 217 196 |  | 
| 218 197 | 
             
              Data_Get_Struct(self, xmlSchemaType, xtype);
         | 
| 219 | 
            -
             | 
| 220 | 
            -
             | 
| 221 | 
            -
             | 
| 222 | 
            -
             | 
| 223 | 
            -
             | 
| 224 | 
            -
             | 
| 225 | 
            -
             | 
| 226 | 
            -
             | 
| 227 | 
            -
                  return rb_iv_get(self, "@attributes");
         | 
| 228 | 
            -
             | 
| 229 | 
            -
                for (i = 0; i < uses->nbItems; i++) {
         | 
| 230 | 
            -
                  use = (xmlSchemaAttributeUsePtr) uses->items[i];
         | 
| 231 | 
            -
                  rb_ary_push(attributes, rxml_wrap_schema_attribute(use));
         | 
| 198 | 
            +
              xuses = xtype->attrUses;
         | 
| 199 | 
            +
             | 
| 200 | 
            +
              if (xuses != NULL)
         | 
| 201 | 
            +
              {
         | 
| 202 | 
            +
                for (i = 0; i < xuses->nbItems; i++)
         | 
| 203 | 
            +
            	{
         | 
| 204 | 
            +
                  xuse = (xmlSchemaAttributeUsePtr)xuses->items[i];
         | 
| 205 | 
            +
                  rb_ary_push(result, rxml_wrap_schema_attribute(xuse));
         | 
| 232 206 | 
             
                }
         | 
| 233 207 | 
             
              }
         | 
| 234 208 |  | 
| 235 | 
            -
              return  | 
| 209 | 
            +
              return result;
         | 
| 236 210 | 
             
            }
         | 
| 237 211 |  | 
| 238 | 
            -
             | 
| 239 212 | 
             
            void rxml_init_schema_type(void)
         | 
| 240 213 | 
             
            {
         | 
| 241 214 | 
             
              /* Add in infinity support for ruby 1.8.7 */
         | 
| @@ -1,9 +1,9 @@ | |
| 1 1 | 
             
            /* Don't nuke this block!  It is used for automatically updating the
         | 
| 2 2 | 
             
             * versions below. VERSION = string formatting, VERNUM = numbered
         | 
| 3 3 | 
             
             * version for inline testing: increment both or none at all.*/
         | 
| 4 | 
            -
            #define RUBY_LIBXML_VERSION  "3. | 
| 5 | 
            -
            #define RUBY_LIBXML_VERNUM    | 
| 4 | 
            +
            #define RUBY_LIBXML_VERSION  "3.2.2"
         | 
| 5 | 
            +
            #define RUBY_LIBXML_VERNUM   321
         | 
| 6 6 | 
             
            #define RUBY_LIBXML_VER_MAJ   3
         | 
| 7 | 
            -
            #define RUBY_LIBXML_VER_MIN    | 
| 8 | 
            -
            #define RUBY_LIBXML_VER_MIC    | 
| 7 | 
            +
            #define RUBY_LIBXML_VER_MIN   2
         | 
| 8 | 
            +
            #define RUBY_LIBXML_VER_MIC   2
         | 
| 9 9 | 
             
            #define RUBY_LIBXML_VER_PATCH 0
         |