/[alph]/alph/org/nongnu/alph/xml/serialization.test
ViewVC logotype

Diff of /alph/org/nongnu/alph/xml/serialization.test

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by tjl, Wed Mar 26 09:39:48 2003 UTC revision 1.2 by tjl, Wed Mar 26 10:17:54 2003 UTC
# Line 1  Line 1 
1    from org.nongnu import alph
2  from org.nongnu.alph.xml import *  from org.nongnu.alph.xml import *
3    
4  def testFoo():  import java
5      print "HEI"  import javax
6    
7    class Ts(alph.TextSpan):
8        def __init__(self, id, s, e):
9            print "TS: ",id,s,e
10            self.id = id
11            self.s = s
12            self.e = e
13    
14    class Sb(alph.TextScrollBlock):
15        def __init__(self, id):
16            self.id = id
17        def getSpan(self, s, e):
18            return Ts(self.id, s, e)
19    
20    class Fact(SpanReader.ScrollBlockFactory):
21        def getScrollBlock(self, id):
22            return Sb(id)
23    
24    def getParser():
25        return javax.xml.parsers.SAXParserFactory.newInstance().newSAXParser()
26    
27    def parseString(string, handler):
28        p = getParser()
29        p.parse(java.io.StringBufferInputStream(string), handler)
30    
31    
32    def testParseSpan():
33        r = SpanReader()
34        r.scrollBlockFactory = Fact()
35        parseString("""<ts b="X" s="5" e="10"/>""", r)
36        sp = r.getSpans()[0]
37        failUnlessEqual(sp.id, "X")
38        failUnlessEqual(sp.s, 5)
39        failUnlessEqual(sp.e, 10)

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26