Hi,
Here's another issue with the packageDescriptor. When I set the
softwareID attribute on the packageIdentity I get the following
exception when saving:
Exception in thread "main" java.lang.ClassCastException: java.lang.String
at
org.apache.tuscany.sdo.util.resource.SDOXMLResourceImpl$SDOXMLSaveImpl.saveElementFeatureMap(SDOXMLResourceImpl.java:753)
at
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1355)
at
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XMLSaveImpl.java:2462)
at
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:1036)
at
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:922)
at
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveContainedSingle(XMLSaveImpl.java:2169)
at
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1384)
at
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XMLSaveImpl.java:2462)
at
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:1036)
at
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:922)
at
org.apache.tuscany.sdo.util.resource.SDOXMLResourceImpl$SDOXMLSaveImpl.saveElementFeatureMap(SDOXMLResourceImpl.java:771)
at
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1355)
at
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.writeTopObject(XMLSaveImpl.java:627)
at
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveImpl.java:552)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl.java:233)
at
org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doSave(XMLResourceImpl.java:203)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:993)
at
org.apache.tuscany.sdo.helper.XMLDocumentImpl.save(XMLDocumentImpl.java:205)
at
org.apache.tuscany.sdo.helper.XMLDocumentImpl.save(XMLDocumentImpl.java:159)
at
org.apache.tuscany.sdo.helper.XMLHelperImpl.save(XMLHelperImpl.java:139)
at
org.apache.tuscany.sdo.helper.XMLHelperImpl.save(XMLHelperImpl.java:134)
at com.ibm.isd.mapper.impl.Test.anyTest_Static_PD(Test.java:118)
at com.ibm.isd.mapper.impl.Test.main(Test.java:125)
Here's the corresponding code:
HelperContext context = SDOUtil.createHelperContext();
oasis.names.tc.sdd._1._0.deployment.descriptor.DescriptorFactory.INSTANCE.register(context);
oasis.names.tc.sdd._1._0.package_.descriptor.DescriptorFactory.INSTANCE.register(context);
oasis.names.tc.sdd._1._0.common.CommonFactory.INSTANCE.register(context);
org.w3._2000._09.xmldsig.XmldsigFactory.INSTANCE.register(context);
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");
identity.setSoftwareID("test");
pd.setPackageIdentity(identity);
context.getXMLHelper().save((DataObject) pd,
"urn:oasis:names:tc:SDD:1:0:packageDescriptor", "PackageDescriptor",
System.out);
I think this may be related to me not being able to set my custom
schema elements in the any element. Please let me know if you need any
additional information.
Thanks,
-Chris
On 5/8/07, Chris Mildebrandt <[EMAIL PROTECTED]> wrote:
Hi Fuhwei,
Perhaps it would help to see what works and what doesn't work. This code works:
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("./wd-sdd-packageDescriptor-1.0.xsd"), (new
File("./wd-sdd-packageDescriptor-1.0.xsd")).toURI().toString());
context.getXSDHelper().define(new
FileInputStream("./xmldsig-core-schema.xsd"), (new
File("./xmldsig-core-schema.xsd")).toURI().toString());
DataObject pd =
context.getDataFactory().create("urn:oasis:names:tc:SDD:1:0:packageDescriptor",
"PackageDescriptorType");
DataObject identity = pd.createDataObject("PackageIdentity");
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);
identity.getList(addressProperty).add(address);
context.getXMLHelper().save(pd,
"urn:oasis:names:tc:SDD:1:0:packageDescriptor", "PackageDescriptor",
System.out);
This code fails at the getList():
HelperContext context = SDOUtil.createHelperContext();
oasis.names.tc.sdd._1._0.deployment.descriptor.DescriptorFactory.INSTANCE.register(context);
oasis.names.tc.sdd._1._0.package_.descriptor.DescriptorFactory.INSTANCE.register(context);
oasis.names.tc.sdd._1._0.common.CommonFactory.INSTANCE.register(context);
org.w3._2000._09.xmldsig.XmldsigFactory.INSTANCE.register(context);
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);
I'm defining the Address the same in both cases. In the first case,
I'm fully dynamic. In the second case, I'm using the static SDOs.
Let me know if I can help narrow this down further. Thanks!
-Chris
On 5/8/07, Fuhwei Lwo <[EMAIL PROTECTED]> wrote:
> Hi Chris,
>
> I think what you did below should work except the addressProperty is null.
Can you make sure your addressProperty is not null (make sure your namespace and
property name are accurate.)
>
>
> ((DataObject)
> identity).getList(addressProperty).add(address);
>
> Here is what I did and it works.
>
> <xsd:schema
> xmlns:open="http://www.example.com/open2"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://www.example.com/open2">
>
> <xsd:element name="address" type="open:Address"/>
> <xsd:complexType name="Address">
> <xsd:sequence>
> <xsd:element name="City" type="xsd:string"/>
> <xsd:element name="Zip" type="xsd:string"/>
> </xsd:sequence>
> </xsd:complexType>
>
> </xsd:schema>
>
> Property addressProperty =
hc.getXSDHelper().getGlobalProperty("http://www.example.com/open2", "address",
true);
>
> DataObject addressSdo2 = hc.getDataFactory().create("http://www.example.com/open2",
"Address");
> addressSdo2.setString("City", "Raleigh");
> addressSdo2.setString("Zip", "27550");
> List addresses = ((DataObject)openQuote).getList(addressProperty);
> addresses.add(addressSdo2);
>
> Fuhwei
>
> Chris Mildebrandt <[EMAIL PROTECTED]> wrote: Hi Fuhwei,
>
> The getSequence() returned null. The getAny() returned a BasicSequence
> object. I added my custom DataObject without error, but it didn't
> display in my output when I wrote the DataObject back out..
>
> Thanks for your help so far. Do you have something else you'd like me to try?
> -Chris
>
> On 5/7/07, Fuhwei Lwo wrote:
> > Hi Chris,
> >
> > It seems you have generated static data API for the PackageIdentityType so your
generated Java class should have a "Sequence getAny()" method. I think you should be
able to do something like this:
> >
> > ((DataObject) identity).getSequence().add(addressProperty, address);
> >
> > or
> >
> > identity.getAny().add(addressProperty, address);
> >
> > Can you try it? Thanks.
> >
> > Fuhwei
> >
> > Chris Mildebrandt wrote: Hello,
> >
> > We have another issue related to 1 and 4 below. We have an "any"
> > element defined by the common schema in the identity element. The
> > packageDescriptor schema defines the packageIdentity element, which
> > extends the identity element in the common schema. I'm running the
> > following code:
> >
> > HelperContext context = SDOUtil.createHelperContext();
> >
> >
oasis.names.tc.sdd._1._0.deployment.descriptor.DescriptorFactory.INSTANCE.register(context);
> >
oasis.names.tc.sdd._1._0.package_.descriptor.DescriptorFactory.INSTANCE.register(context);
> >
oasis.names.tc.sdd._1._0.common.CommonFactory.INSTANCE.register(context);
> > org.w3._2000._09.xmldsig.XmldsigFactory.INSTANCE.register(context);
> >
> > 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);
> >
> > PackageDescriptorType pd =
> > DescriptorFactory.INSTANCE.createPackageDescriptorType();
> > PackageIdentityType identity =
> > DescriptorFactory.INSTANCE.createPackageIdentityType();
> >
> > ((DataObject) identity).getList(addressProperty).add(address);
> >
> > context.getXMLHelper().save((DataObject) pd,
> > "urn:oasis:names:tc:SDD:1:0:packageDescriptor", "PackageDescriptor",
> > System.out);
> >
> > When the getList() method is called, I get the following error:
> >
> > 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:117)
> > at com.ibm.isd.mapper.impl.Test.main(Test.java:126)
> >
> > The problem has to do with a bogus featureID being passed into one of
> > the EMF methods. I need it to return the ANY ID, but I end up getting
> > the ID of an attribute. The attribute I'm getting is the SoftwareID
> > attribute mentioned in my issue 4.
> >
> > Please let me know if you have any insight to this. Thanks,
> > -Chris
> >
> > On 5/7/07, Chris Mildebrandt wrote:
> > > Hello,
> > >
> > > I'm having issues generating static SDOs from my schema. 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 5/6 code in subversion
> > > with IBM's 1.4.2 JDK.
> > >
> > > Ok, with that out of the way, here are the problems I'm seeing:
> > >
> > > 1) Load the generated classes into Eclipse and you'll see this error.
> > > identityTypeType isn't defined. In
> > > oasis.names.tc.sdd._1._0.package_.descriptor.impl.DescriptorFactoryImpl
> > > the following line:
> > >
> > > addSuperType(packageIdentityTypeType, identityTypeType);
> > >
> > > seems like it should be:
> > >
> > > addSuperType(packageIdentityTypeType,
theCommonPackageImpl.getIdentityType());
> > >
> > > Let me know if that is correct.
> > >
> > >
> > > 2) There are a few 2-dimensional arrays being created incorrectly as a
> > > part of xmldsig-core-schema.xsd. For example:
> > >
> > > protected static final byte[][] X509SKI_EEMPTY_ARRAY = new byte[] [0];
> > >
> > > should probably be:
> > >
> > > protected static final byte[][] X509SKI_EEMPTY_ARRAY = new byte[0] [0];
> > >
> > > Let me know if that sounds correct as well.
> > >
> > > 3) This problem just appeared in the past week. I think it may have to
> > > do with issue 1223. After generating the classes from
> > > xmldsig-core-schema.xsd, I get problems with the code generated around
> > > the base64 types. I get errors stating the methods from
> > > XMLTypeFactoryImpl don't exist. Perhaps it's my version of EMF? I've
> > > used 2.2.2, 2.2.3, and 2.3.0, but none solved my problem.
> > >
> > > 4) This is a runtime issue, but it may have to do with issue 1 above.
> > > This was last tested with the Tuscany SDO code built on 4/27.
> > >
> > > I'm getting the following error:
> > >
> > > java.lang.ClassCastException: java.lang.String
> > > at
org.apache.tuscany.sdo.util.resource.SDOXMLResourceImpl$SDOXMLSaveImpl.saveElementFeatureMap(SDOXMLResourceImpl.java:753)
> > > at
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1352)
> > > at
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XMLSaveImpl.java:2459)
> > > at
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:1033)
> > > at
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:919)
> > > at
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveContainedSingle(XMLSaveImpl.java:2166)
> > > at
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1381)
> > > at
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XMLSaveImpl.java:2459)
> > > at
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:1033)
> > > at
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSaveImpl.java:919)
> > > at
org.apache.tuscany.sdo.util.resource.SDOXMLResourceImpl$SDOXMLSaveImpl.saveElementFeatureMap(SDOXMLResourceImpl.java:771)
> > > at
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLSaveImpl.java:1352)
> > > at
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.writeTopObject(XMLSaveImpl.java:624)
> > > at
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveImpl.java:549)
> > > at
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl.java:233)
> > > at
org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doSave(XMLResourceImpl.java:203)
> > > at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:993)
> > > at
org.apache.tuscany.sdo.helper.XMLDocumentImpl.save(XMLDocumentImpl.java:184)
> > > at
org.apache.tuscany.sdo.helper.XMLHelperImpl.save(XMLHelperImpl.java:115)
> > > at
org.apache.tuscany.sdo.helper.XMLHelperImpl.save(XMLHelperImpl.java:110)
> > > at SimpleStaticTest.descriptorTest(SimpleStaticTest.java:47)
> > > at
SimpleStaticTest.packageDescriptorTest(SimpleStaticTest.java:59)
> > > at SimpleStaticTest.main(SimpleStaticTest.java:69)
> > >
> > > When reading in this file:
> > >
> > >
> > >
> > >
descriptorLanguageBundle="com.ibm.res.translations"
> > > lastModified="2001-12-31T12:00:00"
> > > schemaVersion="1.0"
> > > xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
> > >
xmlns:sdd-common="urn:oasis:names:tc:SDD:1:0:common"
> > >
> > > xmlns:sdd-pd="urn:oasis:names:tc:SDD:1:0:packageDescriptor"
> > >
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > >
> > > xsi:schemaLocation="urn:oasis:names:tc:SDD:1:0:packageDescriptor
> > > ../../schema/sdd-20070403_36/wd-sdd-packageDescriptor-1.0.xsd
> > >
> > > http://www.w3.org/2000/09/xmldsig#
> > > http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd
> > >
> > > urn:oasis:names:tc:SDD:1:0:common
> > > ../../schema/sdd-20070403_36/wd-sdd-common-1.0.xsd ">
> > >
> >
> > > Shopping
> > > Shopping Cart Package
> > > Shopping
> > > Cart
> > > 4.5
> > >
> >
> > >
> > >
> > > purpose="content">
> > >
> > >
> > >
> > >
> > >
> > >
> > > with this code:
> > >
> > > HelperContext context = SDOUtil.createHelperContext();
> > >
oasis.names.tc.sdd._1._0.deployment.descriptor.DescriptorFactory.INSTANCE.register(context);
> > >
oasis.names.tc.sdd._1._0.package_.descriptor.DescriptorFactory.INSTANCE.register(context);
> > >
oasis.names.tc.sdd._1._0.common.CommonFactory.INSTANCE.register(context);
> > >
org.w3._2000._09.xmldsig.XmldsigFactory.INSTANCE.register(context);
> > >
> > > InputStream in = new
File(shoppingCart-pd-4.5.xml).toURL().openStream();
> > > XMLDocument doc = context.getXMLHelper().load(in);
> > > in.close();
> > >
> > > DataObject descriptor = doc.getRootObject();
> > >
> > > context.getXMLHelper().save(descriptor,
> > > doc.getRootElementURI(), doc.getRootElementName(), System.out);
> > >
> > > It has to do with the softwareID attribute in the PackageIdentity
> > > element in the xml file above. For some reason, the code is getting a
> > > String returned when it's expecting a List. When I remove the
> > > softwareID attribute, it runs fine. I think this is related to issue 1
> > > above.
> > >
> > > Please let me know if these problems can be resolved. Issue 3 and 4
> > > are the two problems we're unable to work around currently.
> > >
> > > Thanks,
> > > -Chris
> > >
> >
> > ---------------------------------------------------------------------
> > 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]