import java.io.FileInputStream; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.xml.sax.InputSource; import org.xml.sax.XMLReader; public class Demo { public static void main(String[] args) throws Exception { SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); XMLReader xr = sp.getXMLReader(); xr.setContentHandler(new FragmentContentHandler(xr)); xr.parse(new InputSource(new FileInputStream("input.xml"))); } }
public FragmentContentHandler(ContentHandler handler) { super(); setContentHandler(handler); }
protected void writePayloadTo(ContentHandler contentHandler, ErrorHandler errorHandler, boolean fragment) throws SAXException { if(fragment) contentHandler = new FragmentContentHandler(contentHandler); DOMScanner ds = new DOMScanner(); ds.setContentHandler(contentHandler); ds.scan(payload); }
public FragmentContentHandler(ContentHandler handler) { super(); setContentHandler(handler); }
protected void writePayloadTo(ContentHandler contentHandler, ErrorHandler errorHandler, boolean fragment) throws SAXException { if(fragment) contentHandler = new FragmentContentHandler(contentHandler); DOMScanner ds = new DOMScanner(); ds.setContentHandler(contentHandler); ds.scan(payload); }
public FragmentContentHandler(ContentHandler handler) { super(); setContentHandler(handler); }
private void writePayloadTo(ContentHandler contentHandler, ErrorHandler errorHandler, boolean fragment) throws SAXException { if(fragment) contentHandler = new FragmentContentHandler(contentHandler); DOMScanner ds = new DOMScanner(); ds.setContentHandler(contentHandler); ds.scan(payload); }
private void writePayloadTo(ContentHandler contentHandler, ErrorHandler errorHandler, boolean fragment) throws SAXException { if(fragment) contentHandler = new FragmentContentHandler(contentHandler); DOMScanner ds = new DOMScanner(); ds.setContentHandler(contentHandler); ds.scan(payload); }
private void writePayloadTo(ContentHandler contentHandler, ErrorHandler errorHandler, boolean fragment) throws SAXException { if(fragment) contentHandler = new FragmentContentHandler(contentHandler); DOMScanner ds = new DOMScanner(); ds.setContentHandler(contentHandler); ds.scan(payload); }
protected void writePayloadTo(ContentHandler contentHandler, ErrorHandler errorHandler, boolean fragment) throws SAXException { if(fragment) contentHandler = new FragmentContentHandler(contentHandler); DOMScanner ds = new DOMScanner(); ds.setContentHandler(contentHandler); ds.scan(payload); }
/** * Writes the payload as SAX events. */ @Override protected void writePayloadTo(ContentHandler contentHandler, ErrorHandler errorHandler, boolean fragment) throws SAXException { try { if(fragment) contentHandler = new FragmentContentHandler(contentHandler); AttachmentMarshallerImpl am = new AttachmentMarshallerImpl(attachmentSet); if (rawContext != null) { Marshaller m = rawContext.createMarshaller(); m.setProperty("jaxb.fragment", Boolean.TRUE); m.setAttachmentMarshaller(am); m.marshal(jaxbObject,contentHandler); } else bridge.marshal(jaxbObject,contentHandler, am); am.cleanup(); } catch (JAXBException e) { // this is really more helpful but spec compliance // errorHandler.fatalError(new SAXParseException(e.getMessage(),NULL_LOCATOR,e)); // bug 6449684, spec 4.3.4 throw new WebServiceException(e.getMessage(),e); } }
/** * Writes the payload as SAX events. */ @Override protected void writePayloadTo(ContentHandler contentHandler, ErrorHandler errorHandler, boolean fragment) throws SAXException { try { if(fragment) contentHandler = new FragmentContentHandler(contentHandler); AttachmentMarshallerImpl am = new AttachmentMarshallerImpl(attachmentSet); if (rawContext != null) { Marshaller m = rawContext.createMarshaller(); m.setProperty("jaxb.fragment", Boolean.TRUE); m.setAttachmentMarshaller(am); m.marshal(jaxbObject,contentHandler); } else bridge.marshal(jaxbObject,contentHandler, am); am.cleanup(); } catch (JAXBException e) { // this is really more helpful but spec compliance // errorHandler.fatalError(new SAXParseException(e.getMessage(),NULL_LOCATOR,e)); // bug 6449684, spec 4.3.4 throw new WebServiceException(e.getMessage(),e); } }
/** * Writes the payload as SAX events. */ @Override protected void writePayloadTo(ContentHandler contentHandler, ErrorHandler errorHandler, boolean fragment) throws SAXException { try { if(fragment) contentHandler = new FragmentContentHandler(contentHandler); AttachmentMarshallerImpl am = new AttachmentMarshallerImpl(attachmentSet); if (rawContext != null) { Marshaller m = rawContext.createMarshaller(); m.setProperty("jaxb.fragment", Boolean.TRUE); m.setAttachmentMarshaller(am); m.marshal(jaxbObject,contentHandler); } else bridge.marshal(jaxbObject,contentHandler, am); am.cleanup(); } catch (JAXBException e) { // this is really more helpful but spec compliance // errorHandler.fatalError(new SAXParseException(e.getMessage(),NULL_LOCATOR,e)); // bug 6449684, spec 4.3.4 throw new WebServiceException(e.getMessage(),e); } }