class CldrParser extends AbstractXmlParser (View source)

A class which parses CLDR file to simple but useful array representation.

Parsed data is an array where keys are nodes from XML file with its attributes (if any). Only distinguishing attributes are taken into account (see [1]). Below are examples of parsed data structure.

such XML data:

will be converted to such array: array( 'dates' => array( 'calendars' => array( 'calendar[@type="gregorian"]' => array( 'months' => '' ), 'calendar[@type="buddhist"]' => array( 'months' => '' ), ) ) )

Properties

protected array $parsedFiles

Associative array of "filename => parsed data" pairs.

from  AbstractXmlParser

Methods

array
getParsedData(string $sourcePath)

Returns parsed representation of XML file.

getRootNode(string $sourcePath)

No description

array
parseXmlFile(string $sourcePath)

Reads and parses XML file and returns internal representation of data.

array
doParsingFromRoot(SimpleXMLElement $root)

Returns array representation of XML data, starting from a root node.

mixed
parseNode(SimpleXMLElement $node)

Returns array representation of XML data, starting from a node pointed by $node variable.

bool
isDistinguishingAttribute(string $attributeName)

Checks if given attribute belongs to the group of distinguishing attributes

Details

array getParsedData(string $sourcePath)

Returns parsed representation of XML file.

Parses XML if it wasn't done before. Caches parsed data.

Parameters

string $sourcePath

An absolute path to XML file

Return Value

array

Parsed XML file

protected SimpleXMLElement getRootNode(string $sourcePath)

No description

Parameters

string $sourcePath

Return Value

SimpleXMLElement

Exceptions

InvalidXmlFileException

protected array parseXmlFile(string $sourcePath)

Reads and parses XML file and returns internal representation of data.

Parameters

string $sourcePath

An absolute path to XML file

Return Value

array

Parsed XML file

protected array doParsingFromRoot(SimpleXMLElement $root)

Returns array representation of XML data, starting from a root node.

Parameters

SimpleXMLElement $root

A root node

Return Value

array

An array representing parsed XML file (structure depends on concrete parser)

See also

AbstractXmlParser::doParsingFromRoot

protected mixed parseNode(SimpleXMLElement $node)

Returns array representation of XML data, starting from a node pointed by $node variable.

Please see the documentation of this class for details about the internal representation of XML data.

Parameters

SimpleXMLElement $node

A node to start parsing from

Return Value

mixed

An array representing parsed XML node or string value if leaf

protected bool isDistinguishingAttribute(string $attributeName)

Checks if given attribute belongs to the group of distinguishing attributes

Distinguishing attributes in CLDR serves to distinguish multiple elements at the same level (most notably 'type').

Parameters

string $attributeName

Return Value

bool