Hello,

since there is no commons-user-List, i'll try my luck here.
I am using Turbine along with Torque as an OM-Tool.
Some data of an object generated with Torque should be stored in a XML-DB (Xindice, to 
be ecaxt).
Now i thought i might use betwixt to map the wanted attributes to a nice XML and put 
it in the DB.
Now i first wanted to look at the example of betwixt, for some reason i can't (ant 
failes
the build cause it doesn't find org.apache.commons.betwixt.strategy.NameMapper, which 
is in the
source-directory, but not in the jar - why's that? ).
Well, after that i tried to figure it out, and i now have a prettyprinted XML from the 
OM-Class,
though there's all attributes in it. Probably i'm using it all wrong, but the 
documentation is rather
short, so i ought someone here could provide me with some insight ^^ (pretty please)

my OM-Class is named KnowledgeObject and to test it i want to generate an xml just 
with the 
subject and description attribute in it. I made a KnowledgeObject.betwixt-File which 
looks this way:

<?xml version="1.0" encoding="UTF-8" ?>
<KnowledgeObject primitiveTypes="attribute">
  <element name="subject" property="subject"/>
  <element name="description" property="description"/>
</<KnowledgeObject >

and i put that in the class-directory, actually exaclty in the directory the om-Class 
also is (KnowledgeObject.class)
In the Class KnowledgeObjectPeer i made a new method which should also create the xml 
from the OM-Class.

    public static ObjectKey doInsert(Criteria criteria, KnowledgeObject ko) throws 
Exception
    {
// insert the data in the relational DB
        ObjectKey result =  BaseKnowledgeObjectPeer.doInsert(criteria);
        ko.setPrimaryKey(result);

// Use Betwixt to create an XML file from the Knowledge Object
        BeanWriter beanWriter = new BeanWriter(System.out);
        beanWriter.enablePrettyPrint();
        beanWriter.write(ko);
    } // doInsert

Now this produces some nice looking XML, though i only want something like this to be 
created
(and i thought with the betwixt-file i ruled it).

<KnowledgeObject id="2">
  <subject>Subject</subject>
  <description>Description</description>
</KnowledgeObject

How do i tell the BeanWriter to use the betwixt-file? There is no error thrown, so i 
think it doesn't use
the betwixt file at all ... ^^;;

tia, Christine Keim



Reply via email to