<?php

namespace DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Service\Writer\XML;

use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Service\Writer\Generator;
use DOMElement;
use DOMDocument;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\ProductFields\Collection\ProductFieldCollection;
class CustomXmlWriter extends AbstractBatchXmlWriter implements Generator
{
    const PRODUCT_ITEMS = 'products';
    const PRODUCT_ITEM = 'product';
    public static function get_supported_extension(): string
    {
        return 'XML';
    }
    protected function get_product_item_tag(): string
    {
        return self::PRODUCT_ITEM;
    }
    protected function get_product_items_tag(): string
    {
        return self::PRODUCT_ITEMS;
    }
    protected function prepare_root_element(): DOMElement
    {
        $xml_document = new \DOMDocument('1.0', 'UTF-8');
        $xml_document->formatOutput = \true;
        $xml_document->preserveWhiteSpace = \false;
        $root_element = $xml_document->createElement(self::PRODUCT_ITEMS);
        $root_element->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
        $root_element->setAttribute('version', '1');
        $xml_document->appendChild($root_element);
        return $root_element;
    }
}
