3 namespace Drupal\migrate_plus\Plugin\migrate_plus\data_parser;
6 * Common functionality for XML data parsers.
11 * Registers the iterator's namespaces to a SimpleXMLElement.
13 * @param \SimpleXMLElement $xml
14 * The element to apply namespace registrations to.
16 protected function registerNamespaces(\SimpleXMLElement $xml) {
17 if (isset($this->configuration['namespaces']) && is_array($this->configuration['namespaces'])) {
18 foreach ($this->configuration['namespaces'] as $prefix => $ns) {
19 $xml->registerXPathNamespace($prefix, $ns);
25 * Parses a LibXMLError to a error message string.
27 * @param \LibXMLError $error
28 * Error thrown by the XML.
33 public static function parseLibXmlError(\LibXMLError $error) {
34 $error_code_name = 'Unknown Error';
35 switch ($error->level) {
36 case LIBXML_ERR_WARNING:
37 $error_code_name = t('Warning');
40 case LIBXML_ERR_ERROR:
41 $error_code_name = t('Error');
44 case LIBXML_ERR_FATAL:
45 $error_code_name = t('Fatal Error');
50 "@libxmlerrorcodename @libxmlerrorcode: @libxmlerrormessage\n" .
51 "Line: @libxmlerrorline\n" .
52 "Column: @libxmlerrorcolumn\n" .
53 "File: @libxmlerrorfile",
55 '@libxmlerrorcodename' => $error_code_name,
56 '@libxmlerrorcode' => $error->code,
57 '@libxmlerrormessage' => trim($error->message),
58 '@libxmlerrorline' => $error->line,
59 '@libxmlerrorcolumn' => $error->column,
60 '@libxmlerrorfile' => (($error->file)) ? $error->file : NULL,