Here's a trivial excerpt from my XSD file
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="ns"
xmlns:tns="sns" elementFormDefault="qualified">
<element name="document">
<attribute name="title" use="required"/>
</element>
</schema>
I use the maven-jaxb2-plugin
to generate Java classes from this. The Document
class has a getTitle()
method to return the text of the title
attribute.
I want to add an additional method to Document
:
public String getStrippedTitle() {
return getTitle().replaceAll("\\s+", "");
}
I want my extra method to appear on the unmarshalled object (rather than me just calling it or writing a wrapper class) because I want to pass the top-level unmarshalled object off to a string template and have it iterate over sub-elements calling my extra method.
I found instructions but they tell me to set a property on the Unmarshaller
and my (Mac OS X, Java 7) implementation doesn't appear to support any properties.
How should I do this?