Uploaded image for project: 'Commons Digester'
  1. Commons Digester
  2. DIGESTER-142

Apache digester addSetProperty method is unclear and probably wrong.

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Not A Problem
    • Affects Version/s: 2.1
    • Fix Version/s: 3.0
    • Labels:
      None
    • Environment:

      linux, 64 bits

      Description

      The addSetProperty method call:
      Digester d = new Digester();
      d.push(this);
      d.addObjectCreate("rdf:RDF/pgterms:etext", Book.class);
      d.addSetProperty("rdf:RDF/pgterms:etext", "rdf:ID", "setId");
      OR
      d.addSetProperty("rdf:RDF/pgterms:etext", "rdf:ID", "id");

      on a class Book with the method public void setId(String)

      running on this xml (simplified and not tested the simplification):
      <rdf:RDF>
      <pgterms:etext rdf:ID="etext10452">
      <dc:publisher>&pg;</dc:publisher>
      <dc:title rdf:parseType="Literal">Peter's Mother</dc:title>
      <dc:creator rdf:parseType="Literal">De La Pasture, Henry, Mrs., 1866-1945</dc:creator>
      <pgterms:friendlytitle rdf:parseType="Literal">Peter's Mother by Mrs. Henry De La Pasture</pgterms:friendlytitle>
      <dc:language><dcterms:ISO639-2><rdf:value>en</rdf:value></dcterms:ISO639-2></dc:language>
      <dc:created><dcterms:W3CDTF><rdf:value>2003-12-01</rdf:value></dcterms:W3CDTF></dc:created>
      <dc:rights rdf:resource="&lic;" />
      </pgterms:etext>
      </rdf:RDF>

      gives this exception:
      Nov 8, 2010 2:42:12 PM org.apache.commons.digester.Digester startElement
      SEVERE: Begin event threw exception
      java.lang.NoSuchMethodException: Bean has no property named etext10452
      at org.apache.commons.digester.SetPropertyRule.begin(SetPropertyRule.java:154)
      at org.apache.commons.digester.Rule.begin(Rule.java:177)
      at org.apache.commons.digester.Digester.startElement(Digester.java:1583)
      at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:504)
      at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(XMLDTDValidator.java:770)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1340)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2732)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:625)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:488)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:812)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:741)
      at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
      at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1208)
      at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:525)
      at org.apache.commons.digester.Digester.parse(Digester.java:1916)
      ...(my code the rest).

      To work around it use instead:
      d.addSetProperties("rdf:RDF/pgterms:etext", "rdf:ID", "id");

      Doesn't make much sense to me. Also the confusion between a javadoc bean property and a xml one is very, very misleading on the javadoc.

        Attachments

          Activity

            People

            • Assignee:
              simone.tripodi Simone Tripodi
              Reporter:
              i30817 i30817
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: