public function toString()
    {
        $items = $this->data;

        $attachedBaseLib = false;
        $return = array('file' => '', 'script' => '');
        foreach ($items as $item) {
            if ($item['mode'] == 'file' && isset($item['attributes']['src'])) {
                // looking for duplicated base library
                if ($item['attributes']['src'] == $this->getBaseLibrary() && !$attachedBaseLib) {
                    $attachedBaseLib = true;
                } elseif ($item['attributes']['src'] == $this->getBaseLibrary()) {
                    // we have attached base library before
                    continue;
                }
            }

            $return[$item['mode']] .= PHP_EOL.
                $this->startElement().$this->writeAttributes($item['attributes']).$this->endElement().
                (($item['mode'] == 'script') ? $this->overrideScript($item['content']) : '').
                $this->startElement(true).$this->endElement()
            ;
        }

        $return = $return['file'].PHP_EOL.
            $return['script'].PHP_EOL;

        return $return;
    }