You are here

protected function Xliff::writeBPT in Translation Management Tool 8

Writes beginning pair tag.

Parameters

XMLWriter $writer: Writer that writes the output.

DOMElement $node: Current node.

$id: Current node id.

1 call to Xliff::writeBPT()
Xliff::processForExport in translators/tmgmt_file/src/Plugin/tmgmt_file/Format/Xliff.php
Helper function to process the source text.

File

translators/tmgmt_file/src/Plugin/tmgmt_file/Format/Xliff.php, line 589

Class

Xliff
Export to XLIFF format.

Namespace

Drupal\tmgmt_file\Plugin\tmgmt_file\Format

Code

protected function writeBPT(\XMLWriter $writer, \DOMElement $node, $id) {
  $beginning_tag = '<' . $node->nodeName;
  if ($node
    ->hasAttributes()) {
    $attributes = array();

    /** @var DOMAttr $attribute */
    foreach ($node->attributes as $attribute) {
      $attributes[] = $attribute->name . '="' . $attribute->value . '"';
    }
    $beginning_tag .= ' ' . implode(' ', $attributes);
  }
  $beginning_tag .= '>';
  $writer
    ->startElement('bpt');
  $writer
    ->writeAttribute('id', $id);
  $writer
    ->text($beginning_tag);
  $writer
    ->endElement();
}