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


Java TransformerFactory.setURIResolver方法代码示例

本文整理汇总了Java中javax.xml.transform.TransformerFactory.setURIResolver方法的典型用法代码示例。如果您正苦于以下问题:Java TransformerFactory.setURIResolver方法的具体用法?Java TransformerFactory.setURIResolver怎么用?Java TransformerFactory.setURIResolver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.xml.transform.TransformerFactory的用法示例。


在下文中一共展示了TransformerFactory.setURIResolver方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTransformerFactory

import javax.xml.transform.TransformerFactory; //导入方法依赖的package包/类
/**
 * Returns an instance of TransformerFactory with either a custom URIResolver
 * or Catalog.
 *
 * @param setUseCatalog a flag indicates whether USE_CATALOG shall be set
 * through the factory
 * @param useCatalog the value of USE_CATALOG
 * @param catalog a catalog
 * @param resolver a custom resolver
 * @return an instance of TransformerFactory
 * @throws Exception
 */
TransformerFactory getTransformerFactory(boolean setUseCatalog, boolean useCatalog,
        String catalog, URIResolver resolver)
        throws Exception {

    TransformerFactory factory = TransformerFactory.newInstance();
    if (setUseCatalog) {
        factory.setFeature(XMLConstants.USE_CATALOG, useCatalog);
    }
    if (catalog != null) {
        factory.setAttribute(CatalogFeatures.Feature.FILES.getPropertyName(), catalog);
    }

    // use resolver or catalog if resolver = null
    if (resolver != null) {
        factory.setURIResolver(resolver);
    }

    return factory;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:CatalogSupportBase.java

示例2: supportURIResolver

import javax.xml.transform.TransformerFactory; //导入方法依赖的package包/类
@Test(dataProvider = "supportURIResolver")
public void supportURIResolver(URI catalogFile, Source xsl, Source xml, String expected) throws Exception {

    CatalogResolver cr = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalogFile);

        TransformerFactory factory = TransformerFactory.newInstance();
        factory.setURIResolver(cr);
        Transformer transformer = factory.newTransformer(xsl);
        StringWriter out = new StringWriter();
        transformer.transform(xml, new StreamResult(out));
        if (expected != null) {
            Assert.assertTrue(out.toString().contains(expected), "supportURIResolver");
        }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:CatalogTest.java

示例3: resolver01

import javax.xml.transform.TransformerFactory; //导入方法依赖的package包/类
/**
 * This is to test the URIResolver.resolve() method when a transformer is
 * created using StreamSource. style-sheet file has xsl:include in it.
 *
 * @throws Exception If any errors occur.
 */
@Test
public static void resolver01() throws Exception {
    try (FileInputStream fis = new FileInputStream(XSL_INCLUDE_FILE)) {
        TransformerFactory tfactory = TransformerFactory.newInstance();
        URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID);
        tfactory.setURIResolver(resolver);

        StreamSource streamSource = new StreamSource(fis);
        streamSource.setSystemId(SYSTEM_ID);
        assertNotNull(tfactory.newTransformer(streamSource));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:URIResolverTest.java

示例4: resolver02

import javax.xml.transform.TransformerFactory; //导入方法依赖的package包/类
/**
 * This is to test the URIResolver.resolve() method when a transformer is
 * created using DOMSource. style-sheet file has xsl:include in it.
 *
 * @throws Exception If any errors occur.
 */
@Test
public static void resolver02() throws Exception {
    TransformerFactory tfactory = TransformerFactory.newInstance();
    URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID);
    tfactory.setURIResolver(resolver);

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    DocumentBuilder db = dbf.newDocumentBuilder();
    Document document = db.parse(XSL_INCLUDE_FILE);
    DOMSource domSource = new DOMSource(document, SYSTEM_ID);

    assertNotNull(tfactory.newTransformer(domSource));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:URIResolverTest.java

示例5: resolver03

import javax.xml.transform.TransformerFactory; //导入方法依赖的package包/类
/**
 * This is to test the URIResolver.resolve() method when a transformer is
 * created using SAXSource. style-sheet file has xsl:include in it.
 *
 * @throws Exception If any errors occur.
 */
@Test
public static void resolver03() throws Exception {
    try (FileInputStream fis = new FileInputStream(XSL_INCLUDE_FILE)){
        URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID);
        TransformerFactory tfactory = TransformerFactory.newInstance();
        tfactory.setURIResolver(resolver);
        InputSource is = new InputSource(fis);
        is.setSystemId(SYSTEM_ID);
        SAXSource saxSource = new SAXSource(is);
        assertNotNull(tfactory.newTransformer(saxSource));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:URIResolverTest.java

示例6: resolver04

import javax.xml.transform.TransformerFactory; //导入方法依赖的package包/类
/**
 * This is to test the URIResolver.resolve() method when a transformer is
 * created using StreamSource. style-sheet file has xsl:import in it.
 *
 * @throws Exception If any errors occur.
 */
@Test
public static void resolver04() throws Exception {
    try (FileInputStream fis = new FileInputStream(XSL_IMPORT_FILE)) {
        URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID);
        TransformerFactory tfactory = TransformerFactory.newInstance();
        tfactory.setURIResolver(resolver);
        StreamSource streamSource = new StreamSource(fis);
        streamSource.setSystemId(SYSTEM_ID);
        assertNotNull(tfactory.newTransformer(streamSource));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:URIResolverTest.java

示例7: resolver05

import javax.xml.transform.TransformerFactory; //导入方法依赖的package包/类
/**
 * This is to test the URIResolver.resolve() method when a transformer is
 * created using DOMSource. style-sheet file has xsl:import in it.
 *
 * @throws Exception If any errors occur.
 */
@Test
public static void resolver05() throws Exception {
    URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID);
    TransformerFactory tfactory = TransformerFactory.newInstance();
    tfactory.setURIResolver(resolver);
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    dbf.setNamespaceAware(true);
    DocumentBuilder db = dbf.newDocumentBuilder();
    Document document = db.parse(new File(XSL_IMPORT_FILE));
    DOMSource domSource = new DOMSource(document, SYSTEM_ID);
    assertNotNull(tfactory.newTransformer(domSource));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:URIResolverTest.java

示例8: resolver06

import javax.xml.transform.TransformerFactory; //导入方法依赖的package包/类
/**
 * This is to test the URIResolver.resolve() method when a transformer is
 * created using SAXSource. style-sheet file has xsl:import in it.
 *
 * @throws Exception If any errors occur.
 */
@Test
public static void resolver06() throws Exception {
    try (FileInputStream fis = new FileInputStream(XSL_IMPORT_FILE)){
        URIResolverTest resolver = new URIResolverTest(XSL_TEMP_FILE, SYSTEM_ID);
        TransformerFactory tfactory = TransformerFactory.newInstance();
        tfactory.setURIResolver(resolver);
        InputSource is = new InputSource(fis);
        is.setSystemId(SYSTEM_ID);
        SAXSource saxSource = new SAXSource(is);
        assertNotNull(tfactory.newTransformer(saxSource));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:URIResolverTest.java


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