用Java从XML文件中获取业务图表 - 编程入门网
作者 佚名技术
来源 NET编程
浏览
发布时间 2012-06-23
set; import com.jrefinery.data.PieDataset; import com.jrefinery.data.HighLowDataset; import com.jrefinery.data.XYDataset; import com.jrefinery.data.DefaultXYDataset; import com.jrefinery.data.DatasetUtilities; import java.awt.geom.Rectangle2D; import org.apache.xerces.parsers.DOMParser; import org.apache.xpath.XPathAPI; import org.apache.xml.utils.TreeWalker; import org.apache.xml.utils.DOMBuilder; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.DocumentFragment; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.w3c.dom.traversal.NodeIterator; import org.xml.sax.SAXException; import org.xml.sax.InputSource; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.w3c.dom.DOMImplementation; import javax.xml.transform.*; import javax.xml.transform.stream.*; import javax.xml.transform.dom.*; public class BizCharter extends HttpServlet { private static final String CONTENT_TYPE = "image/jpeg"; private static final String DOC_TYPE; private static final String CONFIG_LOC = "http://localhost/charts.xml"; private String version = "0.1.2"; Document xmlConfig; Document xmlData; Document xmlChartSetup; Vector strDataXPaths = new Vector(); Vector strCategoryXPaths = new Vector(); Vector strSTitles = new Vector(); protected String strXPath; private int nCategoryXPathCount=0; private String strDataURL; private String strChartConfigURL; private String strService; private NodeIterator niNodeList; private NodeIterator niServiceList; private Node ndeItem; private Node ndeService; private Element elemItem; private Element elemService; private String strDummy; private DocumentBuilderFactory dfactory; private int nXSize = 0; private int nYSize = 0; private CategoryDataset categoryData; private JFreeChart chart; private boolean bFirstTime=false; private int nDataXPathCount=0; public void init(ServletConfig config) throws ServletException { super.init(config); } public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String strChart = "Points"; String strX = "0"; String strY = "0"; try { strChart = request.getParameter("chart").toLowerCase(); strX = request.getParameter("width"); strY = request.getParameter("height"); if(strX==null) strX = "0"; if(strY==null) strY = "0"; dfactory = DocumentBuilderFactory.newInstance(); dfactory.setNamespaceAware(true); URLConnection con = new URL(CONFIG_LOC).openConnection(); con.connect(); InputStream newin = con.getInputStream(); xmlConfig = dfactory.newDocumentBuilder().parse(newin); strXPath = "/root/chart[@id=''" + strChart + "'']"; niNodeList = XPathAPI.selectNodeIterator(xmlConfig, strXPath); ndeItem = niNodeList.nextNode(); elemItem = (Element) ndeItem; strDataURL = GetChil |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
关于用Java从XML文件中获取业务图表 - 编程入门网的所有评论