Hello everybody,
I'm trying to validate my XML file with and XML schema but I get validations errors where there is not. It is like it doesn't understand my xsd
My XML :
My XSD :
My Oscript script :
My Output :
Thanks for helping me.
I'm trying to validate my XML file with and XML schema but I get validations errors where there is not. It is like it doesn't understand my xsd
My XML :
Code:
<?xml version="1.0" encoding="UTF-8"?>
<personne>
<nom>MBODJ</nom>
<prenom>Babacar</prenom>
<date_naissance>1996-10-06</date_naissance>
<etablissement>NIIT</etablissement>
</personne>
My XSD :
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema">[/URL]
<xs:element name="personne">
<xs:complexType>
<xs:sequence>
<xs:element name="nom" type="xs:string" />
<xs:element name="prenom" type="xs:string" />
<xs:element name="date_naissance" type="xs:date" />
<xs:element name="etablissement" type="xs:string" />
<xs:element name="num_tel" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Code:
function void main()
//Tableau de retour des résultats de la validation
Assoc lRetParseur = Undefined
//Fichiers utilisés
String lXmlFile = "C:\OPENTEXT\testXMLTools\fichier1.xml"
String lXsdFile = "C:\OPENTEXT\testXMLTools\fichier1.xsd"
//Validation
lRetParseur = validation(lXmlFile, lXsdFile)
Echo (lRetParseur)
end
function Assoc validation (String pXmlFile, String pXsdFile)
Assoc lRoRet
Echo ("Fonction de validation : Vérification de l'existance des fichiers")
if (File.Exists(pXmlFile) && File.Exists(pXsdFile))
Echo ("OK")
//Création du parseur
lRoRet = Assoc.CreateAssoc()
DOMParser lparseur = DOMParser.New()
//Localisation du xsd
lparseur.setExternalSchemaLocation(pXsdFile)
//Pour que le parseur rapporte toutes les erreurs
lparseur.setValidationScheme(DomParser.Val_Always)
lparseur.setDoSchema(TRUE)
lparseur.SetValidationSchemaFullChecking(TRUE)
//Parsage
lRoRet = lparseur.parse(pXmlFile)
else
Echo ("KO")
lRoRet = Undefined
end
return lRoRet
end
My Output :
Code:
A<1,?,'Errors'=V{<'ErrType','ErrMsg','PublicID','SystemID','LineNumber','ColumnNumber'><2,'Unknown element \'personne\'','C:\\OPENTEXT\\testXMLTools\\fichier1.xml','',2,10><2,'Unknown element \'nom\'','C:\\OPENTEXT\\testXMLTools\\fichier1.xml','',3,9><2,'Unknown element \'prenom\'','C:\\OPENTEXT\\testXMLTools\\fichier1.xml','',4,12><2,'Unknown element \'date_naissance\'','C:\\OPENTEXT\\testXMLTools\\fichier1.xml','',5,20><2,'Unknown element \'etablissement\'','C:\\OPENTEXT\\testXMLTools\\fichier1.xml','',6,19>},'OK'=false>
Thanks for helping me.