use of org.xml.sax.ContentHandler in project jackrabbit-oak by apache.
the class SessionImpl method exportSystemView.
@Override
public void exportSystemView(String absPath, OutputStream out, boolean skipBinary, boolean noRecurse) throws IOException, RepositoryException {
try {
ContentHandler handler = new ToXmlContentHandler(checkNotNull(out));
export(checkNotNull(absPath), new SystemViewExporter(this, handler, !noRecurse, !skipBinary));
} catch (SAXException e) {
Exception exception = e.getException();
if (exception instanceof RepositoryException) {
throw (RepositoryException) exception;
} else if (exception instanceof IOException) {
throw (IOException) exception;
} else {
throw new RepositoryException("Error serializing system view XML", e);
}
}
}
use of org.xml.sax.ContentHandler in project jackrabbit-oak by apache.
the class SessionImpl method exportDocumentView.
@Override
public void exportDocumentView(String absPath, OutputStream out, boolean skipBinary, boolean noRecurse) throws IOException, RepositoryException {
try {
ContentHandler handler = new ToXmlContentHandler(checkNotNull(out));
export(checkNotNull(absPath), new DocumentViewExporter(this, handler, !noRecurse, !skipBinary));
} catch (SAXException e) {
Exception exception = e.getException();
if (exception instanceof RepositoryException) {
throw (RepositoryException) exception;
} else if (exception instanceof IOException) {
throw (IOException) exception;
} else {
throw new RepositoryException("Error serializing document view XML", e);
}
}
}
use of org.xml.sax.ContentHandler in project robovm by robovm.
the class ExpatSaxParserTest method testExceptions.
public void testExceptions() {
// From startElement().
ContentHandler contentHandler = new DefaultHandler() {
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
throw new SAXException();
}
};
try {
parse(SNIPPET, contentHandler);
fail();
} catch (SAXException checked) {
/* expected */
}
// From endElement().
contentHandler = new DefaultHandler() {
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
throw new SAXException();
}
};
try {
parse(SNIPPET, contentHandler);
fail();
} catch (SAXException checked) {
/* expected */
}
// From characters().
contentHandler = new DefaultHandler() {
@Override
public void characters(char[] ch, int start, int length) throws SAXException {
throw new SAXException();
}
};
try {
parse(SNIPPET, contentHandler);
fail();
} catch (SAXException checked) {
/* expected */
}
}
use of org.xml.sax.ContentHandler in project nokogiri by sparklemotion.
the class DOM2DTMExt method dispatchToEvents.
/**
* Directly create SAX parser events from a subtree.
*
* @param nodeHandle The node ID.
* @param ch A non-null reference to a ContentHandler.
*
* @throws org.xml.sax.SAXException
*/
public void dispatchToEvents(int nodeHandle, org.xml.sax.ContentHandler ch) throws org.xml.sax.SAXException {
TreeWalker treeWalker = m_walker;
ContentHandler prevCH = treeWalker.getContentHandler();
if (null != prevCH) {
treeWalker = new TreeWalker(null);
}
treeWalker.setContentHandler(ch);
try {
Node node = getNode(nodeHandle);
treeWalker.traverseFragment(node);
} finally {
treeWalker.setContentHandler(null);
}
}
use of org.xml.sax.ContentHandler in project spring-framework by spring-projects.
the class CastorMarshaller method marshalXmlStreamWriter.
@Override
protected void marshalXmlStreamWriter(Object graph, XMLStreamWriter streamWriter) throws XmlMappingException {
ContentHandler contentHandler = StaxUtils.createContentHandler(streamWriter);
LexicalHandler lexicalHandler = null;
if (contentHandler instanceof LexicalHandler) {
lexicalHandler = (LexicalHandler) contentHandler;
}
marshalSaxHandlers(graph, StaxUtils.createContentHandler(streamWriter), lexicalHandler);
}
Aggregations