Or better yet would be to add the po: to the types where it's missing:

>             <xsd:element name="shipTo" type="USAddress"/>
>             <xsd:element name="billTo" type="USAddress"/>
>             <xsd:element name="items"  type="Items"/>

like this:

>             <xsd:element name="shipTo" type="po:USAddress"/>
>             <xsd:element name="billTo" type="po:USAddress"/>
>             <xsd:element name="items"  type="po:Items"/>

The problem is that XSDHelper.define() doesn't complain about errors like 
this, it just treats type="USAddress" as an unknown type.

Frank.


[EMAIL PROTECTED] wrote on 07/03/2007 07:29:40 AM:

> Pinaki,
> 
>  there are errors in the schema you are using.  If you remove the ":po" 
from
> xmlns:po="http://www.example.com/PO"; and remove "po:" from the rest of 
the
> file,  when used in referencing type or element definitions,  then your 
test
> code succeeds.
> 
> Regards,Kelvin.
> 
> 
> Regards, Kelvin.
> 
> On 03/07/07, Pinaki Poddar <[EMAIL PROTECTED]> wrote:
> >
> > I switched to EMF core API. The same error. Looks like Tuscany SDO is
> > wrapping EMF core -- is that right?
> >
> >
> >
> > Pinaki Poddar
> > 972.834.2865
> >
> > -----Original Message-----
> > From: kelvin goodson [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, July 03, 2007 3:54 AM
> > To: tuscany-dev@ws.apache.org
> > Subject: Re: How does one specify a Property as containment property 
in
> > XML Schema?
> >
> > Pinaki,
> >   perfect, thanks (yes, the attachments are stripped by the list), 
will
> > try them out soon.
> > Kelvin
> >
> > On 03/07/07, Pinaki Poddar <[EMAIL PROTECTED]> wrote:
> > >
> > > Are you not seeing the e-mail attachements TestSDO.java and po.xsd?
> > >
> > > In any case, here they are
> > > ========================= TestSDO.java
> > > ======================================================
> > >
> > > package test;
> > >
> > > import java.io.IOException;
> > > import java.io.InputStream;
> > > import java.io.OutputStream;
> > > import java.util.List;
> > >
> > > import javax.persistence.EntityManager; import
> > > javax.persistence.EntityManagerFactory;
> > > import javax.persistence.Persistence;
> > >
> > > import org.apache.tuscany.sdo.helper.HelperProviderImpl;
> > >
> > > import com.bea.jpa.SDOEntityManager;
> > > import com.bea.jpa.SDOEntityManagerFactory;
> > >
> > > import commonj.sdo.DataObject;
> > > import commonj.sdo.helper.DataFactory; import
> > > commonj.sdo.helper.XMLHelper; import commonj.sdo.helper.XSDHelper;
> > > import commonj.sdo.impl.HelperProvider;
> > >
> > > import junit.framework.TestCase;
> > >
> > > /**
> > > * JUnit Tests to read a meta-model from XML Schema and create
> > > instances
> > > * according to the meta-model.
> > > *
> > > * @author ppoddar
> > > *
> > > */
> > > public class TestSDO extends TestCase {
> > >         private static final String RESOURCE_SDO_MODEL  = "po.xsd";
> > >         private static final String SDO_MODEL_NAMESPACE =
> > > "http://www.example.com/PO";;
> > >
> > >         /**
> > >          * Create a SDO MetaData Model from a XML Schema and 
populate
> > > instances.
> > >          * Assumes 'po.xsd' be available in classpath as resource.
> > >          *
> > >          */
> > >         public void testCreateModel() {
> > >                 InputStream xsdInputStream =
> > > this.getClass().getClassLoader()
> > >
> > > .getResourceAsStream(RESOURCE_SDO_MODEL);
> > >                 assertNotNull(xsdInputStream);
> > >
> > >                 String schemaLocation = null;
> > >                 List/* <Type> */types =
> > > XSDHelper.INSTANCE.define(xsdInputStream,
> > >                                 schemaLocation);
> > >                 assertTrue(types != null && !types.isEmpty());
> > >                 assertTrue(types.size() >= 2);
> > >
> > >                 DataObject purchaseOrder =
> > DataFactory.INSTANCE.create(
> > >                                 SDO_MODEL_NAMESPACE,
> > > "PurchaseOrderType");
> > >
> > >                 purchaseOrder.setString("orderDate", "1999-10-20");
> > >
> > >                 DataObject shipTo =
> > > purchaseOrder.createDataObject("shipTo");
> > >                 shipTo.set("country", "US");
> > >                 shipTo.set("name", "Alice Smith");
> > >                 shipTo.set("street", "123 Maple Street");
> > >                 shipTo.set("city", "Mill Valley");
> > >                 shipTo.set("state", "CA");
> > >                 shipTo.setString("zip", "90952");
> > >                 DataObject billTo =
> > > purchaseOrder.createDataObject("billTo");
> > >                 billTo.set("country", "US");
> > >                 billTo.set("name", "Robert Smith");
> > >                 billTo.set("street", "8 Oak Avenue");
> > >                 billTo.set("city", "Mill Valley");
> > >                 billTo.set("state", "PA");
> > >                 billTo.setString("zip", "95819");
> > >                 purchaseOrder.set("comment", "Hurry, my lawn is 
going
> > > wild!");
> > >
> > >                 DataObject items =
> > > purchaseOrder.createDataObject("items");
> > >
> > >                 DataObject item1 = items.createDataObject("item");
> > >                 item1.set("partNum", "872-AA");
> > >                 item1.set("productName", "Lawnmower");
> > >                 item1.setInt("quantity", 1);
> > >                 item1.setString("USPrice", "148.95");
> > >                 item1.set("comment", "Confirm this is electric");
> > >
> > >                 DataObject item2 = items.createDataObject("item");
> > >                 item2.set("partNum", "926-AA");
> > >                 item2.set("productName", "Baby Monitor");
> > >                 item2.setInt("quantity", 1);
> > >                 item2.setString("USPrice", "39.98");
> > >                 item2.setString("shipDate", "1999-05-21");
> > >
> > >                 try {
> > >                         OutputStream stream = System.err;
> > >                         XMLHelper.INSTANCE.save(purchaseOrder,
> > > SDO_MODEL_NAMESPACE,
> > >                                         "purchaseOrder", stream);
> > >                 } catch (IOException e) {
> > >                         e.printStackTrace();
> > >                         fail();
> > >                 }
> > >         }
> > >
> > > }
> > >
> > > 
======================================================================
> > > ==
> > > ===========================
> > > XML Schema Definition: po.xsd
> > > 
======================================================================
> > > ==
> > > ===========================
> > > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";
> > >     xmlns:po="http://www.example.com/PO";
> > > targetNamespace="http://www.example.com/PO";>
> > >
> > >     <xsd:element name="purchaseOrder" type="PurchaseOrderType"/>
> > >     <xsd:element name="comment" type="xsd:string"/>
> > >
> > >     <xsd:complexType name="PurchaseOrderType">
> > >         <xsd:sequence>
> > >             <xsd:element name="shipTo" type="USAddress"/>
> > >             <xsd:element name="billTo" type="USAddress"/>
> > >             <xsd:element ref="po:comment" minOccurs="0"/>
> > >             <xsd:element name="items"  type="Items"/>
> > >         </xsd:sequence>
> > >         <xsd:attribute name="orderDate" type="xsd:date"/>
> > >     </xsd:complexType>
> > >
> > >     <xsd:complexType name="USAddress">
> > >         <xsd:sequence>
> > >             <xsd:element name="name"   type="xsd:string"/>
> > >             <xsd:element name="street" type="xsd:string"/>
> > >             <xsd:element name="city"   type="xsd:string"/>
> > >             <xsd:element name="state"  type="xsd:string"/>
> > >             <xsd:element name="zip"    type="xsd:decimal"/>
> > >         </xsd:sequence>
> > >         <xsd:attribute name="country" type="xsd:NMTOKEN" 
fixed="US"/>
> > >     </xsd:complexType>
> > >
> > >     <xsd:complexType name="Items">
> > >         <xsd:sequence>
> > >             <xsd:element name="item" minOccurs="0"
> > > maxOccurs="unbounded">
> > >                 <xsd:complexType>
> > >                     <xsd:sequence>
> > >                         <xsd:element name="productName"
> > > type="xsd:string"/>
> > >                         <xsd:element name="quantity">
> > >                             <xsd:simpleType>
> > >                                 <xsd:restriction
> > > base="xsd:positiveInteger">
> > >                                     <xsd:maxExclusive value="100"/>
> > >                                 </xsd:restriction>
> > >                             </xsd:simpleType>
> > >                         </xsd:element>
> > >                         <xsd:element name="USPrice"
> > > type="xsd:decimal"/>
> > >                         <xsd:element ref="po:comment"
> > minOccurs="0"/>
> > >                         <xsd:element name="shipDate" type="xsd:date"
> > > minOccurs="0"/>
> > >                     </xsd:sequence>
> > >                     <xsd:attribute name="partNum" type="po:SKU"
> > > use="required"/>
> > >                 </xsd:complexType>
> > >             </xsd:element>
> > >         </xsd:sequence>
> > >     </xsd:complexType>
> > >     <xsd:simpleType name="SKU">
> > >         <xsd:restriction base="xsd:string">
> > >             <xsd:pattern value="\d{3}-[A-Z]{2}"/>
> > >         </xsd:restriction>
> > >     </xsd:simpleType>
> > > </xsd:schema>
> > >
> > > Pinaki Poddar
> > > 972.834.2865
> > >
> > > -----Original Message-----
> > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
> > > Behalf Of kelvin goodson
> > > Sent: Tuesday, July 03, 2007 3:43 AM
> > > To: tuscany-dev@ws.apache.org
> > > Subject: Re: How does one specify a Property as containment property
> > > in XML Schema?
> > >
> > > Hi Pinaki,
> > > I'm not sure if we are not understanding each other here,  or 
whether
> > > technology is conspiring against us,  but what I'd like to do is to
> > > execute the test code you are running myself, so please could you
> > > paste the code of your test program.
> > > Regards,Kelvin.
> > >
> > >
> > > Notice:  This email message, together with any attachments, may
> > > contain information  of  BEA Systems,  Inc.,  its subsidiaries  and
> > > affiliated entities,  that may be confidential,  proprietary,
> > > copyrighted  and/or legally privileged, and is intended solely for 
the
> >
> > > use of the individual or entity named in this message. If you are 
not
> > > the intended recipient, and have received this message in error,
> > > please immediately return this by email and then delete it.
> > >
> > > 
---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> >
> > Notice:  This email message, together with any attachments, may 
contain
> > information  of  BEA Systems,  Inc.,  its subsidiaries  and affiliated
> > entities,  that may be confidential,  proprietary,  copyrighted and/or
> > legally privileged, and is intended solely for the use of the 
individual or
> > entity named in this message. If you are not the intended recipient, 
and
> > have received this message in error, please immediately return this by 
email
> > and then delete it.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >


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

Reply via email to