use of org.xml.sax.ext.LexicalHandler in project robovm by robovm.
the class TransformerImpl method executeChildTemplates.
/**
* Execute each of the children of a template element.
*
* @param elem The ElemTemplateElement that contains the children
* that should execute.
* @param handler The ContentHandler to where the result events
* should be fed.
*
* @throws TransformerException
* @xsl.usage advanced
*/
public void executeChildTemplates(ElemTemplateElement elem, ContentHandler handler) throws TransformerException {
SerializationHandler xoh = this.getSerializationHandler();
// These may well not be the same! In this case when calling
// the Redirect extension, it has already set the ContentHandler
// in the Transformer.
SerializationHandler savedHandler = xoh;
try {
xoh.flushPending();
// %REVIEW% Make sure current node is being pushed.
LexicalHandler lex = null;
if (handler instanceof LexicalHandler) {
lex = (LexicalHandler) handler;
}
m_serializationHandler = new ToXMLSAXHandler(handler, lex, savedHandler.getEncoding());
m_serializationHandler.setTransformer(this);
executeChildTemplates(elem, true);
} catch (TransformerException e) {
throw e;
} catch (SAXException se) {
throw new TransformerException(se);
} finally {
m_serializationHandler = savedHandler;
}
}
use of org.xml.sax.ext.LexicalHandler in project robovm by robovm.
the class SAXParserTest method testSetGetProperty.
public void testSetGetProperty() {
// Ordinary case
String validName = "http://xml.org/sax/properties/lexical-handler";
LexicalHandler validValue = new MockHandler(new MethodLogger());
try {
SAXParser parser = spf.newSAXParser();
parser.setProperty(validName, validValue);
assertEquals(validValue, parser.getProperty(validName));
parser.setProperty(validName, null);
assertEquals(null, parser.getProperty(validName));
} catch (Exception e) {
throw new RuntimeException("Unexpected exception", e);
}
// Unsupported property
try {
SAXParser parser = spf.newSAXParser();
parser.setProperty("foo", "bar");
fail("SAXNotRecognizedException expected");
} catch (SAXNotRecognizedException e) {
// Expected
} catch (Exception e) {
throw new RuntimeException("Unexpected exception", e);
}
try {
SAXParser parser = spf.newSAXParser();
parser.getProperty("foo");
fail("SAXNotRecognizedException expected");
} catch (SAXNotRecognizedException e) {
// Expected
} catch (Exception e) {
throw new RuntimeException("Unexpected exception", e);
}
// No name case
try {
SAXParser parser = spf.newSAXParser();
parser.setProperty(null, "bar");
fail("NullPointerException expected");
} catch (NullPointerException e) {
// Expected
} catch (Exception e) {
throw new RuntimeException("Unexpected exception", e);
}
try {
SAXParser parser = spf.newSAXParser();
parser.getProperty(null);
fail("NullPointerException expected");
} catch (NullPointerException e) {
// Expected
} catch (Exception e) {
throw new RuntimeException("Unexpected exception", e);
}
}
use of org.xml.sax.ext.LexicalHandler in project spring-framework by spring-projects.
the class CastorMarshaller method marshalXmlEventWriter.
@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);
}
use of org.xml.sax.ext.LexicalHandler in project spring-framework by spring-projects.
the class AbstractMarshaller method marshalSaxResult.
/**
* Template method for handling {@code SAXResult}s.
* <p>This implementation delegates to {@code marshalSaxHandlers}.
* @param graph the root of the object graph to marshal
* @param saxResult the {@code SAXResult}
* @throws XmlMappingException if the given object cannot be marshalled to the result
* @see #marshalSaxHandlers(Object, org.xml.sax.ContentHandler, org.xml.sax.ext.LexicalHandler)
*/
protected void marshalSaxResult(Object graph, SAXResult saxResult) throws XmlMappingException {
ContentHandler contentHandler = saxResult.getHandler();
Assert.notNull(contentHandler, "ContentHandler not set on SAXResult");
LexicalHandler lexicalHandler = saxResult.getLexicalHandler();
marshalSaxHandlers(graph, contentHandler, lexicalHandler);
}
use of org.xml.sax.ext.LexicalHandler in project spring-framework by spring-projects.
the class AbstractStaxXMLReaderTestCase method mockLexicalHandler.
private LexicalHandler mockLexicalHandler() throws Exception {
LexicalHandler lexicalHandler = mock(LexicalHandler.class);
willAnswer(new CopyCharsAnswer()).given(lexicalHandler).comment(any(char[].class), anyInt(), anyInt());
return lexicalHandler;
}
Aggregations