I am trying to validate an XML file against a schema, which i can achieve without issue normally, however, in this particular schema, there is an imported namespace, that appears to be preventing the validation from happening, as the error being returned is pointing to node of the elements from the imported xsd.

I can manually enter the namespace refrences to the child elements of the XML file and it will validate correctly, however I cannot validate the document, by way of the code.

I have tried a number of things all to no avail:

I have added multiple XSD's to the XMLSchemaSet, which returned a duplicate declaration issue. I assume this is due to the top level schema having an import of the 2nd XMLSchema.

I also tried imports <xmlns="2nd_namespace">, within the declarations, but this seemed to do nothing.

I have also been attempting to apply a namespace to the child elements that I can update manually. When the xDoc is validated against the applied schema it overwrites the previously correct element applied namespaces.

Can I add multiple schemas? am i doing something wrong?
Can i force something in during the validation of a schema.

Any advice would be appreciated here guy's.

Recommended Answers

All 3 Replies

Can we see said XML file and higlight what causes the issues?

Thanks for the response Mikey, I have since come up with the solution. I found that there was a differing 3rd namespace declared within the schema, which was not created by myself or my company and this had been causing the issue. I was able to force the differing namespaces trhroughout the XML document and validate against schema once all child nodes were populate with the appropriate namespaces.

Good to hear :) Namespaces cause havok so much!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.