create_tag.f90 Source File


This file depends on

sourcefile~~create_tag.f90~~EfferentGraph sourcefile~create_tag.f90 create_tag.f90 sourcefile~foxy.f90 foxy.f90 sourcefile~create_tag.f90->sourcefile~foxy.f90 sourcefile~foxy_xml_file.f90 foxy_xml_file.f90 sourcefile~foxy.f90->sourcefile~foxy_xml_file.f90 sourcefile~foxy_xml_tag.f90 foxy_xml_tag.F90 sourcefile~foxy.f90->sourcefile~foxy_xml_tag.f90 sourcefile~penf.f90 penf.F90 sourcefile~foxy.f90->sourcefile~penf.f90 sourcefile~foxy_xml_file.f90->sourcefile~foxy_xml_tag.f90 sourcefile~foxy_xml_file.f90->sourcefile~penf.f90 sourcefile~foxy_xml_tag.f90->sourcefile~penf.f90 sourcefile~stringifor.f90 stringifor.F90 sourcefile~foxy_xml_tag.f90->sourcefile~stringifor.f90 sourcefile~penf_global_parameters_variables.f90 penf_global_parameters_variables.F90 sourcefile~penf.f90->sourcefile~penf_global_parameters_variables.f90 sourcefile~penf_b_size.f90 penf_b_size.F90 sourcefile~penf.f90->sourcefile~penf_b_size.f90 sourcefile~penf_stringify.f90 penf_stringify.F90 sourcefile~penf.f90->sourcefile~penf_stringify.f90 sourcefile~stringifor.f90->sourcefile~penf.f90 sourcefile~stringifor_string_t.f90 stringifor_string_t.F90 sourcefile~stringifor.f90->sourcefile~stringifor_string_t.f90 sourcefile~penf_b_size.f90->sourcefile~penf_global_parameters_variables.f90 sourcefile~penf_stringify.f90->sourcefile~penf_global_parameters_variables.f90 sourcefile~penf_stringify.f90->sourcefile~penf_b_size.f90 sourcefile~stringifor_string_t.f90->sourcefile~penf.f90 sourcefile~befor64.f90 befor64.F90 sourcefile~stringifor_string_t.f90->sourcefile~befor64.f90 sourcefile~face.f90 face.F90 sourcefile~stringifor_string_t.f90->sourcefile~face.f90 sourcefile~befor64.f90->sourcefile~penf.f90 sourcefile~befor64_pack_data_m.f90 befor64_pack_data_m.F90 sourcefile~befor64.f90->sourcefile~befor64_pack_data_m.f90 sourcefile~befor64_pack_data_m.f90->sourcefile~penf.f90

Contents

Source Code


Source Code

!< FoXy test.
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