Page 1 of 1
auto-complete enumerations
Posted: Thu Oct 04, 2007 4:49 pm
by mvkleef
Hello,
Maybe I'm missing something but I cannot get this to work on Oxygen. Please help.
I have a XML file and a XSD file defining the W3C schema. In the XSD file I have created a simpleType XML element for string enumerations like this
Code: Select all
<xs:simpleType name = "Identifier">
<xs:annotation>
<xs:documentation>Indicates whether and how </xs:documentation>
</xs:annotation>
<xs:restriction base = "xs:string">
<xs:enumeration value = "STATIC"/>
<xs:enumeration value = "DYNAMIC_A"/>
<xs:enumeration value = "DYNAMIC_B"/>
</xs:restriction>
</xs:simpleType>
In the XML file I use this enumeration. In Oxygen I only wish to edit using the regular Editor perspective and the Grid view on the XML file. Now when I modify a variable of this enumeration type there is no auto-completion, I still have to type in the enumeration value manually. Can I somehow enable auto-complete for my own enumeration in Oxygen? How?
Please advise. Thanks in advance.[/code]
Posted: Thu Oct 04, 2007 6:30 pm
by sorin_ristache
Hello,
The content completion window just pops up automatically with the three enumeration values when you insert an element of type
Identifier in an XML document based on the schema which defines
Identifier. For example if you create and save the following XML Schema in oXygen:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name = "Identifier">
<xs:annotation>
<xs:documentation>Indicates whether and how </xs:documentation>
</xs:annotation>
<xs:restriction base = "xs:string">
<xs:enumeration value = "STATIC"/>
<xs:enumeration value = "DYNAMIC_A"/>
<xs:enumeration value = "DYNAMIC_B"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="root">
<xs:complexType>
<xs:sequence maxOccurs="10">
<xs:element name="identifier" type="Identifier"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
and you create a new XML file based on this schema (menu File -> New, in the
Create an XML document dialog select this schema in the URL field) the new XML document contains
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ftopic2531.xsd">
<identifier></identifier>
</root>
If you press Enter after
<identifier></identifier> and then you press < the content completion window pops up and contains the
identifier element. When you insert an
identifier element by pressing Enter on it in the content completion window the cursor is moved between the start tag and the end tag of the
identifier element and the content completion window pops up again automatically with the three enumeration values. Can you reproduce this behavior in oXygen?
Regards,
Sorin
Posted: Fri Oct 05, 2007 9:59 am
by mvkleef
Hello,
Yes I can reproduce this behavior using the Text view. However, my question concerned editing the contents of the XML file using the Grid view. If I edit the data content (ie edit a value field of type Identifier) of the XML file using the Grid view I don't seem to get any auto-completion.
EDIT:
Sorry, my bad, the root of my XML file read
Code: Select all
<Settings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
instead of
Code: Select all
<Settings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:/D:/OxygenTest/config.xsd">
This is why auto-completion was not working in Grid view. Thanks for your help sorin![/code]
Posted: Fri Oct 05, 2007 10:08 am
by mvkleef
Hmm, editing this line manually in Text view still doesn't enable auto-completion in Grid view. But creating a new XML document with the schema does. Are there some project related settings involved here?
Posted: Fri Oct 05, 2007 2:15 pm
by sorin_ristache
If the attribute xsi:noNamespaceSchemaLocation contains a correct reference to the schema the auto-completion works correctly both in the text editor and in the grid editor. I did the following: I typed a wrong schema location, the auto-completion feature did not work in text editor or in grid editor, I corrected the schema location in the text editor without saving the file, auto-completion started working correctly, I switched to the grid editor, auto-completion still worked correctly. Do you get the same behavior?
Regards,
Sorin
Posted: Fri Oct 05, 2007 3:33 pm
by mvkleef
Yes, this is exactly the behaviour that got me puzzled. Apparently I had not saved. Thanks for the help!