Forum


Replies: 4   Views: 1696
Domnode::insertbefore(): document fragment is empty
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by neukanri  · 12-11-2020 - 06:43

I use phpdocx 10 premium.

I make a word using a template.
The following warning is given in replaceVariableHTML.
DOMNode:: insertBefore(): Document Fragment is empty

I make a word from HTML.
The options are as follows.
'customListStyles' => true,
'strictWordStyles' => true,
'disableWrapValue' => true,
'removeLineBreaks' => true,
'wordStyles' => array
  '.listA' => 'listA'
)

Warning seems to be over a list when I do not appoint a class at making.

What is the method of preventing you from giving warning?

※The warning was not given in phpdocx9.

Posted by admin  · 12-11-2020 - 07:40

Hello,

Please post (or send to contact[at]phpdocx.com) the most simple code that illustrates your issue and if you are using the classic or namespaces package, so we can test it. Also post the full output of DOMNode:: insertBefore(): Document Fragment is empty (including the line that returns the warning).

The problem seems you are mixing HTML that contains custom list styles and standard lists, so you may get a warning when trying to mix them in the same embedHTML call. The next release of phpdocx will include a minor check to prevent this warning when using custom list styles and standard lists in the same HTML; if the line is the same we'll post it in this same thread so you can apply it to your current version.

Regards.

Posted by neukanri  · 13-11-2020 - 04:19

sample program send to you

pls confirm it

Posted by admin  · 13-11-2020 - 07:09

Hello,

Thanks for sending the requested code. The issue in your script is the one explained in our previous reply. You are mixing a HTML with two list types: one that applies a custom list style and other without it. To avoid the warning, please apply the following minor change that will be added to the next release of phpdocx:

  • Edit CreateDocx.php (classes folder using the classic package).
  • Go to the embedHTML method, and around line 5539 of the classic package, you'll find the following line:
$this->_wordNumberingT = $this->importSingleNumbering($this->_wordNumberingT, self::$customLists[$value['name']]['wordML'], $value['id'], $abstractNumId, true);

You need to replace it by:

if (isset(self::$customLists[$value['name']]['wordML'])) {
    $this->_wordNumberingT = $this->importSingleNumbering($this->_wordNumberingT, self::$customLists[$value['name']]['wordML'], $value['id'], $abstractNumId, true);
}

After this minor change the warning will disappear and you can use both style types (custom and auto generated) in the same HTML.

Regards.

Posted by neukanri  · 13-11-2020 - 08:23

I confirmed that there was no problem.

Thank you very much.