Skip to content

xmlBuilder: oneListGroup option seems to have no effect #768

@massimo-cassandro

Description

@massimo-cassandro
  • Are you running the latest version?
  • Have you included sample input, output, error, and expected output?
  • Have you checked if you are using correct configuration?
  • Did you try online tool?
  • Have you checked the docs for helpful APIs and examples?

Description

oneListGroup option seems to have no effect and produces cdata items errors

Input

Code

configuration

const builder = new XMLBuilder({
     processEntities: true,
    ignoreAttributes : false,
    attributeNamePrefix: '$',
    textNodeName: '_content',
    cdataPropName: '_cdata',
    suppressBooleanAttributes: false,
    oneListGroup: true
  });

json data

{
    "table": {
        "caption": "Table caption",
        "row": [
            [
                {
                    "cell": "cell 1"
                },
                {
                    "cell": "cell 2"
                },
                {
                    "cell": "cell 3"
                }
            ],
            [
                {
                    "cell": "cell 3"
                },
                {
                    "cell": "cell 4"
                },
                {
                    "cell": "cell 5"
                }
            ]
        ]
    }
}

Output

<?xml version="1.0"?>
<table>
  <caption>Table caption</caption>
  <row>
    <0>
      <cell>cell 1</cell>
    </0>
    <1>
      <cell>cell 2</cell>
    </1>
    <2>
      <cell>cell 3</cell>
    </2>
  </row>
  <row>
    <0>
      <cell>cell 3</cell>
    </0>
    <1>
      <cell>cell 4</cell>
    </1>
    <2>
      <cell>cell 5</cell>
    </2>
  </row>
</table>

In addition, adding the oneListGroup option, also cdata processing fails:

<descr>
  <_cdata>&lt;p&gt;some text&lt;/p&gt;</_cdata>
</descr>

expected output

<table>
  <caption>Composizione del MOL</caption>
  <row>
    <cell>cell 1</cell>
    <cell>cell 2</cell>
    <cell>cell 3</cell>
  </row>
  <row>
    <cell>cell 4</cell>
    <cell>cell 5</cell>
    <cell>cell 6</cell>
  </row>
</table>

Would you like to work on this issue?

  • Yes
  • No

Bookmark this repository for further updates. Visit SoloThought to know about recent features.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions