public class ParserTest {
@Test
public void testRead() throws JiBXException {
IBindingFactory bfact = BindingDirectory.getFactory(StyledLayerDescriptorInfo.class);
IUnmarshallingContext uctx = bfact.createUnmarshallingContext();
Object object = uctx.unmarshalDocument(getClass().getResourceAsStream("samples/example-sld.xml"), null);
StyledLayerDescriptorInfo sld = (StyledLayerDescriptorInfo) object;
for (ChoiceInfo choice : sld.getChoiceList()) {
if (choice.ifNamedLayer()) {
NamedLayerInfo layer = choice.getNamedLayer();
Assert.assertEquals("OCEANSEA_1M:Foundation", layer.getName());
}
}
IMarshallingContext ctx = bfact.createMarshallingContext();
StringWriter sw = new StringWriter();
ctx.setOutput(sw);
ctx.marshalDocument(sld);
}