You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by Ashish Panchal <as...@yash.com> on 2007/04/11 18:00:50 UTC

xsd:any problem

Hi,

Iam trying to create a dataobject of xsd which has one of the element as <xsd:any> type. Sample is -

<xsd:element name="ServiceInput" type="ServiceInputType"/>
 
 <xsd:complexType name="ServiceInputType">
  <xsd:sequence>
   <xsd:element minOccurs="0" ref="header"/>
   <xsd:element minOccurs="0" ref="body"/>
  </xsd:sequence>
 </xsd:complexType>

<xsd:element name="body">  
  <xsd:complexType>  
   <xsd:sequence>   
    <xsd:any maxOccurs="1" minOccurs="1" processContents="lax"/>   
   </xsd:sequence>   
  </xsd:complexType>   
 </xsd:element>


The <xsd:any> is used to allow different xml under the 'body' element, as the incoming xml structure is not fixed.
Data object for this xsd is created, but Iam not able to set the dataobject of the variable xml structure under the 'body' element.

I would appreciate any help.

Thanks
Ashish

Re: xsd:any problem

Posted by Chris Mildebrandt <ch...@plasticfrog.info>.
Just to complete this thread, this is being tracked as issue 1254.

-Chris

On 5/8/07, Frank Budinsky <fr...@ca.ibm.com> wrote:
> Hi Chris,
>
> Can you confirm that the cross-package inheritance is the problem by
> creating a similar subtype in the same package and see if it works? It
> should be pretty simple to fix this generator problem, but it would be
> helpful if you could provide a simple test case for us.
>
> Adding open content to an object is an intrinsically dynamic task and
> should be done using the dynamic API, even if the type is static. In other
> words, ask you suggested, this is the way to do it and it should work if
> there are no bugs:
>
> ((DataObject) identity).getList(addressProperty).add(address);
>
> Thanks,
> Frank.
>
> eyeofthefrog@gmail.com wrote on 05/07/2007 04:44:01 PM:
>
> > Hi Frank,
> >
> > I think I've tracked this problem down to an issue with static class
> > generation. The common schema contains the any element in the identity
> > element. The packageIdentity element in the packageDescriptor schema
> > extends the identity element. Some things aren't quite right in the
> > class generation with respect to that. I wrote a note to the dev
> > mailing list explaining some of my issues. Seems this is a new issue
> > related to my other issue. I'll update my note with my new findings.
> >
> > On a side note, adding content to the any element works when accessing
> > the dynamic methods. Is there a way to take my instance of my
> > statically generated class and use the dynamic methods for this set,
> > and then go back to editing using the statically generated objects?
> > Casting to DataObject doesn't seem to work:
> >
> > ((DataObject) identity).getList(addressProperty).add(address);
> >
> > Thanks,
> >
> > -Chris
> >
> > On 5/7/07, Frank Budinsky <fr...@ca.ibm.com> wrote:
> > > 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
> > >
> > >
> > > eyeofthefrog@gmail.com 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 <fr...@ca.ibm.com> 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.
> > > > >
> > > > >
> > > > > eyeofthefrog@gmail.com 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 <fr...@ca.ibm.com> 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.
> > > > > > >
> > > > > > >
> > > > > > > eyeofthefrog@gmail.com 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 <fr...@ca.ibm.com> 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:
> tuscany-user-unsubscribe@ws.apache.org
> > > > > > > > For additional commands, e-mail:
> tuscany-user-help@ws.apache.org
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > ---------------------------------------------------------------------
> > > > > > > To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> > > > > > > For additional commands, e-mail:
> tuscany-user-help@ws.apache.org
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> > > > > > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> > > > > >
> > > > >
> > > > >
> > > > >
> ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> > > > > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> > > > >
> > > > >
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> > > > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> > > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-user-help@ws.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-user-help@ws.apache.org


Re: xsd:any problem

Posted by Frank Budinsky <fr...@ca.ibm.com>.
Hi Chris,

Can you confirm that the cross-package inheritance is the problem by 
creating a similar subtype in the same package and see if it works? It 
should be pretty simple to fix this generator problem, but it would be 
helpful if you could provide a simple test case for us.

Adding open content to an object is an intrinsically dynamic task and 
should be done using the dynamic API, even if the type is static. In other 
words, ask you suggested, this is the way to do it and it should work if 
there are no bugs:

((DataObject) identity).getList(addressProperty).add(address);

Thanks,
Frank.

eyeofthefrog@gmail.com wrote on 05/07/2007 04:44:01 PM:

> Hi Frank,
> 
> I think I've tracked this problem down to an issue with static class
> generation. The common schema contains the any element in the identity
> element. The packageIdentity element in the packageDescriptor schema
> extends the identity element. Some things aren't quite right in the
> class generation with respect to that. I wrote a note to the dev
> mailing list explaining some of my issues. Seems this is a new issue
> related to my other issue. I'll update my note with my new findings.
> 
> On a side note, adding content to the any element works when accessing
> the dynamic methods. Is there a way to take my instance of my
> statically generated class and use the dynamic methods for this set,
> and then go back to editing using the statically generated objects?
> Casting to DataObject doesn't seem to work:
> 
> ((DataObject) identity).getList(addressProperty).add(address);
> 
> Thanks,
> 
> -Chris
> 
> On 5/7/07, Frank Budinsky <fr...@ca.ibm.com> wrote:
> > 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
> >
> >
> > eyeofthefrog@gmail.com 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 <fr...@ca.ibm.com> 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.
> > > >
> > > >
> > > > eyeofthefrog@gmail.com 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 <fr...@ca.ibm.com> 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.
> > > > > >
> > > > > >
> > > > > > eyeofthefrog@gmail.com 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 <fr...@ca.ibm.com> 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: 
tuscany-user-unsubscribe@ws.apache.org
> > > > > > > For additional commands, e-mail: 
tuscany-user-help@ws.apache.org
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > ---------------------------------------------------------------------
> > > > > > To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> > > > > > For additional commands, e-mail: 
tuscany-user-help@ws.apache.org
> > > > > >
> > > > > >
> > > > >
> > > > >
> > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> > > > > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> > > > >
> > > >
> > > >
> > > > 
---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> > > > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> > > >
> > > >
> > >
> > > 
---------------------------------------------------------------------
> > > To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> > > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-user-help@ws.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-user-help@ws.apache.org


Re: xsd:any problem

Posted by Chris Mildebrandt <ch...@plasticfrog.info>.
Hi Frank,

I think I've tracked this problem down to an issue with static class
generation. The common schema contains the any element in the identity
element. The packageIdentity element in the packageDescriptor schema
extends the identity element. Some things aren't quite right in the
class generation with respect to that. I wrote a note to the dev
mailing list explaining some of my issues. Seems this is a new issue
related to my other issue. I'll update my note with my new findings.

On a side note, adding content to the any element works when accessing
the dynamic methods. Is there a way to take my instance of my
statically generated class and use the dynamic methods for this set,
and then go back to editing using the statically generated objects?
Casting to DataObject doesn't seem to work:

((DataObject) identity).getList(addressProperty).add(address);

Thanks,

-Chris

On 5/7/07, Frank Budinsky <fr...@ca.ibm.com> wrote:
> 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
>
>
> eyeofthefrog@gmail.com 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 <fr...@ca.ibm.com> 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.
> > >
> > >
> > > eyeofthefrog@gmail.com 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 <fr...@ca.ibm.com> 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.
> > > > >
> > > > >
> > > > > eyeofthefrog@gmail.com 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 <fr...@ca.ibm.com> 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: tuscany-user-unsubscribe@ws.apache.org
> > > > > > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> > > > > >
> > > > >
> > > > >
> > > > >
> ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> > > > > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> > > > >
> > > > >
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> > > > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> > > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-user-help@ws.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-user-help@ws.apache.org


Re: xsd:any problem

Posted by Frank Budinsky <fr...@ca.ibm.com>.
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


eyeofthefrog@gmail.com 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 <fr...@ca.ibm.com> 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.
> >
> >
> > eyeofthefrog@gmail.com 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 <fr...@ca.ibm.com> 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.
> > > >
> > > >
> > > > eyeofthefrog@gmail.com 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 <fr...@ca.ibm.com> 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: tuscany-user-unsubscribe@ws.apache.org
> > > > > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> > > > >
> > > >
> > > >
> > > > 
---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> > > > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> > > >
> > > >
> > >
> > > 
---------------------------------------------------------------------
> > > To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> > > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-user-help@ws.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-user-help@ws.apache.org


Re: xsd:any problem

Posted by Chris Mildebrandt <ch...@plasticfrog.info>.
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 <fr...@ca.ibm.com> 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.
>
>
> eyeofthefrog@gmail.com 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 <fr...@ca.ibm.com> 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.
> > >
> > >
> > > eyeofthefrog@gmail.com 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 <fr...@ca.ibm.com> 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: tuscany-user-unsubscribe@ws.apache.org
> > > > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> > > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> > > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-user-help@ws.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-user-help@ws.apache.org


Re: xsd:any problem

Posted by Frank Budinsky <fr...@ca.ibm.com>.
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.


eyeofthefrog@gmail.com 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 <fr...@ca.ibm.com> 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.
> >
> >
> > eyeofthefrog@gmail.com 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 <fr...@ca.ibm.com> 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: tuscany-user-unsubscribe@ws.apache.org
> > > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-user-help@ws.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-user-help@ws.apache.org


Re: xsd:any problem

Posted by Chris Mildebrandt <ch...@plasticfrog.info>.
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 <fr...@ca.ibm.com> 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.
>
>
> eyeofthefrog@gmail.com 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 <fr...@ca.ibm.com> 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: tuscany-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-user-help@ws.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-user-help@ws.apache.org


Re: xsd:any problem

Posted by Frank Budinsky <fr...@ca.ibm.com>.
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.


eyeofthefrog@gmail.com 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 <fr...@ca.ibm.com> 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: tuscany-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-user-help@ws.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-user-help@ws.apache.org


Re: xsd:any problem

Posted by Chris Mildebrandt <tu...@plasticfrog.info>.
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 <fr...@ca.ibm.com> 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: tuscany-user-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-user-help@ws.apache.org


Re: xsd:any problem

Posted by Frank Budinsky <fr...@ca.ibm.com>.
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


"Ashish Panchal" <as...@yash.com> wrote on 04/12/2007 10:44:13 AM:

> Thanks for reply Frank,
> 
> I tried, but Iam not able to find any method 'getOpenContentProperty' in
> commonj.sdo.helper.TypeHelper. It seems that this method will return a
> property. What Iam trying to do is something  like -
> 
> body.setDataObject("anyType",DataObject);
> 
> where anyType is defined in schema as  -
> <xsd:complexType>
>     <xsd:sequence>
>         <xsd:any maxOccurs="1" minOccurs="1" />
>     </xsd:sequence>
>  </xsd:complexType>
> 
> and DataObject is the object created by arbitrary input xml.
> 
> Ashish
> 
> 
> ----- Original Message ----- 
> From: "Frank Budinsky" <fr...@ca.ibm.com>
> To: <tu...@ws.apache.org>
> Sent: Wednesday, April 11, 2007 11:12 PM
> Subject: Re: xsd:any problem
> 
> 
> > Hi Ashish,
> >
> > I'm not sure what you tried, but something like this should work:
> >
> >   body.setDataObject(typeHelper.getOpenContentProperty("the target
> > namespace???", "ServiceInput"), value);
> >
> > Frank.
> >
> > "Ashish Panchal" <as...@yash.com> wrote on 04/11/2007 12:00:50 PM:
> >
> > > Hi,
> > >
> > > Iam trying to create a dataobject of xsd which has one of the
> > > element as <xsd:any> type. Sample is -
> > >
> > > <xsd:element name="ServiceInput" type="ServiceInputType"/>
> > >
> > >  <xsd:complexType name="ServiceInputType">
> > >   <xsd:sequence>
> > >    <xsd:element minOccurs="0" ref="header"/>
> > >    <xsd:element minOccurs="0" ref="body"/>
> > >   </xsd:sequence>
> > >  </xsd:complexType>
> > >
> > > <xsd:element name="body">
> > >   <xsd:complexType>
> > >    <xsd:sequence>
> > >     <xsd:any maxOccurs="1" minOccurs="1" processContents="lax"/>
> > >    </xsd:sequence>
> > >   </xsd:complexType>
> > >  </xsd:element>
> > >
> > >
> > > The <xsd:any> is used to allow different xml under the 'body'
> > > element, as the incoming xml structure is not fixed.
> > > Data object for this xsd is created, but Iam not able to set the
> > > dataobject of the variable xml structure under the 'body' element.
> > >
> > > I would appreciate any help.
> > >
> > > Thanks
> > > Ashish
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> >
> >
> >
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-user-help@ws.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-user-help@ws.apache.org


Re: xsd:any problem

Posted by Frank Budinsky <fr...@ca.ibm.com>.
Ashish,

It sounds like what you want is a new feature in SDO version 2.1, 
on-the-fly creation of open content properties. Unfortunately, we haven't 
implemented that in Tuscany yet. For now, you'll need to use an existing 
open content property (global element), like I showed below, or explicitly 
create the open content property before calling set.

See section 3.1.9 of the SDO specification: 
http://osoa.org/download/attachments/36/Java-SDO-Spec-v2.1.0-FINAL.pdf?version=1

Frank.


"Ashish Panchal" <as...@yash.com> wrote on 04/12/2007 10:44:13 AM:

> Thanks for reply Frank,
> 
> I tried, but Iam not able to find any method 'getOpenContentProperty' in
> commonj.sdo.helper.TypeHelper. It seems that this method will return a
> property. What Iam trying to do is something  like -
> 
> body.setDataObject("anyType",DataObject);
> 
> where anyType is defined in schema as  -
> <xsd:complexType>
>     <xsd:sequence>
>         <xsd:any maxOccurs="1" minOccurs="1" />
>     </xsd:sequence>
>  </xsd:complexType>
> 
> and DataObject is the object created by arbitrary input xml.
> 
> Ashish
> 
> 
> ----- Original Message ----- 
> From: "Frank Budinsky" <fr...@ca.ibm.com>
> To: <tu...@ws.apache.org>
> Sent: Wednesday, April 11, 2007 11:12 PM
> Subject: Re: xsd:any problem
> 
> 
> > Hi Ashish,
> >
> > I'm not sure what you tried, but something like this should work:
> >
> >   body.setDataObject(typeHelper.getOpenContentProperty("the target
> > namespace???", "ServiceInput"), value);
> >
> > Frank.
> >
> > "Ashish Panchal" <as...@yash.com> wrote on 04/11/2007 12:00:50 PM:
> >
> > > Hi,
> > >
> > > Iam trying to create a dataobject of xsd which has one of the
> > > element as <xsd:any> type. Sample is -
> > >
> > > <xsd:element name="ServiceInput" type="ServiceInputType"/>
> > >
> > >  <xsd:complexType name="ServiceInputType">
> > >   <xsd:sequence>
> > >    <xsd:element minOccurs="0" ref="header"/>
> > >    <xsd:element minOccurs="0" ref="body"/>
> > >   </xsd:sequence>
> > >  </xsd:complexType>
> > >
> > > <xsd:element name="body">
> > >   <xsd:complexType>
> > >    <xsd:sequence>
> > >     <xsd:any maxOccurs="1" minOccurs="1" processContents="lax"/>
> > >    </xsd:sequence>
> > >   </xsd:complexType>
> > >  </xsd:element>
> > >
> > >
> > > The <xsd:any> is used to allow different xml under the 'body'
> > > element, as the incoming xml structure is not fixed.
> > > Data object for this xsd is created, but Iam not able to set the
> > > dataobject of the variable xml structure under the 'body' element.
> > >
> > > I would appreciate any help.
> > >
> > > Thanks
> > > Ashish
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: tuscany-user-help@ws.apache.org
> >
> >
> >
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-user-help@ws.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-user-help@ws.apache.org


Re: xsd:any problem

Posted by Ashish Panchal <as...@yash.com>.
Thanks for reply Frank,

I tried, but Iam not able to find any method 'getOpenContentProperty' in
commonj.sdo.helper.TypeHelper. It seems that this method will return a
property. What Iam trying to do is something  like -

body.setDataObject("anyType",DataObject);

where anyType is defined in schema as  -
<xsd:complexType>
    <xsd:sequence>
        <xsd:any maxOccurs="1" minOccurs="1" />
    </xsd:sequence>
 </xsd:complexType>

and DataObject is the object created by arbitrary input xml.

Ashish


----- Original Message ----- 
From: "Frank Budinsky" <fr...@ca.ibm.com>
To: <tu...@ws.apache.org>
Sent: Wednesday, April 11, 2007 11:12 PM
Subject: Re: xsd:any problem


> Hi Ashish,
>
> I'm not sure what you tried, but something like this should work:
>
>   body.setDataObject(typeHelper.getOpenContentProperty("the target
> namespace???", "ServiceInput"), value);
>
> Frank.
>
> "Ashish Panchal" <as...@yash.com> wrote on 04/11/2007 12:00:50 PM:
>
> > Hi,
> >
> > Iam trying to create a dataobject of xsd which has one of the
> > element as <xsd:any> type. Sample is -
> >
> > <xsd:element name="ServiceInput" type="ServiceInputType"/>
> >
> >  <xsd:complexType name="ServiceInputType">
> >   <xsd:sequence>
> >    <xsd:element minOccurs="0" ref="header"/>
> >    <xsd:element minOccurs="0" ref="body"/>
> >   </xsd:sequence>
> >  </xsd:complexType>
> >
> > <xsd:element name="body">
> >   <xsd:complexType>
> >    <xsd:sequence>
> >     <xsd:any maxOccurs="1" minOccurs="1" processContents="lax"/>
> >    </xsd:sequence>
> >   </xsd:complexType>
> >  </xsd:element>
> >
> >
> > The <xsd:any> is used to allow different xml under the 'body'
> > element, as the incoming xml structure is not fixed.
> > Data object for this xsd is created, but Iam not able to set the
> > dataobject of the variable xml structure under the 'body' element.
> >
> > I would appreciate any help.
> >
> > Thanks
> > Ashish
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-user-help@ws.apache.org
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-user-help@ws.apache.org


Re: xsd:any problem

Posted by Frank Budinsky <fr...@ca.ibm.com>.
Hi Ashish,

I'm not sure what you tried, but something like this should work:

  body.setDataObject(typeHelper.getOpenContentProperty("the target 
namespace???", "ServiceInput"), value);

Frank.

"Ashish Panchal" <as...@yash.com> wrote on 04/11/2007 12:00:50 PM:

> Hi,
> 
> Iam trying to create a dataobject of xsd which has one of the 
> element as <xsd:any> type. Sample is -
> 
> <xsd:element name="ServiceInput" type="ServiceInputType"/>
> 
>  <xsd:complexType name="ServiceInputType">
>   <xsd:sequence>
>    <xsd:element minOccurs="0" ref="header"/>
>    <xsd:element minOccurs="0" ref="body"/>
>   </xsd:sequence>
>  </xsd:complexType>
> 
> <xsd:element name="body"> 
>   <xsd:complexType> 
>    <xsd:sequence> 
>     <xsd:any maxOccurs="1" minOccurs="1" processContents="lax"/> 
>    </xsd:sequence> 
>   </xsd:complexType> 
>  </xsd:element>
> 
> 
> The <xsd:any> is used to allow different xml under the 'body' 
> element, as the incoming xml structure is not fixed.
> Data object for this xsd is created, but Iam not able to set the 
> dataobject of the variable xml structure under the 'body' element.
> 
> I would appreciate any help.
> 
> Thanks
> Ashish

---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-user-help@ws.apache.org