use of javax.xml.transform.sax.SAXSource in project jersey by jersey.
the class AbstractJaxbProviderTest method abstractJaxbProviderDoesNotReadExternalDtds.
@Test
public void abstractJaxbProviderDoesNotReadExternalDtds() throws Exception {
SAXParserFactory spf = injectionManager.getInstance(SAXParserFactory.class);
String url = "file:///no-such-file";
String s = "<!DOCTYPE x SYSTEM '" + url + "'><x/>";
SAXSource saxSource = AbstractJaxbProvider.getSAXSource(spf, new ByteArrayInputStream(s.getBytes("us-ascii")));
TransformerFactory.newInstance().newTransformer().transform(saxSource, new StreamResult(new ByteArrayOutputStream()));
}
use of javax.xml.transform.sax.SAXSource in project jersey by jersey.
the class SourceProviderTest method saxSourceReaderDoesNotReadExternalDtds.
@Test
public void saxSourceReaderDoesNotReadExternalDtds() throws Exception {
SourceProvider.SaxSourceReader reader = injectionManager.getInstance(SourceProvider.SaxSourceReader.class);
InputStream entityStream = new ByteArrayInputStream("<!DOCTYPE x SYSTEM 'file:///no-such-file'> <rootObject/>".getBytes("us-ascii"));
SAXSource ss = reader.readFrom(null, null, null, null, null, entityStream);
TransformerFactory.newInstance().newTransformer().transform(ss, new StreamResult(new ByteArrayOutputStream()));
}
use of javax.xml.transform.sax.SAXSource in project camel by apache.
the class JcloudsBlobStoreProducerTest method testBlobStorePutWithStreamAndGet.
@Test
public void testBlobStorePutWithStreamAndGet() throws InterruptedException, TransformerException {
ByteArrayInputStream inputStream = new ByteArrayInputStream(MESSAGE.getBytes());
Exchange exchange = new DefaultExchange(context);
StreamCache streamCache = StreamCacheConverter.convertToStreamCache(new SAXSource(new InputSource(inputStream)), exchange);
template.sendBody("direct:put-and-get", streamCache);
Object result = template.requestBodyAndHeader("direct:put-and-get", null, JcloudsConstants.OPERATION, JcloudsConstants.GET, String.class);
assertEquals(MESSAGE, result);
}
use of javax.xml.transform.sax.SAXSource in project camel by apache.
the class SchematronProcessor method validate.
/**
* Validates the given XML for given Rules.
*
* @param xml
* @return
*/
public String validate(final String xml) {
try {
final Source source = new SAXSource(reader, new InputSource(IOUtils.toInputStream(xml)));
final StringWriter writer = new StringWriter();
templates.newTransformer().transform(source, new StreamResult(writer));
return writer.toString();
} catch (TransformerException e) {
logger.error(e.getMessage());
throw new SchematronValidationException("Failed to apply Schematron validation transform", e);
}
}
use of javax.xml.transform.sax.SAXSource in project camel by apache.
the class XmlConverterTest method testToSaxSourceByCustomSource.
public void testToSaxSourceByCustomSource() throws Exception {
XmlConverter conv = new XmlConverter();
Source dummy = new Source() {
public String getSystemId() {
return null;
}
public void setSystemId(String s) {
}
};
SAXSource out = conv.toSAXSource(dummy, null);
assertNull(out);
}
Aggregations