Trifork Blog

Axon Framework, DDD, Microservices

Posts Tagged ‘XML’

January Newsletter

January 25th, 2012 by

Once again, the festive season is behind us and we all start the year as always with a bunch of new years resolutions. At Dutchworks we have made a few of our own too and we’re totally committed to achieving them. Our goals are to:

  1. Recruit the top talent in the industry and engage them with colleagues, customers & projects they can be proud of
  2. Achieve maximum project delivery reliability by striving for top quality & a rock solid delivery process
  3. Explore our key business domains (even more) and gain maximum exposure and experience in these markets.

Watch this space, as we’ll keep you posted on how we are getting on as the year progresses.

Read the rest of this entry »

Migrating content with Spring Integration – A real life example

January 13th, 2010 by

In one of the projects we need to migrate content from multiple websites into Hippo CMS. One of the interesting parts of this migration is that one of the websites will constantly provide us with updates of the content. Therefore it makes the migration a continuous process.

In this post I will explain how we use Spring Integration to migrate content, handle errors, measure performance and deal with the fact that content could contain references to other content that is not imported yet.

Read the rest of this entry »

Customize namespace prefix when marshalling with Jaxb

February 2nd, 2009 by

I was looking a long time on how to set the prefix for a namespace when marshalling an object to xml using JAXB. If you don’t do anything JAXB will write random namespace prefixes (like ns2, ns3).?

This is a repost of a blog item that was originally posted in the Func knowledge base by Martin Tilma on Februari 2, 2009.

First I found: but with that solution you have to implement an internal abstract class NamespacePrefixMapper.

After re-reading the Javadoc of the Marshaller I found the method marshal(Object jaxbElement, XMLStreamWriter writer) and the XMLStreamWriter interface contains a method setPrefix(String prefix, String uri)

A little code example:

JAXBContext context = JAXBContext.newInstance(object.getClass());

XMLStreamWriter xmlStreamWriter = XMLOutputFactory.newInstance()
xmlStreamWriter.setPrefix("func", "");
Marshaller marshaller = context.createMarshaller();

marshaller.marshal(object, xmlStreamWriter);

update: I have one remaining issue, for some reason the namespace declaration isn’t written to the XML when using setPrefix. If you remove the call to setPrefix it writes the namespace declaration.

update2: After digging around I found that my project has dependency on “WoodSToX XML-processor” which specifies its own XMLOutputFactory (see the META-INF/services directory in the jar).

To fix my issue I wrote a XMLStreamWriter wrapper that calls writeNamespace(String prefix, String namespaceURI) to write the declaration.

The attachment (MarshalUtil.java_.txt) contains a utility class to marshal and unmarshal.