|
IntroductionXML is a general purpose tag language developed by the web consortium (W3C). The syntax of XML is very similar to HTML, except that unlike HTML, XML does not define a priori any specific tags. Instead it is up to users of XML within any specific problem domain to develop their own set of tags. HTML can be thought of as a particular set of XML tags for use in the web browser page display domain. XML includes the concept of a DTD, a file which defines a set of tags for a particular problem domain, as well as rules for how tags can be nested and what attributes each tag allows. We have developed a DTD for storing HEP plots as XML. The DTD supports storing all of the display attributes supported by the JAS plot bean. In addition the DTD supports:
Storing the data in the XML itself is useful for storing a snapshot of the data. Storing a reference to the data is useful when the goal is to store the style attributes of a plot, but to access the current "live" version of the data. One advantage of XML is that it is an ASCII format and can, when necessary be edited by hand. The JAS XML has been designed with this capability in mind. In addition we have tried to make the XML format used as generic as possible, in the hopes that it can be used as the basis of a mechanism to exchange plots between different applications in future. Some Simple XML ExamplesExample 1The first example XML file creates a simple 1D histogram from data stored in the XML file itself. The first two lines of the XML file are necessary boilerplate which should appear in all such XML files. Following that the tags define a single plot which has a data area displaying binned 1D data that is specified in the XML file itself. The resulting plot is show below.
More examples to come. The Babar JAS/XML/HTML page also has some detail on using XML to create plots for JAS. PlotML extensionsAs of JAS 2.2.2 it is possible to specify normalization and function overlays (and fits) in the plotml (xml) file. Normalizing PlotsYou can normalize a plot by adding the following tag after the style tag <normalization method="AREA"> The method can be one of:
In addition you can specify the following attributes:
Normalization ExamplesFitting PlotsYou can overlay a function on a plot, and optionally fit it to a dataset by specifying the following tag. <function1d type="Gaussian"> <functionParam name="amplitude" value="372"/> <functionParam name="mean" value="0.996"/> <functionParam name="sigma"value="0.123"/> <functionStyle1d lineColor="Blue"/> </function1d> Where type can be one of:
In addition you can specify <fit ref=dataTag> to fit the function to a specific dataset. To use this option you must tag the data you want to fit by specifying a name=dataTag attribute on the data1D tag. Fitting ExamplesRelated InfomationCreating XML files from within JASThe easiest way to create an XML file is to create the plot graphically inside JAS, and then to right click on the plot and choose "Save Plot As..." from the popup menu. In the file chooser which will then popup be sure to select XML File as the file type before selecting a filename to save your file as. Reading XML files from within JASIn a forthcoming release of JAS you will be able to read XML containing plots simply by choosing Open from the File menu and selecting a file of type XML. Until then you can run the standalone XML viewer utility using the command (after having set the appropriate CLASSPATH): java jas.hist.test.XMLHistViewer yourxmlfile.xml Details of the DTDFor a detailed description of what is allowed in the XML file, refer to the most recent version of the PlotML.dtd file from the JAS source code repository. Using XML with ServletsThe Servlet How To includes an example of using XML with servlets. Using XML to display Plots in HTML pagesThe HTML How To describes how to use the jas.bean.XMLPlot bean to display plots based on XML within the JAS HTML viewer. |
Page last updated: Wednesday, January 14, 2004 by SLAC\tonyj