|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Dec 2003
Città: Ascoli Piceno
Messaggi: 5159
|
[validazione xml]mi dite dove sbaglio??
allora..ho un file xml da validare:
Codice:
<?xml version="1.0"?> <adNewHomes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="schema.xsd"> <adDetail> <property>University Square</property> <area>San Mateo County</area> <developer>Summer Hill Homes</developer> <location>Exit University, off 101. Right on Donahoe </location> <price>from the high $500's</price> <adText>Ponderosa Series. 3 and 4 BR homes with Craftsman details from 1,761 to 2,024 sq ft.</adText> <hours>11-5 Thurs-Sun</hours> <phone>650 466 8700M</phone> </adDetail> <adDetail> <property>Sonsara</property> <area>Contra Costa County</area> <developer>Taylor Woodrow Homes</developer> <location>Moraga. Camino Ricardo and Morago Way </location> <price>from the high $800's</price> <adText>3 to 5 BR homes with great views. Luxury Homes in a great location.</adText> <hours>10-5 Daily</hours> <phone>925/431-2800</phone> </adDetail> <adDetail> <property>Vintners Green</property> <area>Alameda County</area> <developer>Greystone Homes</developer> <location>I-680 to 84. Rt on 84, go several mi. 84 turns into Holmes. Left on Alden Lane.</location> <price>from the mid $600's</price> <adText>bedroom single-family homes.</adText> <hours>11-5 Daily</hours> <phone>925/442-3200</phone> </adDetail> <adDetail> <property>Dublin Ranch</property> <area>Alameda County</area> <developer>Shore Homes</developer> <location>680 at Dublin Canyon</location> <price>from the $400-700's</price> <adText>Master planned community, 3-6 BR Shore Home.</adText> <hours>11-7 Tues-Sun</hours> <phone>925/779-9000</phone> </adDetail> </adNewHomes> Codice:
<?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="adNewHomes" type="adDetail"/> <xsd:complexType name="adDetail"> <xsd:sequence> <xsd:element name="property" type="xsd:string"/> <xsd:element name="area" type="xsd:string"/> <xsd:element name="developer" type="xsd:string"/> <xsd:element name="location" type="xsd:string"/> <xsd:element name="price" type="xsd:string"/> <xsd:element name="adText" type="xsd:string"/> <xsd:element name="hours" type="xsd:string"/> <xsd:element name="phone" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:schema> Element 'adDetail' is not valid for content model: '((property,area,developer,location,price,adText,hours),phone)' a parte le parentesi sballate...ma non dovrebbe validarlo??a me pare corretto. con il dtd invece funziona. EDIT:bene,riguardando dopo 4 giorni di xml mi sono reso conto di aver provato a istanziare un complextype senza definire un elemento.bravo tazok bravo :clap:
__________________
Se dovessi rinascere, farei l'idraulico! Ultima modifica di tazok : 19-02-2007 alle 21:34. |
|
|
|
|
|
#2 |
|
Senior Member
Iscritto dal: Dec 2003
Città: Ascoli Piceno
Messaggi: 5159
|
tutti guru java qua ma nessun guru xml mannaggia
__________________
Se dovessi rinascere, farei l'idraulico! |
|
|
|
|
|
#3 |
|
Senior Member
Iscritto dal: Dec 2003
Città: Ascoli Piceno
Messaggi: 5159
|
altro problemino:
Codice:
<xs:element name="gh" type="xs:string"> <xs:complexType> <xs:attribute name="nome" type="xs:string"/> </xs:complexType> </element> valida.xsd:7,40: Element 'gh' cannot have both a type attribute and a simpleType/complexType type child quando in tutti i libri che ho ci sono esempi tipo questo Codice:
<complexType>
<sequence>
<element name="name" type="string">
<complexType>
<attribute name="title" form="qualified" type="string"/>
</complexType>
</element>
<element name="phone" type="string"/>
</sequence>
</complexType>
che è una versione nuova dell'xml schema?
__________________
Se dovessi rinascere, farei l'idraulico! |
|
|
|
|
|
#4 |
|
Senior Member
Iscritto dal: Dec 2003
Città: Ascoli Piceno
Messaggi: 5159
|
rinuncio a satana,non ci riesco
__________________
Se dovessi rinascere, farei l'idraulico! |
|
|
|
|
|
#5 |
|
Senior Member
Iscritto dal: Dec 2003
Città: Ascoli Piceno
Messaggi: 5159
|
ho scoperto l'arcano dopo svariate ore:
a chi può interessare, gli xsd:attribute vanno sempre dopo la chiusura della xsd:sequence. se lo si mette prima,i parser esplodono e non validano più il file è assurdo,davvero,non c'è un libro che lo dica!
__________________
Se dovessi rinascere, farei l'idraulico! |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 01:54.



















