commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paolo Valladolid" <>
Subject [Digester] Can I do an object-create-rule within a set-properties-rule?
Date Wed, 07 Sep 2005 16:07:22 GMT
I am setting up Digester to parse XML in this format:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
  <Content id='585' type='DocumentTypeA' DateModified='07/19/2005'
    <title>My Book</title>
    <publisher>My Publisher</publisher>
The rules file I have is this:
<?xml version="1.0"?>
  <pattern value="contents">
    <object-create-rule classname="java.util.HashSet" />
    <pattern value="Content">
      <object-create-rule classname="com.myclasses.Document" />
        <alias attr-name="id" prop-name="contentID" />
        <alias attr-name="type">
          <object-create-rule classname="com.myclasses.DocumentType">
            <alias attr-name="type" prop-name="doctypeNm" /> 
      <bean-property-setter-rule pattern="title" propertyname="title" />
      <bean-property-setter-rule pattern="publisher"
propertyname="publisher" />
      <set-next-rule methodname="add" />
My problem is that I use Java classes generated by a tool that scans the
database.  The com.myclasses.Document class does not have a "type"
property.  Instead, it has a "doctypeid" property.  I need to
instantiate a com.myclasses.DocumentType object, set its "doctypeNm"
property to the "type" attribute (eg. "DocumentTypeA"), then use it to
retrieve the value which which I can set the Document.doctypeid
I thought of doing an object-create-rule on a HashMap class and using
that to store attributes, then setting the Document properties out of
the HashMap object, but that seems like a clumsy workaround.
Any ideas?
Paolo Valladolid
Software Developer
DFI International

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message