Autocompletion is a feature in software development tools that helps users enter code efficiently by automatically offering suggestions based on what they type. Using autocompletion in XML allows developers to quickly and accurately add elements and attributes to their code through intelligent suggestions, simplifying the development process and reducing errors. Implementing autocompletion for XML requires loading an XML Schema Definition (XSD) into the development environment, which defines the structure and rules of the XML document and thus forms the basis for the autocompletion feature.

In addition to autocompletion, some tools also offer autofill. Autofill is similar to autocompletion in that the software development tool helps provide suggestions. Autofill is specifically about filling fields. In AFD messages, for example, this involves filling a label with an allowed value from an associated code list. However, not all tools distinguish between autocompletion and autofill, or use the terms interchangeably.

Eclipse

Eclipse is an open source framework from the Eclipse Foundation for software development environments. Eclipse has an open structure and, apart from a small core, consists entirely of plug-ins. This makes it possible to expand the functionality by installing new plug-ins.

Eclipse and XML

In Eclipse you first need to install an XML plugin. A recommended plugin is the Eclipse XML Editors and Tools SDK. You can install this via the menu ‘Help -> Install New Software’ and searching for ‘XML’ (make sure you don’t search for XSD, this will return no results).

Next step is to enable ‘autocompletion’ in ‘settings’ and adjust it to your own preferences. To do this, go to ‘Window -> Preferences -> XML -> XML Files -> Editor -> Content Assist’ and check ‘Automatically make suggestions’. See figure 4.4.1.



Figure 4.4-1 Eclipse settings


Now open an XML file. If you have linked an XSD and autocompletion is enabled, Eclipse will give suggestions and additions for tags as soon as you type an opening tag (“<”). See Figure 4.4.2.. Eclipse does not support autofill and will not provide suggestions for entering values.



Figure 4.4-2 Eclipse autocompletion


Eclipse and JSON

Eclipse does not include any intuitive modules or plugins for JSON Schema, so in case of JSON, we recommend using XMLSpy.

Altova XMLSpy

XMLSpy is a proprietary XML editor and integrated development environment developed by Altova. XMLSpy allows developers to create XML-based and Web services applications using technologies such as XML, JSON, XBRL, XML Schema, XSLT, XPath, XQuery, WSDL and SOAP.

XMLSpy and XML

In XMLSpy it is possible to link a Schema within the editor when composing an XML message. To do this, go to DTD/Schema -> Assign Schema in the menu bar and select an XSD file. XMLSpy now automatically adds the correct reference to the XSD in the header of the XML message.

By default, autocompletion is enabled in XMLSpy. You can check or enable this in Tool -> Options -> Editing, by checking “Auto-completion in Text View”. See figure 4.4.3.


Figure 4.4-3 XML settings


Now open an XML file. If you have linked an XSD and have autocomplete enabled, XMLSpy displays tag suggestions and additions as soon as you type an opening tag (“<”). See Figure 4.4.4. If an AFD tag has a codelist associated with it, XMLSpy also displays possible enumeration values, when populating the field. See Figure.4.4.5. for an example.


Figure 4.4-4 XMLSpy autocompletion with suggestions for tags



Figure 4.4-5 XMLSpy autocompletion with enumeration from codelist


XMLSpy and JSON

In XMLSpy it is possible to link a JSON Schema within the editor when composing a JSON message. To do this, go to DTD/Schema -> Assign Schema in the menu bar and select an XSD file. XMLSpy now automatically adds the correct reference to the XSD in the header of the XML message.

By default, autocompletion is enabled in XMLSpy. You can check or enable this in Tool -> Options -> Editing, by checking “Auto-completion in Text View”. See figure 4.4.3.

Now open a JSON file. If you have linked a JSON Schema and have autocomplete enabled, XMLSpy will provide tag suggestions and additions as soon as you type an opening tag (quotes). See Figure 4.4.6.

Note: for JSON Schema files with a version older than ‘draft-2020-12’, autocompletion works less well, particularly if you are not operating on the root level of the JSON object.


Figure 4.4-6 XMLSpy autocompletion with suggestion tags

VisualStudio

Microsoft Visual Studio is an integrated development environment (IDE) from Microsoft. It offers a complete set of development tools to develop computer programs in various programming languages, especially for Windows environments.

VisualStudio and XML

In Microsoft VisualStudio, ‘IntelliSense’ is enabled by default. IntelliSense in fact corresponds to autofill and autocompletion. If you define a schema in an XML message, VisualStudio will automatically validate the message against this schema. VisualStudio also provides suggestions for autocompletion, see figure 4.4.7 below.


Figure 4.4-7 VisualStudio and suggestions for autocompletion

VisualStudio and JSON

Unfortunately, autofill and autocompletion do not work for JSON files within VisualStudio.

Feedback

Thanks for your feedback.

Post your comment on this topic.

Please do not use this for support questions.
If you have any support questions, do not hesitate to contact us.

Post Comment