📄 xmlreport.java
字号:
package de.spieleck.app.jacson.report;
import java.io.*;
import java.util.*;
import de.spieleck.config.ConfigNode;
import de.spieleck.app.jacson.JacsonConfigException;
/**
* Light Report, that renders the output in a (nearly)
* correct XML.
* <br />More experimental.
* For a truely conformant XML use the XSLTReport
* without specifying a transformer (i.e. identity transformatiom).
* This handles encoding correctly.
* @author fsn
*/
public class XMLReport
extends PrintingReport
{
public void init(ConfigNode config)
throws JacsonConfigException
{
super.init(config);
pw.println("<?xml version='1.0' encoding='UTF-8'?>");
pw.println("<xmlreport>");
}
public void begin(String id)
{
// XXX The id doe not necessarily to be a valid XML name.
pw.println("<"+id+">");
begins.addLast(id);
pw.flush();
}
public void report(String localName, String value)
{
// XXX The value might not be correctly escaped in case of
// >, <, & and so on on.
pw.println("<item name='"+localName+"'>"+value+"</item>");
pw.flush();
}
public void end()
{
String h = (String) begins.removeLast();
if ( h == null )
pw.println("</???>");
else
pw.println("</"+h+">");
pw.flush();
}
public void finish(boolean close)
{
pw.println("</xmlreport>");
super.finish(close);
}
}
//
// Jacson - Text Filtering with Java.
// Copyright (C) 2002 Frank S. Nestel (nestefan -at- users.sourceforge.net)
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -