Visualizzazione dei risultati da 1 a 9 su 9
  1. #1

    validazione xml > xsd schema fallita

    Ciao a tutti,

    ho un problema nella validazione di un xml che a me pare corretto, secondo il seguente schema:

    codice:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    targetNamespace="http://www.example.org/PoliciesList" 
    xmlns:tns="http://www.example.org/PoliciesList" 
    elementFormDefault="qualified">
    
    
    <xs:element name="Policy" >
           <xs:complexType>
           <xs:all>         
             <xs:element name="LastName"  > 
             <xs:annotation>
            	<xs:documentation>The lastname of insured person.</xs:documentation>
              </xs:annotation>
               <xs:simpleType>
                  <xs:restriction base="xs:string">
                   <xs:minLength value="0"/>
                   <xs:maxLength value="35"/>               
                  </xs:restriction>            
               </xs:simpleType>    
             </xs:element>
             <xs:element name="FirstName"  >
              <xs:annotation>
            	<xs:documentation>The firstname of insured person.</xs:documentation>
              </xs:annotation>
               <xs:simpleType>
                  <xs:restriction base="xs:string">
                   <xs:minLength value="0"/>
                   <xs:maxLength value="35"/>               
                  </xs:restriction>            
               </xs:simpleType>    
             </xs:element> 
             <xs:element name="FiscalCode"  >
             <xs:annotation>
            	<xs:documentation>Fiscal code of insured person.</xs:documentation>
              </xs:annotation>
              <xs:simpleType>
                <xs:restriction base="xs:string">
                 <xs:maxLength value="16"/>
                </xs:restriction>
               </xs:simpleType> 
             </xs:element> 
             <xs:element name="ProductCode"  nillable="false"> 
              <xs:annotation>
            	<xs:documentation>Product Code for current policy.</xs:documentation>
              </xs:annotation>
               <xs:simpleType> 
                   <xs:restriction base="xs:string" >
                       <xs:maxLength value="10"/>                
                   </xs:restriction>
              </xs:simpleType>
             </xs:element>
             <xs:element name="PolicyNumber"  nillable="false" > 
              <xs:annotation>
            	<xs:documentation>The policy number.</xs:documentation>
              </xs:annotation>
               <xs:simpleType> 
                   <xs:restriction base="xs:string" >
                       <xs:maxLength value="50"/>                
                   </xs:restriction>
              </xs:simpleType>
             </xs:element>
             <xs:element name="EffectDate" type="xs:dateTime" nillable="false">
             <xs:annotation>
            	<xs:documentation>Date of effect of the policy.</xs:documentation>
              </xs:annotation>
             </xs:element> 
             <xs:element name="EmissionDate" type="xs:dateTime" >
             <xs:annotation>
            	<xs:documentation>Emission date of the policy.</xs:documentation>
              </xs:annotation>
             </xs:element>    
             </xs:all>    
          </xs:complexType>
    </xs:element>
    
    </xs:schema>


    file xml > prelevato da una risposta soap di WCF test client

    codice:
    <?xml version="1.0" encoding="utf-8"?>
     <Policy>
              <EffectDate>2011-07-08T00:00:00</EffectDate>
              <EmissionDate>2011-07-08T00:00:00</EmissionDate>
              <FirstName>xxxxxx</FirstName>
              <FiscalCode>CTTVLL82E18F205R</FiscalCode>
              <LastName>yyyyy</LastName>
              <PolicyNumber>0020021825604</PolicyNumber>
              <ProductCode>AB3</ProductCode>
     </Policy>
    Il validatore mi dice che non trova l'elemento policy...dove sbaglio?
    Entrambi i file sono well-formed e validi a se stanti..per cui non riesco proprio a capire dove sia il problema...


    Grazie


    Mike "The Ram"

  2. #2
    prova a usare questa xsd qua

    codice:
    <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="Policy">
        <xs:complexType>
          <xs:sequence>
            <xs:element type="xs:dateTime" name="EffectDate"/>
            <xs:element type="xs:dateTime" name="EmissionDate"/>
            <xs:element type="xs:string" name="FirstName"/>
            <xs:element type="xs:string" name="FiscalCode"/>
            <xs:element type="xs:string" name="LastName"/>
            <xs:element type="xs:long" name="PolicyNumber"/>
            <xs:element type="xs:string" name="ProductCode"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>

  3. #3
    Ciao Mattia, e grazie per il supporto.

    In realtà ho provveduto ad eliminare dal codice precedente dell'xsd che ho postato questi 2 attributi

    codice:
    targetNamespace="http://www.example.org/PoliciesList"  xmlns:tns="http://www.example.org/PoliciesList"
    ed il validatore presente al sito http://xsdvalidation.utilities-online.info/ mi ha restituito questo messaggio:

    The XML is Well Formed and VALID

    Tieni presente che questi 2 attributi me li ha forniti Eclipse, quindi penso che siano intercambiabili..ammetto di non essere molto pratico di tale amibente in quanto normalmente sviluppo in c# e sono alle prime armi sui webservices ( ma li devo fare per costrizione :P )

    Sembrerebbe che sia a posto cosi'....l'xml che ho postato è frutto dell'implementazione di un web service WCF e la risposta soap rispetta quello schema, mi confermi?

    Grazie

    Mike "The Ram"

  4. #4
    Originariamente inviato da mikeRam
    Ciao Mattia, e grazie per il supporto.

    In realtà ho provveduto ad eliminare dal codice precedente dell'xsd che ho postato questi 2 attributi

    codice:
    targetNamespace="http://www.example.org/PoliciesList"  xmlns:tns="http://www.example.org/PoliciesList"
    ed il validatore presente al sito http://xsdvalidation.utilities-online.info/ mi ha restituito questo messaggio:

    The XML is Well Formed and VALID

    Tieni presente che questi 2 attributi me li ha forniti Eclipse, quindi penso che siano intercambiabili..ammetto di non essere molto pratico di tale amibente in quanto normalmente sviluppo in c# e sono alle prime armi sui webservices ( ma li devo fare per costrizione :P )

    Sembrerebbe che sia a posto cosi'....l'xml che ho postato è frutto dell'implementazione di un web service WCF e la risposta soap rispetta quello schema, mi confermi?

    Grazie

    Mike "The Ram"
    ciao Mike, ti confermo che togliendo quei due namespace valida

    mattia@galaxy:~/Scrivania$ xmllint -schema validatore.xsd -noout davalidare.xml
    davalidare.xml validates

  5. #5
    Grazie Mattia

    Ora posso dare qualcosa di sensato al cliente

  6. #6
    Ciao Mattia,

    adesso pero' mi è sorto un altro problema sui tipi complessi da mettere in uno schema xsd:



    ho la necessita' che uno degli elementi sia una lista di "Guarantuees" di tipo "Guarantee" che ho definito nel mio servizio WCF: non riesco a capire come generare la parte mancante per il tipo che ho definito con la classe guarantee, nello schema XML che valida l'xml

    codice:
     
    <PolicyDetails>
    .....
    <Guarantuees> 
                 <Guarantuee> 
                   <EffectDate>2012-10-10T16:57:27.642374+02:00</EffectDate>          <ExpiryDate>2012-10-10T16:57:27.642374+02:00</ExpiryDate>           <GuarantueeStatus>2</GuarantueeStatus>
           <TariffCode>2</TariffCode> 
              </Guarantuee>
    
    <Guarantuee> 
                   <EffectDate>2011-10-10T16:57:27.642374+02:00</EffectDate>          <ExpiryDate>2012-10-10T16:57:27.642374+02:00</ExpiryDate>           <GuarantueeStatus>4</GuarantueeStatus>
           <TariffCode>2</TariffCode> 
              </Guarantuee>
           </Guarantuees>
    
    ......
    
    </PolicyDetails>

    parte di xsd schema


    codice:
     <xs:element name="Guarantuees">
             <xs:annotation>
            	<xs:documentation>A section repeated once for each guarantuee that is included in the contract.</xs:documentation>
              </xs:annotation>
                  <xs:complexType>
                    <xs:all>               
                        <xs:element name="TariffCode" type="xs:string" > 
                         <xs:annotation>
            	<xs:documentation>The Tariff code of the guarantuee.</xs:documentation>
              </xs:annotation>
                        </xs:element>
                        <xs:element name="EffectDate" type="xs:dateTime" > 
                         <xs:annotation>
            	       <xs:documentation>Date of effect of the guarantuee.</xs:documentation>
              </xs:annotation>
                        </xs:element>
                        <xs:element name="ExpiryDate" type="xs:dateTime" > 
                         <xs:annotation>
            	<xs:documentation>Expiry date of the guarantuee.</xs:documentation>
              </xs:annotation>
                        </xs:element>
                        <xs:element name="GuarantueeStatus" >
                         <xs:annotation>
            	<xs:documentation>Status of the guarantuee</xs:documentation>
              </xs:annotation>
                         <xs:simpleType> 
                            <xs:restriction base="xs:string" >
                              <xs:pattern value="2|4|5|6"/>                   
                           </xs:restriction>
                         </xs:simpleType>
                        </xs:element>                    
                    </xs:all>
                  </xs:complexType>
             </xs:element>

    Grazie

    Mike "The Ram"

  7. #7
    non capisco bene cosa ti serve purtroppo

    dall xml che hai incollato l'xsd sembra una cosa tipo :
    codice:
    <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="PolicyDetails">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="Guarantuees">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="Guarantuee" maxOccurs="unbounded" minOccurs="0">
                    <xs:complexType>
                      <xs:sequence>
                        <xs:element type="xs:dateTime" name="EffectDate"/>
                        <xs:element type="xs:dateTime" name="ExpiryDate"/>
                        <xs:element type="xs:byte" name="GuarantueeStatus"/>
                        <xs:element type="xs:byte" name="TariffCode"/>
                      </xs:sequence>
                    </xs:complexType>
                  </xs:element>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>

  8. #8
    grazie per il supporto Mattia

    anche io ho provato cosi':

    codice:
             <xs:element name="Guarantuees">
                      
             <xs:annotation>
            	<xs:documentation>A section repeated once for each guarantuee that is included in the
                                  contract.</xs:documentation>
              </xs:annotation>
                  <xs:complexType>
                  
                    <xs:all>
                    <xs:element name="Guarantee" >
                      <xs:complexType>
                  
                    <xs:all>              
                        <xs:element name="TariffCode" type="xs:string" > 
                      
                        </xs:element>
                        <xs:element name="EffectDate" type="xs:dateTime" > 
                      
                        </xs:element>
                        <xs:element name="ExpiryDate" type="xs:dateTime" > 
                  
                        </xs:element>
                        <xs:element name="GuarantueeStatus" >                     
                         <xs:simpleType> 
                            <xs:restriction base="xs:string" >
                              <xs:pattern value="......"/>                   
                           </xs:restriction>
                         </xs:simpleType>
                        </xs:element>                    
                    </xs:all>
                  </xs:complexType>
                  
                  </xs:element> 
                  </xs:all>
                  </xs:complexType>
             </xs:element>

    IN c# dovro' restituire un metodo che ritorna un tipo "PolicyDetails" , e la classe PolicyDetails che ho bisogno di definire contiene una proprieta' "Guarantees" che è definita come una list<Guarantee>.

    In un altro punto ho definito la classe ausiliaria "Guarantee" con altri parametri che sono definiti come simpletype nell'xsd.

    In questo modo dovrebbe validare: il mio scopo è consegnare al cliente un xsd valido, avendo già implementato una bozza del servizio...perchè non so fare prima l'xsd , ma direttamente la realizzazione


    Grazie del supporto!

  9. #9
    di nada ! apriamo una ditta e te fai c io xml xslt e le xsd :P

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.