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


Java Source.setSystemId方法代码示例

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


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

示例1: getSchema

import javax.xml.transform.Source; //导入方法依赖的package包/类
@Override
protected Schema getSchema(Model model) {
    if (! (model instanceof WSDLModel)) {
        return null;
    }
    
    InputStream wsdlSchemaInputStream = WSDLSchemaValidator.class.getResourceAsStream(wsdlXSDUrl);
    Source wsdlSource = new StreamSource(wsdlSchemaInputStream);
    wsdlSource.setSystemId(WSDLSchemaValidator.class.getResource(wsdlXSDUrl).toString());
    
    //combine all possible schemas through ElementFactoryProvider mechanism
    Collection<ValidatorSchemaFactory> extSchemaFactories = ValidatorSchemaFactoryRegistry.getDefault().getAllValidatorSchemaFactories();
    
    ArrayList<Source> isList = new ArrayList<Source>();
    isList.add(wsdlSource);
    for (ValidatorSchemaFactory factory : extSchemaFactories) {
        Source is = factory.getSchemaSource();
        if(is != null) {
            isList.add(is);
        } else {
            //any validator should not return a null input stream
            Logger.getLogger(getClass().getName()).severe("getSchema: " + factory.getClass() +" returned null input stream for its schema");
        }
    }

    Schema schema = getCompiledSchema(isList.toArray(new Source[isList.size()]), new CentralLSResourceResolver(extSchemaFactories), new SchemaErrorHandler());
    
    return schema;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:WSDLSchemaValidator.java

示例2: validateDocument

import javax.xml.transform.Source; //导入方法依赖的package包/类
protected void validateDocument() throws Exception {
    Source source = new DOMSource(fDocument);
    source.setSystemId(fDocumentURL.toExternalForm());
    Result result = new DOMResult(fDocument);

    fValidator.validate(source, result);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:BaseTest.java

示例3: testDOMSource

import javax.xml.transform.Source; //导入方法依赖的package包/类
@Test
public final void testDOMSource() {
    String xml = getClass().getResource("SourceTest.xml").getFile();
    xml = "file://" + xml;
    File xsl = new File(getClass().getResource("SourceTest.xsl").getFile());
    try {
        TransformerFactory tFactory = TransformerFactory.newInstance();
        Transformer transformer = tFactory.newTransformer();
        StreamSource source = new StreamSource(xsl);
        transformer = tFactory.newTransformer(source);
        // the xml result
        StringWriter xmlResultString = new StringWriter();
        StreamResult xmlResultStream = new StreamResult(xmlResultString);

        Source xmlSource = new DOMSource();
        xmlSource.setSystemId(xml);

        transformer.transform(xmlSource, xmlResultStream);
        System.out.println(xmlResultString.toString());
        String temp = xmlResultString.toString();
        int pos = temp.lastIndexOf("count");
        if (temp.substring(pos + 8, pos + 9).equals("1")) {
            Assert.fail("count=1");
        } else if (temp.substring(pos + 8, pos + 9).equals("2")) {
            // expected success
            System.out.println("count=2");
        }
    } catch (Exception e) {
        // unexpected failure
        e.printStackTrace();
        Assert.fail(e.toString());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:SourceTest.java

示例4: testSAXSource

import javax.xml.transform.Source; //导入方法依赖的package包/类
@Test
public final void testSAXSource() {
    String xml = getClass().getResource("SourceTest.xml").getFile();
    File xsl = new File(getClass().getResource("SourceTest.xsl").getFile());
    try {
        TransformerFactory tFactory = TransformerFactory.newInstance();
        Transformer transformer = tFactory.newTransformer();
        StreamSource source = new StreamSource(xsl);
        transformer = tFactory.newTransformer(source);
        // the xml result
        StringWriter xmlResultString = new StringWriter();
        StreamResult xmlResultStream = new StreamResult(xmlResultString);

        Source xmlSource = new SAXSource();
        xmlSource.setSystemId(xml);

        transformer.transform(xmlSource, xmlResultStream);
        System.out.println(xmlResultString.toString());
        String temp = xmlResultString.toString();
        int pos = temp.lastIndexOf("count");
        if (temp.substring(pos + 8, pos + 9).equals("1")) {
            Assert.fail("count=1");
        } else if (temp.substring(pos + 8, pos + 9).equals("2")) {
            // expected success
            System.out.println("count=2");
        }
    } catch (Exception e) {
        // unexpected failure
        e.printStackTrace();
        Assert.fail(e.toString());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:SourceTest.java

示例5: testStreamSource

import javax.xml.transform.Source; //导入方法依赖的package包/类
@Test
public final void testStreamSource() {
    String xml = getClass().getResource("SourceTest.xml").getFile();
    File xsl = new File(getClass().getResource("SourceTest.xsl").getFile());
    try {
        TransformerFactory tFactory = TransformerFactory.newInstance();
        Transformer transformer = tFactory.newTransformer();
        StreamSource source = new StreamSource(xsl);
        transformer = tFactory.newTransformer(source);
        // the xml result
        StringWriter xmlResultString = new StringWriter();
        StreamResult xmlResultStream = new StreamResult(xmlResultString);

        Source xmlSource = new StreamSource();
        xmlSource.setSystemId(xml);

        transformer.transform(xmlSource, xmlResultStream);
        System.out.println(xmlResultString.toString());
        String temp = xmlResultString.toString();
        int pos = temp.lastIndexOf("count");
        if (temp.substring(pos + 8, pos + 9).equals("1")) {
            Assert.fail("count=1");
        } else if (temp.substring(pos + 8, pos + 9).equals("2")) {
            // expected success
            System.out.println("count=2");
        }
    } catch (Exception e) {
        // unexpected failure
        e.printStackTrace();
        Assert.fail(e.toString());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:33,代码来源:SourceTest.java

示例6: validateFragment

import javax.xml.transform.Source; //导入方法依赖的package包/类
protected void validateFragment() throws Exception {
    Source source = new DOMSource((Node) fRootNode);
    source.setSystemId(fDocumentURL.toExternalForm());
    Result result = new DOMResult((Node) fRootNode);
    fValidator.validate(source, result);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:BaseTest.java


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