8

I have XSD file (for example) http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd and I would like to use it for adding code autocomplete in my xml editor (I prefer Eclipse but any other free editor would be O.K.).

Is it possible? And if Yes, how can I do it?

Maciek Sawicki
  • 6,717
  • 9
  • 34
  • 48

5 Answers5

5

I had a similar problem but did not find a solution here so I posted a similar question. The answer led me to the Eclipse XML Editors and Tools plugin in Eclipse which supports autocomplete based on XML Schema.

Once the XML document is associated with the relevant XSD file, autocomplete should kick in automatically.

p.s. Considering the date of your question, you probably already found a suitable solution. However I thought I'd leave this answer anyway as a heads up to future visitors. HTH.

Community
  • 1
  • 1
Shawn Chin
  • 84,080
  • 19
  • 162
  • 191
  • the link now is broken but I found [this](http://stackoverflow.com/a/4358757/1422630) (including the comments) to work fine. It is basically the same context of what you said. The default eclipse xml editor will not work. But the same configurations we make while the "Web Developer Tools" plugin is installed, will work perfectly! – Aquarius Power Dec 11 '15 at 21:12
3

Using XML Schema for code autocomplete is supported in Visual Studio more details here.

Alternative XML editor is: Microsoft XML Notepad 2007 (personally I found this editor to be very unfriendly, is very visual but editing files is not very productive)

Mauricio Gracia Gutierrez
  • 10,288
  • 6
  • 68
  • 99
Paulius Zaliaduonis
  • 5,059
  • 3
  • 28
  • 23
0

In Visual Studio 2015 (and most likely earlier versions as well) just go to the Properties tab of the XML file in the solution and specify the path to the xsd in the Schemas attribute.

I haven't spent much time on it, but looks like VS doesn't save the mapping in the csproj file, so the setting won't go in the version control, but if that's not something important for you, it's a quick and easy way to solve the problem.

Nikita R.
  • 7,245
  • 3
  • 51
  • 62
0

xsi:schemaLocation

It is supported by default in Eclipse. You just need to add XSI and schemaLocation as the following example.

<Resource xmlns="http://xml.metamug.net/resource/1.0"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://xml.metamug.net/resource/1.0 http://xml.metamug.net/schema/resource.xsd">
</Resource>

As you can see above, you have need 3 attributes. The autocomplete works because of the valid xsd hosted on a public url and provided in the xsi:schemaLocation attribute

Note that all Editors don't support this by default, but Eclipse and Netbeans I know do.

Reference: https://metamug.com/article/auto-complete-xml-editor-with-xsd-and-validations.php

Metamug Autocomplete XSD Validation

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Sorter
  • 9,704
  • 6
  • 64
  • 74
0

I think you can do it by defining an XML namespace with your XML Schema Definition. Then when you start a tag with that namespace you should get suggestions based on the types of elements that can be used in that situation, according to the XML Schema Definition.

sinisterstuf
  • 195
  • 4
  • 7