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


Java Transformer.reset方法代码示例

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


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

示例1: process

import javax.xml.transform.Transformer; //导入方法依赖的package包/类
@Override
    public void process(ProcessingContext<Corpus> ctx, Corpus corpus) throws ModuleException {
        try {
        	Logger logger = getLogger(ctx);
            TransformerFactory factory = TransformerFactory.newInstance();
            InputStream is = xslTransform.getInputStream();
            Source transformerSource = new StreamSource(is);
            Transformer transformer = factory.newTransformer(transformerSource);
            is.close();
            transformer.setErrorListener(new ListingErrorHandler());

            libraryResolver = getLibraryResolver(ctx);
            Evaluator roots = libraryResolver.resolveNullable(this.roots);
            Evaluator fileName = this.fileName.resolveExpressions(libraryResolver);
            EvaluationContext evalCtx = new EvaluationContext(logger);

            for (Element root : Iterators.loop(getRoots(roots, evalCtx, corpus))) {
                transformer.reset();

                Document doc = XMLUtils.docBuilder.newDocument();
                doc.setUserData(ELEMENT_USER_DATA, root, null);
//				org.w3c.dom.Element elt = getElementProxy(doc, root);
//				doc.appendChild(elt);
                Source source = new DOMSource(doc);

                String fileNameString = fileName.evaluateString(evalCtx, root);
//                System.out.println("creating file: " + fileNameString);
                File outFile = new File(outDir, fileNameString);
                Result result = new StreamResult(outFile);

                transformer.transform(source, result);
            }
        } catch (DOMException | TransformerException | IOException e) {
            rethrow(e);
        }
    }
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:37,代码来源:XMLWriter2ForINIST.java

示例2: processFile

import javax.xml.transform.Transformer; //导入方法依赖的package包/类
private void processFile(ProcessingContext<Corpus> ctx, Logger logger, Corpus corpus, InputStream file, Transformer transformer) throws ModuleException, IOException {
   	try {
   		String name = sourcePath.getStreamName(file);
   		logger.finer("reading: " + name);
   		transformer.reset();
   		transformer.setParameter(SOURCE_PATH_PARAMETER, name);
   		transformer.setParameter(SOURCE_BASENAME_PARAMETER, new File(name).getName());
   		transformer.setParameter(XML_READER_CONTEXT_PARAMETER, new XMLReaderContext(this, corpus));
   		Source source = getSource(ctx, file);
   		doTransform(ctx, transformer, source);
   	}
   	catch (TransformerException|SAXException|ParserConfigurationException e) {
   		rethrow(e);
	}
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:16,代码来源:XMLReader.java

示例3: process

import javax.xml.transform.Transformer; //导入方法依赖的package包/类
@Override
	public void process(ProcessingContext<Corpus> ctx, Corpus corpus) throws ModuleException {
		try {
	    	Logger logger = getLogger(ctx);
	    	EVALUATION_CONTEXT = new EvaluationContext(logger);
			Transformer transformer = getTransformer(ctx);

			XMLWriterResolvedObjects resObj = getResolvedObjects();
	        EvaluationContext evalCtx = new EvaluationContext(logger);
	        
	        outDir.mkdirs();
			for (Element root : Iterators.loop(getRoots(evalCtx, corpus))) {
				transformer.reset();
				
				Document doc = XMLUtils.docBuilder.newDocument();
				doc.setUserData(ELEMENT_USER_DATA, root, null);
//				org.w3c.dom.Element elt = getElementProxy(doc, root);
//				doc.appendChild(elt);
				Source source = new DOMSource(doc);
				
				String fileNameString = resObj.fileName.evaluateString(evalCtx, root);
				File outFile = new File(outDir, fileNameString);
				Result result = new StreamResult(outFile);

				doTransform(ctx, transformer, source, result);
			}
		}
		catch (DOMException|TransformerException|IOException e) {
			rethrow(e);
		}
	}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:32,代码来源:XMLWriter.java


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