Eclipse XML and Schema Editing

From Kb

Jump to: navigation, search

Contact Article Author | Blog of Article Author | FirstPartners.net Home | LinkedIn profile of Author

See Also


Standard Eclipse Setup

  • Installation
    • The functionality below isstandard Eclipse, provided by the WTP (Web Tools Project) Plugins. Th

!! Validating XML and schemas using Eclipse

  • Find the schema and make a note of it's location.
  • Get the xml file that you wish to validate, open using standard xml edito.
  • Put the following at the top of the file (replace the existing 'root node')
<?xml version="1.0" encoding="UTF-8"?>
<RootNodeName xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="my-schema-name.xsd">
  • Save the XML file, close it, then open it again. Eclipse should give you a couple of additional options.
    • Tabs at the bottom of the screen : Design and Source
    • Design : A Tree based editor i
    • Source : gives a validate (against the schema) option. This will highlight any incorrect entries (inline), in the same way Java Syntax errors are. The standard Eclipse 'outline' view should give an outline of the XML Structure, and give you options on how to edi.
  • If you open the Schema file you now have the choice of a Graphic Schema editor (showing which elements in the xml are mandatory or not). Again this has graphic and source views. In the graphic view, licking on the Nodes displayed allows you to drill down through the Schema Structure.
    • Right click on schema in navigator view allows you to generate xml from the schema
    • Refactoring options via outline view / top menu.
  • For more information, search the Eclipse Help for 'Xml Schema'
Personal tools