Assuming that the line numbers in your stack trace correspond to the EMF
version (2.2.3) that I'm looking at, it looks to me like null is being
passed into the getList() method. If so, I assume it's because this line
returned null:
Property addressProperty =
context.getXSDHelper().getGlobalProperty("http://www.example.org/Address",
"Address", true);
That is, it couldn't locate your global property.
Frank
[EMAIL PROTECTED] wrote on 05/07/2007 12:13:35 PM:
> Hi Frank,
>
> Thank you so much for your help so far, your example worked. I'm
> learning quite a bit. I thought that would help me with my real work,
> but I'm seeing a different error.
>
> My schema can be found here:
>
> http://www.oasis-open.org/committees/download.php/23876/CL1_Schema.zip
>
> and here:
>
> http://www.w3.org/2000/09/xmldsig
>
> I generate my classes using IBM's JDK 1.4.2 with the following commands:
>
> set javaExe=C:\ibmsdk1.4.2_sr4-1\bin\java
> set output=.
> set schemaLocation=..\schema\sdd-20070504_49
>
> set sdo_cp=lib\org.eclipse.emf.codegen_2.2.2.v200702131851.jar;
> lib\org.eclipse.emf.codegen.ecore_2.2.2.v200702131851.jar;lib\org.
> eclipse.emf.common_2.2.1.v200702131851.jar;lib\org.eclipse.emf.
> ecore_2.2.2.v200702131851.jar;lib\org.eclipse.emf.ecore.change_2.2.
> 1.v200702131851.jar;lib\org.eclipse.emf.ecore.xmi_2.2.2.
> v200702131851.jar;lib\sdo-api-r2.1-1.0-incubating-SNAPSHOT.jar;
> lib\tuscany-sdo-impl-1.0-incubating-SNAPSHOT.jar;lib\tuscany-sdo-
>
tools-1.0-incubating-SNAPSHOT.jar;lib\org.eclipse.xsd_2.2.2.v200702131851.jar
> set options=-cp %sdo_cp%
> org.apache.tuscany.sdo.generate.XSD2JavaGenerator -arrayAccessors
> -targetDirectory %output%
>
> %javaExe% %options% "%schemaLocation%\wd-sdd-common-1.0.xsd"
> %javaExe% %options%
"%schemaLocation%\wd-sdd-deploymentDescriptor-1.0.xsd"
> %javaExe% %options% "%schemaLocation%\wd-sdd-packageDescriptor-1.0.xsd"
> %javaExe% %options% "%schemaLocation%\xmldsig-core-schema.xsd"
>
> I've built the Tuscany SDO libraries from the 4/27 code in subversion
> with IBM's 1.4.2 JDK.
>
> Ok, with that out of the way, here is the problem I'm seeing:
>
> I have the following code:
>
> HelperContext context = SDOUtil.createHelperContext();
>
> context.getXSDHelper().define(new
> FileInputStream("./wd-sdd-common-1.0.xsd"), (new
> File("./wd-sdd-common-1.0.xsd")).toURI().toString());
> context.getXSDHelper().define(new
> FileInputStream("./wd-sdd-deploymentDescriptor-1.0.xsd"), (new
> File("./wd-sdd-deploymentDescriptor-1.0.xsd")).toURI().toString());
> context.getXSDHelper().define(new
> FileInputStream("./xmldsig-core-schema.xsd"), (new
> File("./xmldsig-core-schema.xsd")).toURI().toString());
>
> PackageDescriptorType pd =
> DescriptorFactory.INSTANCE.createPackageDescriptorType();
>
> PackageIdentityType identity =
> DescriptorFactory.INSTANCE.createPackageIdentityType();
>
> context.getXSDHelper().define(new
> FileInputStream("./Address.xsd"), (new
> File("./Address.xsd")).toURI().toString());
> DataObject address =
> context.getDataFactory().create("http://www.example.org/Address",
> "AddressType");
>
> address.set("Street", "123 Fake St.");
> address.set("City", "Springfield");
> address.set("Zip", "46392");
>
> Property addressProperty =
>
context.getXSDHelper().getGlobalProperty("http://www.example.org/Address",
> "Address", true);
> ((DataObject) identity).getList(addressProperty).add(address);
>
> context.getXMLHelper().save((DataObject) pd,
> "urn:oasis:names:tc:SDD:1:0:packageDescriptor", "PackageDescriptor",
> System.out);
>
> Similar to the other example, though now I'm initializing it using the
> statically generated classes. The call to getList() is throwing the
> following exception:
>
> Exception in thread "main" java.lang.NullPointerException
> at org.eclipse.emf.ecore.impl.BasicEObjectImpl.
> eOpenGet(BasicEObjectImpl.java:645)
> at org.eclipse.emf.ecore.impl.BasicEObjectImpl.
> eGet(BasicEObjectImpl.java(Compiled
> Code))
> at
org.apache.tuscany.sdo.impl.DataObjectImpl.get(DataObjectImpl.java:132)
> at org.apache.tuscany.sdo.util.DataObjectUtil.
> getList(DataObjectUtil.java:172)
> at org.apache.tuscany.sdo.impl.DataObjectImpl.
> getList(DataObjectImpl.java:995)
> at com.ibm.isd.mapper.impl.Test.anyTest_Static_PD(Test.java:116)
> at com.ibm.isd.mapper.impl.Test.main(Test.java:125)
>
> Thanks in advance for any pointers you can give,
> -Chris
>
> On 5/7/07, Frank Budinsky <[EMAIL PROTECTED]> wrote:
> > Sorry, I didn't notice that your xsd:any had maxOccurs > 1:
> >
> > > > <xsd:any namespace="##other" processContents="lax"
> > minOccurs="0" maxOccurs="unbounded"/>
> >
> > If it was maxOccurs="1" then you could do what I suggested.
> >
> > Because it is many valued, however, you need to do this:
> >
> > person.getList(addressProperty).add(address);
> >
> > Notice that the isMany value of a global property is not statically
known,
> > it depends on where it's being used.
> >
> > Frank.
> >
> >
> > [EMAIL PROTECTED] wrote on 05/07/2007 09:54:04 AM:
> >
> > > Hi Frank,
> > >
> > > I replaced my code with what you suggested:
> > >
> > > Property addressProperty =
> > >
> >
context.getXSDHelper().getGlobalProperty("http://www.example.org/Address",
> > > "Address",
> > > true);
> > > person.setDataObject(addressProperty, address);
> > >
> > > The call to setDataObject() generates the following exception:
> > >
> > > Exception in thread "main" java.lang.ClassCastException:
> > > org.apache.tuscany.sdo.impl.DynamicDataObjectImpl
> > > at org.eclipse.emf.ecore.util.BasicFeatureMap.
> > > set(BasicFeatureMap.java:1026)
> > > at org.eclipse.emf.ecore.impl.BasicEObjectImpl.
> > > eOpenSet(BasicEObjectImpl.java:723)
> > > at org.eclipse.emf.ecore.impl.BasicEObjectImpl.
> > > eSet(BasicEObjectImpl.java:658)
> > > at
> >
org.apache.tuscany.sdo.impl.DataObjectImpl.set(DataObjectImpl.java:142)
> > > at org.apache.tuscany.sdo.util.DataObjectUtil.
> > > setDataObject(DataObjectUtil.java:122)
> > > at org.apache.tuscany.sdo.impl.DataObjectImpl.
> > > setDataObject(DataObjectImpl.java:1105)
> > > at com.ibm.isd.mapper.impl.Test.main(Test.java:33)
> > >
> > >
> > > Any Ideas? Thanks for your help this far,
> > >
> > > -Chris
> > >
> > > On 5/7/07, Frank Budinsky <[EMAIL PROTECTED]> wrote:
> > > > Hi Chris,
> > > >
> > > > The problem is this line of code:
> > > >
> > > > > person.setDataObject("address:Address", address);
> > > >
> > > > SDO doesn't support qualified names in string (path) get/set
methods.
> > > > That's why it ignores the "address:" prefix, and simply
demand-creates
> > > > another "Address" property ("PersonType:address").
> > > >
> > > > To accomplish what you want, you can explicitly locate the
> > address:Address
> > > > property like this:
> > > >
> > > > Property addressProperty =
> > > > xsdHelper.getGlobalProperty("http://www.example.org/Address",
> > "Address",
> > > > true);
> > > >
> > > > Then you can set it like this:
> > > >
> > > > person.setDataObject(addressProperty, address);
> > > >
> > > > Frank.
> > > >
> > > >
> > > > [EMAIL PROTECTED] wrote on 05/06/2007 04:08:33 PM:
> > > >
> > > > > Hi Frank (or anyone else that may be able to help),
> > > > >
> > > > > I have a related question to Ashish's. I have the following two
> > schemas:
> > > > >
> > > > > <?xml version="1.0" encoding="UTF-8"?>
> > > > > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> > > > > targetNamespace="http://www.example.org/Person"
> > > > > xmlns:person="http://www.example.org/Person"
> > > > > elementFormDefault="qualified">
> > > > > <xsd:element name="Person"
> > type="person:PersonType"></xsd:element>
> > > > >
> > > > > <xsd:complexType name="PersonType">
> > > > > <xsd:sequence>
> > > > > <xsd:element name="Name"
type="xsd:string"></xsd:element>
> > > > > <xsd:element name="Age"
type="xsd:string"></xsd:element>
> > > > > <xsd:any namespace="##other" processContents="lax"
> > > > minOccurs="0"
> > > > > maxOccurs="unbounded"/>
> > > > > </xsd:sequence>
> > > > > </xsd:complexType>
> > > > > </xsd:schema>
> > > > >
> > > > > <?xml version="1.0" encoding="UTF-8"?>
> > > > > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> > > > > targetNamespace="http://www.example.org/Address"
> > > > > xmlns:address="http://www.example.org/Address"
> > > > > elementFormDefault="qualified">
> > > > >
> > > > > <xsd:element name="Address"
> > > > type="address:AddressType"></xsd:element>
> > > > >
> > > > > <xsd:complexType name="AddressType">
> > > > > <xsd:sequence>
> > > > > <xsd:element name="Street"
> > type="xsd:string"></xsd:element>
> > > > > <xsd:element name="City"
type="xsd:string"></xsd:element>
> > > > > <xsd:element name="Zip"
type="xsd:string"></xsd:element>
> > > > > </xsd:sequence>
> > > > > </xsd:complexType>
> > > > > </xsd:schema>
> > > > >
> > > > >
> > > > > I use the following code to generate my XML:
> > > > >
> > > > > public static void main(String[] args) throws Exception
> > > > > {
> > > > > HelperContext context = SDOUtil.createHelperContext();
> > > > >
> > > > > context.getXSDHelper().define(new
> > > > > FileInputStream("./Person.xsd"), (new
> > > > > File("./Base.xsd")).toURI().toString());
> > > > > context.getXSDHelper().define(new
> > > > > FileInputStream("./Address.xsd"), (new
> > > > > File("./Additional.xsd")).toURI().toString());
> > > > >
> > > > > DataObject person =
> > > > > context.getDataFactory().create("http://www.example.org/Person",
> > > > > "PersonType");
> > > > > DataObject address =
> > > > >
context.getDataFactory().create("http://www.example.org/Address",
> > > > > "AddressType");
> > > > >
> > > > > person.set("Name", "Bart");
> > > > > person.set("Age", "10");
> > > > >
> > > > > address.set("Street", "123 Fake St.");
> > > > > address.set("City", "Springfield");
> > > > > address.set("Zip", "46392");
> > > > >
> > > > > person.setDataObject("address:Address", address);
> > > > >
> > > > > context.getXMLHelper().save(person,
> > > > > "http://www.example.org/Person", "Person", System.out);
> > > > > }
> > > > >
> > > > > This gives the following XML:
> > > > >
> > > > > <?xml version="1.0" encoding="ASCII"?>
> > > > > <person:Person
> > > > xmlns:PersonType="http://www.example.org/Person/PersonType"
> > > > > xmlns:address="http://www.example.org/Address"
> > > > > xmlns:person="http://www.example.org/Person">
> > > > > <person:Name>Bart</person:Name>
> > > > > <person:Age>10</person:Age>
> > > > > <PersonType:Address>
> > > > > <address:Street>123 Fake St.</address:Street>
> > > > > <address:City>Springfield</address:City>
> > > > > <address:Zip>46392</address:Zip>
> > > > > </PersonType:Address>
> > > > > </person:Person>
> > > > >
> > > > > My concern is the "PersonType:Address" element. I'd like that to
be
> > > > > "address:Address" instead. Am I doing something wrong in my
schema
> > > > > definitions and/or code?
> > > > >
> > > > > Thanks for any help you can provide,
> > > > > -Chris
> > > > >
> > > > > On 4/16/07, Frank Budinsky <[EMAIL PROTECTED]> wrote:
> > > > > > Ashish,
> > > > > >
> > > > > > I implemented the on-the-fly property creation support over
the
> > > > weekend
> > > > > > (see https://issues.apache.org/jira/browse/TUSCANY-1211).
> > > > > >
> > > > > > You should now be able to do what you asked:
> > > > > >
> > > > > > body.setDataObject("anyType",DataObject);
> > > > > >
> > > > > > Let me know how it works.
> > > > > >
> > > > > > Thanks,
> > > > > > Frank
> > > > > >
> > > > >
> > > > >
> > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > > >
> > > >
> > > >
> > > >
---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > >
> > > >
> > >
> > >
---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]