New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
i.m_handlers.f90 in vendors/XMLF90/current/doc/Examples/sax/features – NEMO

source: vendors/XMLF90/current/doc/Examples/sax/features/i.m_handlers.f90 @ 1967

Last change on this file since 1967 was 1967, checked in by flavoni, 14 years ago

importing XMLF90 vendor

File size: 2.9 KB
Line 
1module m_handlers
2
3use flib_sax
4
5private
6
7!
8! A prototype of a specific language processor.
9! It defines the routines that are called from xml_parser in response
10! to particular events.
11!
12! In this particular example we just print the names of the elements
13! and the content of the pcdata chunks, as well as any comments, XML
14! and SGML declarations, etc.
15!
16! A module such as this could use "utility routines" to convert pcdata
17! to numerical arrays, and to populate specific data structures.
18!
19public :: begin_element_handler, end_element_handler, pcdata_chunk_handler
20public :: comment_handler, xml_declaration_handler, sgml_declaration_handler
21public :: empty_element_handler
22
23CONTAINS  !=============================================================
24
25subroutine begin_element_handler(name,attributes)
26character(len=*), intent(in)   :: name
27type(dictionary_t), intent(in) :: attributes
28
29write(unit=*,fmt="(2a)") ">>Begin Element: ", name
30write(unit=*,fmt="(a,i2,a)") "--- ", len(attributes), " attributes:"
31call print_dict(attributes)
32end subroutine begin_element_handler
33
34!--------------------------------------------------
35subroutine end_element_handler(name)
36character(len=*), intent(in)     :: name
37
38  write(unit=*,fmt="(/,2a)") ">>-------------End Element: ", trim(name)
39
40end subroutine end_element_handler
41
42!--------------------------------------------------
43subroutine pcdata_chunk_handler(chunk)
44character(len=*), intent(in) :: chunk
45
46write(unit=*,fmt="(a)",advance="no") trim(chunk)
47
48end subroutine pcdata_chunk_handler
49
50!--------------------------------------------------
51subroutine empty_element_handler(name,attributes)
52character(len=*), intent(in)   :: name
53type(dictionary_t), intent(in) :: attributes
54
55write(unit=*,fmt="(2a)") ">>Empty Element: ", name
56write(unit=*,fmt="(a,i2,a)") "--- ", len(attributes), " attributes:"
57call print_dict(attributes)
58write(unit=*,fmt="(2a)") ">>-------------End Empty Element: ", trim(name)
59
60end subroutine empty_element_handler
61
62!--------------------------------------------------
63subroutine comment_handler(comment)
64character(len=*), intent(in) :: comment
65
66write(unit=*,fmt="(a)") ">>Comment: "
67write(unit=*,fmt="(a)") trim(comment)
68
69end subroutine comment_handler
70
71!--------------------------------------------------
72subroutine xml_declaration_handler(name,attributes)
73character(len=*), intent(in)   :: name
74type(dictionary_t), intent(in) :: attributes
75!
76! Same structure as an element tag
77!
78 write(unit=*,fmt="(2a)") ">>XML declaration: ", name
79 call print_dict(attributes)
80
81end subroutine xml_declaration_handler
82
83!--------------------------------------------------
84subroutine sgml_declaration_handler(sgmldecl)
85character(len=*), intent(in) :: sgmldecl
86!
87write(unit=*,fmt="(a)") ">>SGML declaration: "
88write(unit=*,fmt="(a)") trim(sgmldecl)
89
90end subroutine sgml_declaration_handler
91!--------------------------------------------------
92
93end module m_handlers
94
95
96
97
98
99
100
101
102
103
104
105
Note: See TracBrowser for help on using the repository browser.