Bonjour,
Je ne parviens pas à comprendre mon erreur:
J'essaye depuis 3 jours de valider un fichier XML avec un schema XSD en C# 1.1 et j'ai toujours la même anomalie targetNamespace différents ?
Voici mon fichier XML:
Voici le ficheir de validation:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 <?xml version="1.0" encoding="ISO-8859-1"?> <BD2005 day="13" month="11" year="2007" HFin="11:08" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation='http://horologiom.free.fr/INS_TYPE.xsd'> <INS REF="10000643" LABEL="DELITTE" SHORT_LABEL="" DATE_CREATION="13/11/2007" DEV_ID="2" CEX_ID="2" FK_ID=""/> </BD2005>
Et voici le code C#:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 <?xml version="1.0" encoding="utf-8"?> <xs:schema targetNamespace="http://horologiom.free.fr/INS_TYPE.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="BD2005"> <xs:complexType> <xs:sequence> <xs:element name="INS"> <xs:complexType> <xs:attribute name="REF" type="xs:long" /> <xs:attribute name="LABEL" type="xs:string" /> <xs:attribute name="SHORT_LABEL" type="xs:string" /> <xs:attribute name="DATE_CREATION" type="xs:date" /> <xs:attribute name="DEV_ID" type="xs:int" /> <xs:attribute name="CEX_ID" type="xs:int" /> <xs:attribute name="FK_ID" type="xs:string"/> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="day" type="xs:int" /> <xs:attribute name="month" type="xs:int" /> <xs:attribute name="year" type="xs:int" /> <xs:attribute name="HFin" type="xs:string" /> </xs:complexType> </xs:element> </xs:schema>
Si une bonne ame pouvais m'indiquer pourquoi les targetNamespace ne match pas ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 FileStream fs = new FileStream(strFileName, FileMode.Open); XmlValidatingReader xmlValidatingReader = new XmlValidatingReader(new XmlTextReader(fs)); xmlValidatingReader.ValidationType = ValidationType.Schema; XmlSchemaCollection sc = new XmlSchemaCollection(); sc.Add(null, @"http://horologiom.free.fr/INS_TYPE.xsd"); xmlValidatingReader.ValidationEventHandler += new ValidationEventHandler(XmlValidationError); xmlValidatingReader.Schemas.Add(sc); while (xmlValidatingReader.Read()) ; xmlValidatingReader.Close();
Merci d'avance.![]()
Partager