How do I add an XSD fragment to a schema?

roofersgirly

New Member
I'm trying to validate a fragment of an \[code\]XmlDocument\[/code\] against an XSD that only represents that fragment. For instance:\[code\]<!-- Validate entire message against message.xsd --><?xml version="1.0" encoding="utf-8" ?><Message> <Header> ... </Header> <Body> <!-- Validate this against body.xsd --> ... </Body></Message>\[/code\]The entire message is validated against the developer-supplied message.xsd schema. The contents of the \[code\]<Body>\[/code\] element are validated against the client-supplied body.xsd schema.The body.xsd schema knows nothing of the \[code\]<Message>\[/code\], \[code\]<Header>\[/code\] or \[code\]<Body>\[/code\] elements. It only defines what should be contained within the \[code\]<Body>\[/code\] element.I can't work out how to validate an XML fragment against an XML schema fragment. Everything seems to suggest the XML schema fragment is required to know all about its ancestor elements. I have a couple of paths in mind but am not sure how to implement them.[*]Programatically inject the body.xsd into the appropriate node of the message.xsd.[*]Extract the appropriate \[code\]XmlElement\[/code\] from the \[code\]XmlDocument\[/code\] and create a new \[code\]XmlDocument\[/code\] based on this node.[*]Something to do with namespaces, which I'm yet to understand.What solutions exist for this problem?
 
Back
Top