當前位置: 首頁>>代碼示例>>Java>>正文


Java StreamResult.setSystemId方法代碼示例

本文整理匯總了Java中javax.xml.transform.stream.StreamResult.setSystemId方法的典型用法代碼示例。如果您正苦於以下問題:Java StreamResult.setSystemId方法的具體用法?Java StreamResult.setSystemId怎麽用?Java StreamResult.setSystemId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.xml.transform.stream.StreamResult的用法示例。


在下文中一共展示了StreamResult.setSystemId方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createXMLDatasetFileFromList

import javax.xml.transform.stream.StreamResult; //導入方法依賴的package包/類
/**
 * Save list of record IDs as an XML file.
 * 
 * @param dbName
 * @param itemList
 * @param nodeName
 * @param fn_xml
 * @throws Exception
 */
public static void createXMLDatasetFileFromList(String dbName, String[] itemList,
        String nodeName, String fn_xml) throws Exception {                
    DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = docFactory.newDocumentBuilder();

    // root elements
    Document doc = docBuilder.newDocument();        
    
    Element rootElement = doc.createElement("Dataset");
    doc.appendChild(rootElement);        
    // attributes for root node
    rootElement.setAttribute("type", DATASET_TYPE_COLON);
    rootElement.setAttribute("name", dbName);
    rootElement.setAttribute("databaseroot", "./");
    
    Element ele;
    for(String item : itemList) {
        ele = doc.createElement(nodeName);
        ele.appendChild(doc.createTextNode(item));
        
        rootElement.appendChild(ele);
    }
    
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    DOMSource source = new DOMSource(doc);
    File outputFile = new File(fn_xml);
    StreamResult result = new StreamResult(outputFile);
    // replace %20 by whitespace
    result.setSystemId(result.getSystemId().replaceAll("%20", " "));
    
    transformer.transform(source, result);
}
 
開發者ID:NLPReViz,項目名稱:emr-nlp-server,代碼行數:43,代碼來源:XMLUtil.java

示例2: toStreamResult

import javax.xml.transform.stream.StreamResult; //導入方法依賴的package包/類
/** StreamResult object is re-used and the values are set appropriately.
 */
StreamResult toStreamResult(OutputStream os, Writer writer, String systemId){
    StreamResult sr = new StreamResult();
    sr.setOutputStream(os);
    sr.setWriter(writer);
    sr.setSystemId(systemId);
    return sr;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:10,代碼來源:XMLOutputFactoryImpl.java

示例3: createOutput

import javax.xml.transform.stream.StreamResult; //導入方法依賴的package包/類
@Override
public Result createOutput(String namespaceUri, String suggestedFileName) throws IOException {
    File file = new File(fileName);
    StreamResult result = new StreamResult(file);
    result.setSystemId(file.toURI().toURL().toString());
    return result;
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:8,代碼來源:PrintXmlUtility.java

示例4: createXMLPredictor

import javax.xml.transform.stream.StreamResult; //導入方法依賴的package包/類
/**
 * Save a list of models in XML file
 * 
 * @param sessionIDList
 * @param userIDList
 * @param varIDList
 * @param predictorXMLFolder
 * @param maxSessionID
 * @param maxUserID
 * @param fn_xmlPredictor
 * @return
 * @throws Exception
 */
public static String createXMLPredictor(String[] sessionIDList, String[] userIDList, 
        String[] varIDList, String predictorXMLFolder, String maxSessionID,
        String maxUserID, String fn_xmlPredictor) throws Exception {
    DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = docFactory.newDocumentBuilder();

    // root elements
    Document doc = docBuilder.newDocument();        
    
    Element rootElement = doc.createElement("MLPredictor");
    doc.appendChild(rootElement);        
    // attributes for root node
    rootElement.setAttribute("type", "mlpredictor_colonoscopy_vars");
    rootElement.setAttribute("name", "emr-vis-nlp_colonoscopy_" +
            maxSessionID  + "_" + maxUserID);
    rootElement.setAttribute("modelroot", "./");
    // removed the foldname
    
    Element ele;
    Element vals;
    String varID, userID, sessionID;
    for(int i = 0; i < varIDList.length; i++) {
        varID = varIDList[i];
        userID = userIDList[i];
        sessionID = sessionIDList[i];
        ele = doc.createElement("Attr");
        ele.setAttribute("name", varID);
        ele.setAttribute("type", "variable_categorical");
        ele.setAttribute("fileName", sessionID + "." + userID + "." + varID);
        vals = doc.createElement("Vals");
        vals.appendChild(doc.createTextNode("False True"));
        ele.appendChild(vals);
        
        rootElement.appendChild(ele);
    }
    
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    DOMSource source = new DOMSource(doc);
    File outputFile = new File(fn_xmlPredictor);
    StreamResult result = new StreamResult(outputFile);
    // replace %20 by whitespace
    result.setSystemId(result.getSystemId().replaceAll("%20", " "));
    
    transformer.transform(source, result);
    
    return rootElement.getAttribute("name");
}
 
開發者ID:NLPReViz,項目名稱:emr-nlp-server,代碼行數:62,代碼來源:XMLUtil.java


注:本文中的javax.xml.transform.stream.StreamResult.setSystemId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。