Notizia:
  • Rilasciata Precise Pangolin 12.04. Per ottenerla, visitate questa pagina, oppure provate il tour dal vivo con un browser web moderno.
  • Nuovo forum di Ubuntu-it, l'annuncio. È consigliato aggiornare il proprio profilo e controllare la sezione Gruppo Forum per problemi noti.
  • Rilasciata la versione italiana di Precise Pangolin 12.04. Per maggiori informazioni, consultare questa discussione.
  • Il vincitore del Concorso desktop del mese di aprile è Jerico. L'elenco dei precedenti vincitori è qui.
  • È uscito il numero 17 della Newsletter italiana di Ubuntu. Lo trovate a questo indirizzo.
  • È uscito il numero 59 di Full Circle Magazine in italiano. Lo trovate a questo indirizzo.

[Xml]file xsd e uso di xml schema(RISOLTO)

Il ritrovo della comunità dove confrontarsi e discutere sulle notizie dal mondo dell'informatica, di Ubuntu e di tutto quello che la riguarda, novità, pettegolezzi e quant'altro.

[Xml]file xsd e uso di xml schema(RISOLTO)

Messaggioda cristian_c » martedì 21 aprile 2009, 0:36

Ciao,
sto proseguendo il mio viaggio nel mondo di xml.
Questa volta al posto dei dtd come documento di descrizione dei miei file xml utilizzo i file xsd.

Però c'è un problema, non riesco a vedere se sono validi. Premetto che utilizzo xmlcopyeditor come software.

Ecco il file xml:
Codice: Seleziona tutto
<?xml version="1.0"?>
<note xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="note1.xsd">
<to>Mario</to>
<from>Piero</from>
<header>Reminder</header>
<body>Ricordati il vino per il weekend!</body>
</note>


E questo è il file xsd:
Codice: Seleziona tutto
<?xml version="1.0"?>
<xsd:schema   xmlns:xsd="http://www.w3.org/2000/10/XMLSchema">
      <xsd:element name="note">
      <xsd:complexType>
      <xsd:sequence>
      <xsd:element ref="to" minOccurs="1"   maxOccurs="1"/>
      <xsd:element ref="from" minOccurs="1"   maxOccurs=" 1 "/>
      <xsd:element ref="heading" minOccurs="1"   maxOccurs="1"/>
      <xsd:element ref="body" minOccurs="1"   maxOccurs="1"/>
      </xsd:sequence>
      </xsd:complexType>
      </xsd:element>
<xsd:element name="to" type="xsd:string"/>
<xsd:element name="from" type="xsd:string"/>
<xsd:element name="heading" type="xsd:string"/>
<xsd:element name="body" type="xsd:string"/>
</xsd:schema>


Però se provo a fare clic sul pulsante Validate ottengo l'errore:
Validation stopped at line 3, column 43: Unknown element 'note'


Come si può risolvere?  ???
Ultima modifica di cristian_c il domenica 20 settembre 2009, 22:15, modificato 1 volta in totale.
UP! Unreal Project(la resurrezione), il futuro inizia qui | Post dell'anno!
Your questions are not dumb. The way to learn is to ask questions. Not asking is dumb
Avatar utente
cristian_c
Tenace Tecnocrate
Tenace Tecnocrate
 
Messaggi: 14105
Iscrizione: ottobre 2007

Re: [Xml]file xsd e uso di xml schema

Messaggioda Abbio » martedì 21 aprile 2009, 1:31

non tocco xsd da anni però penso che l'elemento padre note debba definire un tipo, e tale tipo dovrebbe essere il nome dell'elemento complesso. forse così può andare:

Codice: Seleziona tutto
<?xml version="1.0"?>
<xsd:schema   xmlns:xsd="http://www.w3.org/2000/10/XMLSchema">
      <xsd:element name="note" type="noteStruct">
      <xsd:complexType name="noteStruct">
      <xsd:sequence>
      <xsd:element ref="to" minOccurs="1"   maxOccurs="1"/>
      <xsd:element ref="from" minOccurs="1"   maxOccurs=" 1 "/>
      <xsd:element ref="heading" minOccurs="1"   maxOccurs="1"/>
      <xsd:element ref="body" minOccurs="1"   maxOccurs="1"/>
      </xsd:sequence>
      </xsd:complexType>
      </xsd:element>
<xsd:element name="to" type="xsd:string"/>
<xsd:element name="from" type="xsd:string"/>
<xsd:element name="heading" type="xsd:string"/>
<xsd:element name="body" type="xsd:string"/>
</xsd:schema>
Maledetto Ubuntu.... nella mia calcolatrice non si installa.... ma quanto è pesante... che ne dite provo Xubuntu Alternate? Ma LOL
Avatar utente
Abbio
Prode Principiante
 
Messaggi: 109
Iscrizione: maggio 2006
Località: Predappio

Re: [Xml]file xsd e uso di xml schema

Messaggioda cristian_c » martedì 21 aprile 2009, 19:57

Ho fatto le modifiche che hai suggerito ma l'errore che ho postato si è ripetuto.

Ho anche corretto 'header' con 'heading' nel file xml, ma la situazione non è migliorata
UP! Unreal Project(la resurrezione), il futuro inizia qui | Post dell'anno!
Your questions are not dumb. The way to learn is to ask questions. Not asking is dumb
Avatar utente
cristian_c
Tenace Tecnocrate
Tenace Tecnocrate
 
Messaggi: 14105
Iscrizione: ottobre 2007

Re: [Xml]file xsd e uso di xml schema

Messaggioda cristian_c » domenica 10 maggio 2009, 13:06

Mi hanno detto di sostituire tutti gli xsd con xs. Così:
Codice: Seleziona tutto
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="note">
      <xs:complexType>
      <xs:sequence>
            <xs:element name="to" type="xs:string"/>
      <xs:element name="from" type="xs:string"/>
      <xs:element name="heading" type="xs:string"/>
      <xs:element name="body" type="xs:string"/>
    </xs:sequence>
      </xs:complexType>
      </xs:element>

</xs:schema>

ma ottengo lo stesso errore!  :-\ ::) ???
N.B. Ho semplificato l'xsd

Però non capisco un'altra cosa: come mai i file xsd che rispettano la sintassi xml quando li si valida restituiscon osempre errori?
Eppure non sono dtd  :(

Edit: Provando con questo:
Codice: Seleziona tutto
<?xml version="1.0"?>
<xs:schema   xmlns:xsd="http://www.w3.org/2000/10/XMLSchema">
      <xs:element name="note">
      <xs:complexType>
      <xs:sequence>
      <xs:element ref="to" minOccurs="1"   maxOccurs="1"/>
      <xs:element ref="from" minOccurs="1"   maxOccurs=" 1 "/>
      <xs:element ref="heading" minOccurs="1"   maxOccurs="1"/>
      <xs:element ref="body" minOccurs="1"   maxOccurs="1"/>
      </xs:sequence>
      </xs:complexType>
      </xs:element>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:schema>

continuo sempre ad ottenere lo stesso errore  >:(
Ultima modifica di cristian_c il domenica 10 maggio 2009, 13:09, modificato 1 volta in totale.
UP! Unreal Project(la resurrezione), il futuro inizia qui | Post dell'anno!
Your questions are not dumb. The way to learn is to ask questions. Not asking is dumb
Avatar utente
cristian_c
Tenace Tecnocrate
Tenace Tecnocrate
 
Messaggi: 14105
Iscrizione: ottobre 2007

Re: [Xml]file xsd e uso di xml schema

Messaggioda cristian_c » lunedì 13 luglio 2009, 14:17

Mi hanno detto di sostituire tutti gli xsd con xs. Così:

questa cosa non funziona perché neanche l'editor di testi lo riconosce come xsd!  ;)

Ad ogni modo ho risolto l'errore precedente in questo modo:

ho sostituito nel file xml
Codice: Seleziona tutto
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"

con
Codice: Seleziona tutto
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"


e nel file dello schema
Codice: Seleziona tutto
xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"

con
Codice: Seleziona tutto
xmlns:xsd="http://www.w3.org/2001/XMLSchema"


A questo punto se premo sul pulsante Validate passo al prossimo errore:
Validation stopped at line 7, column 58: Value '1' does not match regular expression facet '[+\-]?[0-9]+'


Come posso risolvere il problema?  ???
UP! Unreal Project(la resurrezione), il futuro inizia qui | Post dell'anno!
Your questions are not dumb. The way to learn is to ask questions. Not asking is dumb
Avatar utente
cristian_c
Tenace Tecnocrate
Tenace Tecnocrate
 
Messaggi: 14105
Iscrizione: ottobre 2007

Re: [Xml]file xsd e uso di xml schema

Messaggioda shaitan » lunedì 13 luglio 2009, 14:34

se si riferisce a


mi sa che ci sono due spazi di troppo nel valore di maxOccurs
Ultima modifica di shaitan il lunedì 13 luglio 2009, 23:00, modificato 1 volta in totale.
shaitan
Entusiasta Emergente
Entusiasta Emergente
 
Messaggi: 1475
Iscrizione: gennaio 2006

Re: [Xml]file xsd e uso di xml schema

Messaggioda cristian_c » lunedì 13 luglio 2009, 14:49

shaitan ha scritto:se si riferisce a


mi sa che ci sono due spazzi di troppo nel valore di maxOccurs

era proprio quello degli spazi tra le virgolette il problema!  :D
Grazie!  (good) (b2b)
UP! Unreal Project(la resurrezione), il futuro inizia qui | Post dell'anno!
Your questions are not dumb. The way to learn is to ask questions. Not asking is dumb
Avatar utente
cristian_c
Tenace Tecnocrate
Tenace Tecnocrate
 
Messaggi: 14105
Iscrizione: ottobre 2007

Re: [Xml]file xsd e uso di xml schema[RISOLTO]

Messaggioda Rapture » lunedì 13 luglio 2009, 17:54

cristian_c anche di questo ti interessi!!!!  ::)
Avatar utente
Rapture
Prode Principiante
 
Messaggi: 224
Iscrizione: maggio 2006

Re: [Xml]file xsd e uso di xml schema[RISOLTO]

Messaggioda cristian_c » martedì 14 luglio 2009, 0:09

Rapture ha scritto:cristian_c anche di questo ti interessi!!!!  ::)

si, appena avrò finito di studiare gli elementi di xml ho in serbo qualche sorpresina  ;D
UP! Unreal Project(la resurrezione), il futuro inizia qui | Post dell'anno!
Your questions are not dumb. The way to learn is to ask questions. Not asking is dumb
Avatar utente
cristian_c
Tenace Tecnocrate
Tenace Tecnocrate
 
Messaggi: 14105
Iscrizione: ottobre 2007

Re: [Xml]file xsd e uso di xml schema

Messaggioda cristian_c » martedì 14 luglio 2009, 12:24

Riapro questo topic per sottoporvi un altro problema che ho riscontrato con xml schema.  ;D

Ho preso il file studente.xml che fa uso dello schema studente.xsd.  Mi sono studiato la struttura dello schema xsd.
Ho controllato che il file .xml fosse ben formato con Check Well-formedness ed è andato bene questo test.
Poi ho provato a validarlo con Validate, però in questo caso usciva un errore: infatti diceva che l'elemento 'studente' era sconosciuto.

Allora ho fatto delle modifiche in cima al file xml, e sono riuscito a passare all'errore successivo, che è questo:
Validation stopped at line 10, column 9: Element qname beginning with 'xsd:' invalid

che riguarda la linea:
Codice: Seleziona tutto
      <citta>Samarcanda</citta>      


Ecco il file .xml com'è attualmente:
Codice: Seleziona tutto
<?xml version="1.0"?>
<studente xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="studente.xsd" matricola="1234567">
   <nome>Giovanni</nome>
   <cognome>Doe</cognome>
   <sesso>M</sesso>
   <indirizzo>
      <nomeVia>Viale del tramonto 13/17A</nomeVia>
      <CAP>54321</CAP>
      <citta>Samarcanda</citta>      
   </indirizzo>
   <classe sperimentazione="Brocca">3D</classe>
   <pagella>
      Quadro generale dell'alunno:
      I risultati di matematica sono <matematica>4 4.5 3 5.8</matematica>
      , quelli di italiano sono <italiano>6 6.5 6 6 6</italiano>
      e quelli di educazione musicale sono <edmusicale>10 9.5</edmusicale>
   </pagella>
</studente>

ed ecco invece il file xsd:
Codice: Seleziona tutto
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<xsd:annotation>
    <xsd:documentation xml:lang="it">
    XML tutorial per il lavoro di TAW
    </xsd:documentation>
</xsd:annotation>
  
<xsd:choice>
   <xsd: element name="studente" type="StudentType"/>
   <xsd: element name="studente diplomato" type="GraduatedStudent"/>
</xsd:choice>
  
<xsd: complexType name="StudentType">
   <xsd:sequence>
      <xsd:element name="cognome" type="xsd:string"/>
      <xsd:element name="nome" type="xsd:string"/>
      <xsd:element name="sesso" type="SexType"/>
      <xsd:element name="indirizzo" type="AddressType"/>
      <xsd:element name="classe" type="ClassType"/>
      <xsd:element name="pagella">
         <xsd:complexType mixed="true">
            <xsd:sequence>
               <xsd:element name="matematica" type="ListOfMarks"/>
               <xsd:element name="italiano" type="ListOfMarks"/>
               <xsd:element name="edmusicale" type="ListOfMarks"/>
            </xsd:sequence>
         </xsd:complexType>
      </xsd:element>
   </xsd:sequence>
   <xsd:attribute name="matricola" type="xsd:integer"/>
</xsd:complexType>
<xsd:complexType name="AddressType">
   <xsd:sequence>
      <xsd:element name="nomeVia" type="xsd:string"/>
      <xsd:element name="CAP" type="xsd:integer"/>
      <xsd:element name="citta" type="xsd:string"/>
   </xsd:sequence>
</xsd:complexType>

<xsd:simpleType name ="SexType">
   <xsd:restriction base="xsd:string">
      <xsd:enumeration value="M"/>
      <xsd:enumeration value="F"/>
   </xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="ClassType">
   <xsd:restriction base="xsd:string">
      <xsd:pattern value="\d{1}-[A-Z]{1}"/>
   </xsd:restriction>
   <xsd:attribute name="sperimentazione">
      <xsd:simpleType>
         <xsd:restriction base="xsd:string">
            <xsd:enumeration value="Bilingue"/>
            <xsd:enumeration value="Brocca"/>
            <xsd:enumeration value="P.N.I."/>
         </xsd:restriction>
      </xsd:simpleType>
   </xsd:attribute>
</xsd:complexType>
  
<xsd:simpleType name="voto">
   <xsd:restriction base="xsd:decimal">
      <xsd:minExclusive value="0"/>
      <xsd:maxInclusive value="10"/>
   </xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="ListOfMarks">
   <xsd:list itemType="voto"/>
</xsd:simpleType>
  
<xsd:complexType name="GraduatedStudent">
   <xsd:extension base="StudentType">
      <xsd:element name="voto diploma" type="integer"/>
   </xsd:extension>
</xsd:complexType>


Come posso aggiustare la cosa?  ???
Ultima modifica di cristian_c il martedì 14 luglio 2009, 12:32, modificato 1 volta in totale.
UP! Unreal Project(la resurrezione), il futuro inizia qui | Post dell'anno!
Your questions are not dumb. The way to learn is to ask questions. Not asking is dumb
Avatar utente
cristian_c
Tenace Tecnocrate
Tenace Tecnocrate
 
Messaggi: 14105
Iscrizione: ottobre 2007

Re: [Xml]file xsd e uso di xml schema

Messaggioda cristian_c » mercoledì 15 luglio 2009, 23:36

praticamente l'errore stava nelle righe 10 e 11 del file xsd (anche se esce fuori nella validazione del file xml, però c'è da dire anche che veniva evidenziata la linea relativa del file xml che poteva trarre in inganno  :-[ ).
Non ci volevano spazi tra xsd: ed element ed anche alla linea 14 con complexType.
Infatti appena ho fatto la correzione nell'highlight di xmlcopyeditor 'element' è passato dal colore rosso a quello blu.

Risolto questo sono passato all'errore successivo:
Validation stopped at line 76, column 20: The input ended before all started tags were ended. Last tag started was 'xsd:schema'

che ho risolto subito inserendo il fine tag in fondo al file.

Dopodiché ho riprovato a validare, ma è uscito un altro errore:
Validation stopped at line 9, column 13:Error in content of element information item


Questo non so come risolverlo però!  :(

L'attuale file xml è questo:
Codice: Seleziona tutto
<?xml version="1.0"?>
<studente xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="studente.xsd" matricola="1234567">
   <nome>Giovanni</nome>
   <cognome>Doe</cognome>
   <sesso>M</sesso>
   <indirizzo>
      <nomeVia>Viale del tramonto 13/17A</nomeVia>
      <CAP>54321</CAP>
      <citta>Samarcanda</citta>     
   </indirizzo>
   <classe sperimentazione="Brocca">3D</classe>
   <pagella>
      Quadro generale dell'alunno:
      I risultati di matematica sono <matematica>4 4.5 3 5.8</matematica>
      , quelli di italiano sono <italiano>6 6.5 6 6 6</italiano>
      e quelli di educazione musicale sono <edmusicale>10 9.5</edmusicale>
   </pagella>
</studente>

e il file xsd è questo:
Codice: Seleziona tutto
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<xsd:annotation>
    <xsd:documentation xml:lang="it">
    XML tutorial per il lavoro di TAW
    </xsd:documentation>
</xsd:annotation>
 
<xsd:choice>
   <xsd:element name="studente" type="StudentType"/>
   <xsd:element name="studente diplomato" type="GraduatedStudent"/>
</xsd:choice>
 
<xsd:complexType name="StudentType">
   <xsd:sequence>
      <xsd:element name="cognome" type="xsd:string"/>
      <xsd:element name="nome" type="xsd:string"/>
      <xsd:element name="sesso" type="SexType"/>
      <xsd:element name="indirizzo" type="AddressType"/>
      <xsd:element name="classe" type="ClassType"/>
      <xsd:element name="pagella">
         <xsd:complexType mixed="true">
            <xsd:sequence>
               <xsd:element name="matematica" type="ListOfMarks"/>
               <xsd:element name="italiano" type="ListOfMarks"/>
               <xsd:element name="edmusicale" type="ListOfMarks"/>
            </xsd:sequence>
         </xsd:complexType>
      </xsd:element>
   </xsd:sequence>
   <xsd:attribute name="matricola" type="xsd:integer"/>
</xsd:complexType>
<xsd:complexType name="AddressType">
   <xsd:sequence>
      <xsd:element name="nomeVia" type="xsd:string"/>
      <xsd:element name="CAP" type="xsd:integer"/>
      <xsd:element name="citta" type="xsd:string"/>
   </xsd:sequence>
</xsd:complexType>

<xsd:simpleType name ="SexType">
   <xsd:restriction base="xsd:string">
      <xsd:enumeration value="M"/>
      <xsd:enumeration value="F"/>
   </xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="ClassType">
   <xsd:restriction base="xsd:string">
      <xsd:pattern value="\d{1}-[A-Z]{1}"/>
   </xsd:restriction>
   <xsd:attribute name="sperimentazione">
      <xsd:simpleType>
         <xsd:restriction base="xsd:string">
            <xsd:enumeration value="Bilingue"/>
            <xsd:enumeration value="Brocca"/>
            <xsd:enumeration value="P.N.I."/>
         </xsd:restriction>
      </xsd:simpleType>
   </xsd:attribute>
</xsd:complexType>
 
<xsd:simpleType name="voto">
   <xsd:restriction base="xsd:decimal">
      <xsd:minExclusive value="0"/>
      <xsd:maxInclusive value="10"/>
   </xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="ListOfMarks">
   <xsd:list itemType="voto"/>
</xsd:simpleType>
 
<xsd:complexType name="GraduatedStudent">
   <xsd:extension base="StudentType">
      <xsd:element name="voto diploma" type="integer"/>
   </xsd:extension>
</xsd:complexType>
</xsd:schema>


Come posso risolvere ed aggiustare il tutto?  ??? ::) :-\
UP! Unreal Project(la resurrezione), il futuro inizia qui | Post dell'anno!
Your questions are not dumb. The way to learn is to ask questions. Not asking is dumb
Avatar utente
cristian_c
Tenace Tecnocrate
Tenace Tecnocrate
 
Messaggi: 14105
Iscrizione: ottobre 2007

Re: [Xml]file xsd e uso di xml schema

Messaggioda cristian_c » giovedì 6 agosto 2009, 17:18

Per cercare di risolvere il problema, l'errore poteva essere individuato nell'indicatore 'choice' indicato qui: http://www.w3schools.com/schema/schema_complex_indicators.asp.

Forse in quella posizione non va bene, ma dove andrebbe spostato invece?  ???

Allora ho provato a modificare il file xsd cercando di fare a meno del 'choice'. Ho modificato gli elementi complessi StudentType e GraduatedStudent in questo modo:
Codice: Seleziona tutto
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<xsd:annotation>
    <xsd:documentation xml:lang="it">
    XML tutorial per il lavoro di TAW
    </xsd:documentation>
</xsd:annotation>

<xsd:element name="StudentType"> 
    <xsd:complexType>
         <xsd:sequence>
             <xsd:element name="cognome" type="xsd:string"/>
             <xsd:element name="nome" type="xsd:string"/>
             <xsd:element name="sesso" type="SexType"/>
             <xsd:element name="indirizzo" type="AddressType"/>
             <xsd:element name="classe" type="ClassType"/>
             <xsd:element name="pagella">
                 <xsd:complexType mixed="true">
                     <xsd:sequence>
                         <xsd:element name="matematica" type="ListOfMarks"/>
                         <xsd:element name="italiano" type="ListOfMarks"/>
                         <xsd:element name="edmusicale" type="ListOfMarks"/>
                     </xsd:sequence>
                 </xsd:complexType>
             </xsd:element>
         </xsd:sequence>
         <xsd:attribute name="matricola" type="xsd:integer"/>
     </xsd:complexType>
</xsd:element>

<xsd:complexType name="AddressType">
   <xsd:sequence>
      <xsd:element name="nomeVia" type="xsd:string"/>
      <xsd:element name="CAP" type="xsd:integer"/>
      <xsd:element name="citta" type="xsd:string"/>
   </xsd:sequence>
</xsd:complexType>

<xsd:simpleType name ="SexType">
   <xsd:restriction base="xsd:string">
      <xsd:enumeration value="M"/>
      <xsd:enumeration value="F"/>
   </xsd:restriction>
</xsd:simpleType>

<xsd:complexType name="ClassType">
   <xsd:restriction base="xsd:string">
      <xsd:pattern value="\d{1}-[A-Z]{1}"/>
   </xsd:restriction>
   <xsd:attribute name="sperimentazione">
      <xsd:simpleType>
         <xsd:restriction base="xsd:string">
            <xsd:enumeration value="Bilingue"/>
            <xsd:enumeration value="Brocca"/>
            <xsd:enumeration value="P.N.I."/>
         </xsd:restriction>
      </xsd:simpleType>
   </xsd:attribute>
</xsd:complexType>
 
<xsd:simpleType name="voto">
   <xsd:restriction base="xsd:decimal">
      <xsd:minExclusive value="0"/>
      <xsd:maxInclusive value="10"/>
   </xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="ListOfMarks">
   <xsd:list itemType="voto"/>
</xsd:simpleType>
 
<xsd:element name="GraduatedStudent">
    <xsd:complexType>
        <xsd:extension base="StudentType">
            <xsd:element name="voto diploma" type="integer"/>
        </xsd:extension>
    </xsd:complexType>
</xsd:element>

</xsd:schema>


Ma se provo a validare ottengo l'errore:
Validation stopped at line 47, column 39: Invalid child 'restriction' in the complex type


La riga a cui fa riferimento l'errore dovrebbe essere questa:
 


Da cosa può dipendere l'errore, e come posso risolverlo?  ??? ::) :-\ :(
UP! Unreal Project(la resurrezione), il futuro inizia qui | Post dell'anno!
Your questions are not dumb. The way to learn is to ask questions. Not asking is dumb
Avatar utente
cristian_c
Tenace Tecnocrate
Tenace Tecnocrate
 
Messaggi: 14105
Iscrizione: ottobre 2007

Re: [Xml]file xsd e uso di xml schema

Messaggioda cristian_c » lunedì 31 agosto 2009, 16:28

Sono riuscito a risolvere il problema e a validare il documento xml!!!  (good) (b2b)

Praticamente rispetto al post #10 ho cancellato il blocco del tag 'choiche', poi ho corretto altri errori nel file dello schema, uno tra questi ad esempio era invertita la sequenza di 'nome' e 'cognome' rispetto a come si presentava nel file .xml

Ho dovuto correggere anche un errore nel file .xml relativo al non rispetto delle regole del pattern:
Codice: Seleziona tutto
      <xsd:pattern value="\d{1}-[A-Z]{1}"/>

qui:
Codice: Seleziona tutto
   <classe sperimentazione="Brocca">3D</classe>

che ho modificato così:
Codice: Seleziona tutto
   <classe sperimentazione="Brocca">3-D</classe>


Questo è il file .xml conclusivo:
Codice: Seleziona tutto
<?xml version="1.0"?>

<studente xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="studente.xsd" matricola="1234567">

   <nome>Giovanni</nome>

   <cognome>Doe</cognome>

   <sesso>M</sesso>

   <indirizzo>

      <nomeVia>Viale del tramonto 13/17A</nomeVia>

      <CAP>54321</CAP>

      <citta>Samarcanda</citta>     

   </indirizzo>

   <classe sperimentazione="Brocca">3-D</classe>

   <pagella>

      Quadro generale dell'alunno:

      I risultati di matematica sono <matematica>4 4.5 3 5.8</matematica>

      , quelli di italiano sono <italiano>6 6.5 6 6 6</italiano>

      e quelli di educazione musicale sono <edmusicale>10 9.5</edmusicale>

   </pagella>

</studente>

e questo è il file .xsd, detto anche 'schema':
Codice: Seleziona tutto
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:annotation>
    <xsd:documentation xml:lang="it">
    XML tutorial per il lavoro di TAW
    </xsd:documentation>
  </xsd:annotation>
  <xsd:complexType name="StudentType">
    <xsd:sequence>
      <xsd:element name="nome" type="xsd:string"/>
      <xsd:element name="cognome" type="xsd:string"/>
      <xsd:element name="sesso" type="SexType"/>
      <xsd:element name="indirizzo" type="AddressType"/>
      <xsd:element name="classe" type="ClassType"/>
      <xsd:element name="pagella">
        <xsd:complexType mixed="true">
          <xsd:sequence>
            <xsd:element name="matematica" type="ListOfMarks"/>
            <xsd:element name="italiano" type="ListOfMarks"/>
            <xsd:element name="edmusicale" type="ListOfMarks"/>
          </xsd:sequence>
        </xsd:complexType>
      </xsd:element>
    </xsd:sequence>
    <xsd:attribute name="matricola" type="xsd:integer"/>
  </xsd:complexType>
  <xsd:complexType name="AddressType">
    <xsd:sequence>
      <xsd:element name="nomeVia" type="xsd:string"/>
      <xsd:element name="CAP" type="xsd:integer"/>
      <xsd:element name="citta" type="xsd:string"/>
    </xsd:sequence>
  </xsd:complexType>
  <xsd:simpleType name="SexType">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="M"/>
      <xsd:enumeration value="F"/>
    </xsd:restriction>
  </xsd:simpleType>
  <xsd:complexType name="ClassType">
    <xsd:simpleContent>
      <xsd:extension base="ClassTypeContent">
        <xsd:attribute name="sperimentazione">
          <xsd:simpleType>
            <xsd:restriction base="xsd:string">
              <xsd:enumeration value="Bilingue"/>
              <xsd:enumeration value="Brocca"/>
              <xsd:enumeration value="P.N.I."/>
            </xsd:restriction>
          </xsd:simpleType>
        </xsd:attribute>
      </xsd:extension>
    </xsd:simpleContent>
  </xsd:complexType>
  <xsd:simpleType name="ClassTypeContent">
    <xsd:restriction base="xsd:string">
      <xsd:pattern value="\d{1}-[A-Z]{1}"/>
    </xsd:restriction>
  </xsd:simpleType>
  <xsd:simpleType name="voto">
    <xsd:restriction base="xsd:decimal">
      <xsd:minExclusive value="0"/>
      <xsd:maxInclusive value="10"/>
    </xsd:restriction>
  </xsd:simpleType>
  <xsd:simpleType name="ListOfMarks">
    <xsd:list itemType="voto"/>
  </xsd:simpleType>
  <xsd:element name="GraduatedStudent" type="GraduatedStudentType"/>
  <xsd:element name="studente" type="StudentType"/>
  <xsd:complexType name="GraduatedStudentType">
    <xsd:complexContent>
      <xsd:extension base="StudentType">
        <xsd:sequence>
          <xsd:element name="voto_diploma" type="xsd:integer"/>
        </xsd:sequence>
      </xsd:extension>
    </xsd:complexContent>
  </xsd:complexType>
</xsd:schema>
Ultima modifica di cristian_c il lunedì 31 agosto 2009, 16:31, modificato 1 volta in totale.
UP! Unreal Project(la resurrezione), il futuro inizia qui | Post dell'anno!
Your questions are not dumb. The way to learn is to ask questions. Not asking is dumb
Avatar utente
cristian_c
Tenace Tecnocrate
Tenace Tecnocrate
 
Messaggi: 14105
Iscrizione: ottobre 2007


Torna a Bar Ubuntu

Chi c’è in linea

Visualizzano questa pagina: PerryGi, shouldes e 6 ospiti