Tag Archives: XSD

A JAXB Nuance: String Versus Enum from Enumerated Restricted XSD String


via Inspired by Actual Events: A JAXB Nuance: String Versus Enum from Enumerated Restricted XSD String.

Although Java Architecture for XML Binding (JAXB) is fairly easy to use in nominal cases (especially since Java SE 6), it also presents numerous nuances. Some of the common nuances are due to the inability to exactlymatch (bind) XML Schema Definition (XSD) types to Java types. This post looks at one specific example of this that also demonstrates how different XSD constructs that enforce the same XML structure can lead to different Java types when the JAXB compiler generates the Java classes.

The next code listing, for Food.xsd, defines a schema for food types. The XSD mandates that valid XML will have a root element called “Food” with three nested elements “Vegetable”, “Fruit”, and “Dessert”. Although the approach used to specify the “Vegetable” and “Dessert” elements is different than the approach used to specify the “Fruit” element, both approaches result in similar “valid XML.” The “Vegetable” and “Dessert” elements are declared directly as elements of the prescribed simpleTypes defined later in the XSD. The “Fruit” element is defined via reference (ref=) to another defined element that consists of a simpleType.

Eclipse Oxygen XML Editor plugin tutorial


Eclipse Oxygen XML Editor plugin tutorial

In this example we are going to see how you can install and use an XML editor for your Eclipse IDE. XML is a mark-up language that has its own unique characteristics, and it’s used in a vast number of applications, mostly web based, but in recent years it plays a crucial role generally in universal, platform independent information exchanging between systems. A developer can be greatly supported by an IDE when  editing XML files or projects, as it offers features like code completion, code generation etc. Of course, a decent IDE XML Pluging would not only allow you to edit pure raw XML files, but also of XML-like files like HTML, XHTML, WSDL, XSD, XSL and even CSS.

There are many XML Editors as Eclipse plugins that do the job and most of them are quite good. In this example though, we are going to use a famous one, Oxygen XML