XStream
  1. XStream
  2. XSTR-486

Xstream throws com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$DuplicateFieldException if xml has more than one tag in xml

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: 1.3
    • Component/s: Core
    • Labels:
      None
    • JDK version and platform:
      1.5.0_04

      Description

      XML
      =====
      <Config>
      <name>XXX</name>
      <xslConfig>
      <reportFormat>
      <fileName>test.xsl</fileName>
      <dir>H:\xml\data\xsl\</dir>
      </reportFormat>
      <reportFormat>
      <fileName>pdf_cp.xsl</fileName>
      <dir>H:\xml\data\xsl\</dir>
      </reportFormat>
      </xslConfig>
      </Config>

      Code
      ======

      public class Config
      {
      private String name = null;
      private XSLConfig xslConfig = null;

      public class XSLConfig
      {
      ReportFormat reportFormat;
      XSLConfig(ReportFormat reportFormat)

      { this.reportFormat= reportFormat; }

      public ReportFormat getReportFormat()

      { return reportFormat; }

      public void setReportFormat(ReportFormat reportFormat)

      { this.reportFormat= reportFormat; }

      }
      public class ReportFormat
      {
      String fileName = null;

      String dir = null;

      ReportFormat(String fileName, String dir)

      { this.dir = dir; this.fileName = fileName; }

      public String getDir()

      { return dir; }

      public String getFileName()

      { return fileName; }

      public void setDir(String dir)

      { this.dir = dir; }

      public void setFileName(String fileName)

      { this.fileName = fileName; }

      }

      public String getName()

      { return name; }

      public void setName(String name)

      { this.name = name; }

      public static void main(String[] arg)
      {
      BufferedReader reader = new BufferedReader(new FileReader(xmlFile));
      String lineText;
      while ((lineText = reader.readLine()) != null)

      { System.out.println(lineText); xmlString += lineText; }

      reader.close();
      XStream stream = new XStream(new DomDriver());
      stream.setMode(XStream.NO_REFERENCES);
      Config config = (Config) stream.fromXML(xmlString);
      System.out.println(config);

      }
      }

      I keep getting DuplicateFieldException . Could you pls advise. Thanks.

        People

        • Assignee:
          Jörg Schaible
          Reporter:
          Sanjeev Vaghel
        • Votes:
          0 Vote for this issue
          Watchers:
          0 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: