Dear Wiki user, You have subscribed to a wiki page or wiki category on "Ws Wiki" for change notification.
The following page has been changed by KelvinGoodson: http://wiki.apache.org/ws/Tuscany/Java/SDO/ThinkingAloud/OpenContent ------------------------------------------------------------------------------ }}} + [[Anchor(multiprop)]] == Open content with max occurs > 1 == - As seen above in the workaround for setting values into single valued wildcards, you can set multiple values by setting a List value against a Property. + The behaviour of the code here may throw some light on why the single valued case is as it is, and perhaps that I have misunderstood that case. Here's where my experiments have led so far Considering the schema ... - adhering to the schema ... + {{{ <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:simple="http://www.example.com/open" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/open"> - <xsd:element name="openStockQuote" type="simple:OpenQuote"/> + <xsd:element name="openStockQuote2" type="simple:OpenQuote2"/> - - <xsd:element name="company"> - <xsd:complexType> - <xsd:sequence> - <xsd:element name="name" type="xsd:string"/> - </xsd:sequence> - </xsd:complexType> - </xsd:element> <xsd:element name="note" type="xsd:string"/> <xsd:element name="count" type="xsd:int"/> - <xsd:complexType name="OpenQuote"> + <xsd:complexType name="OpenQuote2"> <xsd:sequence> <xsd:element name="symbol" type="xsd:string"/> - <xsd:any maxOccurs="1" namespace="##any"/> + <xsd:any maxOccurs="unbounded" namespace="##any"/> </xsd:sequence> </xsd:complexType> </xsd:schema> }}} - [[Anchor(multiprop)]] - What I cant yet reconcile with the API is how to create the following document, where the unbounded cardinality wildcard has instances of more than one property against it + + The following document .... {{{ - <?xml version="1.0" encoding="UTF-8"?> + <?xml version="1.0" encoding="ASCII"?> + <open:openStockQuote2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:open="http://www.example.com/open" xsi:type="open:OpenQuote2"> - <open:openStockQuote xmlns:open="http://www.example.com/open"> - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.example.com/open open.xsd "> <symbol>ww</symbol> <open:note>TBA</open:note> <open:count>1</open:count> - </open:openStockQuote> + </open:openStockQuote2> }}} - Using the DataObject.set(Property, Object) API, we only get a chance to set multiple values of a single property. + is created by the following code ... + {{{ + OpenQuote2 oq = OpenFactory.INSTANCE.createOpenQuote2(); + oq.setSymbol("ww"); + DataObject doq = (DataObject)oq; + + boolean isElement = true; + Property pc = XSDHelper.INSTANCE.getGlobalProperty("http://www.example.com/open", "note", isElement); + + List lnote = new ArrayList(); + lnote.add(new String("TBA")); + + + doq.set(pc, lnote); + + pc = XSDHelper.INSTANCE.getGlobalProperty("http://www.example.com/open", "count", isElement); + + List lcount = new ArrayList(); + lcount.add(new Integer(1)); + + doq.set(pc, lcount); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + XMLHelper.INSTANCE.save(doq, "http://www.example.com/open", "openStockQuote2", baos); + + System.out.println(baos.toString()); + }}} + + Which kind of surprised me a bit, since I had expected the second set() call to overwrite the first, but now it kind of makes sense. So that makes me reconsider the semantics I had placed upon the single cardinality case above, and begs the question whether the above referenced JIRA I raised was in error. Watch this space! + + OK, so if my theory is correct, adding + {{{ + <xsd:element name="oneNote" type="xsd:string" maxOccurs="1" /> + }}} + + to the schema should allow me to do ... + {{{ + Property pOneNote = XSDHelper.INSTANCE.getGlobalProperty("http://www.example.com/open", "oneNote", true); + doq.set(pOneNote, "this is it!"); + }}} + + but it doesn't! it still fails as described above, when expecting the supplied argument to be a List, even though both the xsd:any and the global element have maxOccurs = 1 on them! So either I still misunderstand, or there's something wrong here. +
