Mercurial > hg > Blog
view content/Eclipse/validating-xml-documents.md @ 109:ee048ed76ea1
Datums- und Syntex Fix
author | Dirk Olmes <dirk.olmes@codedo.de> |
---|---|
date | Fri, 18 Jun 2021 07:24:04 +0200 |
parents | e99db3bc53c1 |
children |
line wrap: on
line source
Title: Validating XML documents against your own schemas with Eclipse Date: 2007-06-07 Tags: XML Lang: en This week I started to work on Mule 2.0 which will be based on Spring. We're dropping our own custom config format in favor of Spring's xml format. This requires me to design the schema for the transports I'm working on as well as convert the configuration of the unit tests to spring config files. I noticed that Eclipse kept complaining <div class="highlight"><pre> The matching wildcard is strict, but no declaration can be found for element 'mule:model-seda'. </pre></div> and that autocomplete in the XML editor didn't work either. With a bit of googling I found out that the key to success is the proper definition of namespaces and their URLs. In the normal case (as with the spring schema) the schema file is published on the net and can be downloaded by the XML parser. Publishing the schema you're just developing each time you make a change is cumbersome so I figured there must be a better way. The solution is to declare your schema in Eclipse's **XML catalog**. Go to `Preferences` -> `Web and XML` -> `XML Catalog` (assuming that you have WTP installed) and declare a user entry for the schema you're currently developing. Your Eclipse XML Catalog should look similar to this (just with more entries): ![Eclipse XML preferences]({static}/images/EclipseXmlCatalog.gif) Unfortunately, the validation and autocompletion still does not work if you don't use a little trick to make things work. XML files can be associated to their schema in two ways: either you point the schemaLocation to the full URL where the schema file can be downloaded or you specify a XML catalog key. When not being processed by Eclipse's XML editor the document should still work. We don't publish an XML catalog for mule but if you use a little trick you can still make the editor validate correctly. As XML catalog key specify the full URL to the schema like this: ![XML Schema entry]({static}/images/EclipseCatalogEntry.gif) The XML catalog validation seems to have preference over the download of schemas from the web. So Eclipse sees the "URL" as catalog key and validates against your schema on disk. When running as part of mule, the schema will be validated by spring's xml parser which uses other means of getting the schema file.