Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

SAX failing text parse case. #29

Merged
merged 1 commit into from

2 participants

@saulius

Hey,

first and foremost - thanks for cool library! I see that the SAX parser strips preceding whitespace from a string. I wonder if that is an expected behaviour. I'm not 100% sure, but I don't think Nokogiri or REXML does that. Is this an expected behaviour?

Thanks

@ohler55
Owner

I suppose that since the regular parser keep the white space now the sax parser should too.

@ohler55 ohler55 merged commit aa159c5 into ohler55:master

1 check passed

Details default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 13, 2012
  1. @saulius

    Failing text parse case.

    saulius authored
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 5 deletions.
  1. +13 −5 test/sax_test.rb
View
18 test/sax_test.rb
@@ -67,7 +67,7 @@ def text(value)
def end_element(name)
@calls << [:end_element, name]
end
-
+
def error(message, line, column)
@calls << [:error, message, line, column]
end
@@ -122,7 +122,7 @@ def parse_compare(xml, expected, handler_class=AllSax, special=false)
end
assert_equal(expected, handler.calls)
end
-
+
def test_sax_instruct_simple
parse_compare(%{<?xml?>}, [[:instruct, 'xml'],
[:end_instruct, 'xml']])
@@ -181,7 +181,7 @@ def test_sax_element_simple
end
def test_sax_element_attrs
- parse_compare(%{<top x="57" y='42' z=33 />},
+ parse_compare(%{<top x="57" y='42' z=33 />},
[[:start_element, :top],
[:attr, :x, "57"],
[:attr, :y, "42"],
@@ -310,6 +310,14 @@ def test_sax_special
], AllSax, true)
end
+ def test_sax_whitespace
+ parse_compare(%{<top> This is some text.</top>},
+ [[:start_element, :top],
+ [:text, " This is some text."],
+ [:end_element, :top]
+ ])
+ end
+
def test_sax_text_no_term
parse_compare(%{<top>This is some text.},
[[:start_element, :top],
@@ -344,7 +352,7 @@ def test_sax_doctype_bad_order
[:error, "invalid format, DOCTYPE can not come after an element", 3, 11],
[:doctype, ' top PUBLIC "top.dtd"']])
end
-
+
def test_sax_comment
parse_compare(%{<?xml version="1.0"?>
<!--First comment.-->
@@ -401,7 +409,7 @@ def test_sax_cdata_no_term
[:start_element, :top],
[:error, "invalid format, cdata terminated unexpectedly", 5, 1]])
end
-
+
def test_sax_cdata_empty
parse_compare(%{<?xml version="1.0"?>
<top>
Something went wrong with that request. Please try again.