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


Java Document.setUserData方法代碼示例

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


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

示例1: process

import org.w3c.dom.Document; //導入方法依賴的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: process

import org.w3c.dom.Document; //導入方法依賴的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

示例3: decorateDocument

import org.w3c.dom.Document; //導入方法依賴的package包/類
/**
 * Decorates the document with the specified file name, which can be
 * retrieved later by calling {@link #extractLineNumber(Node)}.
 * <p/>
 * It also tries to add line number information, with the caveat that the
 * current implementation is a gross approximation.
 * <p/>
 * There is no need to call this after calling one of the {@code parseDocument()}
 * methods since they already decorated their own document.
 *
 * @param doc The document to decorate.
 * @param fileName The name to retrieve later for that document.
 */
static void decorateDocument(@NonNull Document doc, @NonNull String fileName) {
    doc.setUserData(DATA_FILE_NAME, fileName, null /*handler*/);
    findLineNumbers(doc, 1);
}
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:18,代碼來源:MergerXmlUtils.java


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