ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  SVG not well formed XML
Posted by Sam Leung on Jul-18-2011 23:42
I modified your "Concentric Donut Chart" sample codes to generate a SVG output to a SAXParser, the parser threw the following exception:


org.xml.sax.SAXParseException: The entity name must immediately follow the '&' in the entity reference.
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)

I got the same error when I tried validating the file output using Oxygen, can you shed some lights on this, below is the modified codes:


public byte[] getChartSVG() {
int angle = 50;

//The data for the pie chart
double[] data = {25, 18, 15, 12, 8, 30, 35, 40 };
double[] data2 = {20, 25, 15, 10, 15, 35, 20, 35 };

//The labels for the pie chart
String[] labels = {"Cash", "Bonds - Coporate (Cautious)", "Venture", "Other", "Equities - AIM (alternative Investment Market",
"Futures & Options", "Funds - Corporate Bond", "Enterprise Investment Schemes"};

// Create a PieChart object of size 700 x 360 pixels, with transparent background
PieChart c = new PieChart(700, 360);
c.enableVectorOutput();

// Add a title to the chart with 18pts Times Bold Italic font
c.addTitle("Concentric Donut Chart", "Times New Roman Bold Italic", 18);

// Set donut center at (160, 200), and outer/inner radii as 150/100 pixels
c.setDonutSize(160, 200, 150, 100);

// Add a label at the bottom-right corner of the ring to label the outer ring Use
// 12pts Arial Bold Italic font in white (ffffff) color, on a green (008800)
// background, with soft lighting effect and 5 pixels rounded corners
TextBox t = c.addText(260, 300, " Year 2006 ", "Arial Bold Italic", 12, 0xffffff);
t.setBackground(0x008800, Chart.Transparent, Chart.softLighting());
t.setRoundedCorners(5);

// Set the legend box at (320, 50) with 12 pts Arial Bold Italic font, with no border
c.addLegend(320, 50, true, "Arial Bold Italic",
3).setBackground(Chart.Transparent,  Chart.Transparent);

// Set the pie data and the pie labels
c.setData(data, labels);

//Use ring shading effect for the sectors
c.setSectorStyle(Chart.RoundedEdgeShading);

c.setLabelStyle("Arial Bold", 10, Chart.Transparent);

c.set3D(25, angle);

// write output to file system
c.makeChart("C:\\\\Share\\\\test.svg");

// return svg byte output to caller
return c.makeChart(Chart.SVG);
}

  Re: SVG not well formed XML
Posted by Peter Kwan on Jul-19-2011 03:04
Hi Sam,

We apologize very much for this problem. This is in fact due to a bug in ChartDirector, in that it does not escape "&" property when generating the SVG.

I have just uploaded and updated "ChartDirector.jar" and "ChartDirector_s.jar" for "ChartDirector for JSP/Java" that can solve the problem. Please use the updated JAR to replace you existing JAR files to solve the problem.

http://www.advsofteng.com/chartdir_java_502p4.zip

Hope this can help.

Regards
Peter Kwan