views:

258

answers:

3

I wanna verify a digitally signed xml against its schema definition while this schema actually contains this tag

<xs:import namespace="http://www.w3.org/2000/09/xmldsig#" schemaLocation="xmldsig-core-schema.xsd" id="schema"/>

Then I tried to load schemas:

XmlReaderSettings settings = new XmlReaderSettings();
settings.Schemas.Add(null, "a.xsd");
settings.Schemas.Compile();

I will get the following error The 'http://www.w3.org/2000/09/xmldsig#%3ASignature' element is not declared.

A: 

are you sure hash is required at the end of?: http://www.w3.org/2000/09/xmldsig#

dusoft
It is part of the namespace URI, see http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd
Richard
ok, thanks, haven't known about that
dusoft
A: 

From the error it would seem the XML Signature schema is not being loaded, despite the import.

Adding the XML Signature schema to the schema set explicitly should confirm that.

The most likely cause is the schema set's XmlReslver is not finding the file you specify, this could be a current folder/relative path issue.

Using Process Monitor to see where you could is trying to load the XSD file may also help.

Richard
+1  A: 

You need to also load in the imported schema with another

settings.Schemas.Add([importednamespace], [pathtoimportedXSD]);

thehowler