foxy_xml_writer
FoXy XML writer class: stream well-formed XML to a file, a unit or memory.
The document is written sequentially, element by element: start opens an element (its start tag stays pending, so attributes can be added, until its first content), end closes it (written self closing if it has no content). The writer keeps the stack of the open elements, escapes text and attribute values and writes each piece as soon as it is complete: the memory used does not depend on the document size (a memory target grows its buffer geometrically).
Layout: with indent>0 (default 2) every element holding elements has its start and end tags on their own lines, indented by depth; an element holding text is written inline (<a>text</a>), as its children; a block payload (raw(..., is_block=.true.)) is written on its own line. With indent=0 no blank is added.
Errors are sticky: the first one (an I/O error, or a misuse reported as XML_MALFORMED) is kept, every following call does nothing; each call can return it (iostat, iomsg), close always does: called without iostat, close stops the program on an error never returned to the caller, so that no error is lost.
Only well-formed XML is written: element and attribute names are checked (XML names), a duplicate attribute is an error, ]]> is escaped in text and attribute values.
Source: src/lib/foxy_xml_writer.f90
Dependencies
Contents
- open_element
- xml_writer
- cdata
- close
- comment
- declaration
- end
- flush
- open
- pi
- raw
- start
- text_character
- attribute_character
- attribute_i1p
- attribute_i2p
- attribute_i4p
- attribute_i8p
- attribute_r4p
- attribute_r8p
- attribute_logical
- attribute_i1p_1
- attribute_i2p_1
- attribute_i4p_1
- attribute_i8p_1
- attribute_r4p_1
- attribute_r8p_1
- text_i1p
- text_i1p_1
- text_i2p
- text_i2p_1
- text_i4p
- text_i4p_1
- text_i8p
- text_i8p_1
- text_r4p
- text_r4p_1
- text_r8p
- text_r8p_1
- text_logical
- fail
- flush_pending
- markup_line
- put
- report
- string
- is_writable
- start_content
- is_xml_target
- indentation
- new_line_
Variables
| Name | Type | Attributes | Description |
|---|---|---|---|
INITIAL_BUFFER_LEN | integer(kind=I8P) | parameter | Initial length of the memory buffer, doubled when full. |
INITIAL_DEPTH | integer(kind=I4P) | parameter | Initial capacity of the open elements stack, doubled when full. |
Derived Types
open_element
An open element.
Components
| Name | Type | Attributes | Description |
|---|---|---|---|
name | character(len=:) | allocatable | Element name. |
is_inline | logical | It holds text: its content and end tag are written inline. | |
in_inline | logical | It is inside an inline element: no layout around it. |
xml_writer
XML writer.
Components
| Name | Type | Attributes | Description |
|---|---|---|---|
unit | integer | Output unit (file or unit target). | |
is_memory | logical | The target is memory. | |
is_open | logical | The writer is open. | |
is_unit_owned | logical | The unit is opened (and closed) by the writer. | |
buffer | character(len=:) | allocatable | Memory target buffer. |
n | integer(kind=I8P) | Used length of the memory buffer. | |
indent | integer(kind=I4P) | Spaces per indentation level, 0 for no layout. | |
stack | type(open_element) | allocatable | Open elements. |
depth | integer(kind=I4P) | Number of open elements. | |
pending | character(len=:) | allocatable | Pending start tag (<name attributes), unallocated if none. |
pending_names | character(len=:) | allocatable | Attributes names of the pending start tag, a b. |
is_empty | logical | Nothing written yet. | |
roots | integer(kind=I4P) | Root elements started (a document has one). | |
error | integer(kind=I4P) | First error status, 0 if none. | |
error_message | character(len=:) | allocatable | First error message. |
is_reported | logical | The error has been returned to the caller. |
Type-Bound Procedures
| Name | Attributes | Description |
|---|---|---|
attribute | Add an attribute to the pending start tag. | |
cdata | pass(self) | Write a CDATA section. |
close | pass(self) | Close all the open elements and the writer. |
comment | pass(self) | Write a comment. |
declaration | pass(self) | Write the XML declaration. |
end | pass(self) | Close the innermost open element. |
flush | pass(self) | Complete the pending start tag, for direct writes to the unit. |
open | pass(self) | Open the writer on a file, a unit or memory. |
pi | pass(self) | Write a processing instruction. |
raw | pass(self) | Write characters as they are. |
start | pass(self) | Open an element. |
string | pass(self) | Return the memory target content. |
text | Write character data (escaped), a number, a logical or a list. | |
attribute_character | pass(self) | Add a character attribute. |
attribute_i1p | pass(self) | Add an integer attribute. |
attribute_i2p | pass(self) | Add an integer attribute. |
attribute_i4p | pass(self) | Add an integer attribute. |
attribute_i8p | pass(self) | Add an integer attribute. |
attribute_r4p | pass(self) | Add a real attribute. |
attribute_r8p | pass(self) | Add a real attribute. |
attribute_logical | pass(self) | Add a logical attribute. |
attribute_i1p_1 | pass(self) | Add a list attribute. |
attribute_i2p_1 | pass(self) | Add a list attribute. |
attribute_i4p_1 | pass(self) | Add a list attribute. |
attribute_i8p_1 | pass(self) | Add a list attribute. |
attribute_r4p_1 | pass(self) | Add a list attribute. |
attribute_r8p_1 | pass(self) | Add a list attribute. |
text_character | pass(self) | Write escaped character data. |
text_i1p | pass(self) | Write a number. |
text_i2p | pass(self) | Write a number. |
text_i4p | pass(self) | Write a number. |
text_i8p | pass(self) | Write a number. |
text_r4p | pass(self) | Write a number. |
text_r8p | pass(self) | Write a number. |
text_logical | pass(self) | Write a logical. |
text_i1p_1 | pass(self) | Write a list of numbers. |
text_i2p_1 | pass(self) | Write a list of numbers. |
text_i4p_1 | pass(self) | Write a list of numbers. |
text_i8p_1 | pass(self) | Write a list of numbers. |
text_r4p_1 | pass(self) | Write a list of numbers. |
text_r8p_1 | pass(self) | Write a list of numbers. |
fail | pass(self) | Record the first error. |
flush_pending | pass(self) | Complete the pending start tag. |
is_writable | pass(self) | Check that the writer is open and without errors. |
markup_line | pass(self) | Write a comment or PI. |
put | pass(self) | Write characters to the target. |
report | pass(self) | Return the error status. |
start_content | pass(self) | Prepare the innermost element for inline content. |
Subroutines
cdata
Write a CDATA section (]]> in string is split across two sections).
subroutine cdata(self, string, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
string | character(len=*) | in | Characters. | |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
close
Close all the open elements and the writer (a file opened by the writer is closed, a unit passed is left open; the memory target content stays available to string); without iostat, an error not yet returned to the caller stops the program.
subroutine close(self, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
iostat | integer(kind=I4P) | out | optional | IO status: 0, the runtime I/O error code or XML_MALFORMED. |
iomsg | character(len=*) | inout | optional | IO message, unchanged if no error. |
Call graph
comment
Write a comment (<!--string-->); string cannot contain -- nor end with -.
subroutine comment(self, string, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
string | character(len=*) | in | Comment. | |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
declaration
Write the XML declaration, only as the first thing of the document.
subroutine declaration(self, version, encoding, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
version | character(len=*) | in | optional | XML version (default 1.0). |
encoding | character(len=*) | in | optional | Encoding (not written if not passed): UTF-8 (any alias) only. |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
end
Close the innermost open element (self closing if it has no content); name, if passed, must be its name.
subroutine end(self, name, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
name | character(len=*) | in | optional | Name of the element to close. |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
flush
Complete the pending start tag of the innermost element as for block content (a new line follows), so that the caller can write directly to the unit (e.g. binary data); the element end tag is then written on its own line.
subroutine flush(self, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
open
Open the writer: on a file (created, replaced if it exists), on a unit (already open for stream unformatted access, left open by close) or, if neither is passed, on memory (see string).
subroutine open(self, filename, unit, indent, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
filename | character(len=*) | in | optional | File name. |
unit | integer | in | optional | Unit, open for stream unformatted access. |
indent | integer(kind=I4P) | in | optional | Spaces per indentation level (default 2), 0 for no layout. |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
pi
Write a processing instruction (<?target string?>): target is an XML name other than xml (any case), string cannot contain ?>.
subroutine pi(self, target, string, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
target | character(len=*) | in | PI target. | |
string | character(len=*) | in | optional | PI content. |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
raw
Write characters as they are (e.g. pre-formatted numbers, base64 data): inline, or with is_block on their own line (indented, the end tag of the element on its own line too). Large data can be written in pieces, with many calls.
subroutine raw(self, string, is_block, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
string | character(len=*) | in | Characters. | |
is_block | logical | in | optional | Write on their own line. |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
start
Open an element: its start tag stays pending (attributes can be added) up to its first content or its end.
subroutine start(self, name, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
name | character(len=*) | in | Element name. | |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
text_character
Write character data, escaped (&, <, >, ", '); the element is written inline.
subroutine text_character(self, string, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
string | character(len=*) | in | Character data. | |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
attribute_character
Add an attribute to the pending start tag (the value is escaped, tab, new line and CR as references: it reads back exactly).
subroutine attribute_character(self, name, value, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
name | character(len=*) | in | Attribute name. | |
value | character(len=*) | in | Attribute value. | |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
attribute_i1p
Add a integer attribute: integers with their digits (a sign only if negative), or as formatted by fmt.
subroutine attribute_i1p(self, name, value, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
name | character(len=*) | in | Attribute name. | |
value | integer(kind=I1P) | in | Attribute value. | |
fmt | character(len=*) | in | optional | Format, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
attribute_i2p
Add a integer attribute: integers with their digits (a sign only if negative), or as formatted by fmt.
subroutine attribute_i2p(self, name, value, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
name | character(len=*) | in | Attribute name. | |
value | integer(kind=I2P) | in | Attribute value. | |
fmt | character(len=*) | in | optional | Format, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
attribute_i4p
Add a integer attribute: integers with their digits (a sign only if negative), or as formatted by fmt.
subroutine attribute_i4p(self, name, value, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
name | character(len=*) | in | Attribute name. | |
value | integer(kind=I4P) | in | Attribute value. | |
fmt | character(len=*) | in | optional | Format, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
attribute_i8p
Add a integer attribute: integers with their digits (a sign only if negative), or as formatted by fmt.
subroutine attribute_i8p(self, name, value, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
name | character(len=*) | in | Attribute name. | |
value | integer(kind=I8P) | in | Attribute value. | |
fmt | character(len=*) | in | optional | Format, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
attribute_r4p
Add a real attribute: the shortest text that reads back exactly (StringiFor shortest), or as formatted by fmt.
subroutine attribute_r4p(self, name, value, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
name | character(len=*) | in | Attribute name. | |
value | real(kind=R4P) | in | Attribute value. | |
fmt | character(len=*) | in | optional | Format, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
attribute_r8p
Add a real attribute: the shortest text that reads back exactly (StringiFor shortest), or as formatted by fmt.
subroutine attribute_r8p(self, name, value, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
name | character(len=*) | in | Attribute name. | |
value | real(kind=R8P) | in | Attribute value. | |
fmt | character(len=*) | in | optional | Format, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
attribute_logical
Add a logical attribute, as true or false.
subroutine attribute_logical(self, name, value, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
name | character(len=*) | in | Attribute name. | |
value | logical | in | Attribute value. | |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
attribute_i1p_1
Add an attribute holding a list of integer values, separated by one space (each as the scalar attribute).
subroutine attribute_i1p_1(self, name, values, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
name | character(len=*) | in | Attribute name. | |
values | integer(kind=I1P) | in | Attribute values. | |
fmt | character(len=*) | in | optional | Format of each value, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
attribute_i2p_1
Add an attribute holding a list of integer values, separated by one space (each as the scalar attribute).
subroutine attribute_i2p_1(self, name, values, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
name | character(len=*) | in | Attribute name. | |
values | integer(kind=I2P) | in | Attribute values. | |
fmt | character(len=*) | in | optional | Format of each value, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
attribute_i4p_1
Add an attribute holding a list of integer values, separated by one space (each as the scalar attribute).
subroutine attribute_i4p_1(self, name, values, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
name | character(len=*) | in | Attribute name. | |
values | integer(kind=I4P) | in | Attribute values. | |
fmt | character(len=*) | in | optional | Format of each value, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
attribute_i8p_1
Add an attribute holding a list of integer values, separated by one space (each as the scalar attribute).
subroutine attribute_i8p_1(self, name, values, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
name | character(len=*) | in | Attribute name. | |
values | integer(kind=I8P) | in | Attribute values. | |
fmt | character(len=*) | in | optional | Format of each value, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
attribute_r4p_1
Add an attribute holding a list of real values, separated by one space (each as the scalar attribute).
subroutine attribute_r4p_1(self, name, values, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
name | character(len=*) | in | Attribute name. | |
values | real(kind=R4P) | in | Attribute values. | |
fmt | character(len=*) | in | optional | Format of each value, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
attribute_r8p_1
Add an attribute holding a list of real values, separated by one space (each as the scalar attribute).
subroutine attribute_r8p_1(self, name, values, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
name | character(len=*) | in | Attribute name. | |
values | real(kind=R8P) | in | Attribute values. | |
fmt | character(len=*) | in | optional | Format of each value, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
text_i1p
Write a integer value as character data (as attribute); the element is written inline.
subroutine text_i1p(self, value, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
value | integer(kind=I1P) | in | Value. | |
fmt | character(len=*) | in | optional | Format, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
text_i1p_1
Write a list of integer values, separated by one space, as character data (as attribute); the element is written inline.
subroutine text_i1p_1(self, values, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
values | integer(kind=I1P) | in | Values. | |
fmt | character(len=*) | in | optional | Format of each value, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
text_i2p
Write a integer value as character data (as attribute); the element is written inline.
subroutine text_i2p(self, value, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
value | integer(kind=I2P) | in | Value. | |
fmt | character(len=*) | in | optional | Format, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
text_i2p_1
Write a list of integer values, separated by one space, as character data (as attribute); the element is written inline.
subroutine text_i2p_1(self, values, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
values | integer(kind=I2P) | in | Values. | |
fmt | character(len=*) | in | optional | Format of each value, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
text_i4p
Write a integer value as character data (as attribute); the element is written inline.
subroutine text_i4p(self, value, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
value | integer(kind=I4P) | in | Value. | |
fmt | character(len=*) | in | optional | Format, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
text_i4p_1
Write a list of integer values, separated by one space, as character data (as attribute); the element is written inline.
subroutine text_i4p_1(self, values, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
values | integer(kind=I4P) | in | Values. | |
fmt | character(len=*) | in | optional | Format of each value, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
text_i8p
Write a integer value as character data (as attribute); the element is written inline.
subroutine text_i8p(self, value, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
value | integer(kind=I8P) | in | Value. | |
fmt | character(len=*) | in | optional | Format, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
text_i8p_1
Write a list of integer values, separated by one space, as character data (as attribute); the element is written inline.
subroutine text_i8p_1(self, values, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
values | integer(kind=I8P) | in | Values. | |
fmt | character(len=*) | in | optional | Format of each value, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
text_r4p
Write a real value as character data (as attribute); the element is written inline.
subroutine text_r4p(self, value, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
value | real(kind=R4P) | in | Value. | |
fmt | character(len=*) | in | optional | Format, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
text_r4p_1
Write a list of real values, separated by one space, as character data (as attribute); the element is written inline.
subroutine text_r4p_1(self, values, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
values | real(kind=R4P) | in | Values. | |
fmt | character(len=*) | in | optional | Format of each value, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
text_r8p
Write a real value as character data (as attribute); the element is written inline.
subroutine text_r8p(self, value, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
value | real(kind=R8P) | in | Value. | |
fmt | character(len=*) | in | optional | Format, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
text_r8p_1
Write a list of real values, separated by one space, as character data (as attribute); the element is written inline.
subroutine text_r8p_1(self, values, fmt, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
values | real(kind=R8P) | in | Values. | |
fmt | character(len=*) | in | optional | Format of each value, e.g. (F6.3). |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
text_logical
Write a logical value as character data, true or false; the element is written inline.
subroutine text_logical(self, value, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
value | logical | in | Value. | |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
fail
Record an error, if it is the first one.
subroutine fail(self, error, message)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
error | integer(kind=I4P) | in | Error status. | |
message | character(len=*) | in | Error message. |
Call graph
flush_pending
Complete the pending start tag of the innermost element, before its first content (a new line follows, unless the element is inline).
subroutine flush_pending(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. |
Call graph
markup_line
Write a comment or PI: on its own line, or inline inside an inline element.
subroutine markup_line(self, markup)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
markup | character(len=*) | in | Markup. |
Call graph
put
Write characters to the target (unit or memory).
subroutine put(self, string)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
string | character(len=*) | in | Characters. |
Call graph
report
Return the error status (iomsg only if there is an error), through iostat if passed.
subroutine report(self, iostat, iomsg)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
iostat | integer(kind=I4P) | out | optional | IO status. |
iomsg | character(len=*) | inout | optional | IO message. |
Call graph
Functions
string
Return the content of the memory target (empty for a file or unit target).
Attributes: pure
Returns: character(len=:)
function string(self) result(content)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | in | XML writer. |
is_writable
Check that the writer is open and without errors (a call on a writer not open is an error).
Returns: logical
function is_writable(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. |
Call graph
start_content
Prepare the innermost element for inline content (text, data, CDATA): its start tag is completed, it becomes inline.
Returns: logical
function start_content(self, what) result(is_ready)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(xml_writer) | inout | XML writer. | |
what | character(len=*) | in | Content kind, for the error message. |
Call graph
is_xml_target
Return true if a PI target is xml in any case, reserved by XML 1.0 (2.6) for the XML declaration.
Attributes: pure
Returns: logical
function is_xml_target(target) result(is_xml)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
target | character(len=*) | in | PI target. |
Call graph
indentation
Return the indentation of a depth.
Attributes: pure
Returns: character(len=:)
function indentation(self, depth) result(blanks)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | type(xml_writer) | in | XML writer. | |
depth | integer(kind=I4P) | in | Depth. |
Call graph
new_line_
Return a new line, or nothing without layout.
Attributes: pure
Returns: character(len=:)
function new_line_(self) result(nl)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | type(xml_writer) | in | XML writer. |
Call graph