Skip to content

foxy_xml_tag

FoXy XML tag class.

Source: src/lib/foxy_xml_tag.F90

Contents

Derived Types

xml_tag

XML tag class.

A valid XML tag must have the following syntax for a tag without a content (with only attributes):

xml
   <Tag_Name att#1_Name="att#1_val" att#2_Name="att#2_val"... att#Nt_Name="att#Nt_val"/>

while a tag with a content must have the following syntax:

xml
   <Tag_Name att#1_Name="att#1_val" att#2_Name="att#2_val"... att#Nt_Name="att#Nt_val">Tag_Content</Tag_Name>

It is worth noting that the syntax is case sensitive and that the attributes are optional. Each attribute name must be followed by '="' without any additional white spaces and its value must be termined by '"'. Each attribute is separated by one or more white spaces.

Components

NameTypeAttributesDescription
tag_nametype(string)Tag name.
tag_contenttype(string)Tag content.
posinteger(kind=I4P)Characters position (in source) indexes (start, content, end).
attributetype(string)allocatableAttributes names/values pairs, [1:2, 1:].
attributes_numberinteger(kind=I4P)Number of defined attributes.
indentinteger(kind=I4P)Number of indent-white-spaces.
is_self_closinglogicalSelf closing tag flag.
levelinteger(kind=I4P)Tag hierarchy level.
idinteger(kind=I4P)Uniq tag ID.
parent_idinteger(kind=I4P)Uniq ID of parent tag.
children_numberinteger(kind=I4P)Number of children tags.
child_idinteger(kind=I4P)allocatableUniq ID of children tags.

Type-Bound Procedures

NameAttributesDescription
add_attributesAdd attributes name/value pairs.
add_child_idpass(self)Add child ID to children IDs list.
attributespass(self)Return attributes name/value pairs as string.
delete_attributesDelete attributes name/value pairs.
delete_contentpass(self)Delete tag conent.
end_tagpass(self)Return `` end tag.
freepass(self)Free (reset) tag.
get_contentpass(self)Return tag content.
is_attribute_presentpass(self)Return .true. it the queried attribute name is defined.
is_parsedpass(self)Check is tag is correctly parsed, i.e. its tag_name is allocated.
namepass(self)Return tag name.
parsepass(self)Parse the tag contained into a source string.
parse_tag_namepass(self)Parse the tag name contained into a string.
self_closing_tagpass(self)Return `` self closing tag.
setpass(self)Set tag data.
start_tagpass(self)Return `` start tag.
stringifypass(self)Convert the whole tag into a string.
writepass(self)Write tag to unit file.
assignment(=)Assignment operator overloading.
add_single_attributepass(self)Add one attribute name/value pair.
add_multiple_attributespass(self)Add list of attributes name/value pairs.
add_stream_attributespass(self)Add list of attributes name/value pairs passed as stream.
alloc_attributespass(self)Allocate (prepare for filling) dynamic memory of attributes.
delete_single_attributepass(self)Delete one attribute name/value pair.
delete_multiple_attributespass(self)Delete list of attributes name/value pairs.
getpass(self)Get the tag value and attributes from source.
get_valuepass(self)Get the tag value from source after tag_name has been set.
get_attributespass(self)Get the attributes values from source.
parse_attributes_namespass(self)Parse the tag attributes names contained into a string.
searchpass(self)Search tag named tag_name into a string.
assign_tagpass(lhs)Assignment between two tags.

Interfaces

xml_tag

Overload xml_tag with creator procedures.

Module procedures: create_tag_flat, create_tag_nested

Subroutines

add_child_id

Add child ID to children IDs list.

Attributes: pure

fortran
subroutine add_child_id(self, child_id)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_tag)inoutXML tag.
child_idinteger(kind=I4P)inChild ID.

Call graph

free

Free (reset) tag.

Attributes: elemental

fortran
subroutine free(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_tag)inoutXML tag.

get_content

Return tag content of self (or its nested tags) if named name.

@note If there is no value, the content string is returned deallocated.

Attributes: pure

fortran
subroutine get_content(self, name, content)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_tag)inXML tag.
namecharacter(len=*)inSearched tag name.
contentcharacter(len=:)outallocatableTag content.

Call graph

parse

Parse the tag contained into a source string.

It is assumed that the first tag contained into the source string is parsed, the others eventually present are omitted. Valid syntax are:

  • <tag_name att1="att1 val" att2="att2 val"...>...</tag_name>
  • <tag_name att1="att1 val" att2="att2 val".../> @note Inside the attributes value the symbols < and > are not allowed.

Attributes: elemental

fortran
subroutine parse(self, source, tstart, tend)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_tag)inoutXML tag.
sourcecharacter(len=*)inString containing the input.
tstartinteger(kind=I4P)outoptionalStarting index of tag inside the string.
tendinteger(kind=I4P)outoptionalEnding index of tag inside the string.

Call graph

parse_tag_name

Parse the tag name contained into a string.

It is assumed that the first tag contained into the source is parsed, the others eventually present are omitted. Valid syntax are:

  • <tag_name att1="att1 val" att2="att2 val"...>...</tag_name>
  • <tag_name att1="att1 val" att2="att2 val".../> @note Inside the attributes value the symbols < and > are not allowed.

Attributes: elemental

fortran
subroutine parse_tag_name(self, source, tstart, tend)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_tag)inoutXML tag.
sourcecharacter(len=*)inString containing the input.
tstartinteger(kind=I4P)outoptionalStarting index of tag inside the source.
tendinteger(kind=I4P)outoptionalEnding index of tag inside the source.

Call graph

set

Set tag data.

Attributes: pure

fortran
subroutine set(self, name, attribute, attributes, attributes_stream, sanitize_attributes_value, content, pos, indent, is_content_indented, is_self_closing, id, level, parent_id, attributes_stream_alloc, content_alloc)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_tag)inoutXML tag.
namecharacter(len=*)inoptionalTag name.
attributecharacter(len=*)inoptionalAttribute name/value pair [1:2].
attributescharacter(len=*)inoptionalAttributes list of name/value pairs [1:2,1:].
attributes_streamcharacter(len=*)inoptionalAttributes list of name/value pairs as stream.
sanitize_attributes_valuelogicalinoptionalSanitize attributes value.
contentcharacter(len=*)inoptionalTag value.
posinteger(kind=I4P)inoptionalCharacters position (in source) indexes.
indentinteger(kind=I4P)inoptionalNumber of indent-white-spaces.
is_content_indentedlogicalinoptionalActivate value indentation.
is_self_closinglogicalinoptionalThe tag is self closing.
idinteger(kind=I4P)inoptionalUniq ID.
levelinteger(kind=I4P)inoptionalTag hierarchy level.
parent_idinteger(kind=I4P)inoptionalParent uniq ID.
attributes_stream_alloccharacter(len=:)inallocatable, optionalAttributes list stream, allocatable input.
content_alloccharacter(len=:)inallocatable, optionalTag value, allocatable input.

Call graph

write_tag

Write tag to unit file.

fortran
subroutine write_tag(self, unit, is_indented, is_content_indented, form, end_record, only_start, only_content, only_end, iostat, iomsg)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_tag)inXML tag.
unitinteger(kind=I4P)inFile unit.
is_indentedlogicalinoptionalActivate content indentation.
is_content_indentedlogicalinoptionalActivate content indentation.
formcharacter(len=*)inoptionalFormat.
end_recordcharacter(len=*)inoptionalEnding record.
only_startlogicalinoptionalWrite only start tag.
only_contentlogicalinoptionalWrite only content.
only_endlogicalinoptionalWrite only end tag.
iostatinteger(kind=I4P)outoptionalIO status.
iomsgcharacter(len=*)outoptionalIO message.

Call graph

add_single_attribute

Add one attribute name/value pair.

@note Leading and trailing white spaces are trimmed out by attribute's name.

Attributes: pure

fortran
subroutine add_single_attribute(self, attribute, sanitize_value)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_tag)inoutXML tag.
attributecharacter(len=*)inAttribute name/value pair [1:2].
sanitize_valuelogicalinoptionalSanitize attribute value.

Call graph

add_multiple_attributes

Add list of attributes name/value pairs.

Attributes: pure

fortran
subroutine add_multiple_attributes(self, attributes, sanitize_values)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_tag)inoutXML tag.
attributescharacter(len=*)inAttribute name/value pair list [1:2,1:].
sanitize_valueslogicalinoptionalSanitize attribute values.

Call graph

add_stream_attributes

Add list of attributes name/value pairs passed as stream.

@note The character = cannot compare into the attributes names of values.

Attributes: pure

fortran
subroutine add_stream_attributes(self, attributes_stream, sanitize_values)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_tag)inoutXML tag.
attributes_streamcharacter(len=*)inAttribute name/value pair list passed as stream.
sanitize_valueslogicalinoptionalSanitize attribute values.

Call graph

alloc_attributes

Allocate (prepare for filling) dynamic memory of attributes.

Attributes: elemental

fortran
subroutine alloc_attributes(self, Na)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_tag)inoutXML tag.
Nainteger(kind=I4P)inNumber of attributes.

Call graph

delete_content

Delete tag content.

Attributes: pure

fortran
subroutine delete_content(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_tag)inoutXML tag.

delete_single_attribute

Delete one attribute name/value pair.

Attributes: pure

fortran
subroutine delete_single_attribute(self, name)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_tag)inoutXML tag.
namecharacter(len=*)inAttribute name.

Call graph

delete_multiple_attributes

Delete list of attributes name/value pairs.

Attributes: pure

fortran
subroutine delete_multiple_attributes(self, name)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_tag)inoutXML tag.
namecharacter(len=*)inAttributes names.

Call graph

get

Get the tag content and attributes from source after tag_name and attributes names have been set.

Attributes: elemental

fortran
subroutine get(self, source)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_tag)inoutXML tag.
sourcecharacter(len=*)inString containing data.

Call graph

get_attributes

Get the attributes values from source after tag_name and attributes names have been set.

Attributes: elemental

fortran
subroutine get_attributes(self, source)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_tag)inoutXML tag.
sourcecharacter(len=*)inString containing data.

Call graph

get_value

Get the tag value from source after tag_name has been set.

Attributes: elemental

fortran
subroutine get_value(self, source)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_tag)inoutXML tag.
sourcecharacter(len=*)inString containing data.

Call graph

parse_attributes_names

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.

Attributes: elemental

fortran
subroutine parse_attributes_names(self, source)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_tag)inoutXML tag.
sourcecharacter(len=*)inString containing the input.

Call graph

Search tag named tag_name into a string and, in case it is found, store into self.

@note If tag_name is not found, self is returned empty.

Attributes: elemental

fortran
subroutine search(self, tag_name, source, tstart, tend)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_tag)inoutXML tag.
tag_namecharacter(len=*)inSearched tag name.
sourcecharacter(len=*)inString containing the input.
tstartinteger(kind=I4P)outoptionalStarting index of tag inside the source.
tendinteger(kind=I4P)outoptionalEnding index of tag inside the source.

Call graph

assign_tag

Assignment between two tags.

Attributes: elemental

fortran
subroutine assign_tag(lhs, rhs)

Arguments

NameTypeIntentAttributesDescription
lhsclass(xml_tag)inoutLeft hand side.
rhstype(xml_tag)inRight hand side.

finalize

Free dynamic memory when finalizing.

Attributes: elemental

fortran
subroutine finalize(tag)

Arguments

NameTypeIntentAttributesDescription
tagtype(xml_tag)inoutXML tag.

Functions

create_tag_flat

Return an instance of xml tag.

Attributes: pure

Returns: type(xml_tag)

fortran
function create_tag_flat(name, attribute, attributes, attributes_stream, sanitize_attributes_value, pos, content, indent, is_content_indented, is_self_closing, id, level, parent_id, attributes_stream_alloc, content_alloc) result(tag)

Arguments

NameTypeIntentAttributesDescription
namecharacter(len=*)inTag name.
attributecharacter(len=*)inoptionalAttribute name/value pair [1:2].
attributescharacter(len=*)inoptionalAttributes list of name/value pairs [1:2,1:].
attributes_streamcharacter(len=*)inoptionalAttributes list as single stream.
sanitize_attributes_valuelogicalinoptionalSanitize attributes value.
posinteger(kind=I4P)inoptionalCharacters position (in source) indexes.
contentcharacter(len=*)inoptionalTag value.
indentinteger(kind=I4P)inoptionalNumber of indent-white-spaces.
is_content_indentedlogicalinoptionalActivate content indentation.
is_self_closinglogicalinoptionalThe tag is self closing.
idinteger(kind=I4P)inoptionalUniq ID.
levelinteger(kind=I4P)inoptionalTag hierarchy level.
parent_idinteger(kind=I4P)inoptionalParent uniq ID.
attributes_stream_alloccharacter(len=:)inallocatable, optionalAttributes list stream, allocatable input.
content_alloccharacter(len=:)inallocatable, optionalTag value, allocatable input.

Call graph

create_tag_nested

Return an instance of xml tag with value being a nested tag.

Attributes: pure

Returns: type(xml_tag)

fortran
function create_tag_nested(name, content, attribute, attributes, attributes_stream, sanitize_attributes_value, pos, indent, is_content_indented, id, level, parent_id, attributes_stream_alloc, content_alloc) result(tag)

Arguments

NameTypeIntentAttributesDescription
namecharacter(len=*)inTag name.
contenttype(xml_tag)inTag value as nested tag..
attributecharacter(len=*)inoptionalAttribute name/value pair [1:2].
attributescharacter(len=*)inoptionalAttributes list of name/value pairs [1:2,1:].
attributes_streamcharacter(len=*)inoptionalAttributes list as single stream.
sanitize_attributes_valuelogicalinoptionalSanitize attributes value.
posinteger(kind=I4P)inoptionalCharacters position (in source) indexes.
indentinteger(kind=I4P)inoptionalNumber of indent-white-spaces.
is_content_indentedlogicalinoptionalActivate value indentation.
idinteger(kind=I4P)inoptionalUniq ID.
levelinteger(kind=I4P)inoptionalTag hierarchy level.
parent_idinteger(kind=I4P)inoptionalParent uniq ID.
attributes_stream_alloccharacter(len=:)inallocatable, optionalAttributes list stream, allocatable input.
content_alloccharacter(len=:)inallocatable, optionalTag value, allocatable input.

Call graph

attributes

Return attributes name/value pairs as string.

Attributes: pure

Returns: character(len=:)

fortran
function attributes(self) result(att_)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_tag)inXML tag.

Call graph

end_tag

Return </tag_name> end tag.

Attributes: pure

Returns: character(len=:)

fortran
function end_tag(self, is_indented) result(tag_)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_tag)inXML tag.
is_indentedlogicalinoptionalActivate content indentation.

Call graph

is_attribute_present

Return .true. it the queried attribute name is defined, .false. otherwise.

Attributes: pure

Returns: logical

fortran
function is_attribute_present(self, name) result(is_present)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_tag)inXML tag.
namecharacter(len=*)inAttribute name.

is_parsed

Check is tag is correctly parsed, i.e. its tag_name is allocated.

Attributes: elemental

Returns: logical

fortran
function is_parsed(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_tag)inXML tag.

name

Return tag name.

Attributes: pure

Returns: character(len=:)

fortran
function name(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_tag)inXML tag.

Call graph

self_closing_tag

Return <tag_name.../> self closing tag.

Attributes: pure

Returns: character(len=:)

fortran
function self_closing_tag(self, is_indented) result(tag_)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_tag)inXML tag.
is_indentedlogicalinoptionalFlag to check if tag is indented.

Call graph

start_tag

Return <tag_name...> start tag.

Attributes: pure

Returns: character(len=:)

fortran
function start_tag(self, is_indented) result(tag_)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_tag)inXML tag.
is_indentedlogicalinoptionalFlag to check if tag is indented.

Call graph

stringify

Convert the whole tag into a string.

Attributes: pure

Returns: character(len=:)

fortran
function stringify(self, is_indented, is_content_indented, only_start, only_content, only_end, linearize) result(stringed)

Arguments

NameTypeIntentAttributesDescription
selfclass(xml_tag)inXML tag.
is_indentedlogicalinoptionalActivate content indentation.
is_content_indentedlogicalinoptionalActivate content indentation.
only_startlogicalinoptionalWrite only start tag.
only_contentlogicalinoptionalWrite only content.
only_endlogicalinoptionalWrite only end tag.
linearizelogicalinoptionalReturn a "linearized" string of tags without the XML hieararchy.

Call graph