You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by "Fuhwei Lwo (JIRA)" <tu...@ws.apache.org> on 2007/07/03 23:16:04 UTC

[jira] Created: (TUSCANY-1408) Cannot programmatically define a SDO property matching to XSD element

Cannot programmatically define a SDO property matching to XSD element
---------------------------------------------------------------------

                 Key: TUSCANY-1408
                 URL: https://issues.apache.org/jira/browse/TUSCANY-1408
             Project: Tuscany
          Issue Type: Bug
          Components: Java SDO Implementation
    Affects Versions: Java-SDO-1.0
         Environment: WinXP
            Reporter: Fuhwei Lwo
             Fix For: Java-SDO-1.0


The following code will define XSD attributes for "name" and "address" properties. I cannot find a way to define them as XSD elements.

HelperContext hc = HelperProvider.getDefaultContext();
DataFactory dataFactory = hc.getDataFactory();

TypeHelper types = hc.getTypeHelper();
Type stringType = types.getType("commonj.sdo", "String");
        
DataObject customerType = dataFactory.create("commonj.sdo","Type");
customerType.set("uri", "http://sample.data/customer");
customerType.set("name", "Customer");

//create customer name property
DataObject custNameProperty = customerType.createDataObject("property");
custNameProperty.set("name", "name");
custNameProperty.set("type", stringType);

//create address property
DataObject addressProperty = customerType.createDataObject("property");
addressProperty.set("name", "address");
addressProperty.set("type", stringType);

//now define the Customer type so that customers can be made
Type typeDefined = types.define(customerType);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (TUSCANY-1408) Cannot programmatically define a SDO property matching to XSD element

Posted by "Fuhwei Lwo (JIRA)" <tu...@ws.apache.org>.
    [ https://issues.apache.org/jira/browse/TUSCANY-1408?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12510010 ] 

Fuhwei Lwo commented on TUSCANY-1408:
-------------------------------------

Using SDO client code above, I propose the user can do something like below to specify whether the property is an XSD attribute or element.

Property xmlElementProp = hc.getXSDHelper().getGlobalProperty("commonj.sdo/xml", "xmlElement", false);
custNameProperty.set(xmlElementProp, true);  // this SDO property is an XSD element

The question is without setting xmlElement value, should we treat the property as an attribute or element? Current implementation is default to an attribute. Should we change to element? The SDO 2.1 spec didn't mention so it's up to us.

Fuhwei

> Cannot programmatically define a SDO property matching to XSD element
> ---------------------------------------------------------------------
>
>                 Key: TUSCANY-1408
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1408
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SDO Implementation
>    Affects Versions: Java-SDO-1.0
>         Environment: WinXP
>            Reporter: Fuhwei Lwo
>             Fix For: Java-SDO-1.0
>
>
> The following code will define XSD attributes for "name" and "address" properties. I cannot find a way to define them as XSD elements.
> HelperContext hc = HelperProvider.getDefaultContext();
> DataFactory dataFactory = hc.getDataFactory();
> TypeHelper types = hc.getTypeHelper();
> Type stringType = types.getType("commonj.sdo", "String");
>         
> DataObject customerType = dataFactory.create("commonj.sdo","Type");
> customerType.set("uri", "http://sample.data/customer");
> customerType.set("name", "Customer");
> //create customer name property
> DataObject custNameProperty = customerType.createDataObject("property");
> custNameProperty.set("name", "name");
> custNameProperty.set("type", stringType);
> //create address property
> DataObject addressProperty = customerType.createDataObject("property");
> addressProperty.set("name", "address");
> addressProperty.set("type", stringType);
> //now define the Customer type so that customers can be made
> Type typeDefined = types.define(customerType);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (TUSCANY-1408) Cannot programmatically define a SDO property matching to XSD element

Posted by "Frank Budinsky (JIRA)" <tu...@ws.apache.org>.
    [ https://issues.apache.org/jira/browse/TUSCANY-1408?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12510683 ] 

Frank Budinsky commented on TUSCANY-1408:
-----------------------------------------

The spec says this in section 7.1.3:

The xmlElement property is set to true on Properties that are represented as XML elements.  If no value is present there is no information about the mapping.  If the value is false, it indicates that it is not an element, but it does not guarantee that there is mapping to an XML attribute. Only if the property was defined using an XML Schema will a value of false indicate that the property maps to an attribute. If the property was defined using other means, for example, TypeHelper.define(), then a value of false indicates a desire to represent the property as an attribute, but it may not be possible. For example, a containment or nullable property must be serialized as an XML element.

So, what I think is the simplest approach that is compliant and also works is to simply make Element the default. If we want to also add support for xmlElement=False, we need to make sure that we set it back to Element in setContainment and setNullable (any where else?) methods.

I'm also not sure if we should be adding the xmlElment argument to the createProperty method, since it's an XML specific thing. It would probably be better to have a setPropertyXMLKind(Property, boolean) method instead, which is called after createProperty().

> Cannot programmatically define a SDO property matching to XSD element
> ---------------------------------------------------------------------
>
>                 Key: TUSCANY-1408
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1408
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SDO Implementation
>    Affects Versions: Java-SDO-1.0
>         Environment: WinXP
>            Reporter: Fuhwei Lwo
>             Fix For: Java-SDO-1.0
>
>         Attachments: 1408.patch
>
>
> The following code will define XSD attributes for "name" and "address" properties. I cannot find a way to define them as XSD elements.
> HelperContext hc = HelperProvider.getDefaultContext();
> DataFactory dataFactory = hc.getDataFactory();
> TypeHelper types = hc.getTypeHelper();
> Type stringType = types.getType("commonj.sdo", "String");
>         
> DataObject customerType = dataFactory.create("commonj.sdo","Type");
> customerType.set("uri", "http://sample.data/customer");
> customerType.set("name", "Customer");
> //create customer name property
> DataObject custNameProperty = customerType.createDataObject("property");
> custNameProperty.set("name", "name");
> custNameProperty.set("type", stringType);
> //create address property
> DataObject addressProperty = customerType.createDataObject("property");
> addressProperty.set("name", "address");
> addressProperty.set("type", stringType);
> //now define the Customer type so that customers can be made
> Type typeDefined = types.define(customerType);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Updated: (TUSCANY-1408) Cannot programmatically define a SDO property matching to XSD element

Posted by "Fuhwei Lwo (JIRA)" <tu...@ws.apache.org>.
     [ https://issues.apache.org/jira/browse/TUSCANY-1408?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Fuhwei Lwo updated TUSCANY-1408:
--------------------------------

    Attachment: 1408.patch

The new patch is to default SDOHelperImpl.createProperty() to create an XSD element.
Provided a new method called setPropertyXMLKind() to set a SDO property to be an XSD attribute or element.

I also need to fix DefineTypeTestCase.java to adapt to the new XSD element creation by default.

Fuhwei

> Cannot programmatically define a SDO property matching to XSD element
> ---------------------------------------------------------------------
>
>                 Key: TUSCANY-1408
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1408
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SDO Implementation
>    Affects Versions: Java-SDO-1.0
>         Environment: WinXP
>            Reporter: Fuhwei Lwo
>             Fix For: Java-SDO-1.0
>
>         Attachments: 1408.patch, 1408.patch
>
>
> The following code will define XSD attributes for "name" and "address" properties. I cannot find a way to define them as XSD elements.
> HelperContext hc = HelperProvider.getDefaultContext();
> DataFactory dataFactory = hc.getDataFactory();
> TypeHelper types = hc.getTypeHelper();
> Type stringType = types.getType("commonj.sdo", "String");
>         
> DataObject customerType = dataFactory.create("commonj.sdo","Type");
> customerType.set("uri", "http://sample.data/customer");
> customerType.set("name", "Customer");
> //create customer name property
> DataObject custNameProperty = customerType.createDataObject("property");
> custNameProperty.set("name", "name");
> custNameProperty.set("type", stringType);
> //create address property
> DataObject addressProperty = customerType.createDataObject("property");
> addressProperty.set("name", "address");
> addressProperty.set("type", stringType);
> //now define the Customer type so that customers can be made
> Type typeDefined = types.define(customerType);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Updated: (TUSCANY-1408) Cannot programmatically define a SDO property matching to XSD element

Posted by "Fuhwei Lwo (JIRA)" <tu...@ws.apache.org>.
     [ https://issues.apache.org/jira/browse/TUSCANY-1408?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Fuhwei Lwo updated TUSCANY-1408:
--------------------------------

    Attachment: 1408.patch

This patch is to allow the SDO users to programmatically define a SDO property as an XSD element. By default, a programmatically defined SDO property is an XSD attribute.

Fuhwei

> Cannot programmatically define a SDO property matching to XSD element
> ---------------------------------------------------------------------
>
>                 Key: TUSCANY-1408
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1408
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SDO Implementation
>    Affects Versions: Java-SDO-1.0
>         Environment: WinXP
>            Reporter: Fuhwei Lwo
>             Fix For: Java-SDO-1.0
>
>         Attachments: 1408.patch
>
>
> The following code will define XSD attributes for "name" and "address" properties. I cannot find a way to define them as XSD elements.
> HelperContext hc = HelperProvider.getDefaultContext();
> DataFactory dataFactory = hc.getDataFactory();
> TypeHelper types = hc.getTypeHelper();
> Type stringType = types.getType("commonj.sdo", "String");
>         
> DataObject customerType = dataFactory.create("commonj.sdo","Type");
> customerType.set("uri", "http://sample.data/customer");
> customerType.set("name", "Customer");
> //create customer name property
> DataObject custNameProperty = customerType.createDataObject("property");
> custNameProperty.set("name", "name");
> custNameProperty.set("type", stringType);
> //create address property
> DataObject addressProperty = customerType.createDataObject("property");
> addressProperty.set("name", "address");
> addressProperty.set("type", stringType);
> //now define the Customer type so that customers can be made
> Type typeDefined = types.define(customerType);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Resolved: (TUSCANY-1408) Cannot programmatically define a SDO property matching to XSD element

Posted by "Kelvin Goodson (JIRA)" <tu...@ws.apache.org>.
     [ https://issues.apache.org/jira/browse/TUSCANY-1408?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kelvin Goodson resolved TUSCANY-1408.
-------------------------------------

    Resolution: Fixed

> Cannot programmatically define a SDO property matching to XSD element
> ---------------------------------------------------------------------
>
>                 Key: TUSCANY-1408
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1408
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SDO Implementation
>    Affects Versions: Java-SDO-1.0
>         Environment: WinXP
>            Reporter: Fuhwei Lwo
>             Fix For: Java-SDO-1.0
>
>         Attachments: 1408.patch, 1408.patch
>
>
> The following code will define XSD attributes for "name" and "address" properties. I cannot find a way to define them as XSD elements.
> HelperContext hc = HelperProvider.getDefaultContext();
> DataFactory dataFactory = hc.getDataFactory();
> TypeHelper types = hc.getTypeHelper();
> Type stringType = types.getType("commonj.sdo", "String");
>         
> DataObject customerType = dataFactory.create("commonj.sdo","Type");
> customerType.set("uri", "http://sample.data/customer");
> customerType.set("name", "Customer");
> //create customer name property
> DataObject custNameProperty = customerType.createDataObject("property");
> custNameProperty.set("name", "name");
> custNameProperty.set("type", stringType);
> //create address property
> DataObject addressProperty = customerType.createDataObject("property");
> addressProperty.set("name", "address");
> addressProperty.set("type", stringType);
> //now define the Customer type so that customers can be made
> Type typeDefined = types.define(customerType);

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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