foxy_test_add_tag Program

Uses

  • program~~foxy_test_add_tag~~UsesGraph program~foxy_test_add_tag foxy_test_add_tag module~foxy foxy program~foxy_test_add_tag->module~foxy module~foxy_xml_file foxy_xml_file module~foxy->module~foxy_xml_file module~foxy_xml_tag foxy_xml_tag module~foxy->module~foxy_xml_tag penf penf module~foxy->penf module~foxy_xml_file->module~foxy_xml_tag module~foxy_xml_file->penf module~foxy_xml_tag->penf stringifor stringifor module~foxy_xml_tag->stringifor

FoXy test.


Calls

program~~foxy_test_add_tag~~CallsGraph program~foxy_test_add_tag foxy_test_add_tag proc~add_tag xml_file%add_tag program~foxy_test_add_tag->proc~add_tag proc~stringify~2 xml_file%stringify program~foxy_test_add_tag->proc~stringify~2 proc~stringify xml_tag%stringify proc~stringify~2->proc~stringify proc~stringify_recursive xml_file%stringify_recursive proc~stringify~2->proc~stringify_recursive chars chars proc~stringify->chars is_allocated is_allocated proc~stringify->is_allocated proc~end_tag xml_tag%end_tag proc~stringify->proc~end_tag proc~self_closing_tag xml_tag%self_closing_tag proc~stringify->proc~self_closing_tag proc~start_tag xml_tag%start_tag proc~stringify->proc~start_tag proc~stringify_recursive->proc~stringify proc~stringify_recursive->proc~stringify_recursive

Variables

Type Attributes Name Initial
character(len=:), allocatable :: source

String containing the source XML data.

character(len=:), allocatable :: parsed

String containing the parsed XML data.

type(xml_file) :: a_file

XML tag handler.

type(xml_tag) :: a_tag

XML tag handler.

type(xml_tag) :: another_tag

XML tag handler.

logical :: test_passed(1)

List of passed tests.


Source Code

program foxy_test_add_tag
!< FoXy test.
use foxy, only: xml_file, 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_file)                :: a_file         !< XML tag handler.
type(xml_tag)                 :: a_tag          !< XML tag handler.
type(xml_tag)                 :: another_tag    !< XML tag handler.
logical                       :: test_passed(1) !< List of passed tests.

test_passed = .false.

print "(A)", 'source'
source = '<first x="1" y="c" z="2">lorem ipsum...</first>'//new_line('a')//&
         '<second a1="2"/>'//new_line('a')//&
         '<third>bye</third>'//new_line('a')//&
         '<fourth a="3">bye bye Mrs. Robinson</fourth>'//new_line('a')//&
         '<fift>'//new_line('a')//&
         '  <nested l="1">I am supported! Nested tag at level 1</nested>'//new_line('a')//&
         '</fift>'
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]))
call a_file%add_tag(tag=a_tag)
a_tag = xml_tag(name='second', attribute=['a1', '2 '], is_self_closing=.true., sanitize_attributes_value=.true.)
call a_file%add_tag(tag=a_tag)
a_tag = xml_tag(name='third', content='bye')
call a_file%add_tag(tag=a_tag)
a_tag = xml_tag(name='fourth', content='bye bye Mrs. Robinson', attribute=['a', '3'])
call a_file%add_tag(tag=a_tag)
another_tag = xml_tag(name='nested', content='I am supported! Nested tag at level 1', attribute=['l', '1'])
a_tag = xml_tag(name='fift', content=another_tag, is_content_indented=.true.)
call a_file%add_tag(tag=a_tag)

parsed = a_file%stringify()
test_passed(1) = trim(adjustl(source))==trim(adjustl(parsed))
print "(A,L1)", parsed//' Is correct? ', test_passed(1)

print "(A,L1)", new_line('a')//'Are all tests passed? ', all(test_passed)
endprogram foxy_test_add_tag