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