Class: Cfdi40::SchemaValidator
- Inherits:
-
Object
- Object
- Cfdi40::SchemaValidator
- Defined in:
- lib/cfdi40/schema_validator.rb
Constant Summary collapse
- LOCAL_XSD_PATH =
File.join(File.dirname(__FILE__), "..", "xsd", "cfdv40.xsd")
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
options = Nokogiri::XML::ParseOptions.new.nononet schema = Nokogiri::XML::Schema(Net::HTTP.get(‘www.sat.gob.mx’, ‘/sitio_internet/cfd/4/cfdv40.xsd’), options) schema = Nokogiri::XML::Schema(File.open(“/home/israel/git/cfdi40/lib/xsd/cfdv40.xsd”), options).
Instance Method Summary collapse
-
#initialize(xml) ⇒ SchemaValidator
constructor
Param xml is xml string.
- #valid? ⇒ Boolean
Constructor Details
#initialize(xml) ⇒ SchemaValidator
Param xml is xml string
15 16 17 18 |
# File 'lib/cfdi40/schema_validator.rb', line 15 def initialize(xml) @xml_doc = Nokogiri::XML(xml) @schema = Nokogiri::XML::Schema(File.open(LOCAL_XSD_PATH)) end |
Instance Attribute Details
#errors ⇒ Object (readonly)
options = Nokogiri::XML::ParseOptions.new.nononet schema = Nokogiri::XML::Schema(Net::HTTP.get(‘www.sat.gob.mx’, ‘/sitio_internet/cfd/4/cfdv40.xsd’), options) schema = Nokogiri::XML::Schema(File.open(“/home/israel/git/cfdi40/lib/xsd/cfdv40.xsd”), options)
10 11 12 |
# File 'lib/cfdi40/schema_validator.rb', line 10 def errors @errors end |
Instance Method Details
#valid? ⇒ Boolean
20 21 22 23 24 |
# File 'lib/cfdi40/schema_validator.rb', line 20 def valid? validate unless defined?(@errors) @errors.empty? end |