Hello,
I have a schema that has a global element. I need to make it a local element. There's no "Unextract Global Element". How do I do this?
Thanks.
Greg
global element to local
-
- Posts: 4144
- Joined: Fri Mar 28, 2003 2:12 pm
Re: global element to local
Hello,
In the current version there is no automatic refactoring action for that. We will consider adding such an action in a future version.
In the current version, if it is a W3C XML Schema, a RELAX NG schema or a NVDL one you can achieve that by drag and drop in the schema diagram (the Design editing mode), otherwise you should edit the content of the schema file in the Text editing mode.
Regards,
Sorin
In the current version there is no automatic refactoring action for that. We will consider adding such an action in a future version.
In the current version, if it is a W3C XML Schema, a RELAX NG schema or a NVDL one you can achieve that by drag and drop in the schema diagram (the Design editing mode), otherwise you should edit the content of the schema file in the Text editing mode.
Regards,
Sorin
-
- Posts: 16
- Joined: Tue Aug 01, 2006 2:56 am
- Location: Chicago
Re: global element to local
Thank you so much Sorin for all your help. I'm new to xsd's. I have to write a schema where there is an element called TITLE that is used throughout, and therefore should be global. There is one element where TITLE is a child and can have only 3 values (enumerations). So I'm wondering if you can have a global element, yet have local attributes?
But the real question is now, I built a schema with all local elements, some of which would be better as globals because they have the same name. How do I take a local element, make it a global, and also apply its "globalness" to all the other like-named elements?
Thanks again.
But the real question is now, I built a schema with all local elements, some of which would be better as globals because they have the same name. How do I take a local element, make it a global, and also apply its "globalness" to all the other like-named elements?
Thanks again.
-
- Posts: 4144
- Joined: Fri Mar 28, 2003 2:12 pm
Re: global element to local
You should declare that element as a global element in the XML Schema and include it as local element in other definitions with a reference to the global one. For example:
Please read about global elements and references to elements in an XML Schema tutorial.
Regards,
Sorin
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="global">
<xs:complexType>
<xs:sequence>
<xs:element name="elem" type="xs:string" maxOccurs="3"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="type">
<xs:sequence>
<xs:element ref="global" minOccurs="1" maxOccurs="2"/>
</xs:sequence>
<xs:attribute name="attr" type="xs:string"/>
</xs:complexType>
</xs:schema>
Please read about global elements and references to elements in an XML Schema tutorial.
Regards,
Sorin