| XSD wildcard (any) content [message #398520] |
Tue, 14 February 2006 04:47  |
Eclipse User |
|
|
|
Hi,
I have an XML schema containing something like:
<complexType name="Item">
<sequence>
<any namespace="##other" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="primaryKey" type="string" />
</complexType>
When I generate an SDO model from this, I get a method getAny() returning
a Sequence. The 'any' property is backed by a feature map.
What I want to be able to do is add arbitrary EObjects to the Item, and
have them appear in the output XML something like:
<item primaryKey="xx">
<Type1 ..../>
<Type2 ..../>
<Type3 ..../>
</item>
That is, the names of elements should match the classes of the added
objects (there will be at most one of each type).
Is there a way I can use the 'any' feature map to get this effect, or do I
need to be doing something different ? Currently I'm generating the
model from the XML schema, but I don't mind hand-building the model if
necessary.
I'm using EMF 2.0, can move to a newer version if necessary.
Thanks, Catherine.
|
|
|
| Re: XSD wildcard (any) content [message #398534 is a reply to message #398520] |
Tue, 14 February 2006 06:49   |
Eclipse User |
|
|
|
Catherine,
Do you have a schema with global elements named Type1, Type2, and so
on? Since your wildcard is strict, not lax or skip this will be
required. If you have such a schema, there will be a generated document
root with properties for Type1, Type2, and so on. You can use such a
property along with a value of that property's type in the sequence's
add method.
Catherine Griffin wrote:
> Hi,
>
> I have an XML schema containing something like:
>
> <complexType name="Item">
> <sequence>
> <any namespace="##other" minOccurs="0" maxOccurs="unbounded"/>
> </sequence>
> <attribute name="primaryKey" type="string" />
> </complexType>
>
> When I generate an SDO model from this, I get a method getAny()
> returning a Sequence. The 'any' property is backed by a feature map.
>
> What I want to be able to do is add arbitrary EObjects to the Item,
> and have them appear in the output XML something like:
>
> <item primaryKey="xx">
> <Type1 ..../>
> <Type2 ..../>
> <Type3 ..../>
> </item>
>
> That is, the names of elements should match the classes of the added
> objects (there will be at most one of each type).
>
> Is there a way I can use the 'any' feature map to get this effect, or
> do I need to be doing something different ? Currently I'm generating
> the model from the XML schema, but I don't mind hand-building the
> model if necessary.
>
> I'm using EMF 2.0, can move to a newer version if necessary.
>
> Thanks, Catherine.
>
>
|
|
|
| Re: XSD wildcard (any) content [message #398535 is a reply to message #398534] |
Tue, 14 February 2006 07:19  |
Eclipse User |
|
|
|
Thanks Ed, that works fine now.
I will need to add some helper methods to make adding and navigating
these objects easier, but this approach looks like it will work.
Thanks, Catherine.
|
|
|
Powered by
FUDForum. Page generated in 0.03592 seconds