Skip to content

Incorrect logic for serializing comments #85

@abensonca

Description

@abensonca

In the function in fox/dom/m_dom_utils.f90 at line 327:

    case (COMMENT_NODE)
      if (.not.getParameter(getDomConfig(doc), "comments")) then
        call xml_AddComment(xf, getData(this))
      endif

is the logic incorrect? This appears to be only serializing comments if the "comments" DOM config is false, which is counterintuitive to me. I'm unable to get a simple test case to serialize comments. For example, this test code:

program test
  use :: FoX_DOM
  implicit none
  type(DOMConfiguration), pointer :: config
  type(node), pointer :: doc
  config => newDOMConfig()
  call setParameter(config, "comments", .true.)
  doc => parseFile('p.xml',configuration=config)
  call serialize(doc,'t.xml')
end program test

with input file p.xml:

<?xml version="1.0" encoding="UTF-8"?>
<parameters>
  <!-- Component selection -->
</parameters>

produces an output file:

<?xml version="1.0"?>
<parameters>
  
</parameters>

to the comment is removed.

If I change the code in m_dom_utils.f90 to:

    case (COMMENT_NODE)
      if (getParameter(getDomConfig(doc), "comments")) then
        call xml_AddComment(xf, getData(this))
      endif

then it works as expected (i.e. the comment is included in the serialized output).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions