Skip to content

Commit 0875b7c

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

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

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

+9-3
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ class XMLTestJVM {
390390
}
391391

392392
@UnitTest
393-
def t5052 {
393+
def t5052 = {
394394
assertTrue(<elem attr={ null: String }/> xml_== <elem/>)
395395
assertTrue(<elem attr={ None }/> xml_== <elem/>)
396396
assertTrue(<elem/> xml_== <elem attr={ null: String }/>)
@@ -412,7 +412,7 @@ class XMLTestJVM {
412412
}
413413

414414
@UnitTest
415-
def t5843 {
415+
def t5843 = {
416416
val foo = scala.xml.Attribute(null, "foo", "1", scala.xml.Null)
417417
val bar = scala.xml.Attribute(null, "bar", "2", foo)
418418
val ns = scala.xml.NamespaceBinding(null, "uri", scala.xml.TopScope)
@@ -444,7 +444,7 @@ class XMLTestJVM {
444444
}
445445

446446
@UnitTest
447-
def t7074 {
447+
def t7074 = {
448448
assertEquals("""<a/>""", sort(<a/>) toString)
449449
assertEquals("""<a b="2" c="3" d="1"/>""", sort(<a d="1" b="2" c="3"/>) toString)
450450
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)
@@ -456,6 +456,12 @@ class XMLTestJVM {
456456
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)
457457
}
458458

459+
@UnitTest
460+
def t9060 = {
461+
val expected = """<a xmlns:b·="http://example.com"/>"""
462+
assertEquals(expected, XML.loadString(expected).toString)
463+
}
464+
459465
@UnitTest
460466
def attributes = {
461467
val noAttr = <t/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package scala.xml
2+
package parsing
3+
4+
import scala.io.Source
5+
import org.junit.Test
6+
import scala.xml.JUnitAssertsForXML.{ assertEquals => assertXml }
7+
8+
class ConstructingParserTest {
9+
10+
@Test
11+
def t9060 = {
12+
val a = """<a xmlns:b·="http://example.com"/>"""
13+
val source = new Source {
14+
val iter = a.iterator
15+
override def reportError(pos: Int, msg: String, out: java.io.PrintStream = Console.err) = {}
16+
}
17+
val doc = ConstructingParser.fromSource(source, false).content(TopScope)
18+
assertXml(a, doc)
19+
20+
}
21+
22+
}

shared/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

0 commit comments

Comments
 (0)