create_tag Program

Uses

  • program~~create_tag~~UsesGraph program~create_tag create_tag module~foxy foxy program~create_tag->module~foxy module~penf~2 penf module~foxy->module~penf~2 module~foxy_xml_tag foxy_xml_tag module~foxy->module~foxy_xml_tag module~foxy_xml_file foxy_xml_file module~foxy->module~foxy_xml_file module~penf_b_size penf_b_size module~penf~2->module~penf_b_size module~penf_stringify~3 penf_stringify module~penf~2->module~penf_stringify~3 module~penf_global_parameters_variables~2 penf_global_parameters_variables module~penf~2->module~penf_global_parameters_variables~2 module~foxy_xml_tag->module~penf~2 module~stringifor~2 stringifor module~foxy_xml_tag->module~stringifor~2 module~foxy_xml_file->module~penf~2 module~foxy_xml_file->module~foxy_xml_tag module~penf_b_size->module~penf_global_parameters_variables~2 module~stringifor~2->module~penf~2 module~stringifor_string_t stringifor_string_t module~stringifor~2->module~stringifor_string_t module~penf_stringify~3->module~penf_b_size module~penf_stringify~3->module~penf_global_parameters_variables~2 iso_fortran_env iso_fortran_env module~penf_stringify~3->iso_fortran_env module~stringifor_string_t->module~penf~2 module~stringifor_string_t->iso_fortran_env module~face face module~stringifor_string_t->module~face module~befor64~4 befor64 module~stringifor_string_t->module~befor64~4 module~face->iso_fortran_env module~befor64~4->module~penf~2 module~befor64_pack_data_m~4 befor64_pack_data_m module~befor64~4->module~befor64_pack_data_m~4 module~befor64_pack_data_m~4->module~penf~2

Contents

Source Code


Variables

TypeAttributesNameInitial
character(len=:), allocatable:: source
character(len=:), allocatable:: parsed
type(xml_tag) :: a_tag
logical :: test_passed(4)

Source Code

program create_tag
!-----------------------------------------------------------------------------------------------------------------------------------
!< FoXy test.
!-----------------------------------------------------------------------------------------------------------------------------------
use foxy, only: xml_tag
!-----------------------------------------------------------------------------------------------------------------------------------

!-----------------------------------------------------------------------------------------------------------------------------------
implicit none
character(len=:), allocatable :: source         !< String containing the source XML data.
character(len=:), allocatable :: parsed         !< String containing the parsed XML data.
type(xml_tag)                 :: a_tag          !< XML tag handler.
logical                       :: test_passed(4) !< List of passed tests.
!-----------------------------------------------------------------------------------------------------------------------------------

!-----------------------------------------------------------------------------------------------------------------------------------
test_passed = .false.

! create using xml_tag overloaded procedures
print "(A)", 'source'
source = '<first x="1" y="c" z="2">lorem ipsum...</first>'
print "(A)", source
print "(A)", 'created'
a_tag = xml_tag(name='first', content='lorem ipsum...', attributes=reshape([['x', '1'], ['y', 'c'], ['z', '2']], [2,3]))
parsed = a_tag%stringify()
test_passed(1) = trim(source)==trim(parsed)
print "(A,L1)", parsed//'Is correct? ', test_passed(1)

print "(A)", 'source'
source = '<second x="1" y="c" z="2"/>'
print "(A)", source
print "(A)", 'created'
a_tag = xml_tag(name='second', attributes=reshape([['x', '1'], ['y', 'c'], ['z', '2']], [2,3]), is_self_closing=.true.)
parsed = a_tag%stringify()
test_passed(2) = trim(source)==trim(parsed)
print "(A,L1)", parsed//' Is correct? ', test_passed(2)

! create parsing a source
print "(A)", 'source'
source = '<third x="1" y="c" z="2"/>'
print "(A)", source
print "(A)", 'created'
call a_tag%set(name='third')
call a_tag%parse(source=source)
parsed = a_tag%stringify()
test_passed(3) = trim(source)==trim(parsed)
print "(A,L1)", parsed//' Is correct? ', test_passed(3)

print "(A)", 'source'
source = '<fourth x="1" y="c" z="2"></fourth>'
print "(A)", source
print "(A)", 'created'
call a_tag%set(name='fourth')
call a_tag%parse(source=source)
parsed = a_tag%stringify()
test_passed(4) = trim(source)==trim(parsed)
print "(A,L1)", parsed//' Is correct? ', test_passed(4)

print "(A,L1)", new_line('a')//'Are all tests passed? ', all(test_passed)
stop
!-----------------------------------------------------------------------------------------------------------------------------------
endprogram create_tag