use of javax.xml.transform.stream.StreamSource in project jdk8u_jdk by JetBrains.
the class NamespacePrefixTest method testReuseTemplates.
@Test
public void testReuseTemplates() throws Exception {
final TransformerFactory tf = TransformerFactory.newInstance();
final Source xslsrc = new StreamSource(new StringReader(XSL));
final Templates tmpl = tf.newTemplates(xslsrc);
for (int i = 0; i < TRANSF_COUNT; i++) {
checkResult(doTransformation(tmpl.newTransformer()));
}
}
use of javax.xml.transform.stream.StreamSource in project jdk8u_jdk by JetBrains.
the class TransformerTest method testBug8169112.
/**
* @bug 8169112
* @summary Test compilation of large xsl file with outlining.
*
* This test merely compiles a large xsl file and tests if its bytecode
* passes verification by invoking the transform() method for
* dummy content. The test succeeds if no Exception is thrown
*/
@Test
public final void testBug8169112() throws FileNotFoundException, TransformerException {
TransformerFactory tf = TransformerFactory.newInstance();
String xslFile = getClass().getResource("Bug8169112.xsl").toString();
Transformer t = tf.newTransformer(new StreamSource(xslFile));
String xmlIn = "<?xml version=\"1.0\"?><DOCROOT/>";
ByteArrayInputStream bis = new ByteArrayInputStream(xmlIn.getBytes());
ByteArrayOutputStream bos = new ByteArrayOutputStream();
t.transform(new StreamSource(bis), new StreamResult(bos));
}
use of javax.xml.transform.stream.StreamSource in project jdk8u_jdk by JetBrains.
the class FeaturePropagationTest method main.
public static void main(String[] args) throws Exception {
InputStreamReader reader = new InputStreamReader(new ByteArrayInputStream(xsd.getBytes()));
StreamSource xsdSource = new StreamSource(reader);
SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
schemaFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false);
Schema schema = null;
schema = schemaFactory.newSchema(xsdSource);
Validator validator = schema.newValidator();
if (validator.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING)) {
throw new RuntimeException("Feature set on the factory is not inherited!");
}
}
use of javax.xml.transform.stream.StreamSource in project jdk8u_jdk by JetBrains.
the class TransformerTest method transformResourceToStringWriter.
private StringWriter transformResourceToStringWriter(Transformer transformer, String xmlResource) throws TransformerException {
StringWriter sw = new StringWriter();
transformer.transform(new StreamSource(getClass().getResource(xmlResource).toString()), new StreamResult(sw));
return sw;
}
use of javax.xml.transform.stream.StreamSource in project jdk8u_jdk by JetBrains.
the class TransformerTest method transformInputStreamToDocument.
private Document transformInputStreamToDocument(Transformer transformer, InputStream sourceStream) throws TransformerException {
DOMResult response = new DOMResult();
transformer.transform(new StreamSource(sourceStream), response);
return (Document) response.getNode();
}
Aggregations