當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。