Home » Tag Archives: XML (page 4)

Tag Archives: XML

JAXB and Root Elements

java-interview-questions-answers

@XmlRootElement is an annotation that people are used to using with JAXB (JSR-222). It’s purpose is to uniquely associate a root element with a class. Since JAXB classes map to complex types, it is possible for a class to correspond to multiple root elements. In this case @XmlRootElement can not be used and people start getting a bit confused. In ...

Read More »

EclipseLink MOXy as a JAXB provider

eclipselink-logo

EclipseLink MOXy is a JAXB provider and is a compelling alternative to the default JAXB provider built into JDK. First a simple test to marshal a Java object to XML: This is the model: @XmlRootElement(name='MemberDetailsRequest', namespace='http://bk.org/memberservice/') @XmlAccessorType(XmlAccessType.FIELD) public class MemberDetailsRequest { public MemberDetailsRequest() { } public MemberDetailsRequest(Long id) { this.id = id; } private Long id; public Long getId() { ...

Read More »

RichText editor component for SWT based applications

java-duke-logo

This article will go through the task of implementing our own RichText editor component with SWT. I faced the need for such a visual component when developing a desktop based application for one of my customers and wanted to add a functionality to allow users to write rich text comments with bold, italic, strike through, etc. capabilities. At that moment ...

Read More »

Approaches to XML – Part 4 – XMLBeans

apache-xmlbeans-logo

If you remember from Part 1, Part 2 and Part 3, I’m covering different approaches to parsing XML messages using the outrageously corny scenario of Pete’s Perfect Pizza, the pizza company with big ideas. In this story, you are an employee of Pete’s and have been asked to implement a system for sending orders from the front desk to the ...

Read More »

Approaches to XML – Part 3 – JAXB

software-development-2-logo

If you remember from Part 1 and Part 2, I’m covering different approaches to parsing XML messages using the outrageously corny scenario of Pete’s Perfect Pizza, the pizza company with big ideas. In this story, you are an employee of Pete’s and have been asked to implement a system for sending orders from the front desk to the kitchen and you came ...

Read More »

Approaches to XML – Part 2 – What about SAX?

software-development-2-logo

Part 1 introduced the idea that there are different ways to approach XML parsing and highlighted the point that XML is NOT A STRING; rather it’s an object oriented document model that can be represented using a string. Today’s blog continues this discussion using my Pete’s Perfect Pizza scenario. If you remember, Pete’s just popped his head around the door ...

Read More »

Approaches to XML – Part 1 – XML is not a String…

software-development-2-logo

XML has been around a long time: from memory, I’d guess that it’s about 12-14 years old by now; it’s a mature product with, in computing terms, a long history. So, is there anything new that I could possibly add to this subject? How you approach XML is really down to you and your situation, with the emphasis being on ...

Read More »

Scala Basic XML processing

scala-logo

Introduction Pretty much everybody knows what XML is: it is a structured, machine-readable text format for representing information that can be easily checked for the “grammaticality” of the tags, attributes, and their relationship to each other (e.g. using DTD’s). This contrasts with HTML, which can have elements that don’t close (e.g. <p>foo<p>bar rather than <p>foo</p><p>bar</p>) and still be processed. XML ...

Read More »

JAXB and Unmapped Properties

java-interview-questions-answers

JAXB (JSR-222) is configuration by exception, meaning that there is a default mapping applied to domain objects. This means that sometimes you need to explicitly exclude a field/property. In this post I’ll discuss how this can be done using @XmlTransient or @XmlAccessorType(XmlAccessType.NONE) and when each option is appropriate. @XmlTransient When you mark a field/property with @XmlTransient you are explicitly telling ...

Read More »

XML parsing using SaxParser with complete code

java-logo

SAX parser use callback function (org.xml.sax.helpers.DefaultHandler) to informs clients of the XML document structure. You should extend DefaultHandler and override few methods to achieve xml parsing. The methods to override are startDocument() and endDocument() – Method called at the start and end of an XML document.  startElement() and endElement() – Method called at the start and end of a document ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Advanced Java Guide
  • Java Design Patterns
  • JMeter Tutorial
  • Java 8 Features Tutorial
  • JUnit Tutorial
  • JSF Programming Cookbook
  • Java Concurrency Essentials