当前位置: 首页>>代码示例>>Java>>正文


Java TransformerFactory.getFeature方法代码示例

本文整理汇总了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());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:Bug6490921.java

示例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);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:Bug7143711Test.java

示例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());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:XSLTFunctionsTest.java


注:本文中的javax.xml.transform.TransformerFactory.getFeature方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。