PageRenderTime 7ms CodeModel.GetById 2ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/tutorial/xml/dom/example2.e

http://github.com/tybor/Liberty
Specman e | 40 lines | 29 code | 5 blank | 6 comment | 3 complexity | cac24958c6438107ed56e04198cad15f MD5 | raw file
 1class EXAMPLE2
 2   --
 3   -- This example is a bit more complex since it uses a subclass of XML_TREE to provide some validation.
 4   --
 5
 6inherit
 7   EXAMPLE1
 8      redefine make
 9      end
10
11create {}
12   make
13
14feature {}
15   make
16      local
17         in: TEXT_FILE_READ; tree: MY_VALIDATING_TREE; version: UNICODE_STRING
18      do
19         if argument_count = 0 then
20            std_error.put_line(once "Usage: #(1) <file.xml>" # command_name)
21            die_with_code(1)
22         end
23         -- first create the stream
24         create in.connect_to(argument(1))
25         if in.is_connected then
26            -- then create the tree
27            create tree.with_error_handler(in.url, agent error(?, ?))
28            -- now display the results
29            version := tree.attribute_at(once U"version")
30            if version /= Void then
31               io.put_string(once "XML version: ")
32               io.put_string(version.as_utf8)
33               io.put_new_line
34            end
35
36            tree.root.accept(Current)
37         end
38      end
39
40end -- class EXAMPLE2