Hi All,

I am running across a problem using XMLHelper to generate XML from
arbitrary DataObjects.  If I create a bare DataObject it seems to work
fine. If I use the same object contained in a DataDraph it falls in a
heap.  I am using Tuscany SDO 1.0 Beta1.

Here is an example that illustrates the problem:

import java.io.IOException;

import org.apache.tuscany.sdo.util.SDOUtil;

import commonj.sdo.DataGraph;
import commonj.sdo.DataObject;
import commonj.sdo.Type;
import commonj.sdo.helper.DataFactory;
import commonj.sdo.helper.TypeHelper;
import commonj.sdo.helper.XMLHelper;

public class Example {

        
        private static final String NSURI = "http://example.com/";;

        public static void main(String[] args) throws IOException {
                // Create an arbitrary type
                DataObject exampleType =
DataFactory.INSTANCE.create("commonj.sdo",
                                "Type");
                exampleType.set("uri", NSURI);
                exampleType.set("name", "example");
                DataObject exampleProperty =
exampleType.createDataObject("property");
                exampleProperty.set("name", "property");
                exampleProperty.set("type",
TypeHelper.INSTANCE.getType("commonj.sdo", "String"));
                Type type = TypeHelper.INSTANCE.define(exampleType);
                
                // Success
                DataObject ok = DataFactory.INSTANCE.create(type);
                ok.set("property", "Helloworld");
                XMLHelper.INSTANCE.save(ok, NSURI, "example-ok",
System.out);
                
                // Failure
                System.out.println();
                DataGraph dg = SDOUtil.createDataGraph();
                DataObject fails = dg.createRootObject(type);
                fails.set("property", "Helloworld");
                XMLHelper.INSTANCE.save(fails, NSURI, "example-fail",
System.out);
                
        }
}


This generates the output:

<?xml version="1.0" encoding="ASCII"?>
<example-ok xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns="http://example.com/"; xsi:type="example"
    property="Helloworld"/>
<?xml version="1.0" encoding="ASCII"?>
<example-fail xmlns="http://example.com/"; href="root.xml#/"/>

In the later case it has failed to correctly write out the XML.

Is there something I am missing or doing wrong here?

Dean.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to