Warning: DOMDocumentFragment::appendXML(): Entity: line 18: parser error : Attribute lang redefined in Drupal\toc_api\TocBuilder->renderContent() (line 77 of modules/contrib/toc_api/src/TocBuilder.php).

Warning: DOMDocumentFragment::appendXML():

1) 1、renderContent() (line 77 of modules/contrib/toc_api/src/TocBuilder.php).

Issue fork toc_api-2841748

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

anxinax created an issue. See original summary.

anxinax’s picture

Issue summary: View changes
anxinax’s picture

Warning: DOMDocumentFragment::appendXML():

1) 1、renderContent() (line 77 of modules/contrib/toc_api/src/TocBuilder.php).

vladimiraus’s picture

Status: Active » Postponed (maintainer needs more info)

Thanks for reporting.
Can we get starps on how to reproduce it and full error stack?

joelpittet’s picture

Version: 8.x-1.0-beta1 » 8.x-1.x-dev
Status: Postponed (maintainer needs more info) » Needs review

I'm seeing this as well, the step was a rouge HTML from Word pasting. Here's the error

Warning: DOMDocumentFragment::appendXML(): Entity: line 7: parser error : Attribute lang redefined in Drupal\toc_api\TocBuilder->renderContent() (line 89 of modules/contrib/toc_api/src/TocBuilder.php).

Drupal\toc_api\TocBuilder->renderContent(Object) (Line: 176)
Drupal\toc_filter\Plugin\Filter\TocFilter->process('[toc]

<strong lang="EN-US" lang="EN-US" lang="EN-US">The founders and IP Agreement</strong> 

It's failing on the multiple lang attributes

joelpittet’s picture

Ok the MR above fixes the problem, it uses the same function used by the filter for text formats "Correct faulty and chopped off HTML" aka filter_htmlcorrector

smulvih2’s picture

Status: Needs review » Reviewed & tested by the community

I was getting this error when exporting content using the drupal/default_content_deploy module. It appears some of my migrated content also has duplicate lang attributes on an element. Applying patch from MR#6 resolved the issue for me. Also confirmed that the TOC token being used on these pages works correctly.

  • VladimirAus committed 46646a32 on 8.x-1.x
    Issue #2841748 by joelpittet, anxinax, VladimirAus, smulvih2: parser...
vladimiraus’s picture

Status: Reviewed & tested by the community » Fixed

Thank you! Committed and released! 🍻

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.