parse_attributes_names Subroutine

private elemental subroutine parse_attributes_names(self, source)

Parse the tag attributes names contained into a string.

Valid syntax is: + att1="att1 val" att2="att2 val"...

Note

Inside the attributes value the symbols < and > are not allowed.

Type Bound

xml_tag

Arguments

Type IntentOptional Attributes Name
class(xml_tag), intent(inout) :: self

XML tag.

character(len=*), intent(in) :: source

String containing the input.


Calls

proc~~parse_attributes_names~~CallsGraph proc~parse_attributes_names xml_tag%parse_attributes_names proc~alloc_attributes xml_tag%alloc_attributes proc~parse_attributes_names->proc~alloc_attributes

Called by

proc~~parse_attributes_names~~CalledByGraph proc~parse_attributes_names xml_tag%parse_attributes_names proc~parse xml_tag%parse proc~parse->proc~parse_attributes_names proc~search xml_tag%search proc~search->proc~parse program~foxy_test_create_tag foxy_test_create_tag program~foxy_test_create_tag->proc~parse proc~get_content xml_tag%get_content proc~get_content->proc~search proc~content xml_file%content proc~content->proc~get_content

Source Code

   elemental subroutine parse_attributes_names(self, source)
   !< Parse the tag attributes names contained into a string.
   !<
   !< Valid syntax is:
   !< + `att1="att1 val" att2="att2 val"...`
   !< @note Inside the attributes value the symbols `<` and `>` are not allowed.
   class(xml_tag), intent(inout) :: self   !< XML tag.
   character(*),   intent(in)    :: source !< String containing the input.
   character(len=:), allocatable :: att    !< Dummy string for parsing file.
   integer(I4P)                  :: c      !< Counter.
   integer(I4P)                  :: s      !< Counter.
   integer(I4P)                  :: a      !< Counter.
   integer(I4P)                  :: Na     !< Counter.

   Na = 0
   c = 1
   att_count: do while(c<=len(source))
      if (source(c:c)=='=') Na = Na + 1
      c = c + 1
   enddo att_count
   if (Na>0) then
      call self%alloc_attributes(Na=Na)
      c = index(string=source, substring=' ')
      att = source(c:)
      c = 1
      a = 1
      att_search: do while(c<=len(att))
         if (att(c:c)=='=') then
            s = max(0, index(string=att, substring=' '))
            self%attribute(1, a) = trim(adjustl(att(s+1:c-1)))
            att = att(c+1:)
            c = 1
            a = a + 1
         endif
         c = c + 1
      enddo att_search
   endif
   endsubroutine parse_attributes_names