[1960] | 1 | module m_handlers |
---|
| 2 | |
---|
| 3 | use flib_sax |
---|
| 4 | |
---|
| 5 | private |
---|
| 6 | |
---|
| 7 | ! |
---|
| 8 | ! It defines the routines that are called by the XML parser in response |
---|
| 9 | ! to particular events. |
---|
| 10 | ! |
---|
| 11 | ! In this particular example we just print the names of the elements, |
---|
| 12 | ! the attribute list, and the content of the pcdata chunks |
---|
| 13 | ! |
---|
| 14 | ! A module such as this could use "utility routines" to convert pcdata |
---|
| 15 | ! to numerical arrays, and to populate specific data structures. |
---|
| 16 | ! |
---|
| 17 | public :: begin_element_handler, end_element_handler, pcdata_chunk_handler |
---|
| 18 | |
---|
| 19 | CONTAINS !============================================================= |
---|
| 20 | |
---|
| 21 | subroutine begin_element_handler(name,attributes) |
---|
| 22 | character(len=*), intent(in) :: name |
---|
| 23 | type(dictionary_t), intent(in) :: attributes |
---|
| 24 | |
---|
| 25 | write(unit=*,fmt="(2a)") ">>Begin Element: ", name |
---|
| 26 | write(unit=*,fmt="(a,i2,a)") "--- ", len(attributes), " attributes:" |
---|
| 27 | call print_dict(attributes) |
---|
| 28 | end subroutine begin_element_handler |
---|
| 29 | |
---|
| 30 | !-------------------------------------------------- |
---|
| 31 | subroutine end_element_handler(name) |
---|
| 32 | character(len=*), intent(in) :: name |
---|
| 33 | |
---|
| 34 | write(unit=*,fmt="(/,2a)") ">>-------------End Element: ", trim(name) |
---|
| 35 | |
---|
| 36 | end subroutine end_element_handler |
---|
| 37 | |
---|
| 38 | !-------------------------------------------------- |
---|
| 39 | subroutine pcdata_chunk_handler(chunk) |
---|
| 40 | character(len=*), intent(in) :: chunk |
---|
| 41 | |
---|
| 42 | write(unit=*,fmt="(a)",advance="no") trim(chunk) |
---|
| 43 | |
---|
| 44 | end subroutine pcdata_chunk_handler |
---|
| 45 | |
---|
| 46 | end module m_handlers |
---|
| 47 | |
---|
| 48 | |
---|
| 49 | |
---|
| 50 | |
---|
| 51 | |
---|
| 52 | |
---|
| 53 | |
---|
| 54 | |
---|
| 55 | |
---|
| 56 | |
---|
| 57 | |
---|
| 58 | |
---|