[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [sdo] ISSUE 65: SubstitutionGroup support in SDO 3
Hi Frank, it's a good idea to improve the handling of substitution groups. Your proposal is to use global properties to access and differentiate the substitution groups at the DataObject. In my opinion, we must not use the existing api, we need a new api on XMLHelper for two reasons: 1. For DataObjects with open types the behavior of set(globalProperty, value) is already defined. It adds an open-content property. Using your proposal with the existing api would be a breaking change. 2. The global property is not enough to address the local property. In some special cases you need the local property too. Imagine the following freaky XSD an XML: <?xml version="1.0" encoding="UTF-8"?> <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:test="test" targetNamespace="test" elementFormDefault="qualified" attributeFormDefault="unqualified"> <complexType name="A" mixed="true"> </complexType> <complexType name="B"> <complexContent> <extension base="test:A"> <attribute name="id" type="string"/> </extension> </complexContent> </complexType> <element name="a" type="test:A"/> <element name="b" type="test:B" substitutionGroup="test:a"/> <element name="c" type="test:B" substitutionGroup="test:b"/> <complexType name="testDO"> <sequence> <element ref="test:a"/> <element ref="test:b"/> </sequence> </complexType> <element name="root"> <complexType> <sequence> <element name="testDO" type="test:testDO" maxOccurs="unbounded"/> </sequence> </complexType> </element> </schema> <?xml version="1.0" encoding="UTF-8"?> <root xmlns="test" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <testDO> <a xsi:type="B" id="b1">some B value</a> <b id="b2">some B value</b> </testDO> <testDO> <b id="b1">some B value</b> <b id="b2">some B value</b> </testDO> <testDO> <c id="b1">some B value</c> <c id="b2">some B value</c> </testDO> </root> In this case you are not able to find the right local property just by the global property "b" or "c" because of the chained substitution groups. I think, we should define something on the XMLHelper like XMLHelper.setSubstitutionGroupValue(DataObject sdo, Property localProperty, Property globalProperty) Best regards, Stefan. -----Ursprüngliche Nachricht----- Von: Barack, Ron [mailto:ron.barack@sap.com] Gesendet: Montag, 18. Februar 2008 11:17 An: Barack, Ron; sdo@lists.oasis-open.org Betreff: [sdo] ISSUE 65: SubstitutionGroup support in SDO 3 Sorry, wrong Subject line -----Ursprüngliche Nachricht----- Von: Barack, Ron [mailto:ron.barack@sap.com] Gesendet: Montag, 18. Februar 2008 11:15 An: sdo@lists.oasis-open.org Betreff: AW: [sdo] SubstitutionGroup support in SDO 3 http://www.osoa.org/jira/browse/SDO-65 -----Ursprüngliche Nachricht----- Von: Frank Budinsky [mailto:frankb@ca.ibm.com] Gesendet: Freitag, 15. Februar 2008 22:04 An: sdo@lists.oasis-open.org Betreff: [sdo] SubstitutionGroup support in SDO 3 Hi Guys, I've been thinking about what should be the proper handling of substitutionGroups in SDO 3. Here is my first thought. It made good sense until I got to the isMany example (proposal #4, below), at which point I started to wonder if we should not allow setting substitutions through the DataObject API at all. We could instead provide an XMLHelper API to do it. Please take a look at the following proposal and let me know your thoughts. Maybe we can add this issue to the agenda for next weeks call? Thanks, Frank. SubstitionGroups in SDO 3 ======================= There are two dimensions of specialization in XML Schema vs. just one in SDO/Java. In both XSD and SDO you can have type B extend A, but in XSD you can also have substitutionGroups, the equivalent of variable b : B extend variable a : A. You can find examples of one, the other, or both, being used. EXAMPLE: <complexType name="A"> ... </complexType> <complexType name="B"> <complexContent> <extension base="A"> ... </extension> </complexContent> </complexType> <element name="a" type="A"/> <element name="b" substitutionGroup="a" type="B"/> <element name="c" substitutionGroup="a" type="B"/> <complexType name="testDO"> <sequence> <element ref="a"/> </sequence> </complexType> An SDO property "a" of type "B" could be legally serialized in any of the following ways: <testDO1><a xsi:type="B"> some_B_value </a></testDO1> <testDO2><b> some_B_value </b></testDO2> <testDO3><c> some_B_value </c></testDO3> In the SDO 2, all three of these are required to appear as a value for the property "a": DataObject testDO1 = ... testDO1.get("a") == some_B_value DataObject testDO2 = ... testDO2.get("a") == some_B_value DataObject testDO3 = ... testDO3.get("a") == some_B_value SDO 2 does not require that when you reserialize any of the above dataObjects (testDO1, testDO2, or testDO3) that they will produce the same XML (i.e., round trip). More generally, in SDO 2, it is implementation dependent which of the three serializations is used for a property "a": testDO.set("a", some_B_value); may produce any of the three XML forms from above. SDO 2 does suggest that an implementation should use a best guess subsitution element if possible, but it is not required. Note that in this example there is no predictable best guess anyway, since "b" and "c" are both of type "B". SDO 3 PROPOSAL #1: Substitition elements will round trip (XML -> DataObject -> XML). Maybe this should be an option, but it is necessary for an implementation to claim XML fidelity. SDO 3 PROPOSAL #2: testDO.set("a", some_B_value); will produce: <a xsi:type="B"> some_B_value </a> (NOTE this is changed from SDO 2 - no longer implementation dependent) and Property a = xsdHelper.getGlobalProperty(tns, "a", true); testDO.set(a, some_B_value); // note that this call is using the global a, not the local a property as in the previous example will produce: <a xsi:type="B"> some_B_value </a> and Property b = xsdHelper.getGlobalProperty(tns, "b", true); testDO.set(b, some_B_value); will produce: <b> some_B_value </b> and Property c = xsdHelper.getGlobalProperty(tns, "c", true); testDO.set(c, some_B_value); will produce: <c> some_B_value </c> SDO 3 PROPOSAL #3: Property a = xsdHelper.getGlobalProperty(tns, "a", true); Property b = xsdHelper.getGlobalProperty(tns, "b", true); Property c = xsdHelper.getGlobalProperty(tns, "c", true); testDO1.get("a") == some_B_value // no change from SDO 2 testDO1.get(a) == some_B_value testDO1.get(b) == null testDO1.get(c) == null testDO2.get("a") == some_B_value // no change from SDO 2 testDO2.get(a) == null testDO2.get(b) == some_B_value testDO2.get(c) == null testDO3.get("a") == some_B_value // no change from SDO 2 testDO3.get(a) == null testDO3.get(b) == null testDO3.get(c) == some_B_value SDO 3 PROPOSAL #4: Many valued (isMany) subsitutionGroup elements: <complexType name="testDO"> <sequence> <element maxOccurs="unbounded" ref="a"/> </sequence> </complexType> <testDO> <a xsi:type="B"> some_B_value1 </a> <b> some_B_value2 </b> <c> some_B_value3 </c> </testDO> Property a = xsdHelper.getGlobalProperty(tns, "a", true); Property b = xsdHelper.getGlobalProperty(tns, "b", true); Property c = xsdHelper.getGlobalProperty(tns, "c", true); testDO.getList(a) == error testDO.getList(b) == error testDO.getList(c) == error testDO.getList("a") == { some_B_value1, some_B_value2, some_B_value3 } // same as SDO 2 and testDO.setList(a, someList) == error testDO.setList(b, someList) == error testDO.setList(c, someList) == error testDO.setList("a", {some_B_value1, some_B_value2, some_B_value3}) will produce: <testDO> <a xsi:type="B"> some_B_value1 </a> <a xsi:type="B"> some_B_value2 </a> <a xsi:type="B"> some_B_value3 </a> </testDO> Question #1: How to support get/set of isMany substitutions? Do we want to add an XMLHelper method to do it? For example: List<Settings> value = xmlHelper.getSubstitutions(testDO, "a"); would return a List of property/value pairs (class Setting) corresponding to the values of property "a". The following: <testDO> <a xsi:type="B"> some_B_value1 </a> <b> some_B_value2 </b> <c> some_B_value3 </c> </testDO> would return: { (a, some_B_value1), (b, some_B_value2), (c, some_B_value3) } You could set the "a" property in a similar way: xmlHelper.setSubstitutions(testDO, "a", newSettingList); Question #2: Maybe we should only allow single value properties to be set using the XMLHelper API (instead of proposals #2 and #3 from above)? We could use the same methods, but when used for single valued properties (isMany == false) the List would always contain only one entry. Thoughts? --------------------------------------------------------------------- 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 --------------------------------------------------------------------- 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]