HighTechTalks DotNet Forums  

XmlDocument XmlDSig schema validation

Dotnet XML microsoft.public.dotnet.xml


Discuss XmlDocument XmlDSig schema validation in the Dotnet XML forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Iguana
 
Posts: n/a

Default XmlDocument XmlDSig schema validation - 12-07-2007 , 02:35 AM






Hi!
I must to validate xml document with XmlDSig and Xades Schema.
Why this code (with !obsolete! XmlValidatingReader) work and validate
xmldocument:

private bool schemaValidationStatus = true;
static void ValidationEventHandler(object sender, ValidationEventArgs
e)
{
MessageBox.Show(e.Message);
schemaValidationStatus = false;
}
public bool VerifySchemaVersionObsolete(string fileName)
{
XmlTextReader xmlTextReader = new XmlTextReader(fileName);
XmlValidatingReader xmlValidatingReader = new
XmlValidatingReader(xmlTextReader);
xmlValidatingReader.ValidationType = ValidationType.Schema;
xmlValidatingReader.Schemas.Add("http://www.w3.org/2000/09/
xmldsig#", "http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/
xmldsig-core-schema.xsd");
xmlValidatingReader.Schemas.Add("http://uri.etsi.org/01903/
v1.3.2#", "http://uri.etsi.org/01903/v1.3.2/XAdES.xsd");
xmlValidatingReader.ValidationEventHandler +=
ValidationEventHandler;
while (xmlValidatingReader.Read())
{
}
return schemaValidationStatus;
}

-- and this code (with .net 2.0 without !obsolete!
XmlValidatingReader) DONT WORK:

public bool VerifySchemaNet2(string fileName)
{
XmlTextReader xmlTextReader = new XmlTextReader(fileName);
XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();
xmlReaderSettings.ProhibitDtd = false;
xmlReaderSettings.ValidationType = ValidationType.Schema;
xmlReaderSettings.Schemas.Add("http://www.w3.org/2000/09/
xmldsig#", "http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/
xmldsig-core-schema.xsd");
xmlReaderSettings.Schemas.Add("http://uri.etsi.org/01903/v1.3.2#",
"http://uri.etsi.org/01903/v1.3.2/XAdES.xsd");
xmlReaderSettings.ValidationEventHandler +=
ValidationEventHandler;
XmlReader xmlReader = XmlReader.Create(xmlTextReader,
xmlReaderSettings);
while (xmlReader.Read())
{
}
return schemaValidationStatus;
}

the error in code VerifySchemaNet2 is in line:
readerSettings.Schemas.Add("http://www.w3.org/2000/09/xmldsig#",
"http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-
schema.xsd");
with message: to use DTD, set false to XmlReaderSettings.ProhibitDtd
and put this to XmlReader.Create method.
How can I validate xml document with
http://www.w3.org/TR/2002/REC-xmldsi...ore-schema.xsd
schema. I dont understand this, other schemas work good. Is imposible
do this with .net 2.0, I dont believe???
Has anybody the same problem?
Please for help!
Iguana

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.