@Override protected Object unmarshalXmlEventReader(XMLEventReader eventReader) { try { XMLStreamReader streamReader = StaxUtils.createEventStreamReader(eventReader); return unmarshalXmlStreamReader(streamReader); } catch (XMLStreamException ex) { return new UnmarshallingFailureException("JiBX unmarshalling exception", ex); } }
@Override protected Object unmarshalXmlEventReader(XMLEventReader eventReader) throws XmlMappingException { try { XMLStreamReader streamReader = StaxUtils.createEventStreamReader(eventReader); return unmarshalXmlStreamReader(streamReader); } catch (XMLStreamException ex) { throw convertXStreamException(ex, false); } }
@Override protected void marshalXmlEventWriter(Object graph, XMLEventWriter eventWriter) throws XmlMappingException { ContentHandler contentHandler = StaxUtils.createContentHandler(eventWriter); LexicalHandler lexicalHandler = null; if (contentHandler instanceof LexicalHandler) { lexicalHandler = (LexicalHandler) contentHandler; } marshalSaxHandlers(graph, contentHandler, lexicalHandler); }
@Test public void testGetQNameForStaxSourceEventReader() throws Exception { String contents = "<prefix:localname xmlns:prefix='namespace'/>"; XMLInputFactory inputFactory = XMLInputFactory.newInstance(); XMLEventReader eventReader = inputFactory.createXMLEventReader(new StringReader(contents)); Source source = StaxUtils.createStaxSource(eventReader); QName qName = PayloadRootUtils.getPayloadRootQName(source, TransformerFactory.newInstance()); Assert.assertNotNull("getQNameForNode returns null", qName); Assert.assertEquals("QName has invalid localname", "localname", qName.getLocalPart()); Assert.assertEquals("Qname has invalid namespace", "namespace", qName.getNamespaceURI()); Assert.assertEquals("Qname has invalid prefix", "prefix", qName.getPrefix()); }
@Override protected void marshalXmlEventWriter(Object graph, XMLEventWriter eventWriter) { XMLStreamWriter streamWriter = StaxUtils.createEventStreamWriter(eventWriter); marshalXmlStreamWriter(graph, streamWriter); }
@Override protected void marshalXmlEventWriter(Object graph, XMLEventWriter eventWriter) throws XmlMappingException { ContentHandler contentHandler = StaxUtils.createContentHandler(eventWriter); marshalSaxHandlers(graph, contentHandler, null); }