public
Description: ruby libxml library targetting speed and ease of use. provides an hpricot-like interface to xml
Homepage: http://trac.hasno.info/fastxml
Clone URL: git://github.com/segfault/fastxml.git
forgiving and validate options now setup libxml property and set the 
internal vars


git-svn-id: svn://hasno.info/fastxml/trunk@43 
b3082176-f867-4bde-be85-e3c57d66f029
segfault (author)
Tue Oct 30 20:05:34 -0700 2007
commit  f854b2a8eed8ebe62bbe5e6c9bd8932e6631bac6
tree    76563639e0603ded137c67d3a3493af1ccf7bd2a
parent  7a0abd0654bc03960da3384f2d96e68aa85c5984
...
135
136
137
138
 
139
140
141
 
 
 
 
142
 
 
143
144
145
...
135
136
137
 
138
139
 
 
140
141
142
143
144
145
146
147
148
149
0
@@ -135,11 +135,15 @@ VALUE fastxml_doc_initialize(int argc, VALUE* argv, VALUE self)
0
     }
0
 
0
     if (opts != Qnil) {
0
- if (rb_hash_aref(opts, rb_sValidateDtd) != Qnil)
0
+ if (rb_hash_aref(opts, rb_sValidateDtd) == Qtrue) {
0
             parser_opts = parser_opts | XML_PARSE_DTDLOAD | XML_PARSE_DTDATTR | XML_PARSE_DTDVALID;
0
-
0
- if (rb_hash_aref(opts, rb_sForgivingParse) != Qnil)
0
+ rb_iv_set( self, "@validate_dtd", Qtrue );
0
+ }
0
+
0
+ if (rb_hash_aref(opts, rb_sForgivingParse) == Qtrue) {
0
             parser_opts = parser_opts | XML_PARSE_RECOVER;
0
+ rb_iv_set( self, "@forgiving", Qtrue );
0
+ }
0
     }
0
 
0
   if (rb_respond_to( xml_doc_str, s_readlines )) {
...
36
37
38
 
 
 
 
 
 
 
 
39
40
41
...
36
37
38
39
40
41
42
43
44
45
46
47
48
49
0
@@ -36,6 +36,14 @@ class FastXml::Doc
0
     nil
0
   end
0
   
0
+ def forgiving?
0
+ (@forgiving ||= false)
0
+ end
0
+
0
+ def validate?
0
+ (@validate_dtd ||= false)
0
+ end
0
+
0
   def xpath
0
     "/"
0
   end
...
18
19
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
22
23
...
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
0
@@ -18,6 +18,20 @@ describe FastXml::Doc, " functionality" do
0
     doc = FastXml::Doc.new( @data_str, { :forgiving => true } )
0
     doc.should_not be_nil
0
   end
0
+
0
+ it 'should support a forgiving option' do
0
+ doc = FastXml::Doc.new( @data_str, { :forgiving => true } )
0
+ doc.forgiving?.should == true
0
+ alt_doc = FastXml::Doc.new( @data_str, { :forgiving => false } )
0
+ alt_doc.forgiving?.should == false
0
+ end
0
+
0
+ it 'should support a validate option' do
0
+ doc = FastXml::Doc.new( @data_str, { :validate => true } )
0
+ doc.validate?.should == true
0
+ alt_doc = FastXml::Doc.new( @data_str, { :validate => false } )
0
+ alt_doc.validate?.should == false
0
+ end
0
 
0
   it 'should have a root node accessor' do
0
     @doc.should respond_to( :root )

Comments

    No one has commented yet.