Hello all,

I am trying to get Jackson XML deserializer to ensure that XML elements 
that have been qualified by a namespace in the target POJO is correctly 
handled.

This is my POJO class.

@XmlRootElement(name = "open", namespace="foo")
public static class OpenStream {

  @XmlAttribute
  private String id;

  public OpenStream() {}
}

As you can see, the root element "open" is qualified by the "foo" namespace.

And this is the code I am running to deserialize the some XML to this POJO.

@Test
public void testJAXB_JacksonWoodstox() throws Exception {
   XMLInputFactory2 inputFactory = new WstxInputFactory();
   inputFactory.configureForSpeed();

   XMLOutputFactory2 outputFactory = new WstxOutputFactory();
   outputFactory.configureForSpeed();

   XmlMapper mapper = new XmlMapper(new XmlFactory(inputFactory, 
outputFactory));
   mapper.registerModule(new JaxbAnnotationModule());

   OpenStream open = mapper.readValue("<open id=\"1\"/>", OpenStream.class);
   assertEquals("1", open.id);
}

The XML string input to mapper does not have the "foo" namespace, and 
therefore I expect Jackson to FAIL the operation. However, it happily 
deserializes the XML and creates the POJO.

I tested the identical XML through standard JAXB (coupled with Woodstox) 
which throws an exception, as expected, with the following message.

unexpected element (uri:"", local:"open"). Expected elements are 
<{foo}open>]

Am I missing something or is this behaviour not available in Jackson?

Cheers,
Luki

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jackson-user/6da00341-f91a-4a22-b1de-caa1d86d9023n%40googlegroups.com.

Reply via email to