How to split element def -> element + typeref + ComplexType?

Having trouble installing Oxygen? Got a bug to report? Post it all here.
pstein
Posts: 17
Joined: Wed May 21, 2008 9:13 pm

How to split element def -> element + typeref + ComplexType?

Post by pstein »

Assume I have a XSD with something like this inside:

<xsd:complexType name="foobar">
<xsd:sequence>
<xsd:element ... />
<xsd:element ... />
</xsd:sequence>
</xsd:complexType>

Now I want to split this type declaration and make two hierarchy levels out of it:

<xsd:complexType name="foobar" type="foobarType" />

<xsd:complexType name="foobarType">
<xsd:sequence>
<xsd:element ... />
<xsd:element ... />
</xsd:sequence>
</xsd:complexType>

How can I do this in Oxygen without editing the XSD schema file text manually in editor?

Is there e.g. a way to mark a certain <xsd:sequence>...</xsd:sequence> text and select a context menu entry similar to "extract to target XMLschema file...."

What about the other way: Merging an originally external, separate ComplexTypeby replacing an exiting type="foobarType" declaration by its target definition?

Peter
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Re: How to split element def -> element + typeref + ComplexType?

Post by george »

Hi,

I am not sure what exactly you try to accomplish as your desired result

<xsd:complexType name="foobar" type="foobarType" />

is an invalid XML Schema fragment.

If you start with a schema like below

Code: Select all


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="foobar">
<xs:complexType>
<xs:sequence>
<xs:element name="a"/>
<xs:element name="b"/>
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="x"/>
<xs:complexType name="y"/>
</xs:schema>
on the foobar element you can use the contextual action Extract global type to create a new type and set that to the foobar element automatically, resulting:

Code: Select all


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="foobar" type="foobar_type"> </xs:element>

<xs:element name="x"/>
<xs:complexType name="y"/>
<xs:complexType name="foobar_type">
<xs:sequence>
<xs:element name="a"/>
<xs:element name="b"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
Then you can drag and drop foobar_type next to the y type to make y type derived from foobar_type, resulting:

Code: Select all


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="foobar" type="foobar_type"> </xs:element>

<xs:element name="x"/>
<xs:complexType name="y">
<xs:complexContent>
<xs:extension base="foobar_type"/>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="foobar_type">
<xs:sequence>
<xs:element name="a"/>
<xs:element name="b"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
Further you can drag and drop the y type next to x element to set x element type to y, resulting

Code: Select all


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="foobar" type="foobar_type"> </xs:element>

<xs:element name="x" type="y"/>
<xs:complexType name="y">
<xs:complexContent>
<xs:extension base="foobar_type"/>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="foobar_type">
<xs:sequence>
<xs:element name="a"/>
<xs:element name="b"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
Best Regards,
George
George Cristian Bina
pstein
Posts: 17
Joined: Wed May 21, 2008 9:13 pm

Re: How to split element def -> element + typeref + ComplexType?

Post by pstein »

george wrote: on the foobar element you can use the contextual action Extract global type to create a new type and set that to the foobar element automatically
Hi George,
I am not sure about what you are talking.
I did not found a "contextual action" (you mean context menu entry ???)
for the element. See the following snapshot.

http://img170.imageshack.us/img170/3715 ... 224300.png

Where exactly is this "contextual action"?

Thank you
Peter
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Re: How to split element def -> element + typeref + ComplexType?

Post by george »

Hi Peter,

It seems you are using an old version of oXygen - I was talking about version 10. That has a Schema tab on the schema editor where it shows a a schema diagram and those actions are available from the contextual menu (right click on Windows, CTRL+Click on Mac).
See also the following demo
http://www.oxygenxml.com/demo/XMLSchema ... iting.html

Best Regards,
George
George Cristian Bina
Post Reply