Skip to content
This repository has been archived by the owner on Nov 11, 2023. It is now read-only.

Problem parsing xml comment in a closed list #29

Open
onbcst opened this issue Nov 12, 2018 · 5 comments
Open

Problem parsing xml comment in a closed list #29

onbcst opened this issue Nov 12, 2018 · 5 comments

Comments

@onbcst
Copy link

onbcst commented Nov 12, 2018

If I add (by hand) an xml comment to the values of a closed list I cannot change the the possible values any more due to the following error.

Fatal error: Uncaught Error: Call to undefined method DOMComment::getAttribute() in /var/www/tei-roma/roma/romadom.php:845 Stack trace: #0 /var/www/tei-roma/roma/romadom.php(736): romaDom->getAttributeValList('type', '', 'tei', 'att.typed', Array, NULL) #1 /var/www/tei-roma/roma/roma.php(1055): romaDom->getAttributeDefinition('type', '', 'tei', 'att.typed', Object(DOMDocument)) #2 /var/www/tei-roma/roma/roma.php(344): roma->processAddAttribute(NULL) #3 /var/www/tei-roma/startroma.php(33): roma->run() #4 {main} thrown in /var/www/tei-roma/roma/romadom.php on line 845

This can be forced with the following minimalistic example of adding two possible attribute values to @type (att.typed) and a comment afterwards.

    <classSpec ident="att.typed" type="atts" mode="change" module="tei">
     <attList>
      <attDef ident="type" mode="change">
       <valList type="closed" mode="replace">
        <valItem ident="typeA"/>
        <valItem ident="typeB"/><!-- my comment -->
       </valList>
      </attDef>
     </attList>
    </classSpec>

See tei_all(comment).zip for the complete source code.

It looks like Roma is iterating also over comment nodes and not only xml elements.

@martindholmes
Copy link
Contributor

This could be fixed by checking that the DOMNode->nodeType is XML_ELEMENT_NODE before doing anything:

http://php.net/manual/en/class.domnode.php#domnode.props.nodetype

@martindholmes
Copy link
Contributor

Tested and confirmed the bug using the attached file. It does not cause a problem for schema generation, just for editing attributes.

issue_29.odd.zip

@peterstadler
Copy link
Member

Currently giving a workshop, so will review later. Just a quick note that DockerHub has been building that branch (see https://hub.docker.com/r/teic/roma/tags/) successfully for everyone to test :)

@onbcst
Copy link
Author

onbcst commented Nov 13, 2018

The docker image worked for me. Thanks for your support.
However the comment is deleted after saving the customization again to disk.

peterstadler added a commit that referenced this issue Feb 22, 2019
and skip comments etc.

Co-Authored-By: Martin Holmes <[email protected]>
@peterstadler
Copy link
Member

applied @martindholmes's fix so the initial error should be gone. Still, we'll need to fix the unwanted deletion of the comment!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants