Test cases / xml

deft xml convert

Change format: --to json|yaml|toml|jsonl

2 runs on real files, 6 tests on generated files, not shown. 0 failed.

Fixed cases

Generated files, compared with ground truth by tools other than deft.

a real Maven project filePassed

deft xml convert commons-lang.xml --to json -o out.json

Input

<?xml version="1.0" encoding="UTF-8"?>
<!--
 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements.  See the NOTICE file distributed with
 this work for additional information regarding copyright ownership.
 The ASF licenses this file to You under the Apache License, Version 2.0
 (the "License"); you may not use this file except in compliance with
 the License.  You may obtain a copy of the License at

      https://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->
<project
  xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
  <parent>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-parent</artifactId>
    <version>107</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <artifactId>commons-lang3</artifactId>
  <version>3.22.0-SNAPSHOT</version>
  <name>Apache Commons Lang</name>
  <inceptionYear>2001</inceptionYear>
  <description>
  Apache Commons Lang is a package of Java utility classes for the Java lang packages,
  classes that could be considered standard to justify their existence in java.lang.

  The code is tested using the latest revision of the JDK for supported LTS releases: 8, 11, 17, 21, and 25.
  See https://github.com/apache/commons-lang/blob/master/.github/workflows/maven.yml

  Please ensure your build environment is up-to-date and kindly report any build issues.

  Starting with Commons Lang 3.9, we target Java 8 and use those features.

  For advice on upgrading from 2.x to 3.x, see https://commons.apache.org/lang/article3_0.html
  </description>
  <url>https://commons.apache.org/proper/commons-lang/</url>
  <ciManagement>
    <system>github</system>
    <url>https://github.com/apache/commons-lang/actions</url>
  </ciManagement>
  <issueManagement>
    <system>jira</system>
    <url>https://issues.apache.org/jira/browse/LANG</url>
  </issueManagement>
  <scm>
    <connection>scm:git:https://gitbox.apache.org/repos/asf/commons-lang.git</connection>
    <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/commons-lang.git</developerConnection>
    <url>https://gitbox.apache.org/repos/asf/commons-lang.git</url>
    <tag>rel/commons-lang-3.21.0</tag>
  </scm>
  <!-- Lang should depend on very little -->
  <dependencies>
    <!-- testing -->
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit-pioneer</groupId>
      <artifactId>junit-pioneer</artifactId>
      <scope>test<
… 32602 more characters

Output

out.json 29.5 KB
{
  "project": {
    "@schemaLocation": "http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd",
    "parent": {
      "groupId": "org.apache.commons",
      "artifactId": "commons-parent",
      "version": "107"
    },
    "modelVersion": "4.0.0",
    "artifactId": "commons-lang3",
    "version": "3.22.0-SNAPSHOT",
    "name": "Apache Commons Lang",
    "inceptionYear": "2001",
    "description": "Apache Commons Lang is a package of Java utility classes for the Java lang packages,\n  classes that could be considered standard to justify their existence in java.lang.\n\n  The code is tested using the latest revision of the JDK for supported LTS releases: 8, 11, 17, 21, and 25.\n  See https://github.com/apache/commons-lang/blob/master/.github/workflows/maven.yml\n\n  Please ensure your build environment is up-to-date and kindly report any build issues.\n\n  Starting with Commons Lang 3.9, we target Java 8 and use those features.\n\n  For advice on upgrading from 2.x to 3.x, see https://commons.apache.org/lang/article3_0.html",
    "url": "https://commons.apache.org/proper/commons-lang/",
    "ciManagement": {
      "system": "github",
      "url": "https://github.com/apache/commons-lang/actions"
    },
    "issueManagement": {
      "system": "jira",
      "url": "https://issues.apache.org/jira/browse/LANG"
    },
    "scm": {
      "connection": "scm:git:https://gitbox.apache.org/repos/asf/commons-lang.git",
      "developerConnection": "scm:git:https://gitbox.apache.org/repos/asf/commons-lang.git",
      "url": "https://gitbox.apache.org/repos/asf/commons-lang.git",
      "tag": "rel/commons-lang-3.21.0"
    },
    "dependencies": {
      "dependency": [
        {
          "groupId": "org.junit.jupiter",
          "artifactId": "junit-jupiter",
          "scope": "test"
        },
        {
          "groupId": "org.junit-pioneer",
          "artifactId": "junit-pioneer",
          "scope": "test"
        },
        {
          "groupId": "org.easymock",
          "artifactId": "easymock",
          "version": "5.6.0",
          "scope": "test"
        },
        {
          "groupId": "org.mockito",
          "artifactId": "mockito-inline",
          "scope": "test"
        },
        {
          "groupId": "org.apache.commons",
          "artifactId": "commons-text",
          "version": "${commons.text.version}",
          "scope": "test"
        },
        {
          "groupId": "org.openjdk.jmh",
          "artifactId": "jmh-core",
          "version": "${commons.jmh.version}",
          "scope": "test"
        },
        {
          "groupId": "org.openjdk.jmh",
          "artifactId": "jmh-generator-annprocess",
          "version": "${commons.jmh.version}",
          "scope": "test"
        }
      ]
    },
    "distributionManagement": {
      "site": {
        "id": "apache.website",
        "name": "Apache Commons Site",
        "url": "scm:svn:https://svn.apache.org/repos/infra/websites/production/commons/conten
… 27221 more characters
What it printed
ok xml.convert commons-lang.xml -> out.json  30KB  0.01s
warning: comments are not kept
Automatic checks (1)
  • python: code = "import json; d = json.load(open('out.json')); assert d['project']['artifactId'] == 'commons-lang3', list(d['project'])[:8]"

Real-file tasks

Real files and a plain-language job, from the agent benchmark. These are the reference answers, not an agent run.

XML to JSONPassed

Convert catalog.xml to catalog.json.

deft xml convert catalog.xml -o catalog.json

Input

catalog.xml 94.2 KB
<?xml version="1.0" encoding="utf-8"?>
<rollcall-vote>
  <vote-metadata>
    <majority>R</majority>
    <congress>118</congress>
    <session>1st</session>
    <chamber>U.S. House of Representatives</chamber>
    <rollcall-num>1</rollcall-num>
    <legis-num>QUORUM</legis-num>
    <vote-question>Call By States</vote-question>
    <vote-type>QUORUM</vote-type>
    <vote-result>Passed</vote-result>
    <action-date>3-Jan-2023</action-date>
    <action-time time-etz="12:28">12:28 PM</action-time>
    <vote-desc></vote-desc>
    <vote-totals>
      <totals-by-party-header>
        <party-header>Party</party-header>
        <yea-header>Yeas</yea-header>
        <nay-header>Nays</nay-header>
        <present-header>Answered “Present”</present-header>
        <not-voting-header>Not Voting</not-voting-header>
      </totals-by-party-header>
      <totals-by-party>
        <party>Republican</party>
        <yea-total>0</yea-total>
        <nay-total>0</nay-total>
        <present-total>222</present-total>
        <not-voting-total>0</not-voting-total>
      </totals-by-party>
      <totals-by-party>
        <party>Democratic</party>
        <yea-total>0</yea-total>
        <nay-total>0</nay-total>
        <present-total>212</present-total>
        <not-voting-total>1</not-voting-total>
      </totals-by-party>
      <totals-by-party>
        <party>Independent</party>
        <yea-total>0</yea-total>
        <nay-total>0</nay-total>
        <present-total>0</present-total>
        <not-voting-total>0</not-voting-total>
      </totals-by-party>
      <totals-by-vote>
        <total-stub>Totals</total-stub>
        <yea-total>0</yea-total>
        <nay-total>0</nay-total>
        <present-total>434</present-total>
        <not-voting-total>1</not-voting-total>
      </totals-by-vote>
    </vote-totals>
  </vote-metadata>
  <vote-data>
    <recorded-vote>
      <legislator name-id="A000370" sort-field="Adams" unaccented-name="Adams" party="D" state="NC" role="legislator">Adams</legislator>
      <vote>Present</vote>
    </recorded-vote>
    <recorded-vote>
      <legislator name-id="A000055" sort-field="Aderholt" unaccented-name="Aderholt" party="R" state="AL" role="legislator">Aderholt</legislator>
      <vote>Present</vote>
    </recorded-vote>
    <recorded-vote>
      <legislator name-id="A000371" sort-field="Aguilar" unaccented-name="Aguilar" party="D" state="CA" role="legislator">Aguilar</legislator>
      <vote>Present</vote>
    </recorded-vote>
    <recorded-vote>
      <legislator name-id="A000379" sort-field="Alford" unaccented-name="Alford" party="R" state="MO" role="legislator">Alford</legislator>
      <vote>Present</vote>
    </recorded-vote>
    <recorded-vote>
      <legislator name-id="A000372" sort-field="Allen" unaccented-name="Allen" party="R" state="GA" role="legislator">Allen</legislator>
      <vote>Present</vote>
    </recorded-vote>
    <recorded-vote>
      
… 93445 more characters

Output

catalog.json 140.6 KB
{
  "rollcall-vote": {
    "vote-metadata": {
      "majority": "R",
      "congress": "118",
      "session": "1st",
      "chamber": "U.S. House of Representatives",
      "rollcall-num": "1",
      "legis-num": "QUORUM",
      "vote-question": "Call By States",
      "vote-type": "QUORUM",
      "vote-result": "Passed",
      "action-date": "3-Jan-2023",
      "action-time": {
        "@time-etz": "12:28",
        "#text": "12:28 PM"
      },
      "vote-desc": null,
      "vote-totals": {
        "totals-by-party-header": {
          "party-header": "Party",
          "yea-header": "Yeas",
          "nay-header": "Nays",
          "present-header": "Answered “Present”",
          "not-voting-header": "Not Voting"
        },
        "totals-by-party": [
          {
            "party": "Republican",
            "yea-total": "0",
            "nay-total": "0",
            "present-total": "222",
            "not-voting-total": "0"
          },
          {
            "party": "Democratic",
            "yea-total": "0",
            "nay-total": "0",
            "present-total": "212",
            "not-voting-total": "1"
          },
          {
            "party": "Independent",
            "yea-total": "0",
            "nay-total": "0",
            "present-total": "0",
            "not-voting-total": "0"
          }
        ],
        "totals-by-vote": {
          "total-stub": "Totals",
          "yea-total": "0",
          "nay-total": "0",
          "present-total": "434",
          "not-voting-total": "1"
        }
      }
    },
    "vote-data": {
      "recorded-vote": [
        {
          "legislator": {
            "@name-id": "A000370",
            "@sort-field": "Adams",
            "@unaccented-name": "Adams",
            "@party": "D",
            "@state": "NC",
            "@role": "legislator",
            "#text": "Adams"
          },
          "vote": "Present"
        },
        {
          "legislator": {
            "@name-id": "A000055",
            "@sort-field": "Aderholt",
            "@unaccented-name": "Aderholt",
            "@party": "R",
            "@state": "AL",
            "@role": "legislator",
            "#text": "Aderholt"
          },
          "vote": "Present"
        },
        {
          "legislator": {
            "@name-id": "A000371",
            "@sort-field": "Aguilar",
            "@unaccented-name": "Aguilar",
            "@party": "D",
            "@state": "CA",
            "@role": "legislator",
            "#text": "Aguilar"
          },
          "vote": "Present"
        },
        {
          "legislator": {
            "@name-id": "A000379",
            "@sort-field": "Alford",
            "@unaccented-name": "Alford",
            "@party": "R",
            "@state": "MO",
            "@role": "legislator",
            "#text": "Alford"
          },
          "vote": "Present"
        },
        {
          "legislator": {
            "@name-id": "A000372",
            "@sort-field": "
… 140979 more characters
Automatic checks (1)
  • python: code = "import json\nd = json.load(open('catalog.json', encoding='utf-8'))\ndef lists(x):\n if isinstance(x, list):\n yield x\n for v in x: yield from lists(v)\n elif isinstance(x, dict):\n for v in x.values(): yield from lists(v)\nassert any(len(l) == 435 for l in lists(d)), 'no list of the 435 votes'\nt = json.dumps(d, ensure_ascii=False)\nassert 'A000370' in t and 'Barragán' in t, 'attributes or accented names lost'\n"