class XliffParser extends AbstractXmlParser (View source)

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

As for now, this class supports only basic XLIFF specification.

  • it uses only first "file" tag
  • it does support groups only as defined in [2] in order to support plural forms
  • reads only "source" and "target" in "trans-unit" tags

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 XLIFF data, starting from a root node.

array
getFileData(SimpleXMLElement $file)

No description

array|null
getFileDataFromDocument($sourcePath, $fileOffset)

No description

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 XLIFF data, starting from a root node.

Support "approved" attribute

Parameters

SimpleXMLElement $root

A root node

Return Value

array

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

Exceptions

InvalidXliffDataException

protected array getFileData(SimpleXMLElement $file)

No description

Parameters

SimpleXMLElement $file

Return Value

array

Exceptions

InvalidXliffDataException

array|null getFileDataFromDocument($sourcePath, $fileOffset)

No description

Parameters

$sourcePath
$fileOffset

Return Value

array|null

Exceptions

InvalidXliffDataException
InvalidXmlFileException