Skip to content

Commit 1a41348

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 642b853 commit 1a41348

File tree

3 files changed

+39
-6
lines changed

3 files changed

+39
-6
lines changed

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

+10-3
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ class XMLTestJVM {
394394
}
395395

396396
@UnitTest
397-
def t5052 {
397+
def t5052 = {
398398
assertTrue(<elem attr={ null: String }/> xml_== <elem/>)
399399
assertTrue(<elem attr={ None }/> xml_== <elem/>)
400400
assertTrue(<elem/> xml_== <elem attr={ null: String }/>)
@@ -416,7 +416,7 @@ class XMLTestJVM {
416416
}
417417

418418
@UnitTest
419-
def t5843 {
419+
def t5843 = {
420420
val foo = scala.xml.Attribute(null, "foo", "1", scala.xml.Null)
421421
val bar = scala.xml.Attribute(null, "bar", "2", foo)
422422
val ns = scala.xml.NamespaceBinding(null, "uri", scala.xml.TopScope)
@@ -448,7 +448,7 @@ class XMLTestJVM {
448448
}
449449

450450
@UnitTest
451-
def t7074 {
451+
def t7074 = {
452452
assertEquals("""<a/>""", sort(<a/>) toString)
453453
assertEquals("""<a b="2" c="3" d="1"/>""", sort(<a d="1" b="2" c="3"/>) toString)
454454
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)
@@ -460,6 +460,13 @@ class XMLTestJVM {
460460
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)
461461
}
462462

463+
@UnitTest
464+
def t9060 = {
465+
val expected = """<a xmlns:b·="http://example.com"/>"""
466+
val source = Source.fromString(expected)
467+
assertEquals(expected, XML.loadString(expected).toString)
468+
}
469+
463470
@UnitTest
464471
def attributes = {
465472
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+
}

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)