Java Code Examples for javax.xml.transform.sax.SAXSource#setSystemId()

The following examples show how to use javax.xml.transform.sax.SAXSource#setSystemId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CatalogSupport4.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name = "data_ValidatorA")
public Object[][] getDataValidator() {
    DOMSource ds = getDOMSource(xml_val_test, xml_val_test_id, true, true, xml_catalog);

    SAXSource ss = new SAXSource(new InputSource(xml_val_test));
    ss.setSystemId(xml_val_test_id);

    StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id, true, true, xml_catalog);
    StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id, true, true, xml_catalog);

    StreamSource source = new StreamSource(new File(xml_val_test));

    return new Object[][]{
        // use catalog
        {true, false, true, ds, null, null, xml_catalog, null},
        {false, true, true, ds, null, null, null, xml_catalog},
        {true, false, true, ss, null, null, xml_catalog, null},
        {false, true, true, ss, null, null, null, xml_catalog},
        {true, false, true, stax, null, null, xml_catalog, xml_catalog},
        {false, true, true, stax1, null, null, xml_catalog, xml_catalog},
        {true, false, true, source, null, null, xml_catalog, null},
        {false, true, true, source, null, null, null, xml_catalog},
    };
}
 
Example 2
Source File: CatalogSupport5.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name = "data_ValidatorC")
public Object[][] getDataValidator() {
    DOMSource ds = getDOMSource(xml_val_test, xml_val_test_id, true, true, xml_catalog);

    SAXSource ss = new SAXSource(new InputSource(xml_val_test));
    ss.setSystemId(xml_val_test_id);

    StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog);
    StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog);

    StreamSource source = new StreamSource(new File(xml_val_test));

    return new Object[][]{
        // use catalog
        {false, false, true, ds, null, null, xml_bogus_catalog, null},
        {false, false, true, ds, null, null, null, xml_bogus_catalog},
        {false, false, true, ss, null, null, xml_bogus_catalog, null},
        {false, false, true, ss, null, null, null, xml_bogus_catalog},
        {false, false, true, stax, null, null, xml_bogus_catalog, null},
        {false, false, true, stax1, null, null, null, xml_bogus_catalog},
        {false, false, true, source, null, null, xml_bogus_catalog, null},
        {false, false, true, source, null, null, null, xml_bogus_catalog},
    };
}
 
Example 3
Source File: CatalogSupport2.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name = "data_ValidatorC")
public Object[][] getDataValidator() {
    DOMSource ds = getDOMSource(xml_val_test, xml_val_test_id, true, true, xml_catalog);

    SAXSource ss = new SAXSource(new InputSource(xml_val_test));
    ss.setSystemId(xml_val_test_id);

    StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog);
    StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog);

    StreamSource source = new StreamSource(new File(xml_val_test));

    return new Object[][]{
        // use catalog
        {false, false, true, ds, null, null, xml_catalog, null},
        {false, false, true, ds, null, null, null, xml_catalog},
        {false, false, true, ss, null, null, xml_catalog, null},
        {false, false, true, ss, null, null, null, xml_catalog},
        {false, false, true, stax, null, null, xml_catalog, null},
        {false, false, true, stax1, null, null, null, xml_catalog},
        {false, false, true, source, null, null, xml_catalog, null},
        {false, false, true, source, null, null, null, xml_catalog},
    };
}
 
Example 4
Source File: CatalogTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name = "supportLSResourceResolver1")
public Object[][] supportLSResourceResolver1() throws Exception {
    URI catalogFile = getClass().getResource("CatalogSupport.xml").toURI();
    URI catalogFileUri = getClass().getResource("CatalogSupport_uri.xml").toURI();

    /*
     * val_test.xml has a reference to system.dtd and val_test.xsd
    */
    SAXSource ss = new SAXSource(new InputSource(xml_val_test));
    ss.setSystemId(xml_val_test_id);

    return new Object[][]{
        {catalogFile, ss},
        {catalogFileUri, ss},
     };
}
 
Example 5
Source File: CatalogTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name = "supportURIResolver")
public Object[][] supportURIResolver() throws Exception {
    URI catalogFile = getClass().getResource("CatalogSupport.xml").toURI();
    URI catalogFileUri = getClass().getResource("CatalogSupport_uri.xml").toURI();
    SAXSource xslSource = new SAXSource(new InputSource(new File(xsl_doc).toURI().toASCIIString()));

    /*
     * val_test.xml has a reference to system.dtd and val_test.xsd
    */
    SAXSource ss = new SAXSource(new InputSource(xml_val_test));
    ss.setSystemId(xml_val_test_id);

    return new Object[][]{
        {catalogFile, new SAXSource(new InputSource(new File(xsl_doc).toURI().toASCIIString())),
            new StreamSource(new File(xml_doc)), "Resolved by a catalog"},
        {catalogFileUri, new SAXSource(new InputSource(new StringReader(xsl_include))),
            new StreamSource(new StringReader(xml_xsl)), null},
     };
}
 
Example 6
Source File: XSLTExFuncTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
void transform(TransformerFactory factory) throws TransformerConfigurationException, TransformerException {
    SAXSource xslSource = new SAXSource(new InputSource(xslFile));
    xslSource.setSystemId(xslFileId);
    Transformer transformer = factory.newTransformer(xslSource);
    StringWriter stringResult = new StringWriter();
    Result result = new StreamResult(stringResult);
    transformer.transform(new SAXSource(new InputSource(xmlFile)), result);
}
 
Example 7
Source File: XSLTExFuncTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
void transform(TransformerFactory factory) throws TransformerConfigurationException, TransformerException {
    SAXSource xslSource = new SAXSource(new InputSource(xslFile));
    xslSource.setSystemId(xslFileId);
    Transformer transformer = factory.newTransformer(xslSource);
    StringWriter stringResult = new StringWriter();
    Result result = new StreamResult(stringResult);
    transformer.transform(new SAXSource(new InputSource(xmlFile)), result);
}
 
Example 8
Source File: XSLTExFuncTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
void transform(TransformerFactory factory) throws TransformerConfigurationException, TransformerException {
    SAXSource xslSource = new SAXSource(new InputSource(xslFile));
    xslSource.setSystemId(xslFileId);
    Transformer transformer = factory.newTransformer(xslSource);
    StringWriter stringResult = new StringWriter();
    Result result = new StreamResult(stringResult);
    transformer.transform(new SAXSource(new InputSource(xmlFile)), result);
}
 
Example 9
Source File: XSLTExFuncTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
void transform(TransformerFactory factory) throws TransformerConfigurationException, TransformerException {
    SAXSource xslSource = new SAXSource(new InputSource(xslFile));
    xslSource.setSystemId(xslFileId);
    Transformer transformer = factory.newTransformer(xslSource);
    StringWriter stringResult = new StringWriter();
    Result result = new StreamResult(stringResult);
    transformer.transform(new SAXSource(new InputSource(xmlFile)), result);
}
 
Example 10
Source File: XSLTExFuncTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
void transform(TransformerFactory factory) throws TransformerConfigurationException, TransformerException {
    SAXSource xslSource = new SAXSource(new InputSource(xslFile));
    xslSource.setSystemId(xslFileId);
    Transformer transformer = factory.newTransformer(xslSource);
    StringWriter stringResult = new StringWriter();
    Result result = new StreamResult(stringResult);
    transformer.transform(new SAXSource(new InputSource(xmlFile)), result);
}
 
Example 11
Source File: XSLTExFuncTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
void transform(TransformerFactory factory) throws TransformerConfigurationException, TransformerException {
    SAXSource xslSource = new SAXSource(new InputSource(xslFile));
    xslSource.setSystemId(xslFileId);
    Transformer transformer = factory.newTransformer(xslSource);
    StringWriter stringResult = new StringWriter();
    Result result = new StreamResult(stringResult);
    transformer.transform(new SAXSource(new InputSource(xmlFile)), result);
}
 
Example 12
Source File: SAXSourceTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * This test case tries to get InputSource from SAXSource using
 * sourceToInputSource method. This will also check if the systemId
 * remained the same. This is a positive test case.
 *
 * @throws IOException reading file error.
 */
@Test
public void source2inputsource03() throws IOException {
    String SYSTEM_ID = "file:///" + XML_DIR;
    try (FileInputStream fis = new FileInputStream(TEST_FILE)) {
        SAXSource saxSource =
                new SAXSource(new InputSource(fis));
        saxSource.setSystemId(SYSTEM_ID);
        assertEquals(SAXSource.sourceToInputSource(saxSource).getSystemId(),
                SYSTEM_ID);
    }
}
 
Example 13
Source File: CatalogSupport1.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "data_ValidatorC")
public Object[][] getDataValidator() {
    DOMSource ds = getDOMSource(xml_val_test, xml_val_test_id, false, true, null);

    SAXSource ss = new SAXSource(new InputSource(xml_val_test));
    ss.setSystemId(xml_val_test_id);

    StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog);
    StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog);

    StreamSource source = new StreamSource(new File(xml_val_test));

    String[] systemIds = {"system.dtd", "val_test.xsd"};
    XmlInput[] returnValues = {new XmlInput(null, dtd_system, null), new XmlInput(null, xsd_val_test, null)};
    LSResourceResolver resolver = new SourceResolver(null, systemIds, returnValues);

    StAXSource stax2 = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog);

    return new Object[][]{
        // use catalog
        {false, false, true, ds, null, null, null, null},
        {false, false, true, ds, null, null, null, null},
        {false, false, true, ss, null, null, null, null},
        {false, false, true, ss, null, null, null, null},
        {false, false, true, stax, null, null, null, null},
        {false, false, true, stax1, null, null, null, null},
        {false, false, true, source, null, null, null, null},
        {false, false, true, source, null, null, null, null},
        // use resolver
        {false, false, true, ds, resolver, resolver, xml_bogus_catalog, xml_bogus_catalog},
        {false, false, true, ss, resolver, resolver, xml_bogus_catalog, xml_bogus_catalog},
        {false, false, true, stax2, resolver, resolver, xml_bogus_catalog, xml_bogus_catalog},
        {false, false, true, source, resolver, resolver, xml_bogus_catalog, xml_bogus_catalog}
    };
}
 
Example 14
Source File: XSLTExFuncTest.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
void transform(TransformerFactory factory) throws TransformerConfigurationException, TransformerException {
    SAXSource xslSource = new SAXSource(new InputSource(xslFile));
    xslSource.setSystemId(xslFileId);
    Transformer transformer = factory.newTransformer(xslSource);
    StringWriter stringResult = new StringWriter();
    Result result = new StreamResult(stringResult);
    transformer.transform(new SAXSource(new InputSource(xmlFile)), result);
}
 
Example 15
Source File: CatalogSupport3.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "data_ValidatorC")
public Object[][] getDataValidator() {
    DOMSource ds = getDOMSource(xml_val_test, xml_val_test_id, false, true, xml_catalog);

    SAXSource ss = new SAXSource(new InputSource(xml_val_test));
    ss.setSystemId(xml_val_test_id);

    StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog);
    StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id, false, true, xml_catalog);

    StreamSource source = new StreamSource(new File(xml_val_test));

    return new Object[][]{
        // use catalog disabled through factory
        {true, false, false, ds, null, null, xml_catalog, null},
        {true, false, false, ds, null, null, null, xml_catalog},
        {true, false, false, ss, null, null, xml_catalog, null},
        {true, false, false, ss, null, null, null, xml_catalog},
        {true, false, false, stax, null, null, xml_catalog, null},
        {true, false, false, stax1, null, null, null, xml_catalog},
        {true, false, false, source, null, null, xml_catalog, null},
        {true, false, false, source, null, null, null, xml_catalog},
        // use catalog disabled through validatory
        {false, true, false, ds, null, null, xml_catalog, null},
        {false, true, false, ds, null, null, null, xml_catalog},
        {false, true, false, ss, null, null, xml_catalog, null},
        {false, true, false, ss, null, null, null, xml_catalog},
        {false, true, false, stax, null, null, xml_catalog, null},
        {false, true, false, stax1, null, null, null, xml_catalog},
        {false, true, false, source, null, null, xml_catalog, null},
        {false, true, false, source, null, null, null, xml_catalog},
    };
}
 
Example 16
Source File: XSLTExFuncTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
void transform(TransformerFactory factory) throws TransformerConfigurationException, TransformerException {
    SAXSource xslSource = new SAXSource(new InputSource(xslFile));
    xslSource.setSystemId(xslFileId);
    Transformer transformer = factory.newTransformer(xslSource);
    StringWriter stringResult = new StringWriter();
    Result result = new StreamResult(stringResult);
    transformer.transform(new SAXSource(new InputSource(xmlFile)), result);
}
 
Example 17
Source File: XSLTExFuncTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
void transform(TransformerFactory factory) throws TransformerConfigurationException, TransformerException {
    SAXSource xslSource = new SAXSource(new InputSource(xslFile));
    xslSource.setSystemId(xslFileId);
    Transformer transformer = factory.newTransformer(xslSource);
    StringWriter stringResult = new StringWriter();
    Result result = new StreamResult(stringResult);
    transformer.transform(new SAXSource(new InputSource(xmlFile)), result);
}
 
Example 18
Source File: XSLTExFuncTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
void transform(TransformerFactory factory) throws TransformerConfigurationException, TransformerException {
    SAXSource xslSource = new SAXSource(new InputSource(xslFile));
    xslSource.setSystemId(xslFileId);
    Transformer transformer = factory.newTransformer(xslSource);
    StringWriter stringResult = new StringWriter();
    Result result = new StreamResult(stringResult);
    transformer.transform(new SAXSource(new InputSource(xmlFile)), result);
}
 
Example 19
Source File: XSLTExFuncTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
void transform(TransformerFactory factory) throws TransformerConfigurationException, TransformerException {
    SAXSource xslSource = new SAXSource(new InputSource(xslFile));
    xslSource.setSystemId(xslFileId);
    Transformer transformer = factory.newTransformer(xslSource);
    StringWriter stringResult = new StringWriter();
    Result result = new StreamResult(stringResult);
    transformer.transform(new SAXSource(new InputSource(xmlFile)), result);
}
 
Example 20
Source File: XSLTExFuncTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
void transform(TransformerFactory factory) throws TransformerConfigurationException, TransformerException {
    SAXSource xslSource = new SAXSource(new InputSource(xslFile));
    xslSource.setSystemId(xslFileId);
    Transformer transformer = factory.newTransformer(xslSource);
    StringWriter stringResult = new StringWriter();
    Result result = new StreamResult(stringResult);
    transformer.transform(new SAXSource(new InputSource(xmlFile)), result);
}