当前位置: 首页>>代码示例>>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;未经允许,请勿转载。