For some crazy reason you may want to avoid making a CREATE XML SCHEMA COLLECTION statement but still validate your XML. Here is an example to do this with XPath assertions in XQuery:
IF (@xmlInput.exist('//HostName') = 0)
OR (@xmlInput.value('string-length((//HostName/text())[1])','int') = 0)
BEGIN
SET @xmlOutput = '
<Header>Failed to Receive Device Data</Header>
<Code>999</Code>
<Line>XML element “HostName” was not found or is empty.</Line>
'
GOTO RETURN_XML_MESSAGE
END
This technique can be used in the discussion by Denis Ruckebusch filed under “Complementing XSD with CHECK constraints” here:
http://blogs.msdn.com/denisruc/archive/2006/08/22/713342.aspx