XhtmlIxbrlRenderer
in package
Represents a class responsible for rendering XHTML iXBRL and XML documents, particularly aimed at generating reports following the Inline XBRL specification.
Table of Contents
Properties
- $namespaces : array<string|int, mixed>
- An associative array defining namespace prefixes and their corresponding URIs.
Methods
- render() : string
- Renders an XHTML iXBRL report based on the provided document structure.
- renderXML() : string
- Renders an XML document with specified contexts, units, and taxonomy namespaces.
- escape() : string
- Escapes a string value for use in XML, ensuring that special characters are properly encoded.
- renderBody() : string
- Renders the body content by processing an array of nodes.
- renderContext() : string
- Renders an XML representation of a context element.
- renderCover() : string
- Renders an HTML cover page with specified company and report details.
- renderFact() : string
- Renders a fact element in Inline XBRL format based on the provided fact data.
- renderHeader() : string
- Renders the header section of an HTML document with hidden Inline XBRL (iXBRL) context and unit data.
- renderHtmlOpenTag() : string
- Renders the opening HTML tag with specified taxonomy namespaces as attributes.
- renderNode() : string
- renderPage() : string
- Renders an HTML page based on the provided node and its children.
- renderTable() : string
- Renders an HTML table based on the provided table data, including headers and rows.
- renderToc() : string
- Renders a Table of Contents (TOC) as an HTML string.
- renderUnit() : string
- Renders an XML representation of a unit, including its type, measures, and components.
Properties
$namespaces
An associative array defining namespace prefixes and their corresponding URIs.
private
array<string|int, mixed>
$namespaces
= ['xmlns' => 'http://www.w3.org/1999/xhtml', 'xmlns:ix' => 'http://www.xbrl.org/2013/inlineXBRL', 'xmlns:xbrli' => 'http://www.xbrl.org/2003/instance', 'xmlns:xbrldi' => 'http://xbrl.org/2006/xbrldi', 'xmlns:link' => 'http://www.xbrl.org/2003/linkbase', 'xmlns:xlink' => 'http://www.w3.org/1999/xlink', 'xmlns:iso4217' => 'http://www.xbrl.org/2003/iso4217']
Methods
render()
Renders an XHTML iXBRL report based on the provided document structure.
public
render(array<string|int, mixed> $document) : string
Parameters
- $document : array<string|int, mixed>
-
The structured data for the report, containing keys such as
title,lang,taxonomy_namespaces,contexts,units, andbody.
Return values
string —The generated XHTML document as a string.
renderXML()
Renders an XML document with specified contexts, units, and taxonomy namespaces.
public
renderXML(array<string|int, mixed> $document) : string
Parameters
- $document : array<string|int, mixed>
-
An associative array containing the data for the XML generation. Expected keys are:
- contexts: An array of context data to be rendered within the XML.
- units: An array of unit data to be rendered within the XML.
- taxonomy_namespaces: An associative array of prefix-to-URI mappings for taxonomy namespaces.
Return values
string —The generated XML document as a string.
escape()
Escapes a string value for use in XML, ensuring that special characters are properly encoded.
private
escape(string $value) : string
Parameters
- $value : string
-
The string value to be escaped.
Return values
string —The escaped string, safe for XML use.
renderBody()
Renders the body content by processing an array of nodes.
private
renderBody(array<string|int, mixed> $body) : string
Parameters
- $body : array<string|int, mixed>
-
An array of nodes to be rendered into the body content. Each node is expected to contain the necessary data for rendering.
Return values
string —The rendered body content as a concatenated string of nodes.
renderContext()
Renders an XML representation of a context element.
private
renderContext(array<string|int, mixed> $context) : string
Parameters
- $context : array<string|int, mixed>
-
An associative array containing the data required to generate the context XML. Expected keys are:
- id: A unique identifier for the context.
- entity: An associative array with the following keys:
- scheme: The scheme attribute for the entity identifier.
- identifier: The value of the entity identifier.
- period: An associative array containing the period details:
- type: Specifies the type of period ('instant' or other).
- instant: The date for the instant period (if type is 'instant').
- start_date: The start date of the period (if type is not 'instant').
- end_date: The end date of the period (if type is not 'instant').
- dimensions: An optional array of dimension data, where each dimension is an associative array:
- dimension_qname: The QName of the dimension.
- member_qname: The QName of the member.
- context_element: An optional string that specifies the context element type (default is 'scenario').
Return values
string —The generated XML string representing the context element.
renderCover()
Renders an HTML cover page with specified company and report details.
private
renderCover(array<string|int, mixed> $node) : string
Parameters
- $node : array<string|int, mixed>
-
An associative array containing the data for the cover page generation. Expected keys are:
- company_name: The name of the company to be displayed on the cover page.
- report_title: The title of the report to be displayed on the cover page.
- report_subtitle: The subtitle of the report, if any, to be displayed on the cover page.
Return values
string —The generated HTML for the cover page as a string.
renderFact()
Renders a fact element in Inline XBRL format based on the provided fact data.
private
renderFact(array<string|int, mixed> $fact) : string
Parameters
- $fact : array<string|int, mixed>
-
An associative array containing the data for the fact element. Expected keys are:
- fact_type: A string indicating the type of fact (e.g., 'nonNumeric', 'nonFraction').
- name: The name of the fact element.
- context_ref: The reference to the context associated with the fact.
- value: The value of the fact element.
- unit_code: (Optional) The unit code to append to the fact value.
- unit_ref: (Optional, applicable for 'nonFraction' fact_type) The reference to the unit element.
- decimals: (Optional, applicable for 'nonFraction' fact_type) The precision of the fact value.
Return values
string —The rendered Inline XBRL fact element as a string.
renderHeader()
Renders the header section of an HTML document with hidden Inline XBRL (iXBRL) context and unit data.
private
renderHeader(array<string|int, mixed> $contexts, array<string|int, mixed> $units) : string
Parameters
- $contexts : array<string|int, mixed>
-
An array of context data to be rendered within the iXBRL hidden section.
- $units : array<string|int, mixed>
-
An array of unit data to be rendered within the iXBRL hidden section.
Return values
string —The generated HTML header section as a string.
renderHtmlOpenTag()
Renders the opening HTML tag with specified taxonomy namespaces as attributes.
private
renderHtmlOpenTag(array<string|int, mixed> $taxonomyNamespaces) : string
Parameters
- $taxonomyNamespaces : array<string|int, mixed>
-
An associative array of prefix-to-URI mappings for taxonomy namespaces. Each key represents the namespace prefix, and each value represents the corresponding URI.
Return values
string —The generated opening HTML tag as a string with the given namespaces included as attributes.
renderNode()
private
renderNode(array<string|int, mixed> $node) : string
Parameters
- $node : array<string|int, mixed>
Return values
stringrenderPage()
Renders an HTML page based on the provided node and its children.
private
renderPage(array<string|int, mixed> $node) : string
Parameters
- $node : array<string|int, mixed>
-
An associative array representing the node to render. Expected keys are:
- children: An array of child nodes to be rendered within the page.
Return values
string —The generated HTML page as a string.
renderTable()
Renders an HTML table based on the provided table data, including headers and rows.
private
renderTable(array<string|int, mixed> $table) : string
Parameters
- $table : array<string|int, mixed>
-
An associative array containing the data for generating the table. Expected keys are:
- headers: An array of column headers to be rendered in the table's section.
- rows: An array of rows, where each row is an array of cell data. Each cell can be: - A simple value to display as text. - An associative array with a
typekey set to 'fact', in which case it will render as a fact.Return values
string —The generated HTML table as a string.
renderToc()
Renders a Table of Contents (TOC) as an HTML string.
private renderToc(array<string|int, mixed> $node) : stringParameters
- $node : array<string|int, mixed>
-
An associative array representing the data for the TOC generation. Expected key:
- items: An optional array of TOC items to be included in the list.
Return values
string —The generated HTML for the Table of Contents.
renderUnit()
Renders an XML representation of a unit, including its type, measures, and components.
private renderUnit(array<string|int, mixed> $unit) : stringParameters
- $unit : array<string|int, mixed>
-
An associative array containing the data for the unit. Expected keys are:
- id: A string representing the unique identifier for the unit.
- type: (optional) A string specifying the type of the unit, either 'simple' or 'divide'. Defaults to 'simple' if not provided.
- measures: (optional) An array of measure strings for simple units. Required if the type is 'simple'.
- numerator: (optional) An array of measure strings for the numerator in divide-type units. Required if the type is 'divide'.
- denominator: (optional) An array of measure strings for the denominator in divide-type units. Required if the type is 'divide'.
Return values
string —The rendered XML string representation of the unit.
Search results
- rows: An array of rows, where each row is an array of cell data. Each cell can be: - A simple value to display as text. - An associative array with a
- headers: An array of column headers to be rendered in the table's section.