[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [sdo] XML Fidelity issue: xsi:nil with attributes
Hi Frank, For the following example from your doc (section 2.7), I think there are two options: <query> <intRange min="1" xsi:nil="true"/> </query> Option #1 - The property called "intRange" of type "IntegerRange" is set and null. This option will not round trip, since the "min" property is lost. Option #2 - The property called "intRange" is set to an instance of "IntegerRange" and the "min" property is set to "1" and the "value" property is set to null. This option will round trip. Then the problem is with the following use case? Both of the options below would marshal to the same XML document, but we would need to choose one for the unmarshal operation. <query> <intRange xsi:nil="true"/> </query> Option #1 - The property called "intRange" of type "IntegerRange" is set and null. Option #2 - The property called "intRange" is set to an instance of "IntegerRange" and the "min" property is unset, and value property is set to null. This option will round trip. --- I do not believe there is a need for the get/setNil operations. --- I see where you are going with the project to Node.class concept. Our EclipseLink implementation is built on top of our object-to-XML mapping (MOXy) technology (which also supports JAXB). We would offer the corresponding functionality to our users through our implementation of the JAXB Binder (which was designed for just this purpose). The advantage of the JAXB Binder approach is that it provides a specific scope in which the objects and the DOM are linked. If I use marshaller a new DOM is produced for each marshal operation, but binder will return the one linked to my object. -Blaise Frank Budinsky wrote: OF6C748D9B.D0C8DAA9-ON8525745F.00668739-8525745F.0069BB77@ca.ibm.com" type="cite">Hi James, Thanks for the quick response. I'm not sure I understand this part:When we marshal out then it is a simple matter of checking if the property isSet() and isNullable() to know if we need to print out xsi:nil="true".In addition to knowing that the property isSet and isNullable, you need to know if the value is nil ... right? The case where the value is acutally set to null is easy, but the case that I'm looking for a solution to is that the value is an object where only attribute properties are set, while the element content should be xsi:nil. I think this may be an XML-only concept. The more I think about this, I'm starting to wonder if this is too XML-specific to add to SDO? If we introduce an isNil method, like I suggested, that only covers the read case. We would then want to start thinking about adding some kind of setNil() method as well, e.g., xmlHelper.setNil(myDO, "someProperty", true); So, I'm starting to wonder if an Option 4 that allows XML users to fall back to something like DOM and then just use it to look for the xsi:nil attribute, would be a better approach. For other reasons, I have been thinking about suggesting we add a new method to DataObject that allows one to project a DataObject to other interfaces: <T> T project(Class<T> targetClass); I had been thinking that such a method could be used to project to a Sequence "view" of the DataObject (and we could deprecate the getSequence method): Sequence sequence = myDO.project(Sequence.class); or it could be used to project to a static interface (instead of just casting - this would allow implementation to use a different instance for the static object): Company company = myDO.project(Company.class); and now, I think this could be the way we allow XML users to work with advanced XML features: Node node = myDO.project(Node.class); What do others think about this suggestion and this issue in general? Thanks, Frank. "James Hart" <James.Hart@Roguewave.Com> 06/04/2008 10:57 AM To Frank Budinsky/Toronto/IBM@IBMCA, <sdo@lists.oasis-open.org> cc Subject RE: [sdo] XML Fidelity issue: xsi:nil with attributes Our implementation has custom support for this already. I'll describe what we do that seems to work well. In our SDO implementation on our PropertyImpl we support a isNullable state which defaults to false. It also contains a isNullable() method that returns this state. The state can only be set during construction, but it defaults to false. On our Impl's for DataFactory and TypeManager all of our addProperty* methods have an additional method which includes a isNullable parameter so it can be told to create a nullable property. Our XSDHelper when constructing types simply creates the property using the TypeImpl API for addProperty that also exposes the isNullable parameter. When we marshal out then it is a simple matter of checking if the property isSet() and isNullable() to know if we need to print out xsi:nil="true". Otherwise we can print out whatever the default value is. I'd like to point out it doesn't matter in this case if the Property is has a type of DataObject or DataObjectType so it is more generic than the concept of xml's attributes, we just needed this concept to support these kind of xml documents. Saying that I don't think we need a special isNil() method, that would just be icing ;) I do think that the concept of data being "nill" or nullable for other data sets than xml is viable. For example, a DB has nullable columns and have defaults vs. columns that have defaults and are not nullable much in the same fashion of nillable attributes in schema. So I would prefer the benefits of making the concept nillable part of SDO's properties and not something that is only DAS dependant. I can also say option #2 works well because that is essentially what we do and it allows us to support these concepts in both our XSDHelper XMLHelper XMLDas and DBDas. The biggest drawback is that it increases the size of the in memory for every single property which is a concern when having to support very large data sets, but I think that currently is an issue with all of the state information and could be trivialized and a responsibility to solve as an implementation issue and not something that the spec has to solve. Thanks, James -----Original Message----- From: Frank Budinsky [mailto:frankb@ca.ibm.com] Sent: Tuesday, June 03, 2008 7:18 PM To: sdo@lists.oasis-open.org Subject: [sdo] XML Fidelity issue: xsi:nil with attributes Hi Guys, I'd like to start discussing some of the XML fidelity issues. The first one, hopefully easy, is to come up with a way to handle nillable elements with attributes. The problem is described in section 2.7 in this doc: http://www.oasis-open.org/apps/org/workgroup/sdo/download.php/26722/SDO_ XML_Issues.doc Here is my first thoughts on possible solutions: Option 1: Add a helper method (to XMLHelper or maybe DataHelper if we think this may not be an XML-only issue) to determine if a value is nil: boolean isNil(Object value); This method would return true if value == null or if value is a DataObject with an xsi:nil tag. Users could use it something like this: if (xmlHelper.isNil(myDO.get("someValue"))) { // someValue is nil } Option 2: We could have a method that takes a DataObject and a property path as arguments to determine if a property is nil without actually getting the value: boolean isNil(DataObject object, String path); if (xmlHelper.isNil(myDO, "someValue")) { // someValue is nil } If we go with this approach we would probably want 3 methods: boolean isNil(DataObject object, String path); boolean isNil(DataObject object, Property property); boolean isNil(DataObject object, int index); Option 3: Add the methods to DataObject: boolean isNil(String path); boolean isNil(Property property); boolean isNil(int index); if (myDO.isNil("someValue")) { // someValue is nil } This is nice and clean but would only make sense if we can think of other data domains (other than XML) where the concept of nil (different from null) applies. Please let me know what you guys think about these suggestions, or if you have any other ideas. Thanks, Frank. --------------------------------------------------------------------- To unsubscribe from this mail list, you must leave the OASIS TC that generates this mail. You may a link to this group and all your TCs in OASIS at: https://www.oasis-open.org/apps/org/workgroup/portal/my_workgroups.php --------------------------------------------------------------------- To unsubscribe from this mail list, you must leave the OASIS TC that generates this mail. You may a link to this group and all your TCs in OASIS at: https://www.oasis-open.org/apps/org/workgroup/portal/my_workgroups.php |
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]