@Override public Object unmarshal(Source source) throws XmlMappingException, IOException { List<XMLEvent> fragment = (List<XMLEvent>) super.unmarshal(source); if(fragment != null) { return new ItemCountAwareFragment(fragment); } else { return null; } } }