本文整理匯總了Java中javax.xml.transform.TransformerFactory.getFeature方法的典型用法代碼示例。如果您正苦於以下問題:Java TransformerFactory.getFeature方法的具體用法?Java TransformerFactory.getFeature怎麽用?Java TransformerFactory.getFeature使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.xml.transform.TransformerFactory
的用法示例。
在下文中一共展示了TransformerFactory.getFeature方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: test03
import javax.xml.transform.TransformerFactory; //導入方法依賴的package包/類
@Test
public void test03() {
String xsl = "<?xml version='1.0'?>\n" + "<xsl:stylesheet" + " xmlns:xsl='http://www.w3.org/1999/XSL/Transform'" + " version='1.0'>\n"
+ " <xsl:template match='/'>Hello World!</xsl:template>\n" + "</xsl:stylesheet>\n";
ReaderStub.used = false;
setSystemProperty("org.xml.sax.driver", ReaderStub.class.getName());
try {
TransformerFactory transFactory = TransformerFactory.newInstance();
if (transFactory.getFeature(SAXTransformerFactory.FEATURE) == false) {
System.out.println("SAXTransformerFactory not supported");
}
InputSource in = new InputSource(new StringReader(xsl));
SAXSource source = new SAXSource(in);
transFactory.newTransformer(source);
Assert.assertTrue(printWasReaderStubCreated());
} catch (TransformerException e) {
Assert.fail(e.getMessage());
}
}
示例2: testTransform_DOM_withSM
import javax.xml.transform.TransformerFactory; //導入方法依賴的package包/類
@Test(enabled=false) //skipped due to bug JDK-8080097
public void testTransform_DOM_withSM() {
System.out.println("Transform using DOM Source; Security Manager is set:");
setSystemProperty(DOM_FACTORY_ID, "MyDOMFactoryImpl");
try {
TransformerFactory factory = TransformerFactory.newInstance("com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl",
TransformerFactory.class.getClassLoader());
factory.setFeature(ORACLE_FEATURE_SERVICE_MECHANISM, true);
if ((boolean) factory.getFeature(ORACLE_FEATURE_SERVICE_MECHANISM)) {
Assert.fail("should not override in secure mode");
}
} catch (Exception e) {
Assert.fail(e.getMessage());
} finally {
clearSystemProperty(DOM_FACTORY_ID);
}
}
示例3: testNameChange
import javax.xml.transform.TransformerFactory; //導入方法依賴的package包/類
/**
* @bug 8161454
* Verifies that the new / correct name is supported, as is the old / incorrect
* one for compatibility
*/
@Test
public void testNameChange() {
boolean feature;
TransformerFactory tf = TransformerFactory.newInstance();
feature = tf.getFeature(ORACLE_ENABLE_EXTENSION_FUNCTION);
System.out.println("Default setting: " + feature);
// The default: true if no SecurityManager, false otherwise
Assert.assertTrue(feature == getDefault());
setSystemProperty(SP_ENABLE_EXTENSION_FUNCTION, getDefaultOpposite());
tf = TransformerFactory.newInstance();
feature = tf.getFeature(ORACLE_ENABLE_EXTENSION_FUNCTION);
System.out.println("After setting " + SP_ENABLE_EXTENSION_FUNCTION + ": " + feature);
clearSystemProperty(SP_ENABLE_EXTENSION_FUNCTION);
// old/incorrect name is still supported
Assert.assertTrue(feature != getDefault());
setSystemProperty(SP_ENABLE_EXTENSION_FUNCTION_SPEC, getDefaultOpposite());
tf = TransformerFactory.newInstance();
feature = tf.getFeature(ORACLE_ENABLE_EXTENSION_FUNCTION);
System.out.println("After setting " + SP_ENABLE_EXTENSION_FUNCTION_SPEC + ": " + feature);
clearSystemProperty(SP_ENABLE_EXTENSION_FUNCTION_SPEC);
// new/correct name is effective
Assert.assertTrue(feature != getDefault());
}