|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Member
Iscritto dal: Nov 2011
Messaggi: 49
|
[XML]Utilita del parsing
Salve sto imparando un po XML,ho seguito varie guide e sono giusto a qualcosa,questo
file xml Codice:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <simulator> <compilator>gcc -o compilatore simulator.c </compilator> <source>simulator.c</source> <numero_passi>10000</numero_passi> <periodicita>10</periodicita> <colonna_passi>1</colonna_passi> <colonna_azione>2</colonna_azione> <colonna_var1>3</colonna_var1> <colonna_var2>4</colonna_var2> <output_sim>simulatorefinale.dat</output_sim> </simulator> <MILP> <source>next.lp</source> <var1>x_iL</var1> <var2>x_vO</var2> <azione>w_u</azione> <esecuzione>glpsol --lp next.lp -o next.sol</esecuzione> <output_exe>next.sol</output_exe> <final_output>SequenzaNextLp.dat</final_output> </MILP> <gnuplot> <input_source1>SimulatoreFinale.dat</input_source1> <input_source2>SequenzaNextLp.dat</input_source2> <write_terminal>gnuplot</write_terminal> <format>set term png</format> <graph_var1> <setting1>set output "grafico x_iL.png"</setting1> <plot1>plot "SimulatoreFinale.dat" using 1:2 w l, "SequenzaNextLp.dat" using 1:2 w l</plot1> </graph_var1> <graph_var2> <setting2>set output "grafico x_vO.png"</setting2> <plot2>plot "SimulatoreFinale.dat" using 1:3 w l, "SequenzaNextLp.dat" using 1:3 w l</plot2> </graph_var2> <graph_full> <setting3>set output "grafico completo.png"</setting3> <plot3>plot "SimulatoreFinale.dat" using 1:2 w l , "SimulatoreFinale.dat" using 1:3 w l, "SequenzaNextLp.dat" using 1:2 w l, "SequenzaNextLp.dat" using 1:3 w l</plot3> </graph_full> </gnuplot> </configuration> Codice:
<?xml version="1.0"?>
<!-- iniziamo lo schema -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" >
<xs:element name="configuration">
<xs:complexType>
<xs:all>
<xs:element name="simulator">
<xs:complexType>
<xs:all>
<!-- definiamo i vari elementi child di simulator -->
<xs:element name="source" type="xs:string" />
<xs:element name="compilator" type="xs:string" />
<xs:element name="numero_passi" type="xs:integer" />
<xs:element name="periodicita" type="xs:integer" />
<xs:element name="colonna_passi" type="xs:integer" />
<xs:element name="colonna_azione" type="xs:decimal" />
<xs:element name="colonna_var1" type="xs:decimal" />
<xs:element name="colonna_var2" type="xs:decimal" />
<xs:element name="output_sim" type="xs:string" />
</xs:all>
</xs:complexType>
</xs:element>
<xs:element name="MILP">
<xs:complexType>
<xs:all>
<xs:element name="source" type="xs:string" />
<xs:element name="var1" type="xs:string" />
<xs:element name="var2" type="xs:string" />
<xs:element name="azione" type="xs:string" />
<xs:element name="esecuzione" type="xs:string" />
<xs:element name="output_exe" type="xs:string" />
<xs:element name="final_output" type="xs:string" />
</xs:all>
</xs:complexType>
</xs:element>
<xs:element name="gnuplot">
<xs:complexType>
<xs:sequence>
<xs:element name="input_source1" type="xs:string" />
<xs:element name="input_source2" type="xs:string" />
<xs:element name="write_terminal" type="xs:string" />
<xs:element name="format" type="xs:string" />
<xs:element name="graph_var1">
<xs:complexType>
<xs:all>
<xs:element name="setting1" type="xs:string" />
<xs:element name="plot1" type="xs:string" />
</xs:all>
</xs:complexType>
</xs:element>
<xs:element name="graph_var2">
<xs:complexType>
<xs:all>
<xs:element name="setting2" type="xs:string" />
<xs:element name="plot2" type="xs:string" />
</xs:all>
</xs:complexType>
</xs:element>
<xs:element name="graph_full">
<xs:complexType>
<xs:all>
<xs:element name="setting3" type="xs:string" />
<xs:element name="plot3" type="xs:string" />
</xs:all>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
Codice:
Inizio parsing Apertura tab: CONFIGURATION Apertura tab: SIMULATOR Apertura tab: COMPILATOR Valore: gcc -o compilatore simulator.c Chiusura del tag: COMPILATOR Apertura tab: SOURCE Valore: simulator.c Chiusura del tag: SOURCE Apertura tab: NUMERO_PASSI Valore: 10000 Chiusura del tag: NUMERO_PASSI Apertura tab: PERIODICITA Valore: 10 Chiusura del tag: PERIODICITA Apertura tab: COLONNA_PASSI Valore: 1 Chiusura del tag: COLONNA_PASSI Apertura tab: COLONNA_AZIONE Valore: 2 Chiusura del tag: COLONNA_AZIONE Apertura tab: COLONNA_VAR1 Valore: 3 Chiusura del tag: COLONNA_VAR1 Apertura tab: COLONNA_VAR2 Valore: 4 Chiusura del tag: COLONNA_VAR2 Apertura tab: OUTPUT_SIM Valore: simulatorefinale.dat Chiusura del tag: OUTPUT_SIM Chiusura del tag: SIMULATOR Apertura tab: MILP Apertura tab: SOURCE Valore: next.lp Chiusura del tag: SOURCE Apertura tab: VAR1 Valore: x_iL Chiusura del tag: VAR1 Apertura tab: VAR2 Valore: x_vO Chiusura del tag: VAR2 Apertura tab: AZIONE Valore: w_u Chiusura del tag: AZIONE Apertura tab: ESECUZIONE Valore: glpsol --lp next.lp -o next.sol Chiusura del tag: ESECUZIONE Apertura tab: OUTPUT_EXE Valore: next.sol Chiusura del tag: OUTPUT_EXE Apertura tab: FINAL_OUTPUT Valore: SequenzaNextLp.dat Chiusura del tag: FINAL_OUTPUT Chiusura del tag: MILP Apertura tab: GNUPLOT Apertura tab: INPUT_SOURCE1 Valore: SimulatoreFinale.dat Chiusura del tag: INPUT_SOURCE1 Apertura tab: INPUT_SOURCE2 Valore: SequenzaNextLp.dat Chiusura del tag: INPUT_SOURCE2 Apertura tab: WRITE_TERMINAL Valore: gnuplot Chiusura del tag: WRITE_TERMINAL Apertura tab: FORMAT Valore: set term png Chiusura del tag: FORMAT Apertura tab: GRAPH_VAR1 Apertura tab: SETTING1 Valore: set output "grafico x_iL.png" Chiusura del tag: SETTING1 Apertura tab: PLOT1 Valore: plot "SimulatoreFinale.dat" using 1:2 w l, "SequenzaNextLp.dat" using 1:2 w l Chiusura del tag: PLOT1 Chiusura del tag: GRAPH_VAR1 Apertura tab: GRAPH_VAR2 Apertura tab: SETTING2 Valore: set output "grafico x_vO.png" Chiusura del tag: SETTING2 Apertura tab: PLOT2 Valore: plot "SimulatoreFinale.dat" using 1:3 w l, "SequenzaNextLp.dat" using 1:3 w l Chiusura del tag: PLOT2 Chiusura del tag: GRAPH_VAR2 Apertura tab: GRAPH_FULL Apertura tab: SETTING3 Valore: set output "grafico completo.png" Chiusura del tag: SETTING3 Apertura tab: PLOT3 Valore: plot "SimulatoreFinale.dat" using 1:2 w l , "SimulatoreFinale.dat" using 1:3 w l, "SequenzaNextLp.dat" using 1:2 w l, "SequenzaNextLp.dat" using 1:3 w l Chiusura del tag: PLOT3 Chiusura del tag: GRAPH_FULL Chiusura del tag: GNUPLOT Chiusura del tag: CONFIGURATION Parsing completato! Ok,benissimo,ma cosa ho risolto facendo quel parsing? qual è l utilità principale che sicuro non sto sfruttando? |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Apr 2005
Messaggi: 3299
|
Parserizzare l'xml ti serve per recuperare le informazioni contenute all'interno..Cosa poi tu ce ne faccia lo sai tu
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 13:12.


















