Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Plz help me using Java DOM -------- you can use Google chart tools? https://deve

ID: 657959 • Letter: P

Question

Plz help me using Java DOM --------you can use Google chart tools?https://developers.google.com/chart/interactive/docs/quick_start?csw=1 ?--------by processing the XML and  to create graphs like the one shown below...

Part of the charts.xml~~~


<?xml version="1.0"?>

<!DOCTYPE charts [
   <!ELEMENT charts (chart)>
   <!ELEMENT chart (title, columns+, rows+)>
   <!ELEMENT title (#PCDATA)>
   <!ELEMENT columns (column)+>
   <!ELEMENT column EMPTY>
   <!ELEMENT rows (row)+>
   <!ELEMENT row EMPTY>
  
   <!ATTLIST charts
           num_charts CDATA #IMPLIED
           chart_id ID #REQUIRED>
<!ATTLIST chart
           type CDATA #IMPLIED
           width CDATA #IMPLIED
           height CDATA #IMPLIED
           align CDATA #IMPLIED>
   <!ATTLIST column name (Topping|Slices) "Topping">
   <!ATTLIST column type (string|number) "string">
   <!ATTLIST row name (Mushrooms|Onions|Olives|Zucchini|Pepperoni) "Mushrooms">
   <!ATTLIST row value (3|1|2) "3">

]>


<charts num_charts="1" chart_id="chart_div">

<chart type="pie" width="400" height="300" align="left">
<title>How Much Pizza I Ate Last Night</title>
  
<columns>
<column name="Topping" type="string"/>
<column name="Slices" type="number"/>   
</columns>
  
<rows>
<row name="Mushrooms" value="3" />
<row name="Onions" value="1" />   
<row name="Olives" value="1" />
<row name="Zucchini" value="1" />
<row name="Pepperoni" value="2" />
</rows>
</chart>

</charts>

Visit Google's Charts Gallery " https://developers.google.com/chart/interactive/docs/gallery?csw=1 "

How Much Pizza l Ate Last Night Mushrooms Onions Olives 25% Zucchini 37.5% Pepper on 12.5% 12.5% 12.5%

Explanation / Answer

import java.net.URL; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; public class ValidateWithExternalDTD { private static final String URL = "http://127.0.0.1:8080/sample/charts.xml"; private static final String DTD = "http://127.0.0.1/YourDTD.dtd"; public static void main(String args[]) { try { DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance(); factory.setValidating(true); DocumentBuilder builder = factory.newDocumentBuilder(); // Set the error handler builder.setErrorHandler(new org.xml.sax.ErrorHandler() { public void fatalError(SAXParseException spex) throws SAXException { // output error and exit spex.printStackTrace(); System.exit(0); } public void error(SAXParseException spex) throws SAXParseException { // output error and continue spex.printStackTrace(); }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote