Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[BUGFIX] Correctly parse documents which don't specify the xforms nam…

…espace
  • Loading branch information...
commit 23928717a6af80d90d04d9bebc9df1aa58302df2 1 parent 14f5e9a
@benlangfeld authored
View
3  lib/ruby_speech/nlsml.rb
@@ -2,7 +2,8 @@ module RubySpeech
module NLSML
extend ActiveSupport::Autoload
- NLSML_NAMESPACE = 'http://www.w3c.org/2000/11/nlsml'
+ NLSML_NAMESPACE = 'http://www.w3c.org/2000/11/nlsml'
+ XFORMS_NAMESPACE = 'http://www.w3.org/2000/xforms'
eager_autoload do
autoload :Builder
View
2  lib/ruby_speech/nlsml/builder.rb
@@ -4,7 +4,7 @@ class Builder
attr_reader :document
def initialize(options = {}, &block)
- options = {"xmlns" => 'http://www.w3c.org/2000/11/nlsml', "xmlns:xf" => "http://www.w3.org/2000/xforms"}.merge(options)
+ options = {'xmlns' => NLSML_NAMESPACE, 'xmlns:xf' => XFORMS_NAMESPACE}.merge(options)
@document = Nokogiri::XML::Builder.new do |builder|
builder.result options do |r|
apply_block r, &block
View
2  lib/ruby_speech/nlsml/document.rb
@@ -40,7 +40,7 @@ def input_hash_for_interpretation(interpretation)
end
def instance_hash_for_interpretation(interpretation)
- instance_element = interpretation.at_xpath 'xf:instance'
+ instance_element = interpretation.at_xpath 'xf:instance', 'xf' => XFORMS_NAMESPACE
return unless instance_element
element_children_key_value instance_element
end
View
2  spec/ruby_speech/nlsml_spec.rb
@@ -122,7 +122,7 @@
context "with an interpretation that has no model/instance" do
let :example_document do
'''
-<result xmlns="http://www.w3c.org/2000/11/nlsml" xmlns:xf="http://www.w3.org/2000/xforms" grammar="http://flight">
+<result xmlns="http://www.w3c.org/2000/11/nlsml" grammar="http://flight">
<interpretation confidence="60">
<input mode="speech">I want to go to Pittsburgh</input>
</interpretation>
Please sign in to comment.
Something went wrong with that request. Please try again.