blob: d7d2a8144535604bc9990416d22ec27e899b3037 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
package scala.xml;
/** Generic.load( <fileName> ) will load the xml document from file and
* create a tree with scala.Labelled, PCDATA and scala.Symbol objects.
* Text can appear within PCDATA at the leaves.
*/
object Generic {
def load( filename:String ):Labelled = {
val b = new GenericFactoryAdapter().loadXML( filename );
b as Labelled
};
class GenericFactoryAdapter extends dtd2scala.FactoryAdapter() {
import scala.xml.javaAdapter.Map ;
import scala.xml.javaAdapter.HashMap ;
def iterToList[ a ]( iter:java.util.Iterator ):List[a] =
if( !iter.hasNext() )
Nil
else
(iter.next() as a )::iterToList( iter ) ;
def elementContainsText( name:java.lang.String ):boolean = true;
def createElement( elemName:String,
attribs :java.util.Map, // ignore attributes.
children:java.util.Iterator ):scala.Object = {
Labelled( Symbol( elemName), iterToList[ Any ]( children ))
}
def createPCDATA( text:String ):scala.Object = {
new PCDATA( text );
};
} // GenericFactoryAdapter
}
|