Skip to content

Commit 30af185

Browse files
som-snyttashawley
authored andcommitted
Fix #44 Accept fifth edition names
* src/main/scala/scala/xml/parsing/TokenTests.scala (isNameChar): Add middle dot, #xB7, as specified at [4a] of XML 1.0 5th edition. * src/test/scala/scala/xml/XMLTest.scala (t9060): New test. * src/test/scala/scala/xml/parsing/ConstructingParserTest.scala (t9060): New test.
1 parent 42163d4 commit 30af185

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

src/main/scala/scala/xml/parsing/TokenTests.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ trait TokenTests {
3737

3838
/**
3939
* {{{
40-
* NameChar ::= Letter | Digit | '.' | '-' | '_' | ':'
40+
* NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | #xB7
4141
* | CombiningChar | Extender
4242
* }}}
43-
* See [4] and Appendix B of XML 1.0 specification.
43+
* See [4] and [4a] of Appendix B of XML 1.0 specification.
4444
*/
4545
def isNameChar(ch: Char) = {
4646
import java.lang.Character._
@@ -50,7 +50,7 @@ trait TokenTests {
5050
case COMBINING_SPACING_MARK |
5151
ENCLOSING_MARK | NON_SPACING_MARK |
5252
MODIFIER_LETTER | DECIMAL_DIGIT_NUMBER => true
53-
case _ => ".-:" contains ch
53+
case _ => ".-:·" contains ch
5454
})
5555
}
5656

src/test/scala/scala/xml/XMLTest.scala

+11-4
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ class XMLTest {
414414
}
415415

416416
@UnitTest
417-
def XmlEy {
417+
def XmlEy = {
418418
val z = ax \ "@{the namespace from outer space}foo"
419419
assertTrue((ax \ "@{the namespace from outer space}foo") xml_== "baz")
420420
assertTrue((cx \ "@{the namespace from outer space}foo") xml_== "baz")
@@ -721,7 +721,7 @@ expected closing tag of foo
721721
}
722722

723723
@UnitTest
724-
def t5052 {
724+
def t5052 = {
725725
assertTrue(<elem attr={ null: String }/> xml_== <elem/>)
726726
assertTrue(<elem attr={ None }/> xml_== <elem/>)
727727
assertTrue(<elem/> xml_== <elem attr={ null: String }/>)
@@ -743,7 +743,7 @@ expected closing tag of foo
743743
}
744744

745745
@UnitTest
746-
def t5843 {
746+
def t5843 = {
747747
val foo = scala.xml.Attribute(null, "foo", "1", scala.xml.Null)
748748
val bar = scala.xml.Attribute(null, "bar", "2", foo)
749749
val ns = scala.xml.NamespaceBinding(null, "uri", scala.xml.TopScope)
@@ -775,7 +775,7 @@ expected closing tag of foo
775775
}
776776

777777
@UnitTest
778-
def t7074 {
778+
def t7074 = {
779779
assertEquals("""<a/>""", sort(<a/>) toString)
780780
assertEquals("""<a b="2" c="3" d="1"/>""", sort(<a d="1" b="2" c="3"/>) toString)
781781
assertEquals("""<a b="2" c="4" d="1" e="3" f="5"/>""", sort(<a d="1" b="2" e="3" c="4" f="5"/>) toString)
@@ -787,6 +787,13 @@ expected closing tag of foo
787787
assertEquals("""<a a:b="1" a:c="2" a:d="3" a:e="4" a:f="5"/>""", sort(<a a:b="1" a:c="2" a:d="3" a:e="4" a:f="5"/>) toString)
788788
}
789789

790+
@UnitTest
791+
def t9060 = {
792+
val expected = """<a xmlns:b·="http://example.com"/>"""
793+
val source = Source.fromString(expected)
794+
assertEquals(expected, XML.loadString(expected).toString)
795+
}
796+
790797
@UnitTest
791798
def attributes = {
792799
val noAttr = <t/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package scala.xml
2+
package parsing
3+
4+
import scala.io.Source
5+
import org.junit.Test
6+
import org.junit.Ignore
7+
import org.junit.runner.RunWith
8+
import org.junit.runners.JUnit4
9+
import org.junit.Assert
10+
import Assert._
11+
import scala.xml.JUnitAssertsForXML.{ assertEquals => assertXml }
12+
13+
class ConstructingParserTest {
14+
15+
@Test
16+
def t9060 = {
17+
val a = "<a xmlns:b·='http://example.com'/>"
18+
val source = new Source {
19+
val iter = a.iterator
20+
override def reportError(pos: Int, msg: String, out: java.io.PrintStream = Console.err) {}
21+
}
22+
val doc = ConstructingParser.fromSource(source, false).content(TopScope)
23+
24+
}
25+
26+
}

0 commit comments

Comments
 (0)